In the "x86 Native Tools Command Prompt for VS 2017" window, execute these commands, as shown below:
mkdir c:\pe
cd c:\pe
notepad hello.cpp
Notepad asks if you want to create a new file. Click Yes.
Enter this source code, as shown below:
#include <iostream>
using namespace std;
void main()
{
printf("Hello!\n");
}
Save the file.
In the "x86 Native Tools Command Prompt for VS 2017" window, execute these commands, as shown below:
cl /EHsc hello.cpp
hello.exe
Open the C:\pe\hello.exe file in PEview.
In the left pane, click IMAGE_DOS_HEADER.
This header is now unused. The only important features are the first and last item, as shown below.
Scrolling down, we see the Import Address Table, at RVA 11000. As we'll see below, that matches the start of the .rdata section.
For each section, note these features, as shown below.
Then you can calculate the actual memory layout of the program, by adding the RVA to the Image Base, as shown below.
(The Image Base is in the IMAGE_OPTIONAL_HEADER.)
Section RVA Memory Address Image Base 400000 .text 1000 401000 .rdata 12000 412000 .data 19000 419000 .reloc 1B000 41B000
As shown below, the layout matches the pattern, although the base address was not 400000 on my system.
PMA 122.1: Missing Section (10 pts)
Download this file:Examine that file. It has four sections. Compare it to the hello.exe file you made above.
What section is present in hello.exe but not present in hello2.exe?
That section's name is the flag.
PMA 122.2: Broken (20 pts)
Download this file:The file is damaged and cannot run.
Fix it and run it to see the flag.
Hint: Use CFF Explorer. Examine the headers. Invalid fields turn red.
PMA 122.3: Broken (20 pts)
Download this file:The file is damaged and cannot run.
Fix it and run it to see the flag.
Hint: If SmartScreen blocks the file, unblock it in the file Properties.
Hint: In the Section Header, all the Virtual Addresses should end with "000".
Posted 9-23-2020
SmartScreen hint added 9-29-20
brackets around iostream HTML-encoded 9-30-20
Updated 5-30-2021
Extra points enumerated 8-31-2021
FLARE-VM reference removed 9-7-2021
122.1 explanation expanded 9-19-22
122.2 hint added 10-12-22
122.3 hint added 10-14-22
For flag 1, note added that number of sections in hello.exe varies added 3-4-25
Video added 3-26-25