Linux x86_64 inject based on inject
- test.c
gcc -fpie -pie -nostdlib -o test test.c
[use -fpie -pie to generate the position independent code] - code_injection.c
gcc -o code_injection code_injection.c
- inject_me.c
gcc -o inject_me inject_me.c
- Terminal 1
zg@ubuntu:~/Documents/injection$ ./inject_me
main addr : 0x5635c62146da
Please inject me
^Z
[1]+ Stopped ./inject_me
zg@ubuntu:~/Documents/injection$ ps
PID TTY TIME CMD
2959 pts/1 00:00:00 bash
3531 pts/1 00:00:00 inject_me
3532 pts/1 00:00:00 ps
zg@ubuntu:~/Documents/injection$ fg %1
./inject_me
mmap^_^
I am HotIce0
- Terminal 2
zg@ubuntu:~/Documents/injection$ sudo ./code_injection 3531 test
the injection code size : 298
successful to attach the specify process
rip : 0x7f319a58a9a4
addr_text : 0x7f319a58a9a4
The specify process was traped
success to write the sepecify elf file to sepecify proc
success to insert injection program
done