大量 IDA .ASM 文件,需要潜在助记符列表

逆向工程 艾达 六线谱
2021-06-13 13:18:48

我有大约 20,000 个 .asm 文件从 IDA pro 输出通过十六进制射线。

这些都是由已知的恶意软件创建的,并且都来自 32 位 Windows 便携式可执行文件。

没有原始的可执行文件,只有反汇编的输出(.asm)文件。

  • 我试图获得的是任何可能的助记符列表(即添加、异或、跳转等),IDA 可以输出到 .asm 文件中

    有了这个列表,我将尝试使用 grep(或类似的)来编译统计数据的机器学习/恶意软件分类任务。

在本网站的帮助下,我手工制作了 30 个左右的列表(jmp、push、mov、call、lea 等),其中列出了常见的说明http://www.strchr.com/x86_machine_code_statistics

这些文件的标题中是否有任何线索可以帮助定义可能的助记符?这些是跨平台一致的还是特定于原始文件的某些属性?

我搜索了 IDA pros 文档,似乎在反汇编过程中可以使用所有功能,但我坚持使用 .asm 文件进行解析。

类似的问题没有帮助。

解析 IDA Pro .asm 文件

带指令的 IDA Pro 函数列表

示例 .asm 头文件

       ;
       ; +-------------------------------------------------------------------------+
       ; |   This file has been generated by The Interactive Disassembler (IDA)    |
       ; |       Copyright (c) 2013 Hex-Rays, <support@hex-rays.com>       |
       ; |          License info:                              |
       ; |                Microsoft                |
       ; +-------------------------------------------------------------------------+
       ;

       ; ---------------------------------------------------------------------------
       ; Format      : Portable executable for 80386 (PE)
       ; Imagebase   : 400000
       ; Section 1. (virtual address 00001000)
       ; Virtual size              : 0002964D ( 169549.)
       ; Section size in file          : 00029800 ( 169984.)
       ; Offset to raw data for section: 00000400
       ; Flags 60000020: Text Executable Readable
       ; Alignment     : default
       ; OS type     :  MS Windows
       ; Application type:  Executable 32bit

               include uni.inc ; see unicode subdir of ida for info on unicode

               .686p
               .mmx
               .model flat

       ; ===========================================================================

从内部取样

.text:00401080                             ; ---------------------------------------------------------------------------
.text:00401081 CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC            align 10h
.text:00401090 8B 44 24 10                             mov     eax, [esp+10h]
.text:00401094 8B 4C 24 0C                             mov     ecx, [esp+0Ch]
.text:00401098 8B 54 24 08                             mov     edx, [esp+8]
.text:0040109C 56                                  push    esi
.text:0040109D 8B 74 24 08                             mov     esi, [esp+8]
.text:004010A1 50                                  push    eax
.text:004010A2 51                                  push    ecx
.text:004010A3 52                                  push    edx
.text:004010A4 56                                  push    esi
.text:004010A5 E8 18 1E 00 00                              call    _memcpy_s
.text:004010AA 83 C4 10                                add     esp, 10h
.text:004010AD 8B C6                                   mov     eax, esi
.text:004010AF 5E                                  pop     esi
.text:004010B0 C3                                  retn
.text:004010B0                             ; ---------------------------------------------------------------------------

感谢您提供有关解决此问题的最佳方法的任何指示或线索,如果这不适合本论坛,我深表歉意。

1个回答

由于我也在使用kaggle提供的恶意软件样本,我也遇到了同样的问题。我通过两步处理找到了一个解决方案,它提取mnemonics了完整集中使用的所有内容

注意:由于我的工作还没有完成,我无法发布完整的脚本。真正的实现是用线程实现的,9个家庭的过程大概需要一个小时。此外,该解决方案并不完美且性能良好 - 而是一个肮脏的修复。


1. 步骤:粗略地将IDAan列表格式清理INPUT.ASM为 an OUTPUT.ASM(从我的脚本中提取;请参阅此处对此步骤的讨论

注意:应该提到忽略dd类似的指令。此外,我保留由====分隔的子程序和基本块-----

grep -E '^.text:*' INPUT.ASM | grep -v 对齐 | grep -E '^.{10,15}[0-9A-F]{2} *|========================|--- --------------------------------' | sed 's/\t/ /g' | grep -v 'dq' | grep -v 'dd' | grep -v 'db' | grep -v 'dw' | 切-c100-200 | sed -e 's/^[ \t]*//' | tr -s [:空白:] | 切-d ';' -f1 > OUTPUT1.ASM

2.步骤:OUTPUT.ASM在python中处理cleaned(从我的脚本中提取)

#!/usr/bin/python
mneLocal = 设置()
使用 open('OUTPUT.ASM') 作为 oFile:
    对于 oFile.readlines() 中的行:
        mne = line.split(" ")[0]
        如果 mne[0] != '-' 和 mne[0] != '=' 和 len(mne)≤6 而不是 mne[0].isdigit() 和 mne.islower():
            mneLocal.add(mne)
打印(本地)

3. 输出:应用于Ramnit数据集

设置(['jns','fbstp','jnp','rol','psrlw','fld1','jnz','movd','imul','lds','jnb','psrlq' , 'cdq', 'psrld', 'pand', 'pfmax', 'ror', 'fxch', 'jno', 'dt', 'fisub', 'movq', 'cmps', 'arpl', ' pi2fd'、'pfmin'、'cld'、'nop'、'pf2id'、'maxss'、'add'、'jcxz'、'adc'、'fadd'、'pf2iw'、'fistp'、'setbe' , 'aad', 'maxps', 'fmulp', 'movzx', 'fdivp', 'fdivr', 'femms', 'not', 'repe', 'cmc\r\n', 'svts', ' repne', 'shr', 'pfadd', 'sgdt', 'mulps',“离开”、“div”、“mulpd”、“shl”、“btc”、“cmp”、“rcpps”、“psubd”、“psubb”、“bts”、“btr”、“loope”、“jle” ', 'pandn', 'fist', 'out', 'fstcw', 'cbw\r\n', 'xor', 'sub', 'neg', 'rep', 'lddqu', 'jge', “movs”、“pfrcp”、“fdiv”、“jecxz”、“xchg”、“mul”、“pavgb”、“lea”、“ficom”、“pfsub”、“jz”、“addpd”、“jp” ', 'subsd', 'js', 'bt', 'fidiv', 'daa\r\n', 'jo', 'clc\r\n', 'lods', 'jg', 'ja', 'jb'、'addps'、'jl'、'cmovz'、'movsd'、'cld\r\n'、'xorpd', 'les', 'cmovl', 'subss', 'movsx', 'xlat', 'cmova', 'cmovb', 'nop\r\n', 'sbb', 'or', 'cmovg' , 'shrd', 'fsub', 'por', 'bound', 'pop', 'setnb', 'fmul', 'pabsw', 'subps', 'minsd', 'minss', 'sti\r\ n', 'xadd', 'cdq\r\n', 'setnl', 'retf', 'faddp', 'retn', 'rcr', 'rcl', 'pslld', 'call', 'setnz' , 'das\r\n', 'aas\r\n', 'setns', 'setnp', 'sldt', 'ptest', 'fcomi', 'divps', 'jmp', 'rcpss', ' ffree', 'lgdt', 'pfacc', 'utes', 'shld', 'fcomp', 'fsave','psraw', 'aam', 'subpd', 'fstsw', 'psrad', 'pxor', 'fsubp', 'fsubr', 'fldcw', 'dec', 'fld', 'loop', 'and ', 'addsd', 'cmovs', 'fldz', 'psubq', 'sal', 'int', 'lock', 'andpd', 'in', 'fucom', 'ud2\r\n', “addss”、“fild”、“sar”、“scas”、“psllw”、“andps”、“bswap”、“inc”、“mulss”、“paddd”、“std\r\n”、“paddb” ', 'psubw', 'stc\r\n', 'idiv', 'psllq', 'paddw', 'cli\r\n', 'mulsd', 'paddq', 'test', 'setp', 'fiadd', 'hnt', 'orpd', 'enter', 'minps', 'bsr','mov'、'orps'、'fstp'、'xorps'、'setle'、'bsf'、'fo'、'pfmul'、'movss'、'setb'、'aaa\r\n'、'setl ', 'divsd', 'fimul', 'seto', 'fcom', 'hlt\r\n', 'jbe', 'fst', 'divss', 'sets', 'push', 'pavgw', 'setz'])