mirror of
https://github.com/chmod760/CopyReadProcessMemory
synced 2026-06-06 15:24:30 +00:00
FinalProject
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#include "argumentParser.h"
|
||||
#include "handlers.h"
|
||||
#include <iostream>
|
||||
#include "cxxopts.hpp"
|
||||
|
||||
ParsedArguments parse_arguments(int argc, char* argv[])
|
||||
{
|
||||
ParsedArguments args;
|
||||
|
||||
cxxopts::Options options(
|
||||
"CopyReadProcessMemory",
|
||||
"C++ tool that supports exactly one input mode"
|
||||
);
|
||||
|
||||
options.add_options()
|
||||
("s,string_inject", "<STRING_INJECT>", cxxopts::value<std::string>())
|
||||
("f,file_path", "<FILE_PATH>", cxxopts::value<std::string>())
|
||||
("t,remote_payload", "<TARGET_PAYLOAD>", cxxopts::value<std::string>())
|
||||
("e,execute", "Execute payload")
|
||||
("x,xor", "XOR payload with key string", cxxopts::value<std::string>())
|
||||
("h,help", "Show help")
|
||||
("V,version", "Show version")
|
||||
;
|
||||
|
||||
auto result = options.parse(argc, argv);
|
||||
|
||||
// Assign basic flags
|
||||
args.show_help = result.count("help");
|
||||
args.show_version = result.count("version");
|
||||
|
||||
args.execute = result["execute"].as<bool>();
|
||||
|
||||
if (result.count("xor"))
|
||||
{
|
||||
args.xor_key = result["xor"].as<std::string>();
|
||||
if (args.xor_key.empty())
|
||||
throw std::runtime_error("XOR key cannot be empty");
|
||||
}
|
||||
|
||||
|
||||
int mode_count = 0;
|
||||
if (result.count("string_inject")) { args.string_inject = result["string_inject"].as<std::string>(); args.mode = InputMode::StringInject; mode_count++; }
|
||||
if (result.count("file_path")) { args.file_path = result["file_path"].as<std::string>(); args.mode = InputMode::FilePath; mode_count++; }
|
||||
if (result.count("remote_payload")) { args.remote_payload = result["remote_payload"].as<std::string>(); args.mode = InputMode::RemotePayload; mode_count++; }
|
||||
|
||||
if (!args.show_help && !args.show_version)
|
||||
{
|
||||
if (mode_count == 0)
|
||||
throw std::runtime_error("You must select exactly ONE mode: --string_inject, --file_path, or --remote_payload.");
|
||||
|
||||
if (mode_count > 1)
|
||||
throw std::runtime_error("Only ONE mode is allowed. Remove conflicting options.");
|
||||
}
|
||||
|
||||
if (!args.show_help && !args.show_version)
|
||||
{
|
||||
if (mode_count == 0)
|
||||
throw std::runtime_error("You must select exactly ONE mode: --string_inject, --file_path, or --remote_payload.");
|
||||
|
||||
if (mode_count > 1)
|
||||
throw std::runtime_error("Only ONE mode is allowed. Remove conflicting options.");
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
Reference in New Issue
Block a user