Pxiaoer Research
← Back to Blog Uncategorized

Rust 逆向——00.Hello,World

rust

fn main() {
    println!("Hello, world!");
}

我尝试使用-O 和 -C opt-level=3 来编译,发现编译出来的程序没有任何区别。

如果你使用-o 的话,就会发现生成的程序是没有优化的,会大一些,有461K。

使用GDB来调试

你在编译的时候,需要加-g 来添加调试信息

(gdb) list
1       fn main() {
2           println!("Hello, world!");
3       }
(gdb) 
Line number 4 out of range; helloworld.rs has 3 lines.
(gdb) 
Line number 4 out of range; helloworld.rs has 3 lines.
(gdb) b 2
Breakpoint 1 at 0x100004228: file helloworld.rs, line 2.

使用逆向工具

使用Cutter的jsdec反编译结果。看起来生成的C++/C的代码

使用Ghira的结果