Skip to content

Commit

Permalink
Add memory PE image traces output
Browse files Browse the repository at this point in the history
  • Loading branch information
a0rtega committed Nov 8, 2021
1 parent c6c28ab commit f658ccc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pafish/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "common.h"
#include "types.h"

char pafish_pe_img_log[2048];

unsigned short init_cmd_colors() {
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE handler = GetStdHandle(STD_OUTPUT_HANDLE);
Expand Down Expand Up @@ -73,6 +75,9 @@ void write_trace(char product[]) {
#if ENABLE_DNS_TRACE
write_trace_dns(product);
#endif
#if ENABLE_PE_IMG_TRACE
write_trace_pe_img(product, TRUE);
#endif
}

void write_trace_dns(char product[]) {
Expand All @@ -95,6 +100,12 @@ void write_trace_dns(char product[]) {
free(dns);
}

void write_trace_pe_img(char product[], BOOLEAN add_comma) {
strncat(pafish_pe_img_log, product, strlen(product));
if (add_comma)
strncat(pafish_pe_img_log, ",", 2);
}

void print_check_group(char * text) {
printf("\n[-] %s\n", text);
}
Expand Down
2 changes: 2 additions & 0 deletions pafish/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void write_trace(char product[]);

void write_trace_dns(char product[]);

void write_trace_pe_img(char product[], BOOLEAN add_comma);

void print_check_group(char * text);

void exec_check(char * text, int (*callback)(), char * text_log, char * text_trace);
Expand Down
11 changes: 11 additions & 0 deletions pafish/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
#ifndef CONFIG_H
#define CONFIG_H

/* This output flag enables sending of DNS
* requests when pafish detects products.
*/
#define ENABLE_DNS_TRACE 1

/* This output flag enables writing traces of
* detections to a PE section of the pafish
* image in memory. Memory dumps of unpacked executables
* may reveal the detected products.
* Output format: "analysis-start trace1,trace2, analysis-end"
*/
#define ENABLE_PE_IMG_TRACE 1

#endif
6 changes: 6 additions & 0 deletions pafish/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ int main(void)
#if ENABLE_DNS_TRACE
write_trace_dns("analysis-start");
#endif
#if ENABLE_PE_IMG_TRACE
write_trace_pe_img("analysis-start ", FALSE);
#endif

original_colors = init_cmd_colors();
print_header();
Expand Down Expand Up @@ -372,6 +375,9 @@ int main(void)
#if ENABLE_DNS_TRACE
write_trace_dns("analysis-end");
#endif
#if ENABLE_PE_IMG_TRACE
write_trace_pe_img(" analysis-end", FALSE);
#endif

/* Restore window */
ShowWindow(GetConsoleWindow(), SW_RESTORE);
Expand Down

0 comments on commit f658ccc

Please sign in to comment.