Commit 63bf10d8 authored by Kilo Code's avatar Kilo Code

Add GUI dialogs for program selection and output directory, create build/clean scripts

parent d6dda4d4
{
"CurrentProjectSetting": "No Configurations"
}
\ No newline at end of file
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\franc\\source\\repos\\bsc\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
}
]
}
]
}
]
}
\ No newline at end of file
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\franc\\source\\repos\\bsc\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
}
]
}
]
}
]
}
\ No newline at end of file
File added
......@@ -7,14 +7,14 @@ CFLAGS = /W3 /O2 /MT
LDFLAGS =
# Detours paths (adjust if installed elsewhere)
DETOURS_PATH = detours
DETOURS_PATH = .
DETOURS_LIB = $(DETOURS_PATH)\lib64\detours.lib
# Targets
all: network_monitor.exe ssl_hook.dll packet_capture.dll bgvnc.exe
network_monitor.exe: network_monitor.c
$(CC) $(CFLAGS) network_monitor.c /link ws2_32.lib iphlpapi.lib /out:$@
$(CC) $(CFLAGS) network_monitor.c /link ws2_32.lib iphlpapi.lib comdlg32.lib shell32.lib ole32.lib /out:$@
ssl_hook.dll: ssl_hook.c ssl_hook.h
$(CC) /LD $(CFLAGS) ssl_hook.c $(DETOURS_LIB) /I $(DETOURS_PATH)\include /link /out:$@
......
File deleted
@echo off
nmake -f Makefile.win all
\ No newline at end of file
@echo off
nmake -f Makefile.win clean
\ No newline at end of file
This diff is collapsed.
//////////////////////////////////////////////////////////////////////////////
//
// Common version parameters.
//
// Microsoft Research Detours Package, Version 4.0.1
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#define _USING_V110_SDK71_ 1
#include "winver.h"
#if 0
#include <windows.h>
#include <detours.h>
#else
#ifndef DETOURS_STRINGIFY
#define DETOURS_STRINGIFY_(x) #x
#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x)
#endif
#define VER_FILEFLAGSMASK 0x3fL
#define VER_FILEFLAGS 0x0L
#define VER_FILEOS 0x00040004L
#define VER_FILETYPE 0x00000002L
#define VER_FILESUBTYPE 0x00000000L
#endif
#define VER_DETOURS_BITS DETOURS_STRINGIFY(DETOURS_BITS)
//////////////////////////////////////////////////////////////////////////////
//
// Detours Test Program (syelog.h of syelog.lib)
//
// Microsoft Research Detours Package
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#pragma once
#ifndef _SYELOGD_H_
#define _SYELOGD_H_
#include <stdarg.h>
#pragma pack(push, 1)
#pragma warning(push)
#pragma warning(disable: 4200)
//////////////////////////////////////////////////////////////////////////////
//
//
#define SYELOG_PIPE_NAMEA "\\\\.\\pipe\\syelog"
#define SYELOG_PIPE_NAMEW L"\\\\.\\pipe\\syelog"
#ifdef UNICODE
#define SYELOG_PIPE_NAME SYELOG_PIPE_NAMEW
#else
#define SYELOG_PIPE_NAME SYELOG_PIPE_NAMEA
#endif
//////////////////////////////////////////////////////////////////////////////
//
#define SYELOG_MAXIMUM_MESSAGE 4086 // 4096 - sizeof(header stuff)
typedef struct _SYELOG_MESSAGE
{
USHORT nBytes;
BYTE nFacility;
BYTE nSeverity;
DWORD nProcessId;
FILETIME ftOccurance;
BOOL fTerminate;
CHAR szMessage[SYELOG_MAXIMUM_MESSAGE];
} SYELOG_MESSAGE, *PSYELOG_MESSAGE;
// Facility Codes.
//
#define SYELOG_FACILITY_KERNEL 0x10 // OS Kernel
#define SYELOG_FACILITY_SECURITY 0x20 // OS Security
#define SYELOG_FACILITY_LOGGING 0x30 // OS Logging-internal
#define SYELOG_FACILITY_SERVICE 0x40 // User-mode system daemon
#define SYELOG_FACILITY_APPLICATION 0x50 // User-mode application
#define SYELOG_FACILITY_USER 0x60 // User self-generated.
#define SYELOG_FACILITY_LOCAL0 0x70 // Locally defined.
#define SYELOG_FACILITY_LOCAL1 0x71 // Locally defined.
#define SYELOG_FACILITY_LOCAL2 0x72 // Locally defined.
#define SYELOG_FACILITY_LOCAL3 0x73 // Locally defined.
#define SYELOG_FACILITY_LOCAL4 0x74 // Locally defined.
#define SYELOG_FACILITY_LOCAL5 0x75 // Locally defined.
#define SYELOG_FACILITY_LOCAL6 0x76 // Locally defined.
#define SYELOG_FACILITY_LOCAL7 0x77 // Locally defined.
#define SYELOG_FACILITY_LOCAL8 0x78 // Locally defined.
#define SYELOG_FACILITY_LOCAL9 0x79 // Locally defined.
// Severity Codes.
//
#define SYELOG_SEVERITY_FATAL 0x00 // System is dead.
#define SYELOG_SEVERITY_ALERT 0x10 // Take action immediately.
#define SYELOG_SEVERITY_CRITICAL 0x20 // Critical condition.
#define SYELOG_SEVERITY_ERROR 0x30 // Error
#define SYELOG_SEVERITY_WARNING 0x40 // Warning
#define SYELOG_SEVERITY_NOTICE 0x50 // Significant condition.
#define SYELOG_SEVERITY_INFORMATION 0x60 // Informational
#define SYELOG_SEVERITY_AUDIT_FAIL 0x66 // Audit Failed
#define SYELOG_SEVERITY_AUDIT_PASS 0x67 // Audit Succeeeded
#define SYELOG_SEVERITY_DEBUG 0x70 // Debugging
// Logging Functions.
//
VOID SyelogOpen(PCSTR pszIdentifier, BYTE nFacility);
VOID Syelog(BYTE nSeverity, PCSTR pszMsgf, ...);
VOID SyelogV(BYTE nSeverity, PCSTR pszMsgf, va_list args);
VOID SyelogClose(BOOL fTerminate);
#pragma warning(pop)
#pragma pack(pop)
#endif // _SYELOGD_H_
//
///////////////////////////////////////////////////////////////// End of File.
......@@ -19,6 +19,8 @@
#include <winsock2.h>
#include <windows.h>
#include <iphlpapi.h>
#include <commdlg.h>
#include <shlobj.h>
#include <stdio.h>
#include <stdlib.h>
#include <tlhelp32.h>
......@@ -63,10 +65,47 @@ BOOL InjectDLL(HANDLE hProcess, const char* dllPath) {
}
int main() {
char program[256];
printf("Enter program to start: ");
fgets(program, sizeof(program), stdin);
program[strcspn(program, "\n")] = 0;
char program[256] = {0};
char outputDir[256] = {0};
// Select program to monitor
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = program;
ofn.nMaxFile = sizeof(program);
ofn.lpstrFilter = "Executable Files\0*.exe\0All Files\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (!GetOpenFileName(&ofn)) {
printf("No program selected\n");
return 1;
}
// Select output directory
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = outputDir;
bi.lpszTitle = "Select output directory for logs";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = NULL;
bi.lParam = 0;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (!pidl) {
printf("No output directory selected\n");
return 1;
}
SHGetPathFromIDList(pidl, outputDir);
CoTaskMemFree(pidl);
STARTUPINFO si = {0};
si.cb = sizeof(si);
......@@ -90,8 +129,13 @@ int main() {
DWORD pid = pi.dwProcessId;
Sleep(2000); // Wait for process to potentially establish connections
FILE* internal_log = fopen("internal_traffic.log", "a");
FILE* external_log = fopen("external_traffic.log", "a");
char internal_log_path[512];
char external_log_path[512];
sprintf(internal_log_path, "%s\\internal_traffic.log", outputDir);
sprintf(external_log_path, "%s\\external_traffic.log", outputDir);
FILE* internal_log = fopen(internal_log_path, "a");
FILE* external_log = fopen(external_log_path, "a");
PMIB_TCPTABLE_OWNER_PID tcpTable;
DWORD size = 0;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment