Felix_Poison Posted October 17, 2009 at 12:56 AM Report Share #292002 Posted October 17, 2009 at 12:56 AM Esse code nao é meu, é do Prick, mas ele é muito util, entao vim postar aqui 😛 #include <windows.h> #include <tlhelp32.h> /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char szClassName[ ] = "WindowsApp"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; MSG messages; WNDCLASSEX wincl; wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof (WNDCLASSEX); wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND+7; if (!RegisterClassEx (&wincl)) return 0; hwnd = CreateWindowEx ( 0, szClassName, "The Game Injector ", WS_SYSMENU|WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 400, 200, HWND_DESKTOP, NULL, hThisInstance, NULL ); while (GetMessage (&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } return messages.wParam; } HWND Input1,Input2; HWND Inject; BOOL SetPrivilege(LPSTR type) // more flexible { HANDLE Htoken; TOKEN_PRIVILEGES tokprivls; if(!OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &Htoken)){ return 0; } tokprivls.PrivilegeCount = 1; LookupPrivilegeValue(NULL, type, &tokprivls.Privileges[0].Luid); tokprivls.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; BOOL Success =AdjustTokenPrivileges( Htoken, FALSE, &tokprivls, sizeof(tokprivls), NULL, NULL); CloseHandle(Htoken); return Success; } HANDLE GetHandle(char *proc) { PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); HANDLE Snap = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0); Process32First(Snap,&pe32); do{ if(stricmp(pe32.szExeFile,proc)==0) { SetPrivilege(SE_DEBUG_NAME); return OpenProcess(PROCESS_ALL_ACCESS,0,pe32.th32ProcessID); }}while(Process32Next(Snap,&pe32));CloseHandle(Snap); } void InjectDll(char* Name, char *path) { HANDLE hProcess = GetHandle(Name); if(hProcess){ int DllPath = strlen(path) + 20; LPVOID MemSp = VirtualAllocEx(hProcess,NULL,DllPath,MEM_COMMIT,PAGE_READWRITE); WriteProcessMemory(hProcess,MemSp,path,DllPath,NULL); HANDLE hThread = CreateRemoteThread(hProcess,NULL,0,(LPTHREAD_START_ROUTINE)GetProcAddress(LoadLi brary("Kernel32.dll"), "LoadLibraryA"), MemSp, 0, NULL); if(hThread){ WaitForSingleObject(hThread, 30000); CloseHandle(hThread); } VirtualFreeEx(hProcess, MemSp, 0, MEM_RELEASE); } else {MessageBox(0,"Could not get the process handle .",0,0);} } char proc[50],dll[260]; LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND hBmpStat; HBITMAP hBitmap; HFONT hFont ; switch (message) { case WM_CREATE: hFont = CreateFont(20, 0, 0, 10, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DEFAULT_QUALITY, FF_DONTCARE, "Microsoft Sans MS"); hBitmap = (HBITMAP) LoadImage(NULL, "C:\\WINDOWS\\system32\\setup.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); // zomfg h4x hBmpStat = CreateWindowEx(0,"Static","",WS_VISIBLE | WS_CHILD | SS_BITMAP, -200,-220,0,0,hwnd,0,0,0); SendMessage(hBmpStat, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBitmap); Inject = CreateWindow("Button","INJECT",WS_CHILD | WS_VISIBLE | WS_BORDER, 190, 20, 180, 38,hwnd,(HMENU)100,0,NULL); Input1 = CreateWindow("Edit", "wmplayer.exe",WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 20, 180,18,hwnd,0,0,NULL); Input2 = CreateWindow("Edit", "c:\\sample.dll",WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 40, 180,18,hwnd,0,0,NULL); SendMessage(Inject,WM_SETFONT,WPARAM(hFont),0); break; case WM_DESTROY: PostQuitMessage (0); break; case WM_COMMAND: switch(LOWORD(wParam)) { case 100: SendMessage(Input1,WM_GETTEXT,sizeof(proc),LPARAM(proc)); if(proc!=0) { SendMessage(Input2,WM_GETTEXT,sizeof(dll),LPARAM(dll)); if(dll!=0) InjectDll(proc,dll); }break; default:break; }break; default: return DefWindowProc (hwnd, message, wParam, lParam); } return 0; } Link to comment Share on other sites More sharing options...
xlo620 Posted October 19, 2009 at 09:59 AM Report Share #292298 Posted October 19, 2009 at 09:59 AM podias por uma descriçaozinha a dizer para que server 😁 Link to comment Share on other sites More sharing options...
IceBrain Posted October 19, 2009 at 02:47 PM Report Share #292341 Posted October 19, 2009 at 02:47 PM Segundo percebo do código, é um programa que permite injectar uma DLL num processo à escolha. Pode-se ler mais sobre isso aqui: http://www.codeproject.com/KB/DLL/DLL_Injection_tutorial.aspx ❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents A list of command line apps Link to comment Share on other sites More sharing options...
Felix_Poison Posted October 19, 2009 at 11:54 PM Author Report Share #292458 Posted October 19, 2009 at 11:54 PM Poxa, desculpa por nao ter posto a descrição, mas é que o titulo era auto-indicativo 😁 é sim, ele serve pra injetar uma DLL em algum soft 👍 Link to comment Share on other sites More sharing options...
Dkid Posted October 21, 2009 at 10:10 AM Report Share #292655 Posted October 21, 2009 at 10:10 AM Hey Felix_Poison ! Já que nos apresentas-te esse código, tenho uma pergunta: É possivel protegermo-nos de DLL Injection de alguma forma? I promise that I will not change the PATH variable again other than:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games Link to comment Share on other sites More sharing options...
Triton Posted October 21, 2009 at 10:17 AM Report Share #292657 Posted October 21, 2009 at 10:17 AM Hey Felix_Poison ! Já que nos apresentas-te esse código, tenho uma pergunta: É possivel protegermo-nos de DLL Injection de alguma forma? Sim, fazendo um DLL Injector Injector. ? <3 life Link to comment Share on other sites More sharing options...
IceBrain Posted October 21, 2009 at 02:17 PM Report Share #292706 Posted October 21, 2009 at 02:17 PM Impedir DLL Injection é como o DRM: podes tornar mais difícil, mas se o executável está no disco do "atacante", é impossível impedi-lo. ❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents A list of command line apps Link to comment Share on other sites More sharing options...
Felix_Poison Posted October 21, 2009 at 07:09 PM Author Report Share #292767 Posted October 21, 2009 at 07:09 PM Como o IceBrain disse.. agora, eu, particulamente, nao conheço uma forma eficaz de se proteger desse tipo de Ataque. vou procurar mais informaçoes sobre isso e crio um artigo sobre o assunto! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now