J.J. Huang   2019-06-28   Cheat Engine   瀏覽次數:次  

Cheat Engine - 第八章 | CE Tutorial Step 7

📑 目錄
  1. 教程分析
  2. 解題
    1. 第一步
    2. 第二步
    3. 第三步
    4. 第四步
    5. 第五步
    6. 第六步
    7. 代碼說明
    8. 第七步
  3. 完整動態解題
  4. 其他修改方式

教程分析

第七關:代碼注入(密碼是 013370)。

點一下打我減少1滴血。

你需要做的是:點一下打我改成加2滴血。​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

解題

第一步

  • 首先看到頁面上的 100
  • 接著我們在需要搜尋的值那邊輸入100
  • 點擊首次搜尋
  • 會將搜尋結果顯示在搜尋的結果地址表的框內

Cheat Engine - 第八章 - 圖 1 (01)

第二步

  • 點擊 Hit me,讓數字變動
  • 根據 99 數值,在需要搜尋的值重新輸入 (這邊範例為99)
  • 點擊再次搜尋
  • 此時會發現搜尋的結果地址表的結果變少了 (有時候會精準到剩下一個,或是剩下多個)

Cheat Engine - 第八章 - 圖 2 (02)

第三步

  • 針對該地址點擊右鍵
  • 選擇 Find out what writes to this address
  • 會跳出This will attach the debugger on Cheat Engine to the current process. Continue?,點擊Yes
  • 點擊 Hit me,讓數字變動
  • 此時會發現The following opcodes write to xxxxxxxx視窗內計數器視窗的多了一條指令
  • 點擊Show disassembler
  • 會打開Memory viewer視窗

Cheat Engine - 第八章 - 圖 3 (03)​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

第四步

  • 選中指令Tutorial-i386.exe+258ED - 83 AB 78040000 01 - sub dword ptr [ebx+00000478],01 { 1 } (可能會有點不一樣)
  • 點擊Tools -> Auto assemble (簡稱:AA)
  • 將會打開Auto assemble視窗

Cheat Engine - 第八章 - 圖 4 (04)

Cheat Engine - 第八章 - 圖 5 (05)

第五步

  • 點擊Template -> Code injection
  • 確認地址就是剛才在 Disassembler 中選擇的那個地址,直接點 OK 即可。

Cheat Engine - 第八章 - 圖 6 (06)​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

Cheat Engine - 第八章 - 圖 7 (07)

第六步

  • sub dword ptr [ebx+00000478],01 改成 add dword ptr [ebx+00000478],02 就可以了。
  • This code can be injected. Are you sure? 點擊 Yes
  • The code injection eas successfull newmem= ******** Got to ********? 點擊 No

註:原本這條代碼是把 [ebx+00000478] 這個內存地址的資料減 1,把 sub 改成 add 就是加 1 了,再把 01 改成 02 就是加 2 了。如果想更近一步了解組合語言可以參考X86組合語言/基本指令集

修改前/後:​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
sub dword ptr [ebx+00000478],01

exit:
jmp returnhere

"Tutorial-i386.exe"+258ED:
jmp newmem
nop
nop
returnhere:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
add dword ptr [ebx+00000478],02

exit:
jmp returnhere

"Tutorial-i386.exe"+258ED:
jmp newmem
nop
nop
returnhere:

Cheat Engine - 第八章 - 圖 8 (08)

Cheat Engine - 第八章 - 圖 9 (09)

Cheat Engine - 第八章 - 圖 10 (10)​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

代碼說明

newmem:originalcode:exit:"Tutorial-i386.exe"+258ED:returnhere: 這幾個個東西雖然都有冒號,但是的用途是不一樣的。

newmem"Tutorial-i386.exe"+258ED 是具體的內存地址,他表示接下來所有指令將被寫入這個內存地址。

originalcodeexitreturnhere 是標籤,不佔據字節,不佔據指令,他表示一個暫時不知道的地址,僅僅用於跳轉。​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

所以從newmem:"Tutorial-i386.exe"+258ED: 之間的指令都會寫到新分配的地址中,"Tutorial-i386.exe"+258ED: 到結尾的指令都會覆蓋原始指令(實現代碼注入的效果)

而代碼最前面的這四句,就是用來定義這些內存地址或標籤的

1
2
3
4
alloc(newmem,2048) // 申請 2048 字節的內存,newmem 就是這個內存地址
label(returnhere) // 定義用於跳轉的標籤 returnhere
label(originalcode) // 定義用於跳轉的標籤 originalcode
label(exit) // 定義用於跳轉的標籤 exit

第七步

  • 點擊Hit me
  • 可以看到Next已經為可以點擊進入下一關

Cheat Engine - 第八章 - 圖 11 (11)​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

完整動態解題

Cheat Engine - 第八章 - 圖 12 (12)

其他修改方式

在第六步,我們使用注入的方式去修改代碼;更簡單的方式,直接在反彙編窗口中把 sub dword ptr [ebx+00000478],01 中的 01 改成 -02

Cheat Engine - 第八章 - 圖 13 (13)​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌‌​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌​‌‌​‌​​‌‌​​‌​​​‌‌​​​​​​‌‌​​​‌​​‌‌‌​​‌​​‌‌​​​​​​‌‌​‌‌​​​‌‌​​‌​​​‌‌‌​​​​​‌​‌‌​‌​‌‌​​​‌‌​‌‌​‌​​​​‌‌​​‌​‌​‌‌​​​​‌​‌‌‌​‌​​​‌​​​‌​‌​‌‌​‌‌‌​​‌‌​​‌‌‌​‌‌​‌​​‌​‌‌​‌‌‌​​‌‌​​‌​‌​​‌‌‌​​​

Cheat Engine - 第八章 - 圖 14 (14)