Results 1 to 15 of 20

Hybrid View

  1. #1
          ( ° ͜ʖ͡°)╭∩╮
    Former Staff
    MarkHC's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    127.0.0.1
    Posts
    2,750
    Reputation
    66
    Thanks
    14,533
    My Mood
    Angelic
    I'd much rather do syscalls directly instead of calling wrappers which are most of the time hooked by Anti-Cheats. If you look at the exported Nt_____ functions on ntdll.dll it should be pretty obvious what you should do.

    Example: Instead of calling VirtualAlloc(Ex) you can do this and call it instead:

    Code:
    __declspec( naked )
    NTSTATUS NtAllocateVirtualMemory( HANDLE ProcessHandle, PVOID *BaseAddress, ULONG ZeroBits, PULONG AllocationSize, ULONG AllocationType, ULONG Protect ) {
    	__asm
    	{
    		MOV EAX, 0x17;
    		CALL fs : [0xC0];
    		RETN 0x18;
    	}
    }
    
    
    //somewhere...
    if( NT_ERROR( NtAllocateVirtualMemory( 
    			GetCurrentProcess(), 
    			&m_pBuffer, 
    			NULL,
    			&dwSize,
    			MEM_COMMIT | MEM_RESERVE,
    			PAGE_READWRITE ) ) ) {
    	throw Exceptions::MemoryAllocationException( "Unable to alocate memory for the image" );
    }
    Last edited by MarkHC; 07-19-2015 at 09:35 PM.


    CoD Minion from 09/19/2012 to 01/10/2013

  2. #2
    殺す必要がある唯一のものは殺されるために準備され人 々である。
    Premium Member
    Hitokiri~'s Avatar
    Join Date
    Oct 2012
    Gender
    female
    Location
    Cancer.
    Posts
    1,201
    Reputation
    24
    Thanks
    937
    My Mood
    Bitchy
    Quote Originally Posted by -InSaNe- View Post
    I'd much rather do syscalls directly instead of calling wrappers which are most of the time hooked by Anti-Cheats. If you look at the exported Nt_____ functions on ntdll.dll it should be pretty obvious what you should do.

    Example: Instead of calling VirtualAlloc(Ex) you can do this and call it instead:

    Code:
    __declspec( naked )
    NTSTATUS NtAllocateVirtualMemory( HANDLE ProcessHandle, PVOID *BaseAddress, ULONG ZeroBits, PULONG AllocationSize, ULONG AllocationType, ULONG Protect ) {
        __asm
        {
            MOV EAX, 0x17;
            CALL fs : [0xC0];
            RETN 0x18;
        }
    }
    
    
    //somewhere...
    if( NT_ERROR( NtAllocateVirtualMemory( 
                GetCurrentProcess(), 
                &m_pBuffer, 
                NULL,
                &dwSize,
                MEM_COMMIT | MEM_RESERVE,
                PAGE_READWRITE ) ) ) {
        throw Exceptions::MemoryAllocationException( "Unable to alocate memory for the image" );
    }
    System calls are a wide field in Windows programming.

    Points:

    - Call IDs are specific to the computers they're running on ( Meaning you can't just use static numbers )
    - x86 processes use the callgate to enter lower rings which can also be hooked ( mov fs:[c0h], mystub ) -- meaning you'll need to directly find the Cpup function that switches to x64 mode and emulate that directly or risk a hook being placed there and detecting you anyway
    - On x64 systems, KiFastSystemCall is used directly ( Which can also be hooked ). To emulate it directly, you'll need to do all sort of annoying-ass calculations like determining the stack size needed to pop back to etc.
    - Lastly, calling conventions for system calls differ across OSs. Windows 7 and Windows 8/8.1 differ for sure since I did do research on them.

    So, yes system calls are a great way to prevent detections against applications that don't employ drivers but there's far too many variables to consider. At best, you'll only be able to make them for your PC since porting will be hell.

  3. #3
          ( ° ͜ʖ͡°)╭∩╮
    Former Staff
    MarkHC's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    127.0.0.1
    Posts
    2,750
    Reputation
    66
    Thanks
    14,533
    My Mood
    Angelic
    Quote Originally Posted by Hitokiri~ View Post

    System calls are a wide field in Windows programming.

    Points:

    - Call IDs are specific to the computers they're running on ( Meaning you can't just use static numbers )
    - x86 processes use the callgate to enter lower rings which can also be hooked ( mov fs:[c0h], mystub ) -- meaning you'll need to directly find the Cpup function that switches to x64 mode and emulate that directly or risk a hook being placed there and detecting you anyway
    - On x64 systems, KiFastSystemCall is used directly ( Which can also be hooked ). To emulate it directly, you'll need to do all sort of annoying-ass calculations like determining the stack size needed to pop back to etc.
    - Lastly, calling conventions for system calls differ across OSs. Windows 7 and Windows 8/8.1 differ for sure since I did do research on them.

    So, yes system calls are a great way to prevent detections against applications that don't employ drivers but there's far too many variables to consider. At best, you'll only be able to make them for your PC since porting will be hell.
    You are completely right, I hook KiFastSystemCall myself for some other stuff... This article is pretty good: https://www.malwaretech.com/2014/06/u...g-betabot.html

    If you are really worried about detection you should create your own driver and do not do anything on usermode anyways.
    Last edited by MarkHC; 07-20-2015 at 07:23 AM.


    CoD Minion from 09/19/2012 to 01/10/2013

  4. #4
    殺す必要がある唯一のものは殺されるために準備され人 々である。
    Premium Member
    Hitokiri~'s Avatar
    Join Date
    Oct 2012
    Gender
    female
    Location
    Cancer.
    Posts
    1,201
    Reputation
    24
    Thanks
    937
    My Mood
    Bitchy
    Quote Originally Posted by -InSaNe- View Post


    You are completely right, I hook KiFastSystemCall myself for some other stuff... This article is pretty good: https://www.malwaretech.com/2014/06/u...g-betabot.html

    If you are really worried about detection you should create your own driver and do not do anything on usermode anyways.
    One last point I forgot to mention is that Intel CPUs use sysenter as their method of entering lower rings and AMD uses syscall. Another reason why that's such a pain in the ass to implement.

Similar Threads

  1. [HELP] How do I inject(???) the mods into CA?
    By ripper639 in forum Combat Arms Mods & Rez Modding
    Replies: 11
    Last Post: 04-10-2010, 05:58 PM
  2. Code for Injector; Importing DLL into Listbox
    By Invidus in forum Visual Basic Programming
    Replies: 5
    Last Post: 02-20-2010, 01:43 PM
  3. How to do OPK + Code Cave with a debugger and C++
    By radnomguywfq3 in forum C++/C Programming
    Replies: 4
    Last Post: 12-08-2009, 12:00 PM
  4. [Tutorial(C++)]How to call functions within another process
    By radnomguywfq3 in forum Programming Tutorials
    Replies: 4
    Last Post: 07-08-2008, 07:33 PM
  5. [REQUEST] Code Cave Tut
    By HeXel in forum WarRock - International Hacks
    Replies: 10
    Last Post: 02-16-2008, 01:36 AM

Tags for this Thread