看板 C_and_CPP 關於我們 聯絡資訊
原文吃掉 -------------------------------------------------- 作業系統:Windows 10 編譯器:MSVC(x86 32bits模式) ※ 超低可移植性注意 ※ 這個程式在別人的 x86 PC 跑不起來的機率應該有 80% 如果你編譯了這個程式,執行的時候卻當掉, 這是很正常的 (茶 -------------------------------------------------- #include<stdio.h> #include<stdlib.h> #include<string.h> #include "Windows.h" unsigned char code[] = { 0x8b, 0x44, 0x24, 0x04, 0x99, 0x31, 0xd0, 0x29, 0xd0, 0xc3 }; int main() { typedef int(*i_i_fptr)(int); int code_size = sizeof(code); int to_alloc_size = code_size + 20; void *f = VirtualAlloc( NULL, sizeof(to_alloc_size), MEM_COMMIT, PAGE_EXECUTE_READWRITE ); memset(f, 0, to_alloc_size); memcpy(f, code, code_size); i_i_fptr abs = (i_i_fptr)f; printf("%d", abs(-500)); } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.183.81.95 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1460038981.A.B32.html ※ 編輯: ronin728 (175.183.81.95), 04/07/2016 22:27:54
L4ys: 寫 shellcode 不如直接寫 inline asm 啊 XD 04/07 22:43
ronin728: 這問題很奇葩,當然要用不正常的做法啊 XD 04/07 22:57
weiclin: 推不正常作法 xD 04/08 04:17