-Raz0r- (11-20-2010),hadrians (12-06-2012),Hassan (11-24-2010),jkcnair (12-20-2012),Kuro Tenshi (11-29-2010),natselection (06-09-2015),___guilherme___ (12-22-2011)
Lena's Tuts Summaries
03. Basic nag removal + header problems
Intro:
Good News! This one is actually pretty easy. It's mainly just Noping or jumping past a few MessageBox functions. There're many different ways to get rid of the nags. What Lena does is show a variety of ways, outside of simply Noping.
There is a hidden monster in this tut though. The PE Header.
You know that PE File Format Compendium Lena has been mentioning for the past two tutorials? Well its adamant that you read it in this one. In fact I would go as far as saying if you don't read it then just forget about understanding the last part in the tutorial. NOTE: The part about changing the Entry point is not what I'm talking about.
What this covers:
- Nag removal
- Basic Jumps
- NOPing
- PE Header Basics
- Binary Editing
- Little Endian
Requirements:
- Your brain
- Olly
- AnalyzeThis! (you wont be able to complete the ReversMe.Oops.exe w/o this)
- PE File Format Compendium (probably)
This Tutorial consists of two files.
The first ReversMe is a breeze. basically ur just getting a little explanation of the PE Header. I only recommend reading the PE File Format Compendium, because it is much more in depth then the tutorials explanation which has to fit in the constraints of the video. Plus without reading it I seriously doubt you will be able to understand my explanation of the next file.
HERE BE DRAGONS!:
ReversMe.Oops.exe is enough to make some people give up understanding it right there. That is because it is many newbie reversers first introduction to packers, and its not even a real one. Just a couple of PE Header tricks to confuse Olly. The real problem is that Lena takes no time to explain why and how this simple trick can confuse Olly how it works or anything else. Therefore I will try to supplement my own explanation. I can only hope that it does a good enough job. If not please post question on the thread as that's what its here for. If you are hopelessly confused don't worry. The intro to packers was many just to show off how to binary edit in Olly. You can skip the understanding as the next tutorial doesn't require you understand this packer trick.
Explanation of RegisterMe.Oops.exe
There were changes in the PE Header that stopped the Olly from going to the entry point. Olly could also not properly display the section in the Memory view.
In the PE Header:
SizeOfCode = 40000400 It should have been 400.
SizeOfInitializedData = 4000A00 It should have been A00.
BaseOfCode = 40001000 It should have been 1000.
BaseOfData = 40002000 It should have been 2000.
NumberOfRvaandSizes = 40000004 It should have been 10.
Export Table Address = 500000 It should have been 0.
Export Table Size = 50000 It should have been 0.
1. I used LordPE and compared the first file "RegisterMe.exe" with the second file "RegisterMe.Oops.exe.
2. By using Compare I was able to see what was different, and what was changed.
3. Now it occured to me that it might not always be the case that I have a unmanipulated file to look at. So I need to come up with away to notice this change without a second file.
4. One idea was to use commonsense as most of the numbers changed here usually always have the same value. For instance:
The BaseOfCode is almost always 1000. Or 1000 + the image base in Borlands. 40001000 is way too much.Originally Posted by MSDN
The Data Section usually comes after the code section, and since each section must be multiples of the section alignement it has to be some multiple on 1000h. However since it could change I think the best way to get this value is by searching the Section Table for the .data section. We can get the right number from there.Originally Posted by MSDN
NumberOfRvaAndSizes was very easy as this number is always 10h.
Originally Posted by MSDNSizeOfCode should match its size listed in the Section Table. Simple enough.Originally Posted by MSDN
Finally there is the ExportTable RVA and Size. This should be rather easy to spot since it is non existent. Also since executable files usually don't have export tables anyway from what I know atleast.
Now the last on I had trouble on so I was hoping someone could help me out.
SizeOfInitializedData
I'm Not really sure if this space even matters. I'll try correcting the file without it and see if it changes anything, but Im interested in knowing a way to find the right number.Originally Posted by MSDN
Thanks for reading. I know I only offered one solution to each problem and that if someone changed the Section Table of some of the other thing it would be tough for me to figure out what they did, but I think the techniques I suggested would work on any file screwed with the same way. Small steps. I'll worry about other schemes of protection when the come up in the tutorials.
Finally you need to install the AnalyzeThis! Plugin to be able to make the changes to the PE Header and save it in Olly. Get it here: OpenRCE
Conclusion:
Wow! This one really threw us for a loop. If you made it through pat yourself on the back. You just beat your first packer! If not don't worry. This will become clear later through the series. And as always I include the file to decrease the load on Tuts4you, and this time also included PE File Format Compendium and AnalyzeTHis!. Goodluck and see you in #4.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
-Raz0r- (11-20-2010),hadrians (12-06-2012),Hassan (11-24-2010),jkcnair (12-20-2012),Kuro Tenshi (11-29-2010),natselection (06-09-2015),___guilherme___ (12-22-2011)