To determine a file's type
https://linux.die.net/man/1/file
print the strings of printable characters in files.
https://linux.die.net/man/1/strings
預設輸出字串長度為4個以上的連續可顯示字元
list symbols from object files
https://linux.die.net/man/1/nm
如果是執行檔…
we can find owo
in symbol T
nm symbols
Displays information about ELF files.
https://linux.die.net/man/1/readelf
display information from object files.
https://linux.die.net/man/1/objdump
trace system calls and signals
https://linux.die.net/man/1/strace
The default maximum output is 32 consecutive characters
A library call tracer
https://linux.die.net/man/1/ltrace
印出程式實際用到的function
syntax
The GNU Debugger
https://linux.die.net/man/1/gdb
attach <pid>
break <point addr>
delete breakpoints [id]
run
step
stepi
next
nexti
continue
finish
jump <address>
print $<register>
print <address>
set $<register>
set <address>
info break
info register
rsp ..stack的頂端
rbp ..stack的底端
try to output hello world by using assembly code
解說
Line 9:
輸出檔案需要使用write
這個syscall方法,參考資料可以知道sys_write
的rax
是1
Line 10:
這邊要選擇輸出的位置,可以參考資料得知rdi
是1
Line 11:
這邊要指定輸出的內容,在Line4
已經將Hello, world!
存入mag
,rsi
這邊指定是msg
即可
Line 12:
這邊要指定輸出的總長度,在Line5
已經將長度存在len
中,rdx
這邊指定len
即可
compile assembly code to binary
nasm ..把組合語言編譯為物件檔
ld .. 連結…
rsp
store the top address of stack frame
rbp
store the bottom address of stack frame
解說
Line1
: 將舊rbp
位置推入stack頂端
Line2
: 調整rbp
至rsp
的位置
Line3
: 調整rsp
位置,開出stack frame大小為N
解說
Line1
: 調整rsp
至rbp
的位置
Line2
: 將rbp
調整回舊rbp
的位置
Line3
: 結束
可以發現到C++的asembly code命名很複雜,可以透過demangle改善
in gdb
hook
先確定file有動態連結
ISIP SummerCamp 2020