From 2e2056f1530d2343bb76ac50575c681b65e32c2f Mon Sep 17 00:00:00 2001 From: Garrett Dickinson Date: Mon, 23 Jan 2023 21:34:50 -0600 Subject: [PATCH] Initial commit --- Cargo.toml | 9 +++++++++ README.md | 8 +++++++- src/main.rs | 26 +++++++++++++++++++++++++ testing/hello | Bin 0 -> 15960 bytes testing/src/hello.c | 5 +++++ testing/src/hello.s | 46 ++++++++++++++++++++++++++++++++++++++++++++ testing/testfile | 1 + 7 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100755 testing/hello create mode 100644 testing/src/hello.c create mode 100644 testing/src/hello.s create mode 100644 testing/testfile 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 0000000000000000000000000000000000000000..67fac7593d3b1e8b5743dd83c988d3dbf22790dc GIT binary patch literal 15960 zcmeHOYit}>6~4QP6NftS#>u?H$`I?Zerf zrFMa02t`C~)bvlOD5?rVDiTE$i62G^;3^Ob5~zV6q(YTKMNldpbxJ`2M22(joNqIp zt`n((AC=}xyWc&J@7z0Q?#$lVx%YF!qa)EsM4@a@_b8SoW1c1a# zRlC$Ck~eCdXHR%QRZy;n|GgqqMyF9f5qKAykTd(Zq4p9LrIS%I4utDS? zE=mJH*emVDnM@_Fzbp8Lh(JG&yRzKoIV|_B#g9r}CI!J`k$Eo&?*-ujSEZjo8(fZEa?)?5y(7YFjO#Eeh~1uA0ny$^h$p93JZ=m) z%}1rZ_0EGS`3FjRReLrw)!W^kO}Aw;`SL>B!oJ?N-fp8*FuHWZ+^;x&cuXBQG@&TW z3hN||D!Sy!h{v`@v9tfLzwnz+o8OB*HR3chjdebG=0{K6lVl(6H*?sB3&+C{VHx9t zeY|{pp4C!U>b(7{oK~#!#qk@e*bb5|UPb?2(pB@HS;xP;j-LC=vEEcHYkDDN&1CYa zY~}%5Sr#RJ+A2AzqGRP!nY@}WX7bLAVl}6~R~;Bl4h&jdMwii3sqgJpR&spIO4~(y zHdAu!;`rELwve~SQ&U-vI-4uxC937QR&}KAMJfLq=)>Q9E~07=A;wd=C9{Rk%3jfZ z|FOsEG(^>YlDXhI$Mu!i?&(+LI)+|}zBb|6p@)1y0`fWL+@W0b>HXv4vQN+B2xZl$ z*Y`g$T=nU_apW0Z6#ZrrF_sZ4#4rP42Eq)483;2FW+2Q!n1Q!{2L4vR>tE)HKi8TM z*SyrOl=;w#6LnuSPyD3ztUfrm=c}ZC-F@Ga1of?o{pZ;7`m4WpUH3H0Wc`k|4k>LX zx$Kua|B^g;{*&g(SIiTCSUoa6+_}>EbMsW+FDQ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fT*5 zTrh9&B&B$}oSz@uSH=H-`wQ+@(DCn;pO4>5U>uHuLH@m@{|C)M(0|O+fM{Q)OK<9b ziugQ710VA^;J2h*?jz?J$B+3`hIITB5B`#L5cnwB{Douq%W)ETjs-sERX|!|rwjTI zKj4F8RQ-1tL$(=X#L;b<%N8 z5Wn)fAiocouak=|!Snw$()#&v;Z;z00Q~F#p9%02VgSN#J^ph6{t+PnZ^r*YfIle& zAkSC)B^d9=0Y2soWBJAp?(Hw2yf!_O)XF zDqnwGz{7d`HtF~jgOBIH<#zU_^|c;UzQG4>BC?;a65`t7A=*Iz@F4T}VjbGY{4OT^ zpg*_eFWaSkaj%%bzq6w8D&YIEGWLAF2?;nU9eX#~cr2nnxUXy>9s2I0tEc$^iOS1p X$P;z0q^g0Zxz+fe?eV-?Zo>aBWU +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