9using namespace paramkit;
13#define PARAM_PID "pid"
14#define PARAM_SHELLCODE "shellc"
15#define PARAM_OBFUSCATED "obfusc"
16#define PARAM_THREADS "threads"
17#define PARAM_DATA "data"
18#define PARAM_IAT "iat"
19#define PARAM_MODULES_IGNORE "mignore"
20#define PARAM_REFLECTION "refl"
21#define PARAM_DOTNET_POLICY "dnet"
24#define PARAM_IMP_REC "imp"
25#define PARAM_DUMP_MODE "dmode"
26#define PARAM_REBASE "rebase"
28#define PARAM_OUT_FILTER "ofilter"
29#define PARAM_RESULTS_FILTER "report"
30#define PARAM_QUIET "quiet"
31#define PARAM_JSON "json"
32#define PARAM_JSON_LVL "jlvl"
33#define PARAM_DIR "dir"
34#define PARAM_MINIDUMP "minidmp"
35#define PARAM_PATTERN "pattern"
40 if (strparam.buffer !=
nullptr) {
43 strparam.buffer = (
char*)calloc(len + 1,
sizeof(
char));
44 if (strparam.buffer) {
45 strparam.length = len;
53 free(strparam.buffer);
54 strparam.buffer =
nullptr;
64 this->addParam(
new IntParam(
PARAM_PID,
true));
65 this->setInfo(
PARAM_PID,
"Set the PID of the target process.");
67 EnumParam *enumParam =
new EnumParam(
PARAM_IMP_REC,
"imprec_mode",
false);
69 this->addParam(enumParam);
70 this->setInfo(
PARAM_IMP_REC,
"Set in which mode the ImportTable should be recovered");
79 this->addParam(enumParam);
89 this->addParam(enumParam);
94 if (
info.empty())
continue;
101 std::stringstream ss1;
102 ss1 <<
"Do not scan module/s with given name/s.";
103 std::stringstream ss2;
109 this->setInfo(
PARAM_REBASE,
"Rebase the module to its original base (if known).");
112 this->setInfo(
PARAM_QUIET,
"Print only the summary. Do not log on stdout during the scan.");
114 this->addParam(
new BoolParam(
PARAM_JSON,
false));
115 this->setInfo(
PARAM_JSON,
"Print the JSON report as the summary.");
120 this->addParam(enumParam);
121 this->setInfo(
PARAM_JSON_LVL,
"Level of details of the JSON report.");
129 this->setInfo(
PARAM_MINIDUMP,
"Create a minidump of the full suspicious process.");
134 this->addParam(enumParam);
135 this->setInfo(
PARAM_SHELLCODE,
"Detect shellcode implants (by patterns or statistics). ");
143 this->setInfo(
PARAM_PATTERN,
"Set additional shellcode patterns (file in the SIG format).");
148 this->addParam(enumParam);
149 this->setInfo(
PARAM_OBFUSCATED,
"Detect encrypted content, and possible obfuscated shellcodes.");
158 this->setInfo(
PARAM_THREADS,
"Scan threads' callstack. Detect shellcodes, incl. 'sleeping beacons'.");
163 "Make a process reflection before scan.",
164 std::string(INFO_SPACER) +
"This allows i.e. to force-read inaccessible pages."
168 enumParam =
new EnumParam(
PARAM_IAT,
"iat_scan_mode",
false);
170 this->addParam(enumParam);
171 this->setInfo(
PARAM_IAT,
"Scan for IAT hooks.");
181 this->addParam(enumParam);
182 this->setInfo(
PARAM_DOTNET_POLICY,
"Set the policy for scanning managed processes (.NET).");
190 enumParam =
new EnumParam(
PARAM_DATA,
"data_scan_mode",
false);
192 this->addParam(enumParam);
193 this->setInfo(
PARAM_DATA,
"Set if non-executable pages should be scanned.");
203 this->addParam(enumParam);
204 this->setInfo(
PARAM_DUMP_MODE,
"Set in which mode the detected PE files should be dumped.");
206 peconv::t_pe_dump_mode mode = (peconv::t_pe_dump_mode)(i);
212 this->addParam(
new StringParam(
PARAM_DIR,
false));
213 this->setInfo(
PARAM_DIR,
"Set a root directory for the output (default: current directory).");
216 std::string str_group =
"5. output options";
217 this->addGroup(
new ParamGroup(str_group));
218 this->addParamToGroup(
PARAM_DIR, str_group);
224 str_group =
"1. scanner settings";
225 this->addGroup(
new ParamGroup(str_group));
229 str_group =
"3. scan options";
230 this->addGroup(
new ParamGroup(str_group));
232 this->addParamToGroup(
PARAM_IAT, str_group);
238 str_group =
"4. dump options";
239 this->addGroup(
new ParamGroup(str_group));
245 str_group =
"2. scan exclusions";
246 this->addGroup(
new ParamGroup(str_group));
253 StringParam* myStr =
dynamic_cast<StringParam*
>(this->getParam(paramId));
254 if (!myStr || !myStr->isSet()) {
257 std::string val = myStr->valToString();
258 const size_t len = val.length();
263 bool is_copied =
false;
264 if (strparam.buffer) {
265 is_copied = copyCStr<StringParam>(paramId, strparam.buffer, strparam.length);
280 copyVal<BoolParam>(
PARAM_JSON, ps.json_output);
295 copyCStr<StringParam>(
PARAM_DIR, ps.output_dir, _countof(ps.output_dir));
302.______ _______ _______. __ ___________ ____ _______ \n\
303| _ \\ | ____| / || | | ____\\ \\ / / | ____|\n\
304| |_) | | |__ ______ | (----`| | | |__ \\ \\/ / | |__ \n\
305| ___/ | __| |______| \\ \\ | | | __| \\ / | __| \n\
306| | | |____ .----) | | | | |____ \\ / | |____ \n\
307| _| |_______| |_______/ |__| |_______| \\__/ |_______|\n";
310 _ _______ _______ __ _______ __ _______ \n";
312________________________________________________________________________\n";
313 paramkit::print_in_color(DARK_GREEN, logo);
314 paramkit::print_in_color(DARK_RED, logo2);
315 paramkit::print_in_color(DARK_RED, logo3);
PEsieveParams(const std::string &version)
void fillStruct(t_params &ps)
bool fillStringParam(const std::string ¶mId, PARAM_STRING &strparam)
std::string shellc_mode_mode_to_id(const pesieve::t_shellc_mode &mode)
std::string translate_iat_scan_mode(const pesieve::t_iat_scan_mode mode)
std::string translate_data_mode(const pesieve::t_data_scan_mode &mode)
std::string imprec_mode_to_id(const pesieve::t_imprec_mode imprec_mode)
std::string translate_obfusc_mode(const pesieve::t_obfusc_mode &mode)
std::string translate_dump_mode(const DWORD dump_mode)
std::string obfusc_mode_mode_to_id(const pesieve::t_obfusc_mode &mode)
std::string dump_mode_to_id(const DWORD dump_mode)
std::string translate_json_level(const pesieve::t_json_level &mode)
std::string results_filter_to_id(const DWORD r_filter)
std::string translate_out_filter(const pesieve::t_output_filter o_filter)
std::string info()
The string with the basic information about the scanner.
std::string translate_imprec_mode(const pesieve::t_imprec_mode imprec_mode)
std::string translate_results_filter(const pesieve::t_results_filter r_filter)
std::string translate_dotnet_policy(const pesieve::t_dotnet_policy &mode)
std::string translate_shellc_mode(const pesieve::t_shellc_mode &mode)
#define PARAM_RESULTS_FILTER
#define PARAM_DOTNET_POLICY
#define PARAM_MODULES_IGNORE
bool alloc_strparam(PARAM_STRING &strparam, ULONG len)
void free_strparam(PARAM_STRING &strparam)
The root of the PE-sieve scanner.
#define PARAM_LIST_SEPARATOR