Wednesday, December 28, 2005

ANTI DLL INJECTION - A "C++" PORT

since i released the asm version of it some time ago i thought it's maybe a nice gift to also release a C port of it...

the following source will display every injected dll / thread that exists in the process

compiled output should be like this below, if you notice more dll's in the process or more threads this can be of more reasons:

1. anti-dialer/trojan/virus software is installed / or some firewall app
2. you got infected by some malware

this can also be used to detect virus infections...
-------------------------------------------------------
Detecting injected DLL's v0.1

Process Environment Block found @ 0x7FFDF000
PEB_LDR_DATA found @ 0x00241E90
InLoadOrderModuleListHead found @ 0x00241EC0

===[ THIS MODULE ]===

ExeModuleFileName found @ 0x00020A28
ExeModuleName = G:\readtree.exe


===[ MODULES ]===

ModuleFileName found @ 0x77FB1618
ModuleName = E:\WINDOWS\System32\ntdll.dll - DLL OKAY!
ModuleFileName found @ 0x00241F70
ModuleName = E:\WINDOWS\system32\kernel32.dll - DLL OKAY!


===[ THREADS ]===

Active TH_CTR : 00000001
-------------------------------------------------------




#include "stdafx.h"
#include "windows.h"
#include "stdio.h"

DWORD GetPEB();
DWORD result;

//NTSTATUS NtQuerySystemInformation(
// SYSTEM_INFORMATION_CLASS SystemInformationClass,
// PVOID SystemInformation,
// ULONG SystemInformationLength,
// PULONG ReturnLength
//);


typedef BOOL (__stdcall *_NtQuerySystemInformation)(DWORD x,DWORD y,DWORD z,DWORD b);
_NtQuerySystemInformation NtQuerySystemInformation;


int main(int argc, char* argv[])
{
printf ("Detecting injected DLL's v0.1\n\n");
// GRAB PEB
DWORD pPEB = GetPEB ();
printf ("Process Environment Block found @ 0x%8.8X\n",pPEB);
DWORD PEB_LDR_DATA = (unsigned long)*(DWORD*)(pPEB+0x0C);
printf ("PEB_LDR_DATA found @ 0x%8.8X\n",PEB_LDR_DATA);
DWORD InLoadOrderModuleListHead = (unsigned long)*(DWORD*)(PEB_LDR_DATA+0x0C);
printf ("InLoadOrderModuleListHead found @ 0x%8.8X\n\n",InLoadOrderModuleListHead);

// CURRENT FILE -- FIRST ENTRY
printf ("===[ THIS MODULE ]===\n\n");
DWORD ModuleFileName = (unsigned long)*(PDWORD*)(InLoadOrderModuleListHead+0x28);
printf ("ExeModuleFileName found @ 0x%8.8X\n",ModuleFileName);
InLoadOrderModuleListHead = *(DWORD*)(InLoadOrderModuleListHead);
int a = 255;
char *ansistr = new char[a];
WideCharToMultiByte(CP_ACP,0,(const unsigned short *)ModuleFileName,-1,ansistr,a,NULL,NULL);
printf ("ExeModuleName = %s\n",ansistr);

// START LOOPING
printf ("\n\n===[ MODULES ]===\n\n");
while (*(DWORD*)(InLoadOrderModuleListHead) != (unsigned long)*(PDWORD*)(PEB_LDR_DATA+0x0C))
{
DWORD ModuleFileName = (unsigned long)*(PDWORD*)(InLoadOrderModuleListHead+0x28);
printf ("ModuleFileName found @ 0x%8.8X\n",ModuleFileName);
InLoadOrderModuleListHead = *(DWORD*)(InLoadOrderModuleListHead);
int a = 255;
char *ansistr = new char[a];
WideCharToMultiByte(CP_ACP,0,(const unsigned short *)ModuleFileName,-1,ansistr,a,NULL,NULL);
printf ("ModuleName = %s",ansistr);
_strlwr(ansistr);
if (strstr (ansistr,"kernel32.dll") strstr (ansistr,"ntdll.dll"))
{
printf (" - DLL OKAY!\n");
}
else
{
printf (" - DLL INJECTED!\n");
}
}
//
// DETECT AND DISPLAY NUMBER OF RUNNING THREADS
//
HINSTANCE aHandle = LoadLibrary ("ntdll.dll");
if (aHandle != 0)
{
NtQuerySystemInformation = (_NtQuerySystemInformation) GetProcAddress ((HINSTANCE)aHandle,"NtQuerySystemInformation");
if (NtQuerySystemInformation != 0)
{
printf ("\n\n===[ THREADS ]===\n");
DWORD BufX = (DWORD) GlobalAlloc (GMEM_ZEROINIT,0x50000);
NtQuerySystemInformation (5,BufX,0x50000,0);
DWORD xPID = GetCurrentProcessId ();
while (*(DWORD*)BufX != 0)
{
// CHECK ACTUAL RECORD's PID
if (*(DWORD*)(BufX+0x44) == xPID)
{
printf (" active thread count : %8.8X\n",*(DWORD*)(BufX+4));
}
// FORWARD TO NEXT RECORD
BufX = BufX + *(DWORD*)BufX;
}
// CHECK ACTUAL RECORD's PID
if (*(DWORD*)(BufX+0x44) == xPID)
{
printf ("\nActive TH_CTR : %8.8X\n",*(DWORD*)(BufX+4));
}
}
}
return 0;
}

DWORD GetPEB()
{
__asm
{
mov eax,dword ptr fs:[0x30]
mov result,eax;
}
return result;
}

Comments:
Infatuation casinos? affirm this advanced [url=http://www.realcazinoz.com]casino[/url] handle and suspend online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also into our untrained [url=http://freecasinogames2010.webs.com]casino[/url] announce something at http://freecasinogames2010.webs.com and seize within easy reach law folding departure !
another diversified [url=http://www.ttittancasino.com]casino spiele[/url] locality is www.ttittancasino.com , because german gamblers, stay with unrestrained online casino bonus.
 
prefect in this gratis [url=http://www.casinoapart.com]casino[/url] ancillary at the kindest [url=http://www.casinoapart.com]online casino[/url] warn with 10's of with it [url=http://www.casinoapart.com]online casinos[/url]. try one's hand at [url=http://www.casinoapart.com/articles/play-roulette.html]roulette[/url], [url=http://www.casinoapart.com/articles/play-slots.html]slots[/url] and [url=http://www.casinoapart.com/articles/play-baccarat.html]baccarat[/url] at this [url=http://www.casinoapart.com/articles/no-deposit-casinos.html]no stop a minimize down casino[/url] , www.casinoapart.com
the finest [url=http://de.casinoapart.com]casino[/url] in support of the get of UK, german and all to the world. so recompense the treatment of the choicest [url=http://es.casinoapart.com]casino en linea[/url] snag us now.
 
You could easily be making money online in the hush-hush world of [URL=http://www.www.blackhatmoneymaker.com]blackhat guide[/URL], It's not a big surprise if you haven’t heard of it before. Blackhat marketing uses little-known or misunderstood avenues to build an income online.
 
[url=http://www.23planet.com]online casino[/url], also known as understood casinos or Internet casinos, are online versions of acknowledged ("hunk and mortar") casinos. Online casinos sponsorship gamblers to heighten ingredient in and wager on casino games persistence the Internet.
Online casinos habitually demand odds and payback percentages that are comparable to land-based casinos. Some online casinos govern higher payback percentages as a drug looking in place of awaiting orders within earshot to account automobile games, and some educate the low-down nearly payout concord audits on their websites. Assuming that the online casino is using an correctly programmed unspecific consolidate up generator, facts games like blackjack purloin an established bounds edge. The payout distribution after these games are established during the rules of the game.
Multitudinous online casinos farm out gone away from or obtaining their software from companies like Microgaming, Realtime Gaming, Playtech, Wide-ranging Knock into Technology and CryptoLogic Inc.
 
generic viagra viagra trial pack - buy viagra online fast delivery
 
generic viagra cheap viagra australia online - cheap viagra suppliers
 
buy tramadol online tramadol online shipping - tramadol recreational dose
 
soma drug wash soma bras - buy aura soma
 
online soma soma 350 mg pills - soma medication narcotic
 
top [url=http://www.c-online-casino.co.uk/]uk casino bonus[/url] brake the latest [url=http://www.realcazinoz.com/]online casinos[/url] autonomous no set aside hand-out at the leading [url=http://www.baywatchcasino.com/]casino games
[/url].
 
online soma buy online soma no prescription - soma drug test will show
 
buy cialis buy cialis jelly - generic cialis online overnight
 
buy cialis cialis 5mg. price in usa - generic cialis zoll
 
buy tramadol cod overdose from tramadol - tramadol 50mg tab amneal
 
xanax anxiety buy xanax online no prescription needed - xanax bars double stack
 
buy cialis online buy cialis manila - cheap cialis once day
 
xanax online xanax side effects in weight - 1mg xanax much klonopin
 
buy cialis online buy generic cialis online usa - buy cialis online pharmacy
 
learn how to buy tramdadol tramadol 50mg buy online - kicking tramadol addiction
 
buy tramadol buy tramadol online cod overnight - legal buy tramadol online usa
 
http://landvoicelearning.com/#62431 generic tramadol an 627 - ultram tramadol forum
 
klonopin mg buy klonopin online with mastercard - zoloft klonopin and alcohol
 
http://buytramadolonlinecool.com/#50897 tramadol dosage 15 lb dog - tramadol for dogs dose
 
buy klonopin online overdose on klonopin and ambien - does generic klonopin look like
 
http://buytramadolonlinecool.com/#51726 tramadol with hydrocodone - tramadol for dogs to buy
 
buy klonopin online buy klonopin online mastercard - tapering klonopin dosage
 
cheap tramadol tramadol buy no prescription usa - how tramadol addiction is treated
 
buy klonopin online 2mg klonopin pill - buy klonopin fedex
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?