Last active
August 29, 2015 14:14
-
-
Save whitequark/8f0dee6824ff349b5a8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.gdb_history | |
payload | |
payload.o | |
payload.bin | |
packed | |
packer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: payload packed | |
diff: packed | |
bash -c 'diff -u <(objdump -d --adjust-vma 0x400580 payload.o) \ | |
<(objdump -D -j .rodata --start 0x400580 packed); exit 0' | |
packed: packed.c | |
cc $^ -o $@ | |
packed.c: payload.bin packer | |
./packer $< >$@ | |
packer: packer.rs | |
rustc $^ | |
payload.bin: payload.o | |
objcopy -O binary $^ $@ | |
payload.o: payload.s | |
as $^ -o $@ | |
payload: payload.o | |
ld -emain $^ -o $@ | |
clean: | |
rm -rf *.o *.bin payload packer packed packed.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const double main[] = { | |
-1.2882297911452467e-231, | |
6.8056493973162633e38, | |
2.6960150007992882e43, | |
-2.4983353911957602e-127, | |
1.3771508940552131e-307, | |
2.7327264832829496e-71, | |
-7.6918209102389605e-293, | |
3.1317446676317955e-300, | |
-6.1898042705411802e37, | |
-5.1199164284928003e13, | |
-2.494354501505855e35, | |
-1.6955191902826783e-231, | |
-1.3617708398331807e57, | |
-4.469585001523332e95, | |
-1.6444313123558302e-256, | |
-8.815396944887123e4, | |
-2.1580062755299081e52, | |
-5.637139215118955e8, | |
-2.4983353906949675e-127, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{File, IoError, IoErrorKind, println}; | |
use std::path::Path; | |
fn main() { | |
let mut file = File::open(&Path::new(&std::os::args()[1])); | |
println("const double main[] = {"); | |
loop { | |
match file.read_le_f64() { | |
Ok(val) => | |
/* 53 bits in mantissa / log2(10) = log10(precision) ≈ 15.95 */ | |
println!("\t{},", std::f64::to_str_exp_digits(val, 16, false)), | |
Err(IoError { kind: IoErrorKind::EndOfFile, .. }) => | |
break, | |
Err(error) => | |
panic!("{}", error) | |
} | |
} | |
println("};"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.globl main | |
.type main, %function | |
main: | |
# copy to writable memory | |
movq $((.msgpad - .msgstart) / 8), %rcx | |
nop | |
leaq .msgstart(%rip), %rsi | |
movq %rsp, %rdi | |
subq %rcx, %rsp | |
pushq %rdi | |
rep movsq | |
# decode | |
movq $0xa5a5a5a5a5a5a5a5, %rax | |
movq $(.msgpad - .msgstart), %rcx | |
movq (%rsp), %rdi | |
0: | |
xorq %rax, (%rdi) | |
addq $8, %rdi | |
nop | |
subq $8, %rcx | |
jnz 0b | |
movq $1, %rax | |
nop | |
nop | |
movq $0, %rdi | |
popq %rsi | |
movq $(.msgend - .msgstart), %rdx | |
syscall | |
# exit | |
movq $60, %rax | |
syscall | |
.align 8 | |
.msgstart: | |
.byte 0xd7, 0xc8, 0x9f, 0x85, 0xc6, 0xc4, 0xcb, 0xcb, 0xca | |
.byte 0xd1, 0x85, 0xd7, 0xc0, 0xc8, 0xca, 0xd3, 0xc0, 0x85 | |
.byte 0x82, 0x8a, 0xc1, 0xc0, 0xd3, 0x8a, 0xd1, 0xd1, 0xdc | |
.byte 0x82, 0x9f, 0x85, 0xf5, 0xc0, 0xa5, /* nop */ 0xd7, 0xc8, 0xcc, 0xd6 | |
.byte 0xd6, 0xcc, 0xca, 0xcb, 0x85, 0xc1, 0xc0, 0xcb, 0xcc | |
.byte 0xc0, 0xc1, 0xaf | |
.msgend: | |
# padding | |
.align 8, 0xa5 | |
.msgpad: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment