Hack hiding menu

Shout-Out

User Tag List

Thread: Hack hiding

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hack hiding

    I'm trying to unlink my module from the PEB linked list, but it doesn't seem to be doing it. Here's my code. It's only running through the loop one time, then stopping. Olly is still seeing it in the list. I can see that it's the first module loaded inside the process in olly, but it's obviously still being linked unless olly doesn't constantly refresh the list. Any, here's the code.

    Code:
     
    void UnlinkUs(void)
    {
    PPEB_LDR_DATA ldr = NULL;
    PLIST_ENTRY pListEntry, pListStart;
    PLDR_MODULE pLM;
    __asm {
    mov eax, fs:[0x30]; //PEB offset 
    mov eax, [eax + 0x0C]; //PEB_LDR_DATA offset
    mov ldr, eax;
    }
    
    pListEntry = ldr->InMemoryOrderModuleList; //store first link(circular...)
    pListStart = pListEntry->Flink; //Set first link
    while(pListEntry != pListStart)
    {
    pLM = CONTAINING_RECORD(pListEntry, LDR_MODULE, InMemoryOrderModuleList);
    MessageBox(NULL, L"Module.", L"Module", MB_OK);
    if(((DWORD)pLM->BaseAddress < (DWORD)placeholder) && ((DWORD)placeholder < ((DWORD)pLM->BaseAddress + (DWORD)pLM->SizeOfImage))) //only if it's my DLL
    {
    pListEntry->Flink->Blink = pListEntry->Blink; //replace for next link
    pListEntry->Blink->Flink = pListEntry->Flink; //replace for previous link
    }
    pListEntry = pListEntry->Flink; //do next link
    }
    }

    Hack hiding
  2. #2
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I could be very wrong, but as far as I know it only unlinks it for inside the module, and olly will always see it. Find a way to check from inside your DLL.

    Haven't looked at code, don't have time! Gotta go.

  3. #3
    kynox's Avatar Member
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just so you know, all this hides from warden is your module name. No other scan uses the PEB.

  4. #4
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ramey View Post
    I could be very wrong, but as far as I know it only unlinks it for inside the module, and olly will always see it. Find a way to check from inside your DLL.

    Haven't looked at code, don't have time! Gotta go.

    You are wrong. The linked list is process local not module local, so as long as you do it properly (which he isn't, by far) nothing running in userland should be able to see it. You could probably retrieve it from the kernel mode list (I'm pretty sure there is one, but not 100%), but not from usermode.


    Originally Posted by kynox View Post
    Just so you know, all this hides from warden is your module name. No other scan uses the PEB.

    It doesn't even do that. He's missing two of the other documented linked lists, one undocumented one, and he's leaving behind the LDR_ENTRY structure which can be recovered if you know what you're doing, and from there you can get the name and module base address (even if the PE header is gone).
    Last edited by Cypher; 05-08-2009 at 04:26 AM.

  5. #5
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I added ZeroMemory() to get rid of the struct after I replace the previous/next pointers. Is there any reading I can do to learn about the other linked lists? I'm almost done reading Secrets of Reversing and they've only mentioned this list, at the point where I am. I'll search amazon for other windows internals books, I guess.

    EDIT: Your ModuleCloaker is a nice resource.
    Last edited by lanman92; 05-08-2009 at 10:50 AM.

  6. #6
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still missing two 'documented' lists (In InLoadOrderModuleList and InInitializationOrderModuleList), and one 'undocumented' one (which is left as an exercise to the reader to find -- not even 100% if it still exists, your post is actually the one that reminded me of its existence).

    Also, your module can still be very easily identified due to the fact the PE header is still valid and intact.

    Furthermore, your code is one-way (you should really be able to reverse it -- trust me, it will be necessary if you want to be able to do dynamic loading and unloading), and its not compatible with x64.

    Lastly, you're relying on a hardcoded offset into the FS register. Don't do that, you should be calling NtQueryInformationProcess to get a pointer to the PEB. Yes that is still not guaranteed to never change, but it will work across platforms, its more reliable, and currently works on all available Windows versions (unlikely to change in the near future).

  7. #7
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I'm a retard. I totally forgot about the other lists... Don't know why I did that, but w/e. I'll read on the functions you said and see if I can clean up my code as well. I'm sure there's a better way for me to check if it's my module, also.

    EDIT: I'm running x64. What has to be done for it to be compatible?
    Last edited by lanman92; 05-08-2009 at 10:56 AM.

  8. #8
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, thanks for correcting me, was indeed thinking of linked list!

  9. #9
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by lanman92 View Post
    Okay, I'm a retard. I totally forgot about the other lists... Don't know why I did that, but w/e. I'll read on the functions you said and see if I can clean up my code as well. I'm sure there's a better way for me to check if it's my module, also.

    EDIT: I'm running x64. What has to be done for it to be compatible?

    I'm talking about making it compatiable for native x64. Atm your code won't even compile under x64 because of the inline ASM which is obviously for IA-32. You need to rewrite it properly for it to even begin to work.

    Also, your code is pretty awful. Assuming you're using C++ not C.
    1. Initialized variables as close as possible to the point where they are defined.
    2. Use C++ style casts
    3. Use the correct architecture-independent data types (DWORD_PTR, not DWORD).
    4. Get rid of the macros. They are unnecessary.
    5. Remove the 'void' from the param list, it's poor style in c++ code.
    6. Make your strings character set independent. (Use the TEXT macro provided by the Win32 API.)
    Last edited by Cypher; 05-08-2009 at 12:02 PM.

  10. #10
    schlumpf's Avatar Retired Noggit Developer

    Reputation
    755
    Join Date
    Nov 2006
    Posts
    2,759
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by cypher View Post
    3. Use the correct architecture-independent data types (dword_ptr, not dword).
    4. Get rid of the macros. They are unnecessary.
    6. Make your strings character set independent. (use the text macro provided by the win32 api.)
    < 3

  11. #11
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by schlumpf View Post
    < 3
    Sigh. There's a difference between a necessary and an unnecessary macro.

    Necessary:
    Compile-time logic and flag checks

    Unnecesary:
    Run-time unlinking of a module.

    You should avoid the preprocessor when its unnecessary, but sometimes its unavoidable, those cases are acceptable.

    Lrn2program kthx.

  12. #12
    schlumpf's Avatar Retired Noggit Developer

    Reputation
    755
    Join Date
    Nov 2006
    Posts
    2,759
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lrn2irony finally ._____.

  13. #13
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by schlumpf View Post
    Lrn2irony finally ._____.
    Except it's not ironic, it would be ironic if I told him to use the preprocessor unnecessarily, but that's not what I did. The TEXT macro HAS to be compile time, his CONTAINS_ENTRY or w/e macro does not. It's a different situation and hence no irony exists, simply poor programming and a lack of understanding.

  14. #14
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So here's a fun task: how to use templates to do strongly-typed detour-style hooks without preprocessor magic.

    (Totally off topic, so if y'all wanna flame or delete, feel free.)

    Was working on this last night; I know others have invented this wheel but I'm super rusty in C++ (was always more comfortable in C, to my detriment) and was working on it at like 3am last night. Decided that for a rusty C++ programmer trying to "correctly" (elegantly, usefully) write template classes with a factory object and a "manager" (something to roll all the hooks together and patch/unpatch them all at once, as well as exposing the "real" function -- which varies depending upon whether a hook is installed or not, and has to be strongly typed) ... at 3am, was not wise.

    something like...

    Code:
    void __stdcall MyFunc(int someparm);
    
    template <class T>
    class APIHook
    {
    public:
    	T GetRealFunction();
    	bool Hook();
    	void UnHook(); // probably should be bool, but failing to unhook is usu. fatal
    
    	APIHook(std::string libName, std::string apiName, T& hookFunc);
    };
    
    APIHook<void (__stdcall *)(int)> myHook("SomeLibrary", "ZwSomeFunction", MyFunc);
    (Excuse any obvious syntax errors; I'm at work and my Eclipse C++ plugin is currently borked.)

    The prob with this is that I'd like to avoid the template syntax in the object construction. I know this isn't legal code, but it would be cool if I could do something like:

    Code:
    APIHook myHook("SomeLibrary", "ZwSomeFunction", MyFunc);
    I know this isn't valid (compiler doesn't have a non-specialized APIHook type), but it would make the syntax WAY less cumbersome. Aside from the syntax error, all the info the compiler needs is there (the function pointer type can be inferred from the passed-in detour method, etc.)

    Thing is, I'd really like to avoid doing this with a macro (I probably could make it work with the preprocessor, but that doesn't mean that I SHOULD).

    I guess I could define a non-templated base class, but my rusty C++ always fails me in this case (non-templated bases of template classes... when I do I need to use the template syntax in construction? there are non-obvious gotchas in this design).

    Like I said, I'm sure someone else has invented this wheel; I'm re-rolling it mostly to force my aging, rusty-in-C++ brain to start thinking about things like this again.

  15. #15
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Windows via C++ has a decent starting API hooking library (IAT/EAT). The one I'm writing is based off it.

Page 1 of 2 12 LastLast

Similar Threads

  1. Talk to Opposing Faction! (No hacks or Mind Controlling needed!)
    By janzi9 in forum World of Warcraft Exploits
    Replies: 51
    Last Post: 04-06-2007, 01:13 PM
  2. Evading Hack Detection Mechanisms in Online Games
    By Matt in forum World of Warcraft Guides
    Replies: 4
    Last Post: 10-06-2006, 06:47 PM
  3. World of Warcraft Hack - Syndrome (Multi-Hack for 1.9.4)
    By Matt in forum World of Warcraft Bots and Programs
    Replies: 44
    Last Post: 07-26-2006, 12:55 PM
  4. Need a hack
    By kaur in forum World of Warcraft General
    Replies: 2
    Last Post: 03-23-2006, 11:22 PM
  5. Are there any Macintosh Hacks/bots?...
    By Baphomet in forum World of Warcraft General
    Replies: 2
    Last Post: 03-22-2006, 12:56 AM
All times are GMT -5. The time now is 11:25 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search