-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodecave_dumper_cli.cpp
More file actions
60 lines (53 loc) · 1.92 KB
/
codecave_dumper_cli.cpp
File metadata and controls
60 lines (53 loc) · 1.92 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "codecave_dumper_cli.h"
#include <iostream>
#include <tlhelp32.h>
void CodecaveDumperCLI::listProcesses() {
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE) return;
PROCESSENTRY32W pe32;
pe32.dwSize = sizeof(pe32);
std::cout << "\nAvailable Python processes:" << std::endl;
if (Process32FirstW(snapshot, &pe32)) {
do {
std::wstring processName = pe32.szExeFile;
if (processName.find(L"python") != std::wstring::npos) {
std::wcout << pe32.th32ProcessID << L"\t" << processName << std::endl;
}
} while (Process32NextW(snapshot, &pe32));
}
CloseHandle(snapshot);
}
void CodecaveDumperCLI::run() {
while (true) {
std::cout << "Codecave Hook By Libalpm Program Dumper" << std::endl;
std::cout << "\nMenu Options:" << std::endl;
std::cout << "1. List Python Processes" << std::endl;
std::cout << "2. Dump Process Memory" << std::endl;
std::cout << "3. Exit" << std::endl;
std::string choice;
std::cout << "\nEnter your choice (1-3): ";
std::getline(std::cin, choice);
if (choice == "1") {
listProcesses();
}
else if (choice == "2") {
std::cout << "Enter PID to dump: ";
std::string pidStr;
std::getline(std::cin, pidStr);
try {
DWORD pid = std::stoul(pidStr);
dumper.dump(pid);
}
catch (const std::exception&) {
std::cerr << "Error: Please enter a valid PID" << std::endl;
}
}
else if (choice == "3") {
std::cout << "\nGoodbye!" << std::endl;
break;
}
else {
std::cout << "Invalid choice. Please try again." << std::endl;
}
}
}