RE lab 04 - Dynamic Analysis

Lab files and setup

Download the lab files from here. The archive password is infected.

$ apt-get install gdb git
$ cd
$ git clone https://github.com/longld/peda
$ echo "source ~/peda/peda.py" >> ~/.gdbinit

Dynamic analysis on Windows using x64dbg

To find out what an unknown executable (malware or otherwise) does, we plan to use x64dbg on Windows and analyze the actual instructions executed by the CPU. Since there is a GUI interface, it is much easier to navigate (if you know what you’re looking for).

In the main window you can see:

x64dbg tabs (only the ones we need so far):

x64dbg basic commands

Dynamic analysis on Linux using gdb/peda

gdb commands

(gdb) run
Starting program: /tmp/example/ret 
(gdb) b *0x80484f1
Breakpoint 3 at 0x80484f1: file ret.c, line 10.
(gdb) delete
Delete all breakpoints? (y or n) y
(gdb) info breakpoints 
Num     Type           Disp Enb Address    What
4       breakpoint     keep y   0x080484f1 in main at ret.c:10
(gdb) info break
Num     Type           Disp Enb Address    What
4       breakpoint     keep y   0x080484f1 in main at ret.c:10
5       breakpoint     keep y   0x080484c9 in main at ret.c:7
6       breakpoint     keep y   0x080484c9 in main at ret.c:8
(gdb) delete 5
(gdb) info break
Num     Type           Disp Enb Address    What
4       breakpoint     keep y   0x080484f1 in main at ret.c:10
6       breakpoint     keep y   0x080484c9 in main at ret.c:8
gdb-peda$ dump memory blabla.out 0x00400000 0x00400020
gdb-peda$ hexdump 0x00400000 20
0x00400000 : 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00   .ELF............
0x00400010 : 02 00 3e 00                                       ..>.

Task 1: Windows dynamic analysis

We will continue the puzzle-based tasks with a Windows PE (exe) file. The executable asks for a password and after doing some checks on it, alerts you if you’re correct or wrong. However, the correct password is not in the binary such that you will have to investigate how the password-checking works.

It is possible to completely reverse the program using static analysis alone. However, there are three complex functions that would normally take additional time. As we want to illustrate how dynamic analysis can speed up static analysis, you are not allowed to look into these three functions at all:

Objectives:

Task 2: Linux dynamic analysis

The Linux binary for today is a bit more convoluted as it has some anti-debugging and anti-disassembly mechanisms which you will learn to bypass.

Approaches we learned so far:

We need a different approach:

You have successfully bypassed the anti-debugging mechanism!

You now have the third function decrypted, but in binary form. For the following, if you do not have IDAPython (e.g. IDA Trial), use this IDC guide