http://blogs.msdn.com/geffner/archive/2006/02/10/529320.aspx, i managed to work out another way to
accomplish the same work:
#include "stdafx.h"
typedef unsigned char __u8;
void __declspec(naked) shellcode(void)
{
__asm {
mov eax, 0x15db
rol eax, 0x13
xor eax, 0xdeadbeef
shr eax, 0x10
mov ebx, eax
shl eax, 0x2
add eax, ebx
add eax, ebx
add eax, ebx
add eax, 0x4
}
}
void __declspec(naked) stub(void)
{
}
int __cdecl main(int argc, char* argv[])
{
int i;
for (i = 0; i < (__u8 *)stub - (__u8 *)shellcode; i++)
{
printf ("//x%02x", ((__u8*)shellcode)[i]);
}
printf("/n");
return 0;
}
don't forget to turn on Minimize Size optimization option in Visual C++ compiler, missing this option will make the compiler align the machine code with 4 bytes, so for the sample code, there're 2 byte nop instruction in tail.
Jason is a Virus Analyst of Microsoft Anti Malware team, his blog is worth of a reading.
本文介绍了一种使用C++实现的批量打印汇编代码的方法。通过一个具体的示例展示了如何利用裸汇编指令进行特定操作,并提供了一个简单的主函数来逐字节输出汇编代码。为了确保代码的有效性和紧凑性,特别提到了在编译时启用最小化大小优化选项的重要性。
1582

被折叠的 条评论
为什么被折叠?



