shellcode
2019-07-18 15:38:15 Author: wbglil.github.io(查看原文) 阅读量:499 收藏

最近复习一下汇编顺便加深一下shellcode自己写写
介绍什么就不说了。

编写shellcode的基本方式

1.直接编写十六进制操作码
2.采用C或者Delphi这种高级语言编写程序,编译后,对其反汇编进而获得十六进制操作码
3.编写汇编程序,将该程序汇编,然后从二进制中提取十六进制操作码

###编写shellcode常见要解决的一些问题###
1.不能使用绝对地址重定位问题
2.获取函数地址
3.编码问题
4.躲避IDS检测。

###编写的基本步骤###
获取kernel32.dll基地址
定位GetProcAddress函数地址
使用GetProcAddress确定LoadLibrary函数地址
使用LoadLibrary加载DLL文件
使用GetProcAddress查找要的函数地址指定函数参数并调用

获取kernel32.dll基址
一般使用VS编写shellcode如果是32位的可以使用内嵌汇编,但如果是x64位的就无法使用内嵌汇编只能:
1.使用纯C/C++
2.将程序段全部放到一个asm文件下进行编译
3.恢复VS__asm关键字
4.其他编译器(GCC)

X64上恢复VS关键字__asm的方法可参照:
http://bbs.pediy.com/showthread.php?p=1260419

获取kernel32基址其他的就都好说了就是要注意定义变量是要将其放在代码段否则VS会将其放在数据段这样在其他程序中shellcode就无法运

###shellcode编码###
shellcode编码简单的可以使用异或进行解码或使用其他的加密方式只要记得在最开始进行解码就行

shellcode自动生成工具:
https://github.com/NytroRST/ShellcodeCompiler
https://github.com/aaaddress1/shellDev.py

一些文章和资源:
https://xz.aliyun.com/t/2108
https://www.cnblogs.com/manu18/articles/9445130.html
https://github.com/peterferrie/win-exec-calc-shellcode
https://github.com/killeven/ObjToShellCode
https://github.com/tophertimzen/shellcodeTester
https://github.com/3gstudent/Shellcode-Generater


文章来源: http://wbglil.github.io/2019/02/01/shellcode/
如有侵权请联系:admin#unsafe.sh