rust恢复符号表

clev1L Lv3

BITSCTF - Reverse Mishap

参考博客https://blog.diefunction.io/ctf/bitsctf-reverse-mishap

尝试恢复符号表解决这题rust,动调猜还是太糖了

字符串搜索rustc

百度查一下rust版本

rust1.80.0

再搜索index.crates.io查看调用库

所以配置文件如下

拷打gpt和deepseek多调用点函数,实际效果不尽如人意,可能是我调教的不太好,但是够用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use rand_core::{RngCore, SeedableRng};
use rand_chacha::ChaCha20Rng;
use generic_array::{GenericArray, typenum::U16};
use cipher::{BlockEncrypt, BlockDecrypt, KeyInit};
use aes::Aes256;
use rand::{Rng, thread_rng, distributions::Uniform};
use std::time::{SystemTime, UNIX_EPOCH};
use std::fs::{self, File};
use std::io::{self, Write, Read};

fn main() -> io::Result<()> {
// 使用 rand_core 生成随机数
let mut rng = ChaCha20Rng::from_entropy();
let mut random_bytes = [0u8; 16];
rng.fill_bytes(&mut random_bytes);
println!("Random bytes: {:?}", random_bytes);

// 使用 rand_chacha 生成随机数
let mut chacha_rng = ChaCha20Rng::from_seed([0; 32]);
let random_u32: u32 = chacha_rng.next_u32();
println!("Random u32 from ChaCha20: {}", random_u32);

// 使用 generic-array 创建固定大小的数组
let array: GenericArray<u8, U16> = GenericArray::default();
println!("GenericArray: {:?}", array);

// 使用 cipher 和 aes 进行加密和解密
let key = GenericArray::from_slice(&[0u8; 16]);
let mut block = GenericArray::clone_from_slice(&[0u8; 16]); // 创建可变的 GenericArray
let cipher = Aes256::new(&key);

cipher.encrypt_block(&mut block);
println!("Encrypted block: {:?}", block);

cipher.decrypt_block(&mut block);
println!("Decrypted block: {:?}", block);

// 使用 rand 生成随机数
let random_number: u32 = thread_rng().gen();
println!("Random number from rand: {}", random_number);

// 使用 rand 生成范围内的随机数
let range = Uniform::new(0, 100);
let random_in_range: u32 = thread_rng().sample(range);
println!("Random number in range 0..100: {}", random_in_range);

// 使用 Rust 标准库函数
let vec = vec![1, 2, 3, 4, 5];
let sum: i32 = vec.iter().sum();
println!("Sum of vector: {}", sum);

let mut sorted_vec = vec.clone();
sorted_vec.sort();
println!("Sorted vector: {:?}", sorted_vec);

let string = "hello, world!";
let uppercase = string.to_uppercase();
println!("Uppercase string: {}", uppercase);

// 获取当前时间戳
let now = SystemTime::now();
let timestamp = now.duration_since(UNIX_EPOCH).expect("Time went backwards").as_secs();
println!("Current timestamp: {}", timestamp);

// 文件操作
// 1. 创建文件并写入内容
let mut file = File::create("example.txt")?;
file.write_all(b"Hello, file!")?;
println!("File created and written to.");

// 2. 读取文件内容
let mut file = File::open("example.txt")?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
println!("File contents: {}", contents);

// 3. 删除文件
fs::remove_file("example.txt")?;
println!("File deleted.");

Ok(())
}

在linux里 cargo build 一下

ida打开编译好的文件,创建一个sig文件

file_encrypt导入生成的sig文件

可以看到一些关键函数符号都被还原出来了

  • Title: rust恢复符号表
  • Author: clev1L
  • Created at : 2025-02-12 09:45:33
  • Updated at : 2025-02-23 12:29:57
  • Link: https://github.com/clev1l/2025/02/12/rust恢复符号表/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
rust恢复符号表