Loading... 在写ShellCode的时候难免需要用到内联汇编,在X64的情况下无法使用,不说废话开始配置。 ![image.png](https://www.irohane.top/usr/uploads/2021/05/980841399.png) # 安装clang工具库 1. 安装Clang工具集. 打开Visual Studio Installer--如果有安装可以跳过此步 ![image.png](https://www.irohane.top/usr/uploads/2021/05/4061670388.png) ![image.png](https://www.irohane.top/usr/uploads/2021/05/4111901206.png) 安装完毕重启一下 ![image.png](https://www.irohane.top/usr/uploads/2021/05/1069366179.png) 这是我们正在用的工具集。 ![image.png](https://www.irohane.top/usr/uploads/2021/05/2779183161.png) 选择Clang-cl LLVM ![image.png](https://www.irohane.top/usr/uploads/2021/05/610181968.png) 点击应用 ![image.png](https://www.irohane.top/usr/uploads/2021/05/182483300.png) 重新运行之后发现失败 ![image.png](https://www.irohane.top/usr/uploads/2021/05/2667289276.png) # 使用ASM文件编译 参考文章:https://www.cnblogs.com/revercc/p/14609685.html 创建ASM文件 ![image.png](https://www.irohane.top/usr/uploads/2021/05/2506574750.png) ![image.png](https://www.irohane.top/usr/uploads/2021/05/3190466225.png) `ml64 /c %(filename).asm` `%(filename).obj;%(Outputs)` ![image.png](https://www.irohane.top/usr/uploads/2021/05/939474056.png) 点击确定 ![image.png](https://www.irohane.top/usr/uploads/2021/05/2217615668.png) ### 安装一个插件 AsmDude ![image.png](https://www.irohane.top/usr/uploads/2021/05/993436485.png) 安装完成之后 放入创建的ASM汇编文件里编译即可,C++调用声明如下规则 ![image.png](https://www.irohane.top/usr/uploads/2021/05/2636865344.png) 记得!记得要把平常用的变量类型改为64位类型。 ``` ;AddTowSum_64.asm ExitProcess PROTO public mytest .code mytest proc mov rax, 10 ;返回值为10 ret mytest endp GetPc proc sub rax, 5 ret GetPc endp ;返回TEB GetTeb64 PROC mov rax,gs:[30h] ret GetTeb64 endp ;返回PEB GetPeb64 PROC mov rax,gs:[60h] ret GetPeb64 endp ;返回PEBLdr GetPebLdr64 proc call GetPeb64 add eax,18h mov eax,[eax] ret GetPebLdr64 endp ; 返回 加载基址 GetImageBase64 proc mov rax, GS:[30h] mov rax, [rax + 60h] mov rax, [rax + 10h] ret GetImageBase64 endp ;返回Kernel32.dll GetModuleBase64 proc push RSI mov RSI,gs:[60h] ;esi = PEB地址 mov RSI,[RSI+18h] ;指向PEB_LDR_DATA 结构体 mov RSI,[RSI+30h] ;模块链表指针,InInit...List mov RAX,RSI pop RSI ret GetModuleBase64 endp ;内存拷贝 des src size Mymemcpy64 proc push rbp mov rbp,rsp sub rsp,50h push rcx push rdx mov rcx,r8 pop rsi pop rdi rep movsb add rsp,50h mov rsp,rbp pop rbp ret Mymemcpy64 endp ;设置内存为0 MySetMemZero64 proc mov rdi,rcx xor rax,rax mov rcx,r8 cld rep stosb MySetMemZero64 endp end ``` 最后修改:2021 年 05 月 22 日 © 允许规范转载 赞 0 如果觉得我的文章对你有用,请随意赞赏
1 条评论
不错不错,我喜欢看 www.jiwenlaw.com