#!/usr/bin/perl # # parser.pl: a script to call a bunch of different tools to manipulate kismet files # # required tools and locations: # - pykismetearth.py (in executable path somewhere /bin /usr/bin etc...) # - mergecsv, mergexml, mergegps. (there is a variable in sub merge() where you can # set the location of these files # - klc.pl & klv.pl (there is a variable in sub klc () where you can set the location # of these files # - mergecap (in executable path somewhere /bin /usr/bin etc...) # - tcpsplit (in executable path somewhere /bin /usr/bin etc...) # - wifi_parser (in /usr/local/bin) # # changelog: 0.2: added in wifi_parser # # written by csr-group for the AOE wireless class # $ver = "0.2 beta"; printf "\nparser.pl ver $ver - a script to manipulate kismet log files\n"; printf "coded by the minions of CSRgroup\n"; # here we give you the option to do stuff! printf "\nWhat do you want to do to the kismet logs?\n"; printf "[ 1 ] Create a .kml file from a SINGLE kismet session to read into google earth\n"; printf "[ 2 ] Merge a BUNCH of kismet sessions and create a .kml file for google earth\n"; printf "[ 3 ] Merge a BUNCH of kismet sessions and create HTML based pages of each node\n"; printf " (this option also combines all the kismet dump files into a single big file)\n"; printf "[ 4 ] Merge several kismet .dump files into 1 BIG file (based on frame timestamp)\n"; printf "[ 5 ] Split a large dump file into smaller dump files\n"; printf "[ 6 ] Pull BSSID's from a dump file\n"; printf "\n"; printf "\nWhat number do you want to choose: "; my $choice = ; chomp($choice); if ($choice == 1){ pykis(); } elsif ($choice == 2){ merge(); } elsif ($choice == 3){ klc(); } elsif ($choice == 4){ mergecap(); } elsif ($choice == 5){ tcpsplit(); } elsif ($choice == 6){ wifi_parser(); } else { printf "\nYou must choose either 1,2,3,4,5 or 6...guess again\n"; exit; } sub pykis { printf "\nCreating a kml file from a single session\n"; printf "\nWhat is the name of the kismet session file you want to use?\n"; printf "\nFile probably has a name like: Kismet-Jan-30-2007-1 ...no need for any extension\n"; printf "\n"; printf "\nEnter the File name here: "; $kml = ; chomp($kml); printf "\nEnter the path to those files: "; $path = ; chomp($path); printf "\nCreating the file $path/$kml.kml \n"; system "pykismetearth.py $path/$kml"; } sub merge { # enter location of merge tools in this next variable # $mergepath="/pentest/wireless/kismettoolsuite"; printf "\nCreating a kml file from multiple kismet sessions\n"; printf "\n"; printf "\nEnter the path to the files, no trailing slash required\n"; printf "Ex: /home/kismet or /root\n"; printf "\n"; $loc = ; chomp($loc); printf "\nEnter the name of the output file (no extension needed): "; $out = ; chomp($out); # Now we take user input, put it into an array and then prepend the $loc and # also add the correct extenstion (.gps .csv .xml) to the input files so # we can create the merged output # printf "\nFile name Example: Kismet-Jan-30-2007-1 (no need for the extension)\n"; printf "\nEnter the File names to read in, when you are done, finish by typing\n"; printf "CTRL-D on a seperate line):\n\n"; @files = ; chomp(@files); printf "\nmerging the files and creating a $out.gps, $out.xml and $out.csv file too!\n"; @xmlarray = (); @gpsarray = (); @csvarray = (); foreach (@files){ push(@gpsarray, "$loc/$_.gps"); push(@xmlarray, "$loc/$_.xml"); push(@csvarray, "$loc/$_.csv"); } system "$mergepath/mergegps $loc/$out.gps @gpsarray"; system "$mergepath/mergexml $loc/$out.xml @xmlarray"; system "$mergepath/mergecsv $loc/$out.csv @csvarray"; # now we take the output file and create a big old .kml file out of it printf "\nCreating the file $loc/$out.kml could take a couple minutes...\n"; system "pykismetearth.py $loc/$out"; } sub klc { # enter location of kismet tools in this next variable # $kl="/pentest/wireless/kismet-log-viewer"; printf "\nCombining the kismet sessions into one BIG session\n"; printf "\n"; printf "\nEnter the path to the files, no trailing slash required\n"; printf "Ex: /home/kismet or /root\n"; printf "\n"; $loc = ; chomp($loc); printf "\nEnter the name of the output file (no extension needed): "; $out = ; chomp($out); printf "\nEnter the names of the .xml files to combine, one per line\n"; printf "\nExample: Kismet-Jan-30-2007-1.xml, when you are done, finish by typing\n"; printf "CTRL-D on a seperate line):\n\n"; @klcfiles = ; chomp(@klcfiles); printf "\ncombining the files and merging the dump files now\n"; @klcarray = (); foreach (@klcfiles){ push(@klcarray, "$loc/$_"); } system "$kl/klc.pl @klcarray $loc/$out.xml -dump"; printf "\nYour files $out.xml and $out.dump have been created in the $loc directory\n"; printf "\nNow we are going to create a bunch of html pages for each node we find\n"; system "$kl/klv.pl $loc/$out.xml -snort"; printf "\nYour html files have been created in the $loc directory\n"; printf "\nThe index file is called $out.xml-kismet-log-view.html\n\n"; } sub mergecap { printf "\nCombining several dump/pcap sessions into one larger file\n\n"; printf "\nEnter the path to the files, no trailing slash required\n"; printf "Ex: /home/kismet or /root\n"; printf "\n"; $loc = ; chomp($loc); printf "\nEnter the name of the output file (no extension needed): "; $out = ; chomp($out); printf "\nEnter the names of the dump files to combine, one per line\n"; printf "\nExample: Kismet-Jan-30-2007-1.dump, airodump.cap, when you are done,\n"; printf "finish by typing CTRL-D on a seperate line):\n\n"; @dumpfiles = ; chomp(@dumpfiles); printf "\nMerging the dump files now\n"; @dumparray = (); foreach (@dumpfiles){ push(@dumparray, "$loc/$_"); } system "mergecap -w $loc/$out.cap @dumparray"; } sub tcpsplit { printf "\nSplitting up several dump/pcap sessions into smaller files\n\n"; printf "\nEnter the path to the file you want to split, no trailing slash required\n"; printf "Ex: /home/kismet or /root\n"; printf "\n"; $loc = ; chomp($loc); printf "\nEnter the name of the input file (big dump file): "; $input = ; chomp($input); printf "\nEnter the name of the output file (no extension needed): "; $out = ; chomp($out); printf "\nEnter how many pieces you want to split the file into: "; $split = ; chomp($split); printf "\nSplitting the file up now\n"; system "tcpsplit $loc/$input $loc/$out.%d $split"; printf "\nCreated $split files in $loc directory with the prefix of $out\n"; printf "\n"; } sub wifi_parser { $wp = "/usr/local/bin/wifi_parser"; printf "\nWhat do you want to do now?\n"; printf "[ a ] List all Unique BSSIDs?\n"; printf "[ b ] List by BSSID/SRC/DEST MAC?\n"; printf "[ c ] Find traffic for a specific BSSID?\n"; printf "\n\nEnter your Choice: "; $wpc = ; chomp($wpc); if ($wpc eq a){ printf "\nEnter the full path and name of the file to parse\n"; printf "\n"; $file = ; chomp($file); printf "\n\nPrinting Unique BSSID's found in $file\n"; system "$wp -r $file -s b | sort | uniq"; } elsif ($wpc eq b){ printf "\nEnter the full path and name of the file to parse\n"; printf "\n"; $file = ; chomp($file); printf "\n\nPrinting a list of BSSID/SRC/DEST MAC addresses from $file\n"; system "$wp -r $file -s bsd | sort | uniq"; } elsif ($wpc eq c){ printf "\nEnter the full path and name of the file to parse\n"; printf "\n"; $file = ; chomp($file); printf "\nEnter the BSSID you want to search for\n"; printf "\n(enter the numbers only, no colons, dashes or spaces\n"; printf "\n(ex: 0045ffd1e0b2): "; $mac = ; chomp($mac); printf "\n\nPrinting Unique BSSID's found in $file\n"; system "$wp -r $file -s bsd | sort | uniq | grep $mac"; } else { printf "\nValid choices are either a, b or c\n"; wifi_parser(); } } exit();