Click here to Skip to main content
15,887,485 members
Articles / Desktop Programming / MFC
Article

HackPro: All About about network

Rate me:
Please Sign up or sign in to vote.
1.80/5 (6 votes)
18 Dec 2007CPOL 58K   688   35   2
HackPro is a utility developed for System Administrators and Software developers for the purpose of monitoring analyzing and maintaining their network

Introduction

This article is about the tool written by me named HackPro.

Background

HackPro is a utility developed for System Administrators and Software developers for the purpose of monitoring analyzing and maintaining their network. It consists of manyfunctionalities that is necessary for the administrators to monitor and maintain their network.

It is developed upon concepts that have been used by hackers previously to monitor and attack the network.

HackPro ScreenShot

Using the code

HackPro has multiple functionality you can use its code for writing.

  • Dll Injector
  • Understand Socket APIs
  • Understand CSocket details.
  • Implement Raw Packet Sender
  • Understand ARP Process

Here is an example of DLL Injection

void InjectDll(HANDLE hProc)
{
 DWORD dwFuncSize=0;
    DWORD dwBytesToAlloc=0;
    LPVOID pRemoteAlloc = NULL;
    REMOTE_INFO remInfo;
    HINSTANCE hKernel32=0;
    CHAR szDllName[MAX_PATH];
    DWORD dwBytesWritten;
    HANDLE hRemoteThread = 0;
    DWORD dwIgnored;
  //
    // Prepare the info to send across
    //
 //HANDLE hProc=OpenProcess(PROCESS_ALL_ACCESS,FALSE,Pid);
    hKernel32 = LoadLibrary ("Kernel32");
    remInfo.pLoadLibrary = (pLoadLib_t) GetProcAddress (hKernel32, "LoadLibraryA");
    remInfo.pGetProcAddress = (pGetProcAddr_t) GetProcAddress (hKernel32, "GetProcAddress");
    remInfo.pFreeLibrary = (pFreeLib_t) GetProcAddress (hKernel32, "FreeLibrary");
    strncpy (remInfo.szDllName, DllPath, sizeof (remInfo.szDllName));
    strncpy (remInfo.szProcName, "OnLoad", sizeof (remInfo.szProcName));
    
    //
    // Determine amount of memory to allocate
    //
 dwFuncSize = (DWORD)DummyFunc - (DWORD)RemoteFunction;
    dwBytesToAlloc = dwFuncSize + sizeof (REMOTE_INFO) + 4;
    //
    // Allocate memory in remote proc
    //
    pRemoteAlloc = VirtualAllocEx (hProc, NULL, dwBytesToAlloc,MEM_COMMIT, PAGE_READWRITE);
    if (pRemoteAlloc == NULL)
    {
        CString str;
  str.Format("VirtualAllocEx Error code (GetLastError)=%d",GetLastError());
  MessageBox(NULL,str,"Error",0);
        return ;
    }
     //
    // Write data to the proc
    //
    if(!WriteProcessMemory (hProc, pRemoteAlloc, &remInfo, sizeof (remInfo),&dwBytesWritten))
    {
        CString str;
  str.Format("WriteProcessMemory1 Error code (GetLastError)=%d",GetLastError());
  MessageBox(NULL,str,"Error",0);
        goto exit;
    }
    //
    // Write code to the proc
    //
 if (!WriteProcessMemory (hProc,(PBYTE)pRemoteAlloc + sizeof (REMOTE_INFO) + 4,(LPVOID)(DWORD)RemoteFunction, dwFuncSize, &dwBytesWritten))
 {
        
  CString str;
  str.Format("WriteProcessMemory2 Error code (GetLastError)=%d",GetLastError());
  MessageBox(NULL,str,"Error",0);
        goto exit;
    }
    //
    // Create the remote thread
    //
 //hRemoteThread = CreateRemoteThread (hProc, NULL, 0,(LPTHREAD_START_ROUTINE)remInfo.pLoadLibrary,DllPath, 0,&dwIgnored);
    hRemoteThread = CreateRemoteThread (hProc, NULL, 0,(LPTHREAD_START_ROUTINE)((PBYTE) pRemoteAlloc + sizeof (REMOTE_INFO) + 4),pRemoteAlloc, 0, &dwIgnored);
    if (!hRemoteThread)
    {
        MessageBox(NULL,"CreateRemoteThread Error","Dll Injection Failed",NULL);
        goto exit;
    }
 //WaitForSingleObject (hRemoteThread, INFINITE);
  
exit:
 if (hRemoteThread)
        CloseHandle (hRemoteThread);
   // VirtualFreeEx (hProc, pRemoteAlloc, 0, MEM_RELEASE);
   return ;
}        

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
(Computer) Engineer, (Life)Hacker, (Tech)Blogger

Comments and Discussions

 
QuestionOH RLY? Pin
Aoi Karasu 12-Jan-10 4:02
professional Aoi Karasu 12-Jan-10 4:02 
AnswerRe: OH RLY? Pin
PrafullaVedante13-Nov-11 19:16
PrafullaVedante13-Nov-11 19:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.