Mobile Tech Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 4 April 2012

EXE dependencies - Read from PEB

Posted on 10:34 by Unknown
I was trying to understand where executables load all their dependencies from. So for example: When I load up minesweeper (winmine.exe) there are a host of additional DLLs that are loaded up as well. That's fine as there are functions inside each of those DLLs that winmine uses. What was interesting to find out though, was how the list of those DLLs was built in the first place. Where did the OS loader look...into the process..to find out 'what else to load'?

So I loaded up winmine.exe in Olly, Dep Walker and a few other tools to get an understanding of 'what all' was loaded. Once that was done I read up a little about the PE header to understand where dependencies are accessed from. In PE terminology, these are called imports. It turned out there was a Data Directory for the Import Table. So i thought; lets read the import table; that should give me a list.

So I wrote a little bit of Python code [after learning Python from Google's Python class ;)] to read the IMPORT TABLE from the PE header. This did give me quite a few DLLs but it still did not tally with what Olly was displaying.

The next thing I did was to modify my code to be recursive. So...

--- Load EXE. Get dependent DLLs from import table.
--- Load 1st DLL from previous list. Get its dependent DLLs. Add to list.
--- Load 2nd DLL from previous list. Get its dependent DLLs. Add to list.

And so on... until all dependencies were resolved.This was doubtlessly an improvement as I was closer to what was displayed in Olly [Alt+E]. It still wasn't complete though.

Then I read some more, read how Dependency Walker works, asked on Woodmann and re-read a few sections from Xeno Kovah's Life Of Binaries class. Turns out there are somethings called Delayed Imports. These aren't loaded statically at load time; like the Import table but only when a particular function needs to be called..later on...at runtime.

So I modified the code a little to recursively get all the DELAYED IMPORTS too. This would have been enough but it gave me a huge huge list which contained much much more than what Olly ever showed me :). So obviously this wasn't efficient either and it was something else.

So as usual when I'm stuck I bug the nice guys on Woodmann and I'm rarely disappointed. This time was no exception and I was pointed in the direction of something called a PEB.

The PEB or the Process Environment Block is apparently the only "part" (very loosely used) of a process that is in User Mode. Everything else is in Kernel mode. So if you want to find out every DLL that an EXE depends upon; its best to query the PEB instead of doing all that stuff I did earlier :)

I want to quickly touch upon the structure of the PEB before I finish this post. To look at the entire structure of the PEB you can visit this link. You need to query the PEB_LDR_DATA structure to get the list of Loaded DLLs. Here is an article that I found quite useful while I was learning stuff about all this.

And lastly..here is the complete thread of my discussion on Woodmann, if at all you are interested :).
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in loaderdata, olly, ollydbg, peb, peb_ldr_data, view | No comments
Newer Post Older Post Home
View mobile version

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • EMC Defenders CTF - Week 3 - Contest 14 - Reversing
    I played the EMC defenders CTF with a few of my friends a while back. We sadly couldn't complete all the challenges. All the same it was...
  • ASRock unveils a pair of motherboards designed specifically for Bitcoin mining!!!
    Those looking to generate some extra cash by mining for Bitcoin now have a couple of new hardware options courtesy of ASRock. The motherboar...
  • AuthenTec co-founder discusses how Touch ID fingerprint reader evolved from early prototypes!!!
    AuthenTec co-founder F. Scott Moody recently stopped by his alma mater to deliver a  speech  about the company he helped launch. His company...
  • Hackers breach vBulletin support forum using zero-day vulnerability!!!
    A group of European hackers by the name of Inj3ct0r Team have taken  responsibility  for hacking the support forums of vBulletin.com and the...
  • Amazon's trio of biospheres gets two thumbs up from Seattle Design Review Board!!!
    Earlier this year Amazon  submitted a building proposal  to construct a series of massive biospheres in downtown Seattle adjacent to three o...
  • Asus reveals Chromecast-like Miracast Dongle, has new smartphone and Chromebook line-ups on the way!!!
    Asus has made its way mainly in the PC business for quite some time now, but new reports have  surfaced pointing at the company looking to e...
  • Google Nexus 5: The geekysupport Review!!!
    It’s that time of the year again, where Google releases a new Nexus handset for those wanting a cheap yet powerful device running stock Andr...
  • A peek at the inside of Sony's PlayStation 4!!!
    See  what's inside the PlayStation 4 with these exclusive photos  Inside Sony headquarters, at the heart of Tokyo’s Shinagawa district, ...
  • A Software Challenge: Why Users Uninstall Apps!!!
    Getting an app developed is just the first step in a long journey. One of the more daunting problems facing developers is user engagement; b...
  • Apple iPad Air: The geekysupport Review!!!
    Read user comments It's hard to believe but it’s been less than four years since Apple released the iPad, opening the door to an entirel...

Categories

  • 100
  • 12.04
  • 2.2
  • 2013
  • 21
  • 4848
  • 8080
  • add
  • alternative
  • analysis
  • android
  • apk
  • app
  • applet
  • applets
  • appletviewer
  • application
  • appsec
  • asmx
  • assembly
  • attack
  • attacks
  • basic
  • basics
  • beginner
  • blazeds
  • blog
  • book
  • books
  • breakpoint
  • breakpoints
  • browser
  • burp
  • CALL
  • capture
  • certificate
  • chain
  • cheops
  • client side
  • code
  • conference
  • console
  • content-type
  • coverage
  • CRLF
  • cross
  • crossdomain
  • csrf
  • ctf
  • customer service
  • database
  • deblaze
  • debug
  • debugger
  • decision
  • defcon
  • delete
  • deleting
  • dll
  • dogbert
  • dom
  • dynamic
  • element
  • emulator
  • encryption
  • engineering
  • entity
  • environment
  • example
  • executable
  • external
  • firebug
  • flash
  • flex
  • FlourineFX
  • flow
  • flowchart
  • forensics
  • fs
  • fuzz
  • glassfish
  • graph
  • handbook
  • harden
  • hash
  • hints
  • hit
  • hittrace
  • howto
  • IDA
  • idapro
  • IDB
  • immunity
  • in use
  • incremental
  • inetsim
  • injection
  • install
  • introduction
  • java
  • java.policy
  • javaee
  • javascript
  • jks
  • jump
  • keyboard
  • lab
  • loaderdata
  • malware
  • management
  • mapper
  • market
  • MD Description
  • MD FAQ
  • MD Technical Support
  • MD Updates
  • MD User Guide
  • md5deep
  • mount
  • msdn
  • network
  • newbie
  • olly
  • ollydbg
  • options
  • packet
  • password
  • pbkdf
  • pcap
  • peb
  • peb_ldr_data
  • penetration
  • pentest
  • permissions
  • phone
  • pkcs12
  • policytool
  • port
  • practical
  • procedure
  • proxy
  • resign
  • resignation
  • response
  • restrict
  • reverse
  • reversing
  • review
  • salt
  • same origin
  • sample
  • scripting
  • sdk
  • secure
  • security
  • set
  • setup
  • sharif
  • shortcuts
  • SI
  • signed
  • site
  • snapshot
  • soapui
  • source
  • splitting
  • ssl
  • start
  • static
  • steps
  • stunnel
  • superblock
  • support
  • test
  • thoughts
  • thread
  • tips
  • tool
  • tools
  • tor
  • trace
  • truecrypt
  • tutorial
  • ubuntu
  • umask
  • understand
  • university
  • unsigned
  • video
  • view
  • virgin
  • virtual
  • virtual box
  • virtual machine
  • virtualbox
  • vm
  • watch
  • web
  • web application
  • web service
  • work
  • wsdl
  • xhr
  • xml
  • xss
  • xxe

Blog Archive

  • ►  2013 (496)
    • ►  November (143)
    • ►  October (297)
    • ►  September (51)
    • ►  August (2)
    • ►  March (1)
    • ►  January (2)
  • ▼  2012 (16)
    • ►  October (3)
    • ►  September (1)
    • ►  August (4)
    • ►  June (1)
    • ►  May (4)
    • ▼  April (2)
      • Olly - Hit trace..finding code flow
      • EXE dependencies - Read from PEB
    • ►  February (1)
  • ►  2011 (22)
    • ►  October (1)
    • ►  September (2)
    • ►  August (1)
    • ►  July (9)
    • ►  June (1)
    • ►  May (2)
    • ►  April (6)
  • ►  2010 (8)
    • ►  August (3)
    • ►  April (2)
    • ►  January (3)
  • ►  2009 (6)
    • ►  December (6)
Powered by Blogger.

About Me

Unknown
View my complete profile