提交 38fbc862 authored 作者: Mitch Capper's avatar Mitch Capper

Added option to obfuscate file after its generated

上级 865d09b6
...@@ -22,7 +22,7 @@ my ($pid,$output_buffer,$in_cleanup,$proc_stdin); ...@@ -22,7 +22,7 @@ my ($pid,$output_buffer,$in_cleanup,$proc_stdin);
my @AUTOS = qw/-pb -do -st internal -l 7/; my @AUTOS = qw/-pb -do -st internal -l 7/;
push @AUTOS, "-ia" if (! $IS_WINDOWS || $THREADS_SUPPORTED); push @AUTOS, "-ia" if (! $IS_WINDOWS || $THREADS_SUPPORTED);
my ($DISPLAY_OUTPUT,$ACCEPT_INPUT,$PASTEBIN_USER,$FILE,$OB_AUTO,$OB_FILE,@SIP_TRACE_ON,$SOFIA_LOG_LEVEL,$CLEANUP_COMMANDS,$DEBUG_MODE); my ($DISPLAY_OUTPUT,$ACCEPT_INPUT,$PASTEBIN_USER,$FILE,$OB_AUTO,$OB_FILE,@SIP_TRACE_ON,$SOFIA_LOG_LEVEL,$CLEANUP_COMMANDS,$DEBUG_MODE,$OB_ONLY_FILE);
$SIG{INT} = \&cleanup; $SIG{INT} = \&cleanup;
my $FS_CLI = $IS_WINDOWS ? "fs_cli.exe" : "./fs_cli"; my $FS_CLI = $IS_WINDOWS ? "fs_cli.exe" : "./fs_cli";
...@@ -59,6 +59,7 @@ sub usage(){ ...@@ -59,6 +59,7 @@ sub usage(){
-do --display-output Display output on stdout -do --display-output Display output on stdout
-ia --input-accept Pass input to the freeswitch console -ia --input-accept Pass input to the freeswitch console
-D, --fslogger-debug FSLogger debug mode -D, --fslogger-debug FSLogger debug mode
-jof --just-obfuscate-file=<file> Just obfuscate text from file and exit
The -st, -X, -x options can be used multiple times The -st, -X, -x options can be used multiple times
fs_logger.pl will run until fs_cli ends or control+c fs_logger.pl will run until fs_cli ends or control+c
...@@ -71,6 +72,10 @@ sub main(){ ...@@ -71,6 +72,10 @@ sub main(){
parse_args(); parse_args();
my $to_write_fs_cli=""; my $to_write_fs_cli="";
$CLEANUP_COMMANDS=""; $CLEANUP_COMMANDS="";
if ($OB_ONLY_FILE){
$output_buffer = slurp($OB_ONLY_FILE);
cleanup(0);
}
foreach my $to_trace (@SIP_TRACE_ON){ foreach my $to_trace (@SIP_TRACE_ON){
$to_write_fs_cli .= $to_trace eq "_global_" ? "sofia global siptrace on\n" : "sofia profile " . $to_trace . " siptrace on\n"; $to_write_fs_cli .= $to_trace eq "_global_" ? "sofia global siptrace on\n" : "sofia profile " . $to_trace . " siptrace on\n";
$CLEANUP_COMMANDS .= $to_trace eq "_global_" ? "sofia global siptrace off\n" : "sofia profile " . $to_trace . " siptrace off\n"; $CLEANUP_COMMANDS .= $to_trace eq "_global_" ? "sofia global siptrace off\n" : "sofia profile " . $to_trace . " siptrace off\n";
...@@ -430,13 +435,18 @@ sub puke($$){ ...@@ -430,13 +435,18 @@ sub puke($$){
($matches,$value) = arg_test("-of","--obfuscate-file",1,1); ($matches,$value) = arg_test("-of","--obfuscate-file",1,1);
die "Obfuscate file not found: $value" if ($matches && ! -e $value); die "Obfuscate file not found: $value" if ($matches && ! -e $value);
$OB_FILE=$value and next if ($matches); $OB_FILE=$value and next if ($matches);
($matches,$value) = arg_test("-jof","--just-obfuscate-file",1,1);
die "File to just Obfuscate not found: $value" if ($matches && ! -e $value);
$OB_ONLY_FILE=$value and $OB_AUTO=1 and next if ($matches);
($matches,$value) = arg_test("-do","--display-output",0,0);
$DISPLAY_OUTPUT=1 and next if ($matches);
($matches,$value) = arg_test("-do","--display-output",0,0); ($matches,$value) = arg_test("-do","--display-output",0,0);
$DISPLAY_OUTPUT=1 and next if ($matches); $DISPLAY_OUTPUT=1 and next if ($matches);
($matches,$value) = arg_test("-ia","--input-accept",0,0); ($matches,$value) = arg_test("-ia","--input-accept",0,0);
die "Sorry you perl doesn't threading and its required for input redirection on windows" if ($matches && $IS_WINDOWS && ! $THREADS_SUPPORTED); die "Sorry you perl doesn't threading and its required for input redirection on windows" if ($matches && $IS_WINDOWS && ! $THREADS_SUPPORTED);
$ACCEPT_INPUT=1 and next if ($matches); $ACCEPT_INPUT=1 and next if ($matches);
next if ($ignore_if_already); next if ($ignore_if_already);
print STDERR "Invalid option: " . $ARGV[$parse_pos] . "\n"; print STDERR "Invalid option: " . $ARGV[$parse_pos] . "\n";
usage(); usage();
} }
......
...@@ -9,7 +9,7 @@ Auto mode (or -A) turns on a few different options to some defaults that are gen ...@@ -9,7 +9,7 @@ Auto mode (or -A) turns on a few different options to some defaults that are gen
Obfuscation Obfuscation
The -oa and -of options. The -oa and -of options.
The auto obfuscation mode (-oa) will try to randomize any ips/passwords/hashes or domains found in the log file. It tries to do so in a discrete manor so that it does not interfere with debugging (mainly ips/passwords/hashes/domains). IP addresses when randomized have their common subnets preserved relative to each other. This means 192.168.50.10 may turn into 123.123.123.8 but ensures that 192.168.50.30 will have the same base (123.123.123.) class so networks can be identified. The auto obfuscation mode (-oa) will try to randomize any ips/passwords/hashes or domains found in the log file. It tries to do so in a discrete manor so that it does not interfere with debugging (mainly ips/passwords/hashes/domains). IP addresses when randomized have their common subnets preserved relative to each other. This means 192.168.50.10 may turn into 123.123.123.8 but ensures that 192.168.50.30 will have the same base (123.123.123.) class so networks can be identified.
The file obfuscation (-of) allows you to manually specify sensitive data you want always obfuscated and optionally what to obfuscate it with. File should have one entry per line. If the line starts with a '^' it treats the pattern as a regular expression, you can optionally capture groups to only replace those groups or no groups and it will replace the entire match. If line contains an equals sign(not proceeded by a '\\') what is to the right of the equals sign is used as the replacement. The file obfuscation (-of) allows you to manually specify sensitive data you want always obfuscated and optionally what to obfuscate it with. File should have one entry per line. If the line starts with a '^' it treats the pattern as a regular expression, you can optionally capture groups to only replace those groups or no groups and it will replace the entire match. If line contains an equals sign(not proceeded by a '\\') what is to the right of the equals sign is used as the replacement. Note keep in mind the longest items are replaced first. This means if you tell it to replace XYZ but the text contains XYZ.com it will not be replaced by what you specified (unless you specify XYZ.com).
Interactive Options Interactive Options
The -ia and -do options allow FS Logger to behave more like you were interacting with fs_cli directly. The display ouput (-do) option shows you what data is being logged as its being generated (although not obfuscated yet). The input accept mode (-ia) passes lines you type in FS Logger to fs_cli. With both these options it is almost exactly as if you were interacting with fs_cli. There are a few minor differences: tab auto complete does not work, function keys (F1-F12) do not work, up and down for history only work in windows (as its the console that actually does it there) and there is no colorization of lines. The -ia and -do options allow FS Logger to behave more like you were interacting with fs_cli directly. The display ouput (-do) option shows you what data is being logged as its being generated (although not obfuscated yet). The input accept mode (-ia) passes lines you type in FS Logger to fs_cli. With both these options it is almost exactly as if you were interacting with fs_cli. There are a few minor differences: tab auto complete does not work, function keys (F1-F12) do not work, up and down for history only work in windows (as its the console that actually does it there) and there is no colorization of lines.
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论