|
Posted on 2009-03-25 18:07 besterChen 阅读(2729) 评论(3) 编辑 收藏 引用 所属分类: C/C++/STL/boost
比赛的地址是: http://www.ghoffice.com/bbs/read-htm-fid-97-tid-63475.html引用一下原题目:
很简单的题目,可是要求是:要不你精简,要不你奇特,我看到这个比赛题目的时候,没有办法,人家已经把我知道的精简式的代码几乎贴完了,那我也就只能来个奇特的了,用shellcode实现,代码如下:
#include "stdio.h" #include "windows.h" typedef unsigned char BYTE;
typedef VOID (CALLBACK *MYSPRINTF)(char *, const char *, ); typedef VOID (CALLBACK *MYLSTRCAT)(char *, char *); typedef VOID (CALLBACK *MYMSGBOX)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
MYSPRINTF mySprintf = (MYSPRINTF)GetProcAddress(LoadLibraryA("msvcr71.dll"), "sprintf"); MYLSTRCAT myStrCat = (MYLSTRCAT)GetProcAddress(LoadLibraryA("KERNEL32.dll"), "lstrcatA"); MYMSGBOX myMsgBox = (MYMSGBOX)GetProcAddress(LoadLibraryA("user32.dll"), "MessageBoxA");
BYTE buf[] = { 0xB8,0x00,0x12,0x00,0x00,0xE8,0xAE,0x00,0x00,0x00,0x55,0x56,0x57,0xB9,0x7F,0x00,\ 0x00,0x00,0x33,0xC0,0x8D,0x7C,0x24,0x0D,0xC6,0x44,0x24,0x0C,0x00,0xC6,0x84,0x24,\ 0x0C,0x02,0x00,0x00,0x00,0xF3,0xAB,0x66,0xAB,0xAA,0xB9,0xFF,0x03,0x00,0x00,0x33,\ 0xC0,0x8D,0xBC,0x24,0x0D,0x02,0x00,0x00,0xBE,0x01,0x00,0x00,0x00,0xF3,0xAB,0x66,\ 0xAB,0xAA,0xBF,0x01,0x00,0x00,0x00,0x3B,0xF7,0x7C,0x33,0x8B,0xEE,0xA1,0x18,0x61,\ 0x40,0x00,0x55,0x57,0x56,0x8D,0x4C,0x24,0x18,0x50,0x51,0xFF,0x15,0x20,0x86,0x40,\ 0x00,0x83,0xC4,0x14,0x8D,0x54,0x24,0x0C,0x8D,0x84,0x24,0x0C,0x02,0x00,0x00,0x52,\ 0x50,0xFF,0x15,0x28,0x86,0x40,0x00,0x47,0x03,0xEE,0x3B,0xFE,0x7E,0xCF,0x8D,0x8C,\ 0x24,0x0C,0x02,0x00,0x00,0x68,0x24,0x61,0x40,0x00,0x51,0xFF,0x15,0x28,0x86,0x40,\ 0x00,0x46,0x83,0xFE,0x0A,0x7C,0xAB,0x6A,0x00,0x8D,0x94,0x24,0x10,0x02,0x00,0x00,\ 0x68,0x28,0x61,0x40,0x00,0x52,0x6A,0x00,0xFF,0x15,0x24,0x86,0x40,0x00,0x5F,0x5E,\ 0x5D,0x81,0xC4,0x00,0x12,0x00,0x00,0xC3\ };
BYTE AllocBuf[] = { 0x51,0x3D,0x00,0x10,0x00,0x00,0x8D,0x4C,0x24,0x08,\ 0x72,0x14,0x81,0xE9,0x00,0x10,0x00,0x00,0x2D,0x00,\ 0x10,0x00,0x00,0x85,0x01,0x3D,0x00,0x10,0x00,0x00,\ 0x73,0xEC,0x2B,0xC8,0x8B,0xC4,0x85,0x01,0x8B,0xE1,\ 0x8B,0x08,0x8B,0x40,0x04,0x50,0xC3\ }; const char *pConChar = "%d*%d=%-4d\0"; const char *pTitle = "九九乘法表\0"; char *pNchar = "\n";
void main() { long* pVoid = (long *)buf; __asm { CALL pVoid; } }
就这样了,贴小效果的图片吧: 贴一下bin和SRC: bin和Src (说明,由于全部用了硬编码,所以,有可能在各位的电脑上不能正常运行!) MS:本程序在WinXP SP3下测试通过!
Feedback
# re: 广海社区 --- 编程大塞题目《打印九九乘法表》 回复 更多评论
2009-03-26 19:28 by
其实有一种方法 有效率又很小
# re: 广海社区 --- 编程大塞题目《打印九九乘法表》[未登录] 回复 更多评论
2010-01-13 08:04 by
小论坛吧。
# re: 广海社区 --- 编程大塞题目《打印九九乘法表》 回复 更多评论
2012-01-10 10:45 by
胖子这么变态。。。
puts("1x1=1");
.....
puts("9x9=81");
|