Author Topic: Import Table Hooking in C with Win32 API  (Read 2452 times)

0 Members and 1 Guest are viewing this topic.

Offline Karmic

  • /dev/null
  • *
  • Posts: 10
  • Cookies: 0
    • View Profile
Import Table Hooking in C with Win32 API
« on: April 26, 2015, 04:28:07 am »
I have the following assignment in class:

Develop a Win32 DLL that can be injected into a process using the injector that you have developed in Lab #2 (Code Injection). This DLL must install an import table hook to intercept calls made to the function CreateFileW() in kernelbase.dll from the mode kernel32.dll. The hook function must display the lpFileName parameter to CreateFileW() using OutputDebugString(). You will build a DLL (not an .EXE).

I have programmed the the injector and it works, but I am having a lot of trouble with the DLL. I dont want the answer, just a few clarifications.


I understand how to locate the IAT entry for CreateFileW() and how to change the value for it. I don't quite understand the following:

1. What do I change the IAT entry of CreateFileW() to? my malicious dll and have it execute my version of CreateFileW()?
« Last Edit: April 26, 2015, 04:29:04 am by Karmic »

Offline HTH

  • Official EZ Slut
  • Administrator
  • Knight
  • *
  • Posts: 395
  • Cookies: 158
  • EZ Titan
    • View Profile
Re: Import Table Hooking in C with Win32 API
« Reply #1 on: April 26, 2015, 11:09:44 am »
Correct, this is similar to hooking syscalls on a linux platform, there is also a good bit of info on this in the ShellCoders handbook.
<ande> HTH is love, HTH is life
<TurboBorland> hth is the only person on this server I can say would successfully spitefuck peoples women

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: Import Table Hooking in C with Win32 API
« Reply #2 on: April 29, 2015, 03:43:37 pm »
Erm, what class is this?  Your course sounds far, far more interesting than mine.
-Xires

Offline Karmic

  • /dev/null
  • *
  • Posts: 10
  • Cookies: 0
    • View Profile
Re: Import Table Hooking in C with Win32 API
« Reply #3 on: April 29, 2015, 06:21:10 pm »
Thanks HTH, I looked through it and I think I have a better understanding of what needs to be done, and fortunately the deadline was extended so I think i'll be able to finish.

Xires, this is a Windows internals and exploit development course focusing on persistence and priv esc in Windows. It's offered through an organization called cyberwarriors (worst name ever) to university students with some security background.

It's sponsored by the U.S. defense community, with whom you may not necessarily agree with, but hey, if they want to give free training, take it

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: Import Table Hooking in C with Win32 API
« Reply #4 on: April 30, 2015, 11:26:10 am »
Ah, okay, that makes more sense.  I'm familiar with them.  Unfortunately, such courses are not offered to me.  Thanks for the info.
-Xires