SGN算法可能已经死了|The SGN algorithm is dead.
The SGN algorithm is dead. Yara hunting for the sgn encode , i success 100% hunting all the sgn in the last relase version . SGN算法是什么? SGN算法是一种变异处理shellcode算法,被渗透测试、红队、APT广泛的使用,具体这个地址了解: https://github.com/EgeBalci/sgn 截至目前2026年3月16日,目前Sgn的混淆算法依然可以到VT0: 挑战编写Yara识别SGN算法 Github悬赏的挑战,比特币换算大概有1000RMB,我没有比特币的钱包地址,不过我依然决定亲自挑战一下全世界安全研究员都没做到的事情,疑似? 这个规则前几个月,我肝了几周写完的,本来想整理出来复习一下,但是现在时间隔得有点久了,没写记录,完全忘记了之前具体是怎么样分析SGN算法的(哈哈哈,专家一样会遗忘,我又不是机器人),想了一下算了,不写分析了,重新分析又要浪费好几天时间,目前精力主要在windows内核开发和基础的学习,就直接分享出来吧。。。。。 具体规则 注意,下面这个规则必须最新的yara版本才能解析,我不会提供老版本yara的语法规则。 具体Github地址,已经设置MIT版权了,随便用:https://github.com/kaliworld/theyaraforsgn 记得给我star,谢谢 rule sgn_plain_x86 { meta: description = "高置信度的 SGN x86 明文解码器 stub" author = "EndlessParadox" confidence = "high" strings: $stub = { E8 00 00 00 00 5? B9 ?? ?? ?? ?? [0-4] B? ?? [0-4] 30 ?? [2-8] 02 ?? [1-8] E2 ?? } condition: filesize > 32 and $stub in (0..64) } rule sgn_plain_x64 { meta: description = "高置信度的 SGN x64 明文解码器 stub" author = "EndlessParadox" confidence = "high" strings: $stub = { 48 C7 C1 ?? ?? ?? ?? [0-12] ( 48 | 49 | 4C | 4D ) 8D ?? ?? ?? ?? ?? [0-8] ( 30 ?? | 40 30 ?? | 41 30 ?? | 44 30 ?? | 45 30 ?? ) [0-6] ( 02 ?? | 40 02 ?? | 41 02 ?? | 44 02 ?? | 45 02 ?? ) [0-6] E2 ?? } condition: filesize > 32 and $stub in (0..96) } rule sgn_schema_x86 { meta: description = "高置信度的 SGN x86 架构型解码器" author = "EndlessParadox" confidence = "high" strings: $call = { E8 ?? ?? ?? ?? } $jmp = { FF E? } $tail = { 5? [0-64] ( 81 ?? ?? ?? ?? ?? | 81 ?? ?? ?? ?? ?? ?? | F7 1? | F7 5? ?? | C1 0? ?? | C1 4? ?? ?? ) [0-48] ( 81 ?? ?? ?? ?? ?? | 81 ?? ?? ?? ?? ?? ?? | F7 1? | F7 5? ?? | C1 0? ?? | C1 4? ?? ?? ) [0-48] ( 81 ?? ?? ?? ?? ?? | 81 ?? ?? ?? ?? ?? ?? | F7 1? | F7 5? ?? | C1 0? ?? | C1 4? ?? ?? ) [0-64] FF E? } condition: filesize > 96 and $call in (0..64) and $jmp in (filesize-8..filesize) and $tail } rule sgn_schema_x64 { meta: description = "高置信度的 SGN x64 架构型解码器" author = "EndlessParadox" confidence = "high" strings: $call = { E8 ?? ?? ?? ?? } $jmp_lo = { FF E? } $jmp_hi = { 41 FF E? } $tail_lo = { 5? [0-64] ( 81 ?? ?? ?? ?? ?? | 81 ?? ?? ?? ?? ?? ?? | F7 1? | F7 5? ?? | C1 0? ?? | C1 4? ?? ?? ) [0-48] ( 81 ?? ?? ?? ?? ?? | 81 ?? ?? ?? ?? ?? ?? | F7 1? | F7 5? ?? | C1 0? ?? | C1 4? ?? ?? ) [0-48] ( 81 ?? ?? ?? ?? ?? | 81 ?? ?? ?? ?? ?? ?? | F7 1? | F7 5? ?? | C1 0? ?? | C1 4? ?? ?? ) [0-64] FF E? } $tail_hi = { 41 5? [0-64] ( 41 81 ?? ?? ?? ?? ?? | 41 81 ?? ?? ?? ?? ?? ?? | 41 F7 1? | 41 F7 5? ?? | 41 C1 0? ?? | 41 C1 4? ?? ?? ) [0-48] ( 41 81 ?? ?? ?? ?? ?? | 41 81 ?? ?? ?? ?? ?? ?? | 41 F7 1? | 41 F7 5? ?? | 41 C1 0? ?? | 41 C1 4? ?? ?? ) [0-48] ( 41 81 ?? ?? ?? ?? ?? | 41 81 ?? ?? ?? ?? ?? ?? | 41 F7 1? | 41 F7 5? ?? | 41 C1 0? ?? | 41 C1 4? ?? ?? ) [0-64] 41 FF E? } condition: filesize > 96 and $call in (0..64) and ( $jmp_lo in (filesize-8..filesize) or $jmp_hi in (filesize-8..filesize) ) and any of ($tail*) } rule sgn_high_confidence { meta: description = "高置信度的 SGN 编码器检测规则" author = "EndlessParadox" profile = "high-confidence-SGN" release = "1.0" condition: sgn_plain_x86 or sgn_plain_x64 or sgn_schema_x86 or sgn_schema_x64 } 识别效果 msf生成shellcode: ...