首页
社区
课程
招聘
[讨论]仿fill-array-data-payload混淆尝试(失败)
2014-4-18 12:32 6037

[讨论]仿fill-array-data-payload混淆尝试(失败)

2014-4-18 12:32
6037
http://dexlabs.org/blog/bytecode-obfuscation
老文了

文中提到利用的条件之一是长度不一定
查了下pseudo-instructions,发现还有:packed-switch和sparse-switch

测试用的是sparse-switch

ident ushort = 0x0200 // id
size ushort // case数
keys int[] // int case-values
targets // offsets


首先插smali:

const/4 v0, 0x0
if-ne v0, v0, :cond_START
sparse-switch v0, :sswitch_data_SOMEDATA
:sswitch_GOTO_BEGIN
goto :cond_START
:sswitch_data_SOMEDATA
.sparse-switch
0x0 -> :sswitch_GOTO_BEGIN
.end sparse-switch
nop
nop
nop
nop
:cond_START

我用了一个case,并预留了一段空位,相当于两个case

正常dex如下:

.short 0x200
.short 1
.int 0
.int 3


强制改成3个case

.short 3 //强制3位
.int 0, 3, 4 // 0是准备switch到的,1占的本来0跳转的位置,3占了一组nop nop
.int 0xF, 0x4206F, 0x106E0032
// 0xF占了一组nop nop,0xF*2是相对swtich语句的偏移,0x4206F, 0x106E0032实际是正常代码


最后配个图:虽然混淆了,但执行不过……


测试结果是失败 FC
我初步结论是,switch-case的跳转不能瞎跳,即使逻辑上走不到,系统也会检查跳转点……

[培训]内核驱动高级班,冲击BAT一流互联网大厂工 作,每周日13:00-18:00直播授课

上传的附件:
收藏
点赞0
打赏
分享
最新回复 (2)
雪    币: 1413
活跃值: (401)
能力值: (RANK:270 )
在线值:
发帖
回帖
粉丝
Claud 6 2014-4-19 12:17
2
0
没自己写过,只分析过几个样本用了这玩意儿,所以不清楚错误原因。是不是没有四字节对齐?
雪    币: 224
活跃值: (42)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
tastypear 2014-4-19 22:37
3
0
没找到原因,一开始我以为是dalvik执行链不允许badcode,后来我发现跳到没有badcode的地方也出错
比如说
address switch-case
address 01 00 00 00、02 00 00 00 key
address 03 00 00 00、06 00 00 00 offset
0003008 #code after swich-case

如果03 00 00 00这个偏移改成到不走 goto 语句,到 3008 去,是可以正确执行的
如果03 00 00 00偏移到 3006,也就是 06 00 00 00的最后两个00 00,相当于nop用,它就FC

既然跳3008可以,应该和对齐没关系…
游客
登录 | 注册 方可回帖
返回