|
3 | 3 | name: enumerate PE sections |
4 | 4 | namespace: load-code/pe |
5 | 5 | authors: |
6 | | - - "@Ana06" |
7 | | - - "@mr-tz" |
| 6 | + - sara-rn |
8 | 7 | scopes: |
9 | 8 | static: function |
10 | | - dynamic: unsupported # requires offset, operand[1].offset, characteristic, mnemonic, basicblock features |
11 | | - mbc: |
12 | | - - Discovery::Code Discovery::Enumerate PE Sections [B0046.001] |
13 | | - references: |
14 | | - - https://0x00sec.org/t/reflective-dll-injection/3080 |
15 | | - - https://www.ired.team/offensive-security/code-injection-process-injection/reflective-dll-injection |
| 9 | + dynamic: unsupported # requires characteristic, offset, mnemonic features |
16 | 10 | examples: |
17 | | - - E4C33AC3638EEF68311F8AC0D72483C7:0x401510 |
| 11 | + - 73CE04892E5F39EC82B00C02FC04C70F:0x406BA1 |
18 | 12 | features: |
19 | 13 | - and: |
20 | 14 | - os: windows |
21 | | - # there should be some complexity to functions like this |
22 | | - - count(basic blocks): 3 or more |
23 | | - - optional: |
24 | | - - offset: 0x3C = IMAGE_DOS_HEADER.e_lfanew |
25 | | - - instruction: |
26 | | - - or: |
27 | | - - mnemonic: mov |
28 | | - - mnemonic: movzx |
29 | | - - operand[1].offset: 0x6 = IMAGE_NT_HEADERS.FileHeader.NumberOfSections |
30 | | - - basic block: |
| 15 | + - or: |
| 16 | + - characteristic: loop |
| 17 | + - mnemonic: movzx |
| 18 | + - and: |
| 19 | + - offset: 0x3C = IMAGE_DOS_HEADER.PE.e_lfanew |
31 | 20 | - or: |
32 | 21 | - and: |
33 | | - - description: IMAGE_FIRST_SECTION(nt_header) |
34 | | - - instruction: |
35 | | - - or: |
36 | | - - mnemonic: add |
37 | | - - mnemonic: mov |
38 | | - - mnemonic: movzx |
39 | | - - operand[1].offset: 0x14 = IMAGE_NT_HEADERS.FileHeader.SizeOfOptionalHeader |
40 | | - - operand[1].offset: 0x18 = FileHeader.SizeOfOptionalHeader |
| 22 | + - arch: i386 |
| 23 | + - offset: 0x78 = offset to IMAGE_DATA_DIRECTORY[IMAGE_DIRECTORY_ENTRY_EXPORT] |
41 | 24 | - and: |
42 | | - - description: (DWORD)dll_raw + dos_header->e_lfanew + sizeof(IMAGE_NT_HEADERS) + sizeof(IMAGE_SECTION_HEADER) * i |
43 | | - - number: 0x28 = sizeof(IMAGE_SECTION_HEADER) |
44 | | - - or: |
45 | | - - and: |
46 | | - - arch: i386 |
47 | | - - operand[1].offset: 0xF8 = sizeof(IMAGE_NT_HEADERS32) |
48 | | - - and: |
49 | | - - arch: amd64 |
50 | | - - operand[1].offset: 0x108 = sizeof(IMAGE_NT_HEADERS64) |
51 | | - - 2 or more: |
52 | | - - operand[1].offset: 0xC = IMAGE_SECTION_HEADER.VirtualAddress |
53 | | - - operand[1].offset: 0x14 = IMAGE_SECTION_HEADER.PointerToRawData |
54 | | - - operand[1].offset: 0x10 = IMAGE_SECTION_HEADER.SizeOfRawData |
55 | | - # there's also offset 0x8 = IMAGE_SECTION_HEADER.Misc.PhysicalAddress, but it's likely too common |
56 | | - - not: |
57 | | - # non-zeroing XOR was observed in FPs |
58 | | - - characteristic: nzxor |
| 25 | + - arch: amd64 |
| 26 | + - offset: 0x88 = offset to IMAGE_DATA_DIRECTORY[IMAGE_DIRECTORY_ENTRY_EXPORT] |
| 27 | + - 3 or more: |
| 28 | + - offset: 0x14 = IMAGE_EXPORT_DIRECTORY.NumberOfFunctions |
| 29 | + - offset: 0x24 = IMAGE_EXPORT_DIRECTORY.AddressOfNameOrdinals |
| 30 | + - offset: 0x20 = IMAGE_EXPORT_DIRECTORY.AddressOfNames |
| 31 | + - offset: 0x18 = IMAGE_EXPORT_DIRECTORY.NumberOfNames |
| 32 | + - offset: 0x1C = IMAGE_EXPORT_DIRECTORY.AddressOfFunctions |
| 33 | + - optional: |
| 34 | + - or: |
| 35 | + - api: LoadLibrary |
| 36 | + - api: strcmp |
0 commit comments