Results 1 to 9 of 9
  1. #1
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow

    [Help]Externally listing functions in the IAT.

    Sup, so I wanted to list the functions in the IAT of another process without having to inject a module into it so I decided to do this. |:

    Anyway, it's extremely messy and probably inefficient, I had to use ReadProcessMemory quite a bit to achieve what I wanted, anyways, it works...

    Here ya' go, I tested it using calculator, as you can see.

    [highlight=cpp]
    #include <windows.h>
    #include <iostream>
    #include <tlhelp32.h>

    using namespace std;

    void DisplayIAT(unsigned long processid)
    {
    PROCESSENTRY32 ProcEnt;
    ProcEnt.dwSize = sizeof( PROCESSENTRY32 );

    HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);


    Process32First(Snapshot,&ProcEnt);

    do {
    if(ProcEnt.th32ProcessID == processid)
    {
    break;
    }
    }while(Process32Next(Snapshot,&ProcEnt));

    MODULEENTRY32 ModEnt;
    ModEnt.dwSize = sizeof( MODULEENTRY32 );

    HMODULE hMod;
    HANDLE Snapshot1 = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,ProcEnt .th32ProcessID);

    Module32First(Snapshot1,&ModEnt);
    do {
    if( strcmp(ProcEnt.szExeFile,ModEnt.szModule) == 0 )
    {
    hMod = ModEnt.hModule;
    break;
    }
    }while(Module32Next(Snapshot1,&ModEnt));

    cout << hex << (int)hMod << endl;
    cout << ModEnt.szModule << endl;

    HANDLE handle = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ,0,ProcEnt.th32ProcessID);

    unsigned char* temp;

    //DOS
    IMAGE_DOS_HEADER* pDos;
    temp = new unsigned char[sizeof(IMAGE_DOS_HEADER)];
    ReadProcessMemory(handle,(LPVOID)hMod,(LPVOID)temp ,sizeof(IMAGE_DOS_HEADER),0);
    pDos = (IMAGE_DOS_HEADER*)temp;
    temp = 0;

    //HEADER
    IMAGE_OPTIONAL_HEADER* pHeader;
    temp = new unsigned char[sizeof(IMAGE_OPTIONAL_HEADER)];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + pDos->e_lfanew + 24 ),(LPVOID)temp,sizeof(IMAGE_OPTIONAL_HEADER),0);
    pHeader = (IMAGE_OPTIONAL_HEADER*)temp;
    temp = 0;

    //DESCRIPTOR
    IMAGE_IMPORT_DESCRIPTOR* pDescriptor;
    temp = new unsigned char[sizeof(IMAGE_IMPORT_DESCRIPTOR)];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + pHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress ),(LPVOID)temp,sizeof(IMAGE_IMPORT_DESCRIPTOR),0);
    pDescriptor = (IMAGE_IMPORT_DESCRIPTOR*)temp;
    temp = 0;

    int i = 0;
    while( pDescriptor->FirstThunk )
    {
    IMAGE_THUNK_DATA* pThunk;
    temp = new unsigned char[sizeof(IMAGE_THUNK_DATA)];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + pDescriptor->OriginalFirstThunk ),(LPVOID)temp,sizeof(IMAGE_THUNK_DATA),0);
    pThunk = (IMAGE_THUNK_DATA*)temp;
    temp = 0;

    i+= sizeof(IMAGE_IMPORT_DESCRIPTOR);

    char modName[24];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + pDescriptor->Name ),modName,24,0);
    cout << "\n\n" << modName << "\n\n" << endl;

    int n = 0;
    while(pThunk->u1.Function)
    {
    n+=4;

    char funcName[100];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + (DWORD)pThunk->u1.AddressOfData + 2 ),funcName,100,0);

    temp = new unsigned char[sizeof(IMAGE_THUNK_DATA)];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + pDescriptor->OriginalFirstThunk + n ),(LPVOID)temp,sizeof(IMAGE_THUNK_DATA),0);
    pThunk = (IMAGE_THUNK_DATA*)temp;
    temp = 0;

    cout << funcName << endl;
    }

    temp = new unsigned char[sizeof(IMAGE_IMPORT_DESCRIPTOR)];
    ReadProcessMemory(handle,(LPVOID)( (BYTE*)hMod + pHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress + i),(LPVOID)temp,sizeof(IMAGE_IMPORT_DESCRIPTOR),0) ;
    pDescriptor = (IMAGE_IMPORT_DESCRIPTOR*)temp;
    temp = 0;
    }

    }

    int main()
    {
    DWORD pid;
    HWND hwnd = FindWindow(0,"Calculator");
    GetWindowThreadProcessId(hwnd,&pid);
    DisplayIAT(pid);

    cin.get();
    }
    [/highlight]

    Yep.

  2. The Following 10 Users Say Thank You to Void For This Useful Post:

    'Bruno (09-26-2010),ha11owed (09-28-2011),Hell_Demon (09-30-2010),Jason (06-16-2012),Kallisti (09-25-2010),Melodia (09-26-2010),MyPianoSucks (10-05-2010),NextGen1 (09-24-2010),therofl (10-01-2010),why06 (09-26-2010)

  3. #2
    zeco's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Canada
    Posts
    683
    Reputation
    12
    Thanks
    78
    My Mood
    Cynical
    ▓▓▓▓▓▓▓▓▓▓
    ▓▓▓ -__- ▓▓▓
    ▓▓▓▓▓▓▓▓▓▓

  4. #3
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by zeco View Post
    ▓▓▓▓▓▓▓▓▓▓
    ▓▓▓ -__- ▓▓▓
    ▓▓▓▓▓▓▓▓▓▓
    Jon said it best. (though Im not sure what he said) I didn't know they had structures for those image structures in the WinAPI. But everything looks right to me, you even used e_lfanew. Looks like u did your homework. Good job.

    "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

  5. #4
    zeco's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Canada
    Posts
    683
    Reputation
    12
    Thanks
    78
    My Mood
    Cynical
    Quote Originally Posted by why06 View Post
    Jon said it best. (though Im not sure what he said) I didn't know they had structures for those image structures in the WinAPI. But everything looks right to me, you even used e_lfanew. Looks like u did your homework. Good job.
    Good job shaun. . .It would seem the other 70 people who looked at this were just left utterly speechless in the presence of David's awe inspiring work.

    By the way, you like replied to this thread as soon as I clicked it to check it :/ Hax0r

    By the, by the way, whats with the awesome new emoticons like onionhead etc.?

    P.S. I'm not sure if you can stack by the way like P.S.
    Last edited by zeco; 09-26-2010 at 07:28 AM.

  6. #5
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by zeco View Post
    Good job shaun. . .It would seem the other 70 people who looked at this were just left utterly speechless.
    Yeh that's why I said u said it best. Cuz no1 else said anything.

    And the emoticons are from when MPGH1 (msn group) spilled over into MPGH. So no the msn and the regular emots are mixed.

    Finally I was outta town and just got back this morning, I didn't notice you just posted though. /

    "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

  7. #6
    .::SCHiM::.'s Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    733
    Reputation
    180
    Thanks
    880
    My Mood
    Twisted
    Huh?

    I didn't know that the pe structure was loaded into memory...
    Strange...

    I'm SCHiM

    Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.

    Polymorphic engine
    Interprocess callback class
    SIN
    Infinite-precision arithmetic
    Hooking dynamic linkage
    (sloppy)Kernel mode Disassembler!!!

    Semi debugger




  8. #7
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by zeco View Post
    Good job shaun. . .It would seem the other 70 people who looked at this were just left utterly speechless in the presence of David's awe inspiring work.

    By the way, you like replied to this thread as soon as I clicked it to check it :/ Hax0r

    By the, by the way, whats with the awesome new emoticons like onionhead etc.?

    P.S. I'm not sure if you can stack by the way like P.S.
    Mighty zeco has returned.

  9. The Following 2 Users Say Thank You to Void For This Useful Post:

    therofl (10-01-2010),why06 (09-26-2010)

  10. #8
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by Void View Post
    Mighty zeco has returned.
    Yes he has.

    "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

  11. #9
    zeco's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Canada
    Posts
    683
    Reputation
    12
    Thanks
    78
    My Mood
    Cynical
    Quote Originally Posted by why06 View Post
    Yes he has.
    No he hasn't.

    This is all a phallacy. (misspelling intentional)

Similar Threads

  1. help proxy list
    By Mike273 in forum Spammers Corner
    Replies: 3
    Last Post: 05-28-2018, 05:44 PM
  2. Displaying the IAT list from within a injected dll
    By Anddos in forum C++/C Programming
    Replies: 2
    Last Post: 08-18-2010, 04:09 AM
  3. i need help to hack i need the sluff for free
    By killercamer9 in forum Flaming & Rage
    Replies: 10
    Last Post: 01-26-2008, 06:36 PM
  4. [HELP] How do i get the form to target a proccess...
    By Nightlord in forum Visual Basic Programming
    Replies: 4
    Last Post: 11-27-2007, 11:43 AM
  5. [help]how would i get the superjump address?
    By fable741 in forum WarRock - International Hacks
    Replies: 9
    Last Post: 05-08-2007, 08:37 AM