diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5943d25 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "chisel" +version = "0.1.0" +authors = ["Garrett Dickinson "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/README.md b/README.md index d763e33..eec7569 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # chisel -Binary analysis tool developed in Rust +`chisel` is a tool for decompiling *nix ELF programs for binary analysis and reverse engineering. This project is being developed alongside coursework for **Auburn University's COMP5970 Binary Program Analysis**. + + +## Supported Binary formats + +`chisel` supports binaries compiled to the [ELF format](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) from most x86 *nix systems, and *does not* currently support macOS Mach-O or Windows PE binaries. + diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8702591 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,26 @@ +use std::path; +use std::env; +use std::fs; +use std::process::exit; + +fn main() { + let args: Vec = env::args().collect(); + + let file_path = &args[1]; + println!("Got target file '{}'", file_path); + + + if path::Path::new(file_path).exists() { + println!("File exists, reading '{}'", file_path); + let contents: Result, std::io::Error> = fs::read(file_path); + if contents.is_ok() { + let bytes: &Vec = &contents.expect(""); + for byte in bytes { + println!("{}", byte); + } + } + } else { + println!("[Error] '{}' does not exist", file_path); + exit(-1); + } +} diff --git a/testing/hello b/testing/hello new file mode 100755 index 0000000..67fac75 Binary files /dev/null and b/testing/hello differ diff --git a/testing/src/hello.c b/testing/src/hello.c new file mode 100644 index 0000000..dcfb86b --- /dev/null +++ b/testing/src/hello.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/testing/src/hello.s b/testing/src/hello.s new file mode 100644 index 0000000..2edc149 --- /dev/null +++ b/testing/src/hello.s @@ -0,0 +1,46 @@ + .file "main.c" + .text + .section .rodata +.LC0: + .string "Hello, World!" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + endbr64 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + leaq .LC0(%rip), %rax + movq %rax, %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0" + .section .note.GNU-stack,"",@progbits + .section .note.gnu.property,"a" + .align 8 + .long 1f - 0f + .long 4f - 1f + .long 5 +0: + .string "GNU" +1: + .align 8 + .long 0xc0000002 + .long 3f - 2f +2: + .long 0x3 +3: + .align 8 +4: diff --git a/testing/testfile b/testing/testfile new file mode 100644 index 0000000..95d09f2 --- /dev/null +++ b/testing/testfile @@ -0,0 +1 @@ +hello world \ No newline at end of file