Category: | Text Processing |
Author/Contact Info | David M. Hagens - brassmon_k@yahoo.com |
Description: | First off this is a menu script with simple options that include multiple scripts. Uses Erriccssons Dump_Eric decrypter for cell traffic call records and I've developed a tool to search on the encrypted file names (a ksh and a CGI, posting ksh though) You specify the date first - Then the time - By doing this the records you pick are thinned out allowing for faster processing of the call record files. It finds the call record files by using a simple pattern match. From top to bottom here is the process. Search tool - Specify date & time. sends the names of the files found to a file then a "sed" statement is created to put dump_eric infront of all filenames in the file then the output is sent to another file then the awk script is run after the above is done and you put in your msisdn and the awk script searches on the output in the second file and outputs that to another file. then after all that you can view the results. Lastly (as we all know the files that dump_eric runs on are rather large)We delete the search results as you're done with them(You're givne the option to delete) Only 2 flaws as I'm aware of is the fact that you can only do one search at a time or else the files with the output get overwritten if somebody else is running a search after you. (I had my own purposes for that) You can easily get around this by having the script ask you what you want to name the output files, to solve the unknown factor for other users just keep a known file extension on it. Last flaw (not really a flaw on my part a necessity because dump_eric is picky - If you run the searchtool from a different directory it includes the fullpath in the file so your call record location output would be (for me atleast) /home/bgw/AccessBill/TTFILE.3345010602123567 and dump_eric won't take anything but the call record file name and not the path) The date&time search tools must be in the same directory as the calltrace records....All the other scripts can go anywhere you wish. Now the code I will list below is multiple scripts each with their own heading. NOTE: Don't forget to change your PERL path for the "#!/usr/bin/perl" as your path might be different. NOTE: There are 3 search tools: A dateonly, a timeonly, and a date&time NOTE: I only put in the date&time search tool because it's really easy to change this script to a timeonly or dateonly and change the menu to suit your needs so you can change it at your leisure(and to save space down here:-). NOTE: THE AWK SCRIPT(except the part where you append or output to your file)can't have any whitespace after each line or it won't work so cut and paste it but make sure that you go through it and get rid of any after each line if there is any. I'll list the code in order. If any help is needed don't hesitate to contact myself at "brassmon_k@yahoo.com" |
Calltrace MENU
# This script is a menu and all files (Not TTFILES) associated with it + are located in the same directory. # All script explanations are located within the associated script fil +es themseleves # This menu is quite understandable so no explanation is needed. # Script written by David M. Hagens # Use as you want #! /usr/bin/sh LOGO="Call Trace Menu" amenu="a. Display search results" ; bmenu="b. Use a date only search" ; cmenu="c. Use a time only search" ; dmenu="d. Use a date range and time range search" ; emenu="e. Get call records" ; fmenu="f. Clean up search files" ; badchoice () { MSG="Invalid Selection... Please Try Again" ; } apick () { cat msisdnoutput.abbazabba | more; echo "\nPress Enter to r +eturn to menu"; read DUMMY; } bpick () { echo "Enter a range in the form YYMMDD-YYMMDD:>"; ./datesea +rch TTFILE* >> calltracedate.abbazabba; } cpick () { echo "Enter a range in the form HHMMSS-HHMMSS:>"; ./timesea +rch TTFILE* >> calltracetime.abbazabba; } dpick () { echo "Follow the trailing instructions:\n"; sleep 1; echo " +Enter a search range in the form YYMMDD-YYMMDD"; echo "Then push the +(ENTER) key, Next"; echo "Enter a search range in the form HHMMSS-HHM +MSS"; echo "Push the (ENTER) key again and you're done!"; ./narrowtim +esearch TTFILE* >> calltracenarrowtime.abbazabba; } epick () { echo "This choice makes call records readable then finds th +e number you are looking for.\n"; echo "NOTE: This process takes hour +s to complete because of the volume of data which is being searched.\ +n"; echo "NOTE: During the midpoint of this program you will be asked + to supply a msisdn.\n"; echo "Press Enter to Continue"; read DUMMY; +./calltracesed; } fpick () { echo "This removes files you created during your call recor +ds search.\n"; echo "If you wish to keep these files resident on the +system please choose 'n'.\n"; echo "Please remember to delete the fil +es you created by using this menu when you no longer need them.\n"; e +cho "Press Enter to continue"; read DUMMY; echo "Please choose 'y' fo +r (yes) or 'n' for (no)""\n"; ./calltraceremove; } themenu () { clear date echo echo "\t\t\t" $LOGO echo echo "\t\tNOTE: Search results can only be displayed after option 'd' +has been completed." echo "\t\tNOTE: You must do an 'b' 'c' or 'd' search before executing +option 'd'\n" echo "\t\tPlease Select:" echo echo "\t\t\t" $amenu echo "\t\t\t" $bmenu echo "\t\t\t" $cmenu echo "\t\t\t" $dmenu echo "\t\t\t" $emenu echo "\t\t\t" $fmenu echo "\t\t\tx. Exit" echo echo $MSG echo echo Select by pressing the letter and then ENTER; } MSG= while true do themenu read answer MSG= case $answer in a|A) apick;; b|B) bpick;; c|C) cpick;; d|D) dpick;; e|E) epick;; f|F) fpick;; x|X) break;; *) badchoice;; esac doneTHE DATE & TIME SEARCH SCRIPT #!/usr/bin/perl -w
my %mylist;
my $datemin;
my $datemax;
my $timemin;
my $timemax;
my $range;
my $rangex;
# get the range (in this throwtogether it must be entered
# with no spaces in the form YYMMDD-YYMMDD)
# Get the range
$range = <STDIN>;
$rangex = <STDIN>;
# Break up the range
($datemin, $datemax) = split /-/, $range;
($timemin, $timemax) = split /-/, $rangex;
# Squeeze out leading and trailing spaces
$datemin =~ s/^\s+//;
$datemin =~ s/\s+$//;
$timemin =~ s/^\s+//;
$timemin =~ s/\s+$//;
$datemax =~ s/^\s+//;
$datemax =~ s/\s+$//;
$timemax =~ s/^\s+//;
$timemax =~ s/\s+$//;
# Get the filenames and break into fields
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
if ($_ =~ m/(\w+)\.(\d{4})(\d{6})(\d{6})$/) {
# push the restricted range of filenames onto a hash of arrays
# keyed on the date field
if (($3>= $datemin) && ($3 <= $datemax) && ($4>= $timemin) && ($4 <= $
+timemax)) {
push(@{$mylist{$3}}, $_);
}
}
}
my @keys = sort (keys %mylist);
foreach my $key (@keys) {
foreach my $thing (@{%mylist}{$key}){
foreach my $it (@$thing) {
print "$it\n";
}
}
}
THE SED SCRIPT
# This script first makes a file then appends to a file. The reason i +t has to append to a file is a sed command is involved # Which will then make the appended to file executable. Then it is ex +ecuted with dump_eric and it's output is appended to another file # Because without this file being executed the next script "calltrace. +awk" can't read the output to draw out a msisdn # Calltrace.awk finds the msisdn (phone number) you are looking for. # Script Written by David M. Hagens #! /usr/bin/ksh echo "Please choose the name corelating to your search:\n"; echo "'cal +ltracedate.abbazabba' for a date search"; echo "'calltracetime.abbaza +bba' for time search"; echo " or"; echo "'calltracenarrowtime.abbazab +ba' for a more specific search\n"; echo "Which trace file do you want +:>\c " read ANSWER if [ "$ANSWER" = "calltracedate.abbazabba" ]; then sed -e 's/^/\dump_eric /' calltracedate.abbazabba >> calltrace2.abbaza +bba; chmod 777 calltrace2.abbazabba; ./calltrace2.abbazabba >> output +.abbazabba; calltrace.awk; break; elif [ "$ANSWER" = "calltracetime.abbazabba" ]; then sed -e 's/^/\dump_eric + /' calltracetime.abbazabba >> calltrace2.abbazabba; chmod 777 calltr +ace2.abbazabba; ./calltrace2.abbazabba >> output.abbazabba; calltrace +.awk; break; else sed -e 's/^/\dump_eric /' calltracenarrowtime.abbazabba >> calltrace2. +abbazabba; chmod 777 calltrace2.abbazabba; ./calltrace2.abbazabba >> +output.abbazabba; calltrace.awk; break fiTHE AWK SCRIPT # Asks input for what msisdn (phone number) you are looking for and th +en it appends it's output to a file otherwise it is displayed on scre +en. # The fields Called, Calling, Redirecting, are fields pulled out of th +e TTFILES # Script written by David M. Hagens # Copyright Airadigm Communications #! /usr/bin/sh echo "What msisdn?" read msisdn awk "BEGIN{ msisdn=\"$msisdn\"; }"' { #printf("%s\n", ARGV[2]) line14 =line13 line13 =line12 line12 =line11 line11 =line10 line10 =line9 line9 =line8 line8 =line7 line7 =line6 line6 =line5 line5 =line4 line4 =line3 line3 =line2 line2 =line1 line1 =$0 } /Called/ {if(match($9,msisdn)) a=1;} a>0 {if(a==1&&match(line12,"MSTerm")) {print "\n" line12"\n" line2"\n" +line1;MSTerm=1} if(a==1&&match(line11,"TRANSIT")) {print "\n" line11"\n" line2"\n"line +1; Transit=1} if((a==8||a==9||a==10)&&MSTerm) print $0 if((a==6||a==7||a==8)&&Transit) print $0 if (a++>10) { a=0;MSTerm=0;Transit=0}; } /Calling/ {if(match($9,msisdn)) b=1;} b>0 {if(b==1&&match(line10,"MSORIG")) {print "\n" line10"\n"; MSOrig= +1} if(b==1&&match(line10,"TRANSIT")){print "\n" line10"\n"; Transit=1} if((b<=2||b==5||b==7||b==8)&&MSOrig) print $0 if((b<=2||b==7||b==8||b==9)&&Transit) print $0 if (b++>8) { b=0; MSOrig=0;Transit=0}; } /Redirecting/ {if(match($8,msisdn)) c=1;} c>0 {if(c==1&&match(line14,"CallForward")) print "\n" line14"\n" line5 +"\n" line4"\n" ; if(b<=5) print $0 if (c++>5) { c=0;}; }' output.abbazabba >> msisdnoutput.abbazabba; echo "The file with you +r search results is called "msisdnoutput.abbazabba""THE CALLTRACE REMOVE SCRIPT # This script removes files created by the user doing a calltrace. # if answer is "n" stop the script if the answer is "y" remove all .ab +bazabba files # Files have .abbazabba extension so when they are removed vital syste +m files will not accidentally be removed # Script written by David M. Hagens # Copyright Airadigm Communication #! /usr/bin/sh echo "Are you sure you want to remove these files" read ANSWER if [ "$ANSWER" = "n" ]; then sleep 1; break; elif [ "$ANSWER" = "y" ]; then rm *.abbazabba; else echo "Bad Option"; echo "Please answer y(yes) or n(no)"; read ANSWER fi |
|
---|
Back to
Code Catacombs