【2022.3.8】记一次exe手动添加shellcode

【2022.3.8】记一次exe手动添加shellcode


测试的exe和添加了shellcode的exe:

链接:https://pan.baidu.com/s/1QJ02pb0_YxIgQCNY15LBAA
提取码:aura

0.大致思路

先在exe内部添加一段shellcode(这里只是简单弹出一个 MessageBox框的字节码),再修改exe的pe格式中的OEP,执行完shellcode之后,再跳回原本OEP

说明:修改的这个exe原本功能是弹出一个MessageBox,我做的是在他的MessageBox之前再弹出一个MessageBox,因为原本存在MessageBoxbox函数,所以方便我们获取MessageBox的真实地址。

image-20210518211000354

1.获取MessageBox的真实地址VA

OD调试测试exe,逻辑比较简单。

image-20210518211435099

双击地址0x40101a可以看到汇编指令为jmp dword ptr [402008],就是在IAT表里取地址,说明该exe的虚拟地址VA:402008,存储的是MessageBox函数的地址。

2.通过OD在代码段添加shellcode

其实任意节区都可以,但要执行代码,该节区头属性(Characteristics)字段必须包含可读可执行的权限,直接添加到代码段(节区)可以省去更改节区头属性的步骤

这里代码段空的地方比较多,我们直接在原有代码下方靠近的位置选一片区域添加shellcode(内存对应一般为1000,应该不会超出代码段)。

image-20210518213450316

记住我们添加代码段的地方,为0x401030

3.dump出数据,设置程序OEP

image-20210518213950988

4.测试dump出来的exe

已经在执行我们的shellcode了

image-20210518214146677

5.方法总结

这种直接在OD里通过书写汇编指令添加shellcode方式不用手动计算跳转地址,和构造字节码,直接在OD里相应位置写汇编指令,他会自动计算地址并生成字节码,比较简洁易上手。

我这里测试exe和添加的shellcode都比较短小,没有测试过更大的exe和shellcode,可能会以偏概全了,但是通过在OD里写汇编,OD可以给我们自动计算跳转指令的地址和生成字节码,省去我们手动构造,并且不用管FOA和RVA的转换。

给我们自动计算跳转指令的地址和生成字节码,省去我们手动构造,并且不用管FOA和RVA的转换。

如果Dump方法不行,可以先在OD书写shellcode的汇编指令,然后拷贝其生成的字节码,再手动在exe二进制文件相应位置添加即可(注意FOA和RVA的转换)。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Shellcode Helper v1.62 Coded by TeLeMan (c) 2008-2013 Usage: schelper.exe [options] Options: -i [input file] input file (Default: stdin) -o [output file] output file (Default: stdout) -s input file format (Default: Auto-Detection) -sb input file format is Binary -sp the input file format's parameters -d output file format (Default: C format) -db output file format is Binary -dp the output file format's parameters -search get the start offset by the pattern: e.g. PK\x03\x04 -soff fix the match offset after searching (Default: 0) -off convert the input file from the offset (Default: 0) -len convert the input file with the length (Default: 0 - MAX) -en [encoder] encode shellcode (Default: XorDword) -de [encoder] decode shellcode (Default: Auto-Detection) -ex exclude characters: e.g. 0x00,0x01-0x1F,0xFF (Default: 0x00) -in incude characters only -ep the encoder's parameters -t [pid] execute or inject shellcode into process for testing -td [pid] execute or inject shellcode into process for debugging -stack put shellcode into stack and execute it (ESP is the shellcode start) -noinfo display no normal messages except error messages Available formats: 0 - C 1 - C(HexArray) 2 - Perl 3 - Python 4 - Ruby 5 - JavaScript(Escape) 6 - VBScript(Escape) 7 - Pascal 8 - MASM(Data) 9 - HexDump 10 - BitString 11 - HexString 12 - HexArray(C like) 13 - Base64 14 - Binary 15 - HexString(C like) 16 - HexString(Escape) 17 - HexString(JavaScript,UNICODE) 18 - URI(ISO-8859-1) 19 - XML(PCDATA) 20 - BigNumber 21 - BigNumber(Hex) 22 - BigNumber(BaseX) 23 - FloatPoint 24 - UnixTimestamp 25 - GUID 26 - MASM(ASM) 27 - NASM 28 - YASM(ASM) 29 - FASM(ASM) 30 - JWASM(ASM) 31 - POASM(ASM) 32 - GOASM(ASM) 33 - GNU ASM Available encoders:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值