提交 5ed8ad8f authored 作者: Mitch Capper's avatar Mitch Capper

Changed to just read file to allow pb of raw files and supporting of other pb…

Changed to just read file to allow pb of raw files and supporting of other pb highlighting types based on extension, also pointed to new wiki docs
上级 39a4ed2a
...@@ -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,$OB_ONLY_FILE); my ($DISPLAY_OUTPUT,$ACCEPT_INPUT,$PASTEBIN_USER,$FILE,$OB_AUTO,$OB_FILE,@SIP_TRACE_ON,$SOFIA_LOG_LEVEL,$CLEANUP_COMMANDS,$DEBUG_MODE,$JUST_READ_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,7 +59,7 @@ sub usage(){ ...@@ -59,7 +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 -jrf --just-read-file=<file> Read file instead of collecting log from fs_cli
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
...@@ -72,8 +72,8 @@ sub main(){ ...@@ -72,8 +72,8 @@ sub main(){
parse_args(); parse_args();
my $to_write_fs_cli=""; my $to_write_fs_cli="";
$CLEANUP_COMMANDS=""; $CLEANUP_COMMANDS="";
if ($OB_ONLY_FILE){ if ($JUST_READ_FILE){
$output_buffer = slurp($OB_ONLY_FILE); $output_buffer = slurp($JUST_READ_FILE);
cleanup(0); cleanup(0);
} }
foreach my $to_trace (@SIP_TRACE_ON){ foreach my $to_trace (@SIP_TRACE_ON){
...@@ -233,6 +233,12 @@ sub pastebin_post($$){ ...@@ -233,6 +233,12 @@ sub pastebin_post($$){
my ($post_as,$to_post) = @_; my ($post_as,$to_post) = @_;
$post_as = uri_escape($post_as); $post_as = uri_escape($post_as);
$to_post = uri_escape($to_post); $to_post = uri_escape($to_post);
my $file_ext = "";
$file_ext = $1 if ($JUST_READ_FILE =~ /.\.([A-Za-z0-9]{1,4})$/);
my %PASTEBIN_TYPES = ("sh"=>"bash","c"=>"c","cpp"=>"cpp","h"=>"cpp","htm"=>"html4strict","html"=>"html4strict","pl"=>"perl","cgi"=>"perl","py"=>"python","php"=>"php","cs"=>"csharp","lua"=>"lua","xml"=>"xml","fsxml"=>"xml","ini"=>"ini");
my $type = $PASTEBIN_TYPES{lc($file_ext)};
$type = "fslog" if (! $type);
my $pb_post = qq~POST http://pastebin.freeswitch.com/pastebin.php HTTP/1.1 my $pb_post = qq~POST http://pastebin.freeswitch.com/pastebin.php HTTP/1.1
Accept: text/html, application/xhtml+xml, */* Accept: text/html, application/xhtml+xml, */*
Referer: http://pastebin.freeswitch.com/ Referer: http://pastebin.freeswitch.com/
...@@ -247,7 +253,7 @@ sub pastebin_post($$){ ...@@ -247,7 +253,7 @@ sub pastebin_post($$){
~; ~;
$pb_post =~ s/^\t//mg; $pb_post =~ s/^\t//mg;
my $post_body = "parent_pid=&format=fslog&poster=" . $post_as . "&paste=Send&expiry=m&code2="; my $post_body = "parent_pid=&format=$type&poster=" . $post_as . "&paste=Send&expiry=m&code2=";
$post_body .= $to_post; $post_body .= $to_post;
my $post_len = length($post_body); my $post_len = length($post_body);
$pb_post =~ s/CONT_LEN/$post_len/; $pb_post =~ s/CONT_LEN/$post_len/;
...@@ -436,9 +442,9 @@ sub puke($$){ ...@@ -436,9 +442,9 @@ 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); ($matches,$value) = arg_test("-jrf","--just-read-file",1,1);
die "File to just Obfuscate not found: $value" if ($matches && ! -e $value); die "File to just read not found: $value" if ($matches && ! -e $value);
$OB_ONLY_FILE=$value and $OB_AUTO=1 and next if ($matches); $JUST_READ_FILE=$value 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);
...@@ -569,6 +575,7 @@ sub puke($$){ ...@@ -569,6 +575,7 @@ sub puke($$){
ob_handle_found($output_buffer =~ m|$MD5_RESP|g); ob_handle_found($output_buffer =~ m|$MD5_RESP|g);
} }
foreach my $item (sort { length($b) <=> length($a) } keys %OB_TO_REPLACE){ foreach my $item (sort { length($b) <=> length($a) } keys %OB_TO_REPLACE){
print "Obfuscation replacing: $item => $OB_TO_REPLACE{$item}\n"if ($DEBUG_MODE);
$output_buffer = str_replace($output_buffer,$item,$OB_TO_REPLACE{$item}); $output_buffer = str_replace($output_buffer,$item,$OB_TO_REPLACE{$item});
} }
} }
......
FS Logger is a tool to assist with the collection of logging data from freeswitch. It runs fs_cli at the core and excepts all the parameters fs_cli takes in addition to its own. Note the -x behavior is changed. See http://wiki.freeswitch.com/wiki/Fs_logger.pl
The tool will save the log data it collects either to a file or send it to pastebin depending on the command line option and can optionally obfuscate of sensitive information before doing so. To finish hit control + c. \ No newline at end of file
FS Logger will try to clean up any changes it made to loglevels of tracing prior to exiting.
For all parameters see -h
Auto Mode
Auto mode (or -A) turns on a few different options to some defaults that are generally what developers are looking for when debugging. All the options it would set are not overwritten if already specified on the command line. To see the exact options it turns on see -h but in short it will enable sip tracing on the internal profile, turn on obfuscation mode, turn up some debug levels and send the results to pastebin.
Obfuscation
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 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
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 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论