Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
Added multiple process name support, process name regex, added Port, IP in GUI
Sourav Kalal8a3ed146f53a
diff --git a/gui/Interop/ProxyBridgeNative.cs b/gui/Interop/ProxyBridgeNative.csindex 3e939a7..9ad6126 100644--- a/gui/Interop/ProxyBridgeNative.cs+++ b/gui/Interop/ProxyBridgeNative.cs@@ -35,6 +35,13 @@ public static class ProxyBridgeNativeBLOCK = 2}+ public enum RuleProtocol+ {+ TCP = 0,+ UDP = 1,+ BOTH = 2+ }+[UnmanagedFunctionPointer(CallingConvention.Cdecl)]public delegate void LogCallback([MarshalAs(UnmanagedType.LPStr)] string message);@@ -49,6 +56,9 @@ public static class ProxyBridgeNative[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]public static extern uint ProxyBridge_AddRule([MarshalAs(UnmanagedType.LPStr)] string processName,+ [MarshalAs(UnmanagedType.LPStr)] string targetHosts,+ [MarshalAs(UnmanagedType.LPStr)] string targetPorts,+ RuleProtocol protocol,RuleAction action);[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]diff --git a/gui/Services/ProxyBridgeService.cs b/gui/Services/ProxyBridgeService.csindex 9a12ac5..ecfa399 100644--- a/gui/Services/ProxyBridgeService.cs+++ b/gui/Services/ProxyBridgeService.cs@@ -58,7 +58,7 @@ public class ProxyBridgeService : IDisposablereturn ProxyBridgeNative.ProxyBridge_SetProxyConfig(proxyType, ip, port);}- public uint AddRule(string processName, string action)+ public uint AddRule(string processName, string targetHosts, string targetPorts, string protocol, string action){var ruleAction = action.ToUpper() switch{@@ -67,7 +67,15 @@ public class ProxyBridgeService : IDisposable_ => ProxyBridgeNative.RuleAction.PROXY};- return ProxyBridgeNative.ProxyBridge_AddRule(processName, ruleAction);+ var ruleProtocol = protocol.ToUpper() switch+ {+ "UDP" => ProxyBridgeNative.RuleProtocol.UDP,+ "BOTH" => ProxyBridgeNative.RuleProtocol.BOTH,+ "TCP+UDP" => ProxyBridgeNative.RuleProtocol.BOTH,+ _ => ProxyBridgeNative.RuleProtocol.TCP+ };++ return ProxyBridgeNative.ProxyBridge_AddRule(processName, targetHosts, targetPorts, ruleProtocol, ruleAction);}public bool EnableRule(uint ruleId)diff --git a/gui/ViewModels/MainWindowViewModel.cs b/gui/ViewModels/MainWindowViewModel.csindex d6785e2..26fff83 100644--- a/gui/ViewModels/MainWindowViewModel.cs+++ b/gui/ViewModels/MainWindowViewModel.cs@@ -219,13 +219,18 @@ public class MainWindowViewModel : ViewModelBase{if (_proxyService != null){- uint ruleId = _proxyService.AddRule(rule.ProcessName, rule.Action);+ uint ruleId = _proxyService.AddRule(+ rule.ProcessName,+ rule.TargetHosts,+ rule.TargetPorts,+ rule.Protocol,+ rule.Action);if (ruleId > 0){rule.RuleId = ruleId;rule.Index = ProxyRules.Count + 1;ProxyRules.Add(rule);- ActivityLog += $"[{DateTime.Now:HH:mm:ss}] Added rule: {rule.ProcessName} -> {rule.Action} (ID: {ruleId})\n";+ ActivityLog += $"[{DateTime.Now:HH:mm:ss}] Added rule: {rule.ProcessName} ({rule.TargetHosts}:{rule.TargetPorts} {rule.Protocol}) -> {rule.Action} (ID: {ruleId})\n";}else{@@ -295,13 +300,16 @@ public class MainWindowViewModel : ViewModelBasevar rule = new ProxyRule{ProcessName = NewProcessName,+ TargetHosts = "*",+ TargetPorts = "*",+ Protocol = "TCP",Action = NewProxyAction,IsEnabled = true};if (_proxyService != null){- var ruleId = _proxyService.AddRule(NewProcessName, NewProxyAction);+ var ruleId = _proxyService.AddRule(NewProcessName, "*", "*", "TCP", NewProxyAction);if (ruleId > 0){rule.RuleId = ruleId;@@ -367,7 +375,10 @@ public class MainWindowViewModel : ViewModelBasepublic class ProxyRule : ViewModelBase{- private string _processName = "";+ private string _processName = "*";+ private string _targetHosts = "*";+ private string _targetPorts = "*";+ private string _protocol = "TCP";private string _action = "PROXY";private bool _isEnabled = true;private int _index;@@ -391,6 +402,24 @@ public class ProxyRule : ViewModelBaseset => SetProperty(ref _processName, value);}+ public string TargetHosts+ {+ get => _targetHosts;+ set => SetProperty(ref _targetHosts, value);+ }++ public string TargetPorts+ {+ get => _targetPorts;+ set => SetProperty(ref _targetPorts, value);+ }++ public string Protocol+ {+ get => _protocol;+ set => SetProperty(ref _protocol, value);+ }+public string Action{get => _action;diff --git a/gui/ViewModels/ProxyRulesViewModel.cs b/gui/ViewModels/ProxyRulesViewModel.csindex e8e50ce..e44b36c 100644--- a/gui/ViewModels/ProxyRulesViewModel.cs+++ b/gui/ViewModels/ProxyRulesViewModel.cs@@ -8,7 +8,10 @@ namespace ProxyBridge.GUI.ViewModels;public class ProxyRulesViewModel : ViewModelBase{private bool _isAddRuleViewOpen;- private string _newProcessName = "";+ private string _newProcessName = "*";+ private string _newTargetHosts = "*";+ private string _newTargetPorts = "*";+ private string _newProtocol = "TCP";private string _newProxyAction = "PROXY";private string _processNameError = "";private Action<ProxyRule>? _onAddRule;@@ -33,6 +36,24 @@ public class ProxyRulesViewModel : ViewModelBase}}+ public string NewTargetHosts+ {+ get => _newTargetHosts;+ set => SetProperty(ref _newTargetHosts, value);+ }++ public string NewTargetPorts+ {+ get => _newTargetPorts;+ set => SetProperty(ref _newTargetPorts, value);+ }++ public string NewProtocol+ {+ get => _newProtocol;+ set => SetProperty(ref _newProtocol, value);+ }+public string NewProxyAction{get => _newProxyAction;@@ -69,23 +90,34 @@ public class ProxyRulesViewModel : ViewModelBaseSaveNewRuleCommand = new RelayCommand(() =>{+ // Use "*" if emptyif (string.IsNullOrWhiteSpace(NewProcessName)){- ProcessNameError = "Process name is required";- return;+ NewProcessName = "*";+ }++ if (string.IsNullOrWhiteSpace(NewTargetHosts))+ {+ NewTargetHosts = "*";+ }++ if (string.IsNullOrWhiteSpace(NewTargetPorts))+ {+ NewTargetPorts = "*";}// This could be an issue if app name contain char- if (!System.Text.RegularExpressions.Regex.IsMatch(NewProcessName, @"^[a-zA-Z0-9\s._\-*]+$"))+ if (!System.Text.RegularExpressions.Regex.IsMatch(NewProcessName, @"^[a-zA-Z0-9\s._\-*;""\\:]+$")){- ProcessNameError = "Invalid characters in process name. Only letters, numbers, spaces, dots, dashes, underscores and * are allowed";+ ProcessNameError = "Invalid characters in process name. Only letters, numbers, spaces, dots, dashes, underscores, semicolons, quotes, and * are allowed";return;}if (NewProcessName != "*" && !NewProcessName.Equals("*", StringComparison.OrdinalIgnoreCase)){if (!NewProcessName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) &&- !NewProcessName.Contains(".exe ", StringComparison.OrdinalIgnoreCase))+ !NewProcessName.Contains(".exe ", StringComparison.OrdinalIgnoreCase) &&+ !NewProcessName.Contains(";", StringComparison.OrdinalIgnoreCase)){NewProcessName += ".exe";}@@ -94,6 +126,9 @@ public class ProxyRulesViewModel : ViewModelBasevar newRule = new ProxyRule{ProcessName = NewProcessName,+ TargetHosts = NewTargetHosts,+ TargetPorts = NewTargetPorts,+ Protocol = NewProtocol,Action = NewProxyAction,IsEnabled = true};@@ -101,14 +136,23 @@ public class ProxyRulesViewModel : ViewModelBasenewRule.PropertyChanged += Rule_PropertyChanged;_onAddRule?.Invoke(newRule);- NewProcessName = "";++ // Reset to defaults+ NewProcessName = "*";+ NewTargetHosts = "*";+ NewTargetPorts = "*";+ NewProtocol = "TCP";NewProxyAction = "PROXY";ProcessNameError = "";IsAddRuleViewOpen = false;}); CancelAddRuleCommand = new RelayCommand(() =>{- NewProcessName = "";+ NewProcessName = "*";+ NewTargetHosts = "*";+ NewTargetPorts = "*";+ NewProtocol = "TCP";NewProxyAction = "PROXY";+ ProcessNameError = "";IsAddRuleViewOpen = false;});diff --git a/gui/Views/ProxyRulesWindow.axaml b/gui/Views/ProxyRulesWindow.axamlindex 647a520..6a846f4 100644--- a/gui/Views/ProxyRulesWindow.axaml+++ b/gui/Views/ProxyRulesWindow.axaml@@ -122,26 +122,38 @@BorderBrush="#FF3F3F46"BorderThickness="0,1,0,1"Padding="20,12">- <Grid ColumnDefinitions="100,80,*,200">+ <Grid ColumnDefinitions="80,60,200,150,120,*"><TextBlock Grid.Column="0"Text="Enabled"FontSize="13"FontWeight="SemiBold"Foreground="#FFB0B0B0"- Margin="0,0,20,0"/>+ Margin="0,0,10,0"/><TextBlock Grid.Column="1"Text="SR"FontSize="13"FontWeight="SemiBold"Foreground="#FFB0B0B0"- Margin="0,0,20,0"/>+ Margin="0,0,10,0"/><TextBlock Grid.Column="2"- Text="Process Name"+ Text="Process"FontSize="13"FontWeight="SemiBold"Foreground="#FFB0B0B0"- Margin="0,0,20,0"/>+ Margin="0,0,10,0"/><TextBlock Grid.Column="3"+ Text="Target Hosts"+ FontSize="13"+ FontWeight="SemiBold"+ Foreground="#FFB0B0B0"+ Margin="0,0,10,0"/>+ <TextBlock Grid.Column="4"+ Text="Target Ports"+ FontSize="13"+ FontWeight="SemiBold"+ Foreground="#FFB0B0B0"+ Margin="0,0,10,0"/>+ <TextBlock Grid.Column="5"Text="Action"FontSize="13"FontWeight="SemiBold"@@ -151,7 +163,7 @@<!-- Table Body --><ScrollViewer Grid.Row="1"- HorizontalScrollBarVisibility="Disabled"+ HorizontalScrollBarVisibility="Auto"VerticalScrollBarVisibility="Auto"><ItemsControl ItemsSource="{Binding ProxyRules}" x:Name="RulesItemsControl"><ItemsControl.ItemTemplate>@@ -160,17 +172,17 @@BorderBrush="#FF3F3F46"BorderThickness="0,0,0,1"Padding="20,16">- <Grid ColumnDefinitions="100,80,*,200">+ <Grid ColumnDefinitions="80,60,200,150,120,*"><CheckBox Grid.Column="0"IsChecked="{Binding IsEnabled}"VerticalAlignment="Center"- Margin="0,0,20,0"/>+ Margin="0,0,10,0"/><TextBlock Grid.Column="1"Text="{Binding Index}"FontSize="14"Foreground="#FF999999"VerticalAlignment="Center"- Margin="0,0,20,0"/>+ Margin="0,0,10,0"/><TextBlock Grid.Column="2"Text="{Binding ProcessName}"FontSize="14"@@ -178,8 +190,22 @@Foreground="#FFE0E0E0"VerticalAlignment="Center"TextTrimming="CharacterEllipsis"- Margin="0,0,20,0"/>+ Margin="0,0,10,0"/><TextBlock Grid.Column="3"+ Text="{Binding TargetHosts}"+ FontSize="13"+ Foreground="#FF999999"+ VerticalAlignment="Center"+ TextTrimming="CharacterEllipsis"+ Margin="0,0,10,0"/>+ <TextBlock Grid.Column="4"+ Text="{Binding TargetPorts}"+ FontSize="13"+ Foreground="#FF999999"+ VerticalAlignment="Center"+ TextTrimming="CharacterEllipsis"+ Margin="0,0,10,0"/>+ <TextBlock Grid.Column="5"Text="{Binding Action}"FontSize="14"FontWeight="SemiBold"@@ -194,49 +220,92 @@</Grid><!-- Add Rule Form View -->- <StackPanel Margin="24,20"- Spacing="20"- IsVisible="{Binding IsAddRuleViewOpen}">- <StackPanel Spacing="6">- <TextBlock Text="Process Name" Classes="label"/>- <TextBox Text="{Binding NewProcessName}"- Watermark="e.g., chrome.exe, firefox.exe"/>+ <ScrollViewer VerticalScrollBarVisibility="Auto"+ HorizontalScrollBarVisibility="Disabled"+ IsVisible="{Binding IsAddRuleViewOpen}">+ <StackPanel Margin="24,20"+ Spacing="20">+ <!-- Applications Section -->+ <StackPanel Spacing="6">+ <TextBlock Text="Applications" Classes="label"/>+ <TextBox Text="{Binding NewProcessName}"+ Watermark="Any"/>+ <TextBlock Text="Example: iexplore.exe; "C:\some app.exe"; fire*.exe; *.bin"+ FontSize="11"+ Foreground="#FF999999"+ TextWrapping="Wrap"+ Margin="0,4,0,0"/>+ </StackPanel>++ <!-- Target Hosts Section -->+ <StackPanel Spacing="6">+ <TextBlock Text="Target hosts" Classes="label"/>+ <TextBox Text="{Binding NewTargetHosts}"+ Watermark="Any"/>+ <TextBlock Text="Example: 127.0.0.1; *.example.com; 192.168.1.*; 10.1.0.0-10.5.255.255"+ FontSize="11"+ Foreground="#FF999999"+ TextWrapping="Wrap"+ Margin="0,4,0,0"/>+ </StackPanel>++ <!-- Target Ports Section -->+ <StackPanel Spacing="6">+ <TextBlock Text="Target ports" Classes="label"/>+ <TextBox Text="{Binding NewTargetPorts}"+ Watermark="Any"/>+ <TextBlock Text="Example: 80; 8000-9000; 3128"+ FontSize="11"+ Foreground="#FF999999"+ TextWrapping="Wrap"+ Margin="0,4,0,0"/>+ </StackPanel>++ <!-- Protocol Section -->+ <StackPanel Spacing="6">+ <TextBlock Text="Protocol" Classes="label"/>+ <ComboBox SelectedIndex="0"+ HorizontalAlignment="Stretch"+ IsEnabled="False"+ x:Name="ProtocolComboBox">+ <ComboBoxItem Content="TCP (UDP not yet supported)" Tag="TCP"/>+ </ComboBox>+ </StackPanel>++ <!-- Action Section -->+ <StackPanel Spacing="6">+ <TextBlock Text="Action" Classes="label"/>+ <ComboBox SelectedIndex="0"+ HorizontalAlignment="Stretch"+ x:Name="ActionComboBox"+ SelectionChanged="ActionComboBox_SelectionChanged">+ <ComboBoxItem Content="PROXY" Tag="PROXY"/>+ <ComboBoxItem Content="DIRECT" Tag="DIRECT"/>+ <ComboBoxItem Content="BLOCK" Tag="BLOCK"/>+ </ComboBox>+ </StackPanel>++ <!-- Validation Error --><TextBlock Text="{Binding ProcessNameError}"IsVisible="{Binding ProcessNameError, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"Foreground="#FFFF6B6B"FontSize="12"Margin="0,4,0,0"/>- <TextBlock Text="Enter the application name you want to control (e.g., chrome, firefox.exe, notepad). You can use * to apply the rule to all system traffic."- FontSize="11"- Foreground="#FF999999"- TextWrapping="Wrap"- Margin="0,4,0,0"/>- </StackPanel>- <StackPanel Spacing="6">- <TextBlock Text="Action" Classes="label"/>- <ComboBox SelectedIndex="0"- HorizontalAlignment="Stretch"- x:Name="ActionComboBox"- SelectionChanged="ActionComboBox_SelectionChanged">- <ComboBoxItem Content="PROXY" Tag="PROXY"/>- <ComboBoxItem Content="DIRECT" Tag="DIRECT"/>- <ComboBoxItem Content="BLOCK" Tag="BLOCK"/>- </ComboBox>- </StackPanel>-- <StackPanel Orientation="Horizontal"- HorizontalAlignment="Right"- Spacing="12"- Margin="0,16,0,0">- <Button Content="Cancel"- Classes="secondary"- Command="{Binding CancelAddRuleCommand}"- Width="100"/>- <Button Content="Save Rule"- Command="{Binding SaveNewRuleCommand}"- Width="130"/>+ <!-- Action Buttons -->+ <StackPanel Orientation="Horizontal"+ HorizontalAlignment="Right"+ Spacing="12"+ Margin="0,16,0,0">+ <Button Content="Cancel"+ Classes="secondary"+ Command="{Binding CancelAddRuleCommand}"+ Width="100"/>+ <Button Content="Save Rule"+ Command="{Binding SaveNewRuleCommand}"+ Width="130"/>+ </StackPanel></StackPanel>- </StackPanel>+ </ScrollViewer></DockPanel></Window>diff --git a/gui/Views/ProxyRulesWindow.axaml.cs b/gui/Views/ProxyRulesWindow.axaml.csindex 8dee49e..b2293ee 100644--- a/gui/Views/ProxyRulesWindow.axaml.cs+++ b/gui/Views/ProxyRulesWindow.axaml.cs@@ -9,6 +9,11 @@ public partial class ProxyRulesWindow : Windowpublic ProxyRulesWindow(){InitializeComponent();++ if (this.FindControl<ComboBox>("ProtocolComboBox") is ComboBox protocolComboBox)+ {+ protocolComboBox.SelectionChanged += ProtocolComboBox_SelectionChanged;+ }}private void ActionComboBox_SelectionChanged(object? sender, SelectionChangedEventArgs e)@@ -21,4 +26,15 @@ public partial class ProxyRulesWindow : Windowvm.NewProxyAction = tag;}}++ private void ProtocolComboBox_SelectionChanged(object? sender, SelectionChangedEventArgs e)+ {+ if (sender is ComboBox comboBox &&+ comboBox.SelectedItem is ComboBoxItem item &&+ item.Tag is string tag &&+ DataContext is ProxyRulesViewModel vm)+ {+ vm.NewProtocol = tag;+ }+ }}\ No newline at end of filediff --git a/src/ProxyBridge.c b/src/ProxyBridge.cindex c4239b4..81010af 100644--- a/src/ProxyBridge.c+++ b/src/ProxyBridge.c@@ -80,12 +80,25 @@ static void log_message(const char *msg, ...)g_log_callback(buffer);}+// Extract filename from full path C:\path\chrome.exe >> chrome.exe+static const char* extract_filename(const char* path)+{+ if (!path) return "";+ const char* last_backslash = strrchr(path, '\\');+ const char* last_slash = strrchr(path, '/');+ const char* last_separator = (last_backslash > last_slash) ? last_backslash : last_slash;++ return last_separator ? (last_separator + 1) : path;+}+static UINT32 parse_ipv4(const char *ip);static int socks5_connect(SOCKET s, UINT32 dest_ip, UINT16 dest_port);static BOOL match_ip_pattern(const char *pattern, UINT32 ip);static BOOL match_port_pattern(const char *pattern, UINT16 port);static BOOL match_ip_list(const char *ip_list, UINT32 ip);static BOOL match_port_list(const char *port_list, UINT16 port);+static BOOL match_process_pattern(const char *pattern, const char *process_name);+static BOOL match_process_list(const char *process_list, const char *process_name);static int http_connect(SOCKET s, UINT32 dest_ip, UINT16 dest_port);static DWORD WINAPI local_proxy_server(LPVOID arg);static DWORD WINAPI connection_handler(LPVOID arg);@@ -196,7 +209,8 @@ static DWORD WINAPI packet_processor(LPVOID arg)g_proxy_type == PROXY_TYPE_HTTP ? "HTTP" : "SOCKS5",g_proxy_ip, g_proxy_port);- g_connection_callback(process_name, pid, dest_ip_str, orig_dest_port, proxy_info);+ const char* display_name = extract_filename(process_name);+ g_connection_callback(display_name, pid, dest_ip_str, orig_dest_port, proxy_info);}}@@ -298,15 +312,12 @@ static BOOL get_process_name_from_pid(DWORD pid, char *name, DWORD name_size)if (QueryFullProcessImageNameA(hProcess, 0, full_path, &path_len)){- char *filename = strrchr(full_path, '\\');- if (filename != NULL)- {- filename++;- strncpy(name, filename, name_size - 1);- name[name_size - 1] = '\0';- CloseHandle(hProcess);- return TRUE;- }+++ strncpy(name, full_path, name_size - 1);+ name[name_size - 1] = '\0';+ CloseHandle(hProcess);+ return TRUE;}CloseHandle(hProcess);@@ -442,13 +453,132 @@ static BOOL match_port_list(const char *port_list, UINT16 port)return matched;}+// Match process name with wildcard support+// Supports: "*" (all),+// "chrome.exe" (exact), "fire*.exe" (wildcard), "*.bin" (extension wildcard)+// added support for full paths - C:\Program Files\Google\Chrome\Application\chrome.exe+// Nedd to Test all combination at sanme time+static BOOL match_process_pattern(const char *pattern, const char *process_full_path)+{+ if (pattern == NULL || strcmp(pattern, "*") == 0)+ return TRUE;++ // Extract just the filename from the full path for comparison+ // Windows path sucks+ const char *filename = strrchr(process_full_path, '\\');+ if (filename != NULL)+ filename++; // Skip the backslash+ else+ filename = process_full_path; // No path separator, use as-is++ size_t pattern_len = strlen(pattern);+ size_t name_len = strlen(filename);+ size_t full_path_len = strlen(process_full_path);++ // Check if pattern contains path separators (backslash or forward slash)+ BOOL is_full_path_pattern = (strchr(pattern, '\\') != NULL || strchr(pattern, '/') != NULL);++ // check if pattern has path seperator match for full path+ const char *match_target = is_full_path_pattern ? process_full_path : filename; // match against filename only+ size_t target_len = is_full_path_pattern ? full_path_len : name_len;++ // check for * at the end: "fire*" or "C:\Program Files\*"+ if (pattern_len > 0 && pattern[pattern_len - 1] == '*')+ {+ // Match prefix: "fire*" matches "firefox.exe"+ return _strnicmp(pattern, match_target, pattern_len - 1) == 0;+ }++ // Check for wildcard at the beginning: "*.exe"+ if (pattern_len > 1 && pattern[0] == '*')+ {+ // Match suffix: "*.exe" matches "chrome.exe"+ const char *pattern_suffix = pattern + 1;+ size_t suffix_len = pattern_len - 1;+ if (target_len >= suffix_len)+ {+ return _stricmp(match_target + target_len - suffix_len, pattern_suffix) == 0;+ }+ return FALSE;+ }++ // check for * in the middle: "fire*.exe" or C:\Program Files\*\chrome.exe+ const char *star = strchr(pattern, '*');+ if (star != NULL)+ {+ size_t prefix_len = star - pattern;+ const char *suffix = star + 1;+ size_t suffix_len = strlen(suffix);++ // Check prefix matches+ if (_strnicmp(pattern, match_target, prefix_len) != 0)+ return FALSE;++ if (target_len < prefix_len + suffix_len)+ return FALSE;++ return _stricmp(match_target + target_len - suffix_len, suffix) == 0;+ }++ // No * , use case insensitive+ return _stricmp(pattern, match_target) == 0;+}++// Match process list: "chrome.exe;firefox.exe;*.bin"+static BOOL match_process_list(const char *process_list, const char *process_name)+{+ if (process_list == NULL || process_list[0] == '\0' || strcmp(process_list, "*") == 0)+ return TRUE;++ size_t len = strlen(process_list) + 1;+ char *list_copy = (char *)malloc(len);+ if (list_copy == NULL)+ return FALSE;++ strncpy(list_copy, process_list, len);+ BOOL matched = FALSE;++ // Support both semicolon and comma as separators - Need to figure complex rules in CLI parsing+ char *token = strtok(list_copy, ",;");+ while (token != NULL)+ {+ // Skip leading whitespace+ while (*token == ' ' || *token == '\t')+ token++;++ // Remove trailing whitespace // this shit cause error in CLI parsing+ char *end = token + strlen(token) - 1;+ while (end > token && (*end == ' ' || *end == '\t'))+ {+ *end = '\0';+ end--;+ }++ // Remove quotes if present: "C:\some app.exe" - Need to carefully handle this in CLI app+ if (*token == '"' && strlen(token) > 1)+ {+ token++;+ char *quote = strchr(token, '"');+ if (quote != NULL)+ *quote = '\0';+ }++ if (match_process_pattern(token, process_name))+ {+ matched = TRUE;+ break;+ }+ token = strtok(NULL, ",;");+ }+ free(list_copy);+ return matched;+}+static RuleAction check_process_rule(UINT32 src_ip, UINT16 src_port, UINT32 dest_ip, UINT16 dest_port){DWORD pid;char process_name[MAX_PROCESS_NAME];- char target_with_exe[MAX_PROCESS_NAME];- char target_without_exe[MAX_PROCESS_NAME];RuleAction wildcard_action = RULE_ACTION_DIRECT;BOOL wildcard_found = FALSE;@@ -483,22 +613,9 @@ static RuleAction check_process_rule(UINT32 src_ip, UINT16 src_port, UINT32 destcontinue; // Skip to next rule}- // Process specific process name matching- strncpy(target_without_exe, rule->process_name, MAX_PROCESS_NAME - 1);- target_without_exe[MAX_PROCESS_NAME - 1] = '\0';-- char *dot = strrchr(target_without_exe, '.');- if (dot && _stricmp(dot, ".exe") == 0)- *dot = '\0';-- if (strrchr(rule->process_name, '.') == NULL)- snprintf(target_with_exe, MAX_PROCESS_NAME, "%s.exe", rule->process_name);- else- strncpy(target_with_exe, rule->process_name, MAX_PROCESS_NAME - 1);-- if (_stricmp(process_name, rule->process_name) == 0 ||- _stricmp(process_name, target_with_exe) == 0 ||- _stricmp(process_name, target_without_exe) == 0)+ // Use new wildcard process matching+ // Supports: "chrome.exe", "fire*.exe", "*.bin", "chrome.exe;firefox.exe;*.bin"+ if (match_process_list(rule->process_name, process_name)){// Process name matched! Now check IP and port filtersif (!match_ip_list(rule->target_hosts, dest_ip))