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.
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;
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));
dwFuncSize = (DWORD)DummyFunc - (DWORD)RemoteFunction;
dwBytesToAlloc = dwFuncSize + sizeof (REMOTE_INFO) + 4;
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 ;
}
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;
}
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;
}
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;
}
exit:
if (hRemoteThread)
CloseHandle (hRemoteThread);
return ;
}