【软件安全实验2022】验证码——1
exeinfo 查殼,沒啥問題
打開 IDA,查找字符串
其中這一項比較可疑,形式一樣,進入查看
進入,A 鍵整理字符串
整理好后是這樣
X 鍵查看交叉引用
運氣不錯!進入
嘗試 Tab 鍵轉換成類 C 語言,因未定義函數,失敗。
到起始位置,C 鍵轉換成 code,后 P 鍵轉換成函數
這時就可以 Tab 鍵轉換成類 C 語言,是函數 sub_40243A
this 類型明顯不是 char**,應該是個句柄結構體指針,更換類型
IDA 幫我們分析好了,強強
觀察這幾部分,應該是個全局變量的數組
雙擊進入
換成數組
并 N 鍵重命名
ESC 鍵返回
Graph View 別扭,換成 Text View,再在函數區域按 Tab
名字不對的話可以按 N 刷新
看著煩,隱藏了
發現里面沒有加密函數,對 global_passwd 查看交叉引用,發現函數 sub_401F60
同樣分析,先更換類型
函數 sub_401F60 關鍵代碼如下,其中有生成 global_passwd 的關鍵部分
global_passwd 與程序開始運行時的時間、位置、計算機名稱有關
GetLocalTime(&this->systemtime64);v2 = this->systemtime64.wHour + this->systemtime64.wDay; weekday = this->systemtime64.wDayOfWeek; month = this->systemtime64.wMonth; nSize = 256; global_passwd[0] = this->systemtime64.wYear + month + weekday + 2 * v2; GetComputerNameA(computerName, &nSize); v5 = 0; if (strlen(computerName)) {v6 = global_passwd[1];do{v7 = computerName[v5++];v6 += this->systemtime64.wMonth + v7;global_passwd[1] = v6;} while (v5 < strlen(computerName)); } GetModuleFileNameA(0, Filename, 0x100u); for (i = 0; i < strlen(Filename); ++i)global_passwd[2] = this->systemtime64.wHour * (global_passwd[1] + Filename[i]);而對于比較難看懂的第四部分的驗證,在于函數 sub_402340 中,其中有
(A= dword ptr -20h) mov [esp+30h+A], 67452301h mov [esp+30h+A+4], 0EFCDAB89h mov [esp+30h+A+8], 98BADCFEh mov [esp+30h+A+12], 10325476h經搜索得 67452301h,0EFCDAB89h,98BADCFEh,10325476h 均為 MD5 中使用的函數,經進一步分析,得出函數行為就是 MD5!
最終,驗證碼的主體邏輯代碼如下,其中
CWnd::UpdateData(1); // 刷新輸入數據strcpy(passwd, this->pchar7C); // 復制到Stringpasswd[19] = 0; // 末尾置'0'v6 = global_passwd[0];passwd[4] = 0; // 刪除第一個'-'passwd[9] = 0; // 刪除第二個'-'passwd[14] = 0; // 刪除第三個'-'passwd_1 = strtol(passwd, &EndPtr, 16); // 第一部分轉成數值passwd_2 = strtol(&passwd[5], &EndPtr, 16); // 第二部分轉成數值passwd_3 = strtol(&passwd[10], &EndPtr, 16); // 第三部分轉成數值strtol(&passwd[15], &EndPtr, 16);a1[0] = passwd[15];a1[1] = 0;md5(a1, strlen(a1), v8);if ( passwd_1 == v6&& (CWnd::MessageBoxA(this, "恭喜你!序列號第1部分正確!", 0, 0), passwd_2 == (global_passwd[1] >> 8))&& (CWnd::MessageBoxA(this, "恭喜你!序列號第2部分正確!", 0, 0), passwd_3 == ((global_passwd[0] + global_passwd[2]) >> 8))&& (CWnd::MessageBoxA(this, "恭喜你!序列號第3部分正確!", 0, 0), v8[3] == 0x69772661)&& passwd[16] == 'F'&& passwd[17] == 'F'&& passwd[18] == '0' ){result = CWnd::MessageBoxA(this, "恭喜你!序列號完全正確!", 0, 0);}分析得 python 腳本
import hashlib import datetime import socket import ostime = datetime.datetime.now() # 獲取當前時間 year = time.year month = time.month weekday = time.weekday() + 1 # 星期一應該對應'1',故加一 hour = time.hour day = time.daypasswd = [0, 0, 0, 0]passwd[0] = year + month + weekday + 2 * (hour + day)computerName = socket.gethostname().upper() # 獲取計算機名,需要大寫 for ch in computerName:passwd[1] += month + ord(ch)fileFlag = False filePath = '' for root, dirs, files in os.walk(os.getcwd(), topdown=True):if 'DemoD2022.exe' in files:filePath = root + '\\DemoD2022.exe'fileFlag = Truebreak if fileFlag == False:print('未找到 DemoD2022.exe ,請放至同一文件夾下')exit(0) for ch in filePath:passwd[2] = hour * (passwd[1] + ord(ch))for i in range(255):m = hashlib.md5()m.update(i.to_bytes(1, 'big'))if m.hexdigest()[24:] == '69772661':print(('{:04X}-{:04X}-{:04X}-{}FF0').format(passwd[0], passwd[1] >> 8,(passwd[0] + passwd[2]) >> 8,chr(i)))總結
以上是生活随笔為你收集整理的【软件安全实验2022】验证码——1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浅谈MOS管的工作原理
- 下一篇: KUKA机器人使用PLC外部自动运行配置