Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24

  Click here to go to the first staff post in this thread.   Thread: Manual Mapped Dll's

  1. #16
    Join Date
    Oct 2010
    Location
    France
    Posts
    73
    Thanks
    199
    Thanked 21 Times in 15 Posts
    Rep Power
    36

    Re: Manual Mapped Dll's

    Quote Originally Posted by everdox View Post
    Hook NtQueryVirtualMemory, ive never looked at VAC but there should be a pluthera of solutions for your problem.
    VAC call NtQueryVirtualMemory, and if they find something "suspect", they call NtReadVirtualMemory

    1118.29443359 [Driver] NtQueryVirtualMemory (Address: 0x22DBE000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory (Address: 0x22DC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory (Address: 0x22DC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory (Address: 0x22DC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory (Address: 0x22DC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory (Address: 0x22DFF000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22EC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22EC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22EC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22EC0000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22EC1000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22F2A000, Size: 0x1C)
    1118.29443359 [Driver] NtQueryVirtualMemory Warning (Address: 0x22F62000, Size: 0x1C)
    1118.29455566 [Driver] NtQueryVirtualMemory Warning (Address: 0x22EC0000, Size: 0x210)
    1118.29455566 [Driver] NtReadVirtualMemory Warning (Address: 0x22EC0000, Size: 0x2000)
    1118.29455566 [Driver] NtQueryVirtualMemory Warning (Address: 0x22F62000, Size: 0x1C)

    1118.29455566 [Driver] NtQueryVirtualMemory (Address: 0x23000000, Size: 0x1C)
    1118.29455566 [Driver] NtQueryVirtualMemory (Address: 0x23000000, Size: 0x1C)
    1118.29455566 [Driver] NtQueryVirtualMemory (Address: 0x23000000, Size: 0x1C)
    1118.29455566 [Driver] NtQueryVirtualMemory (Address: 0x230FD000, Size: 0x1C)
    1118.29455566 [Driver] NtQueryVirtualMemory (Address: 0x230FE000, Size: 0x1C)
    Here is what you get if you log NtQueryVirtualMemory and NtReadVirtualMemory calls. (the "Warning" region is where my mapped module was).
    goto KERNELAND;

  2. #17
    Join Date
    Jun 2004
    Location
    The Moon
    Posts
    4,547
    Thanks
    0
    Thanked 825 Times in 431 Posts
    Rep Power
    351

    Re: Manual Mapped Dll's

    Didn't differentiate between VAC2/3. See that large scan for 2 pages? Probably looking to find a pe header. So I'd bet that's VAC2, Scan Gate 0xF. Besides logging the size is a moot point and rather useless ( VirtualQuery ).

    @ how did you leave your pages explicitly set to RWE ?




    ([oC]Streetmedic): wav hate my guts
    ([oC]Streetmedic): i swear he shadowz me
    (Absolution): its true
    (Absolution): actually
    P47R!CK says:
    you are no good for me
    [gØt]wäv? says:
    wrong
    i am good for you
    [gØt]wäv? says:
    and you know it

  3. #18
    Join Date
    Oct 2010
    Location
    France
    Posts
    73
    Thanks
    199
    Thanked 21 Times in 15 Posts
    Rep Power
    36

    Re: Manual Mapped Dll's

    I didn't map PE headers.

    I do this for each section:
    PHP Code:
    DWORD dwOldProtect;
    MEMORY_BASIC_INFORMATION mbi;
    VirtualQueryEx(this->hProcessMakePtr(LPVOIDthis->dwModuleBaseheader->VirtualAddress), &mbisizeof(mbi));
    VirtualProtectEx(this->hProcessmbi.BaseAddressmbi.RegionSizeheader->Characteristics 0x00FFFFFF, &dwOldProtect);
    FlushInstructionCache(this->hProcessmbi.BaseAddressmbi.RegionSize); 
    PS: for the logs I was returning the real value (not hiding anything).
    goto KERNELAND;

  4. #19
    Join Date
    Jun 2004
    Location
    The Moon
    Posts
    4,547
    Thanks
    0
    Thanked 825 Times in 431 Posts
    Rep Power
    351

    Re: Manual Mapped Dll's

    Quote Originally Posted by how02 View Post
    I didn't map PE headers.

    I do this for each section:
    PHP Code:
    DWORD dwOldProtect;
    MEMORY_BASIC_INFORMATION mbi;
    VirtualQueryEx(this->hProcessMakePtr(LPVOIDthis->dwModuleBaseheader->VirtualAddress), &mbisizeof(mbi));
    VirtualProtectEx(this->hProcessmbi.BaseAddressmbi.RegionSizeheader->Characteristics 0x00FFFFFF, &dwOldProtect);
    FlushInstructionCache(this->hProcessmbi.BaseAddressmbi.RegionSize); 
    PS: for the logs I was returning the real value (not hiding anything).
    Well of course the pe header shouldn't be mapped, neither should the .reloc section. Is each section of the file mapped independently or as one large allocation?




    ([oC]Streetmedic): wav hate my guts
    ([oC]Streetmedic): i swear he shadowz me
    (Absolution): its true
    (Absolution): actually
    P47R!CK says:
    you are no good for me
    [gØt]wäv? says:
    wrong
    i am good for you
    [gØt]wäv? says:
    and you know it

  5. #20
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Manual Mapped Dll's

    yeh so just hook it and filter out the mbi buffer to your liking. though why are you using a driver? have they mapped the ntdll call stubs for manually accessing system services? I can see if it were 32 bit windows with no KPP that's probably a viable approach though if you were looking to make your hack portable maybe you could just find where they map it to

    otherwise another non portable approach could be hooking outside of the wow64 thunk layer provided they don't check and build a 64 bit stack to access a system service (yes ive seen that done but pretty rare).

  6. #21
    Join Date
    Jun 2004
    Location
    The Moon
    Posts
    4,547
    Thanks
    0
    Thanked 825 Times in 431 Posts
    Rep Power
    351

    Re: Manual Mapped Dll's

    Quote Originally Posted by everdox View Post
    yeh so just hook it and filter out the mbi buffer to your liking. though why are you using a driver? have they mapped the ntdll call stubs for manually accessing system services? I can see if it were 32 bit windows with no KPP that's probably a viable approach though if you were looking to make your hack portable maybe you could just find where they map it to

    otherwise another non portable approach could be hooking outside of the wow64 thunk layer provided they don't check and build a 64 bit stack to access a system service (yes ive seen that done but pretty rare).
    KPP is easy to bypass :/




    ([oC]Streetmedic): wav hate my guts
    ([oC]Streetmedic): i swear he shadowz me
    (Absolution): its true
    (Absolution): actually
    P47R!CK says:
    you are no good for me
    [gØt]wäv? says:
    wrong
    i am good for you
    [gØt]wäv? says:
    and you know it

  7. #22
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Manual Mapped Dll's

    Quote Originally Posted by wav View Post
    KPP is easy to bypass :/
    indeed it is ;p

    but i think a time comes for everyone when they just want the quickest way out. and since im sure you already know with x64 system service table only branching at 32 bit boundaries that leaves people with having to use inline hooks. just easier to hook the wow64 dispatcher sometimes

  8. #23
    Join Date
    Oct 2010
    Location
    France
    Posts
    73
    Thanks
    199
    Thanked 21 Times in 15 Posts
    Rep Power
    36

    Re: Manual Mapped Dll's

    Quote Originally Posted by wav View Post
    Well of course the pe header shouldn't be mapped, neither should the .reloc section. Is each section of the file mapped independently or as one large allocation?
    Oh I didn't know about the .reloc, thanks
    I do 1 alloc for the size of the image, and then for each section:
    PHP Code:
    WriteProcessMemory(this->hProcessMakePtr(LPVOIDthis->dwModuleBaseheader->VirtualAddress), MakePtr(LPCVOIDthis->bDllheader->PointerToRawData), header->SizeOfRawDataNULL); 
    goto KERNELAND;

  9. #24
    Join Date
    Jun 2004
    Location
    The Moon
    Posts
    4,547
    Thanks
    0
    Thanked 825 Times in 431 Posts
    Rep Power
    351

    Re: Manual Mapped Dll's

    Quote Originally Posted by how02 View Post
    Oh I didn't know about the .reloc, thanks
    I do 1 alloc for the size of the image, and then for each section:
    PHP Code:
    WriteProcessMemory(this->hProcessMakePtr(LPVOIDthis->dwModuleBaseheader->VirtualAddress), MakePtr(LPCVOIDthis->bDllheader->PointerToRawData), header->SizeOfRawDataNULL); 
    You should adjust the protections based on each section to avoid bunching the memory regions together, preferably insert dummy regions in between filled with garbage or VirtualFree.

    In reality you shouldn't have a .rdata section at all. All you should have is a mapped .text section and a mapped .data section.




    ([oC]Streetmedic): wav hate my guts
    ([oC]Streetmedic): i swear he shadowz me
    (Absolution): its true
    (Absolution): actually
    P47R!CK says:
    you are no good for me
    [gØt]wäv? says:
    wrong
    i am good for you
    [gØt]wäv? says:
    and you know it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question Memory mapped files?
    By maybnxtseasn in forum Beginner
    Replies: 3
    Last Post: 12-24-2010, 01:58 PM
  2. Memory mapped files. The correct solution?
    By syntroniks in forum Intermediate
    Replies: 6
    Last Post: 03-27-2010, 04:10 PM
  3. Delete mapped DLL
    By h1web in forum Intermediate
    Replies: 2
    Last Post: 10-25-2008, 08:07 AM
  4. string to a mapped file
    By panzer in forum Beginner
    Replies: 1
    Last Post: 10-24-2004, 04:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •