當你在 main 中找不到程式邏輯的時候,如何考慮?
-
有沒有註冊異常處理程式。還有像
__cxa_atexit
這樣退出時執行的函數。 -
__lib_start_main
的參數中有用於初始化的函數。順便貼一下它的定義:int __libc_start_main( int (*main) (int, char * *, char * *), int argc, char * * ubp_av, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void (* stack_end) );
• performing any necessary security checks if the effective user ID is
not the same as the real user ID.
• initialize the threading subsystem.
• registering the rtld_fini to release resources when this dynamic shared object exits (or is unloaded).
• registering the fini handler to run at program exit.
• calling the initializer function (*init)().
• calling main() with appropriate arguments.
• calling exit() with the return value from main(). -
通過字串或位元組陣列的交叉引用,可以找出隱藏的操作。
所以當你遇到了靈異事件的時候,不要驚慌,不然連個難度 1 的題的隱藏操作都找不出來。