讓scanf()接收空格
阿新 • • 發佈:2018-05-19
逆向大家都知道scanf()遇到空格後就會結束 原因是底層函數是這麽返回給你的
調用scanf()時 那現在從底層把他截獲
源碼://vs2015
調用scanf()時 那現在從底層把他截獲
源碼://vs2015
#include <windows.h> #include<iostream> using namespace std; _ACRTIMP_ALT FILE* __cdecl __acrt_iob_func(unsigned); #ifdef __cplusplus extern "C" #endif FILE* __cdecl __iob_func(unsigned i) { return __acrt_iob_func(i); } // 全局變量 char g_szId[120] = { " i love this game\n\n" }; #pragma comment(lib,"user32.lib") int main() { // 局部變量 char szBuf[120]; printf("please input password: "); scanf_s("%s", szBuf, 120); char* p = *(char**)((int)__iob_func(0) + 4); //取緩沖區中的值 __iob_func(0)輸入 //__iob_func(1)輸出 __iob_func(2)錯誤 printf("%s\n", szBuf); printf("%s", p); if (strcmp(p, g_szId) == 0) { printf("It‘s Right\n"); } else { printf("It‘s Err \n"); } system("pause"); return 0; } //vc6.0版 //#include "stdio.h" //#include <windows.h> //// 全局變量 //char g_szId[120] = { " i love this game\n\n" }; //#pragma comment(lib,"user32.lib") // //int _tmain(int argc, _TCHAR* argv[]) //{ // // 局部變量 // char szBuf[120]; // printf("please input password: "); // scanf_s("%s", szBuf, 120); // // char* p = *(char**)((int)__iob_func() + 8); // if (strcmp(p, g_szId) == 0) // { // printf("It‘s Right \n"); // } // else // { // printf("It‘s Err \n"); // } // system("pause"); // // return 0; //}
為什麽打那麽多呢 其時底層不管你打什麽它都保存在那
用途:
優化下可以作為登錄密碼(我本來就是逆出來的)
讓scanf()接收空格