Lab 16b Hacking Minesweeper With Ollydbg
Lab 16b Hacking Minesweeper With Ollydbg
Purpose
To hack MineSweeper at the binary level. This gives you practice using the Ollydbg debugger, Procdump, and
The Windows Server 2008 machine we have been using already has Python installed.
To see if you have it, open a Command Prompt and execute this command:
python
https://samsclass.info/124/proj14/python2.7-win.htm
Getting Minesweeper
Download the minesweeper program from the link below.
minesam.exe.zip
The game launches. Click Game, Beginner to see the small gameboard shown below. as shown below.
Click a cell. Some of the cells appear empty, and others are revealed with numbers in them, as shown below.
Viewing the Game in OllyDbg
Close Minesweeper.
below.
A Minesweeper window opens, but does not come to the front. Click its button on the taskbar to bring it to the front, as shown below.
Viewing the Stored Gameboard
From the OllyDbg menu bar, click Window, Dump.
Click the Minesweeper button on the taskbar to bring it to the front. Click a cell to change the display.
Comare the Minesweeper gameboard with the Dump window. You can see that the gameboard is stored in RAM, using an "A" for "1", and a "B" for "2",
as
shown below.
Notice the green-highlighted region in the image above. If we can find this sequence of bytes in RAM, we can find the gameboard in a memory dump.
Getting Procdump
In a Web browser, go to
https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
Download Procdump.zip, and put it in your Downloads folder.
Click Start, Computer. Navigate to your Download folder.
Right-click Procdump.zip and click "Extract All...", Extract.
# Dump memory
cmd = "del mine.dmp"
os.system(cmd)
cmd = "procdump -ma minesam.exe mine"
os.system(cmd)
# Find gameboard
mark ='\x0A\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\x10'
nread = 20
boardfound = 0
gameboard = []
# Print Gameboard
l = len(gameboard)
m = 32 # items per line
python cheat.py
The program shows the location of the mines. With this information, you should easily be able to click all the squares without mines, as shown below.
When you win the game, a secret word will appear, which is covered by a green box in the image below.
11.1 Beginner Level: Recording Your Score (15
pts) Use the form below to record your score in Canvas.
Name or Email:
Non-CCSF Student
Create a cheating tool that works for this level and win the game, as shown below.
CCSF Student
Non-CCSF Student
Non-CCSF Student
Sources
Game Hacking: WinXP Minesweeper
_MINIDUMP_TYPE Enumeration
Posted 9-18-18