[kisgearth] r25 committed - * changed: xml parsing for kismet newcore...

23 views
Skip to first unread message

kisg...@googlecode.com

unread,
Jan 22, 2010, 2:46:55 AM1/22/10
to kisg...@googlegroups.com
Revision: 25
Author: katanga
Date: Thu Jan 21 23:46:20 2010
Log: * changed: xml parsing for kismet newcore
* changed: encryption colors. wpa2 = red, wpa = orange, wep = yellow, opn =
green
# fixed: "ordering by encryption" bug
# fixed: essid extraction in kismet newcore
+ added: 'nmanuf'
- removed: pdupeiv (pivdupe already there)


http://code.google.com/p/kisgearth/source/detail?r=25

Added:
/branches/katanga/kisgearth.pl

=======================================
--- /dev/null
+++ /branches/katanga/kisgearth.pl Thu Jan 21 23:46:20 2010
@@ -0,0 +1,1730 @@
+#!/usr/bin/perl -w
+################################################################################
+# KisGearth - a Kismet xml log to GoogleEarth kml converter *KISMET
NEWCORE VER*
+################################################################################
+# 0.01g - 2010.01.19 - NewCore fixes by 'mon' kat...@gmail.com
+# 0.01f - 2008.08.28 - by Richard Sammet (e-axe) richard...@gmail.com
+################################################################################
+# Information and latest version available at:
+# http://mytty.org/kisgearth/
+################################################################################
+# This file is part of KisGearth.
+#
+# KisGearth is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# KisGearth is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with KisGearth; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# http://www.gnu.org/licenses/gpl.txt
+################################################################################
+
+use XML::Simple;
+use Class::Struct;
+
+# activating autoflush on stdout, stderr gets flushed automatic
+$| = 1;
+
+# constants
+my $CODENAME = 'KisGearth';
+my $VERSION = '0.01g';
+my $AUTHOR = 'Richard Sammet (e-axe) / mon (newcore fixes)';
+my $CONTACT = 'richard...@gmail.com';
+my $WEBSITE = 'http://mytty.org/kisgearth/';
+
+# color constants
+# used for network drawing
+my $AliceBlue = 'F0F8FF';
+my $AntiqueWhite = 'FAEBD7';
+my $Aquamarine1 = '7FFFD4';
+my $Azure1 = 'F0FFFF';
+my $Beige = 'F5F5DC';
+my $Bisque1 = 'FFE4C4';
+my $Black = '000000';
+my $BlanchedAlmond = 'FFEBCD';
+my $Blue1 = 'FF0000';
+my $BlueViolet = '8A2BE2';
+my $Brown1 = 'A52A2A';
+my $Burlywood1 = 'DEB887';
+my $Cadetblue1 = '5F9EA0';
+my $Chartreuse1 = '7FFF00';
+my $Chocolate1 = 'D2691E';
+my $Coral1 = 'FF7F50';
+my $CornFlowerBlue = '6495ED';
+my $Cornsilk1 = 'FFF8DC';
+my $Cyan1 = '00FFFF';
+my $DarkGoldenrod1 = 'B8860B';
+my $DarkGreen = '006400';
+my $DarkKhaki = 'BDB768';
+my $DarkOliveGreen1 = '556B2F';
+my $DarkOrange1 = 'FF8C00';
+my $DarkOrchid1 = '9932CC';
+my $DarkSalmon = 'E9967A';
+my $DarkSeaGreen1 = '8FBC8F';
+my $DarkSlateBlue = '483D8B';
+my $DarkSlateGray1 = '2F4F4F';
+my $DarkTurquoise = '00CED1';
+my $DarkViolet = '9400D3';
+my $DeepPink1 = 'FF1493';
+my $DeepSkyBlue1 = '00BFFF';
+my $DimGray = '696969';
+my $DodgerBlue1 = '1E90FF';
+my $Firebrick1 = 'B22222';
+my $FloralWhite = 'FFFAF0';
+my $ForestGreen = '228B22';
+my $Gainsboro = 'DCDCDC';
+my $GhostWhite = 'F8F8FF';
+my $Gold1 = 'FFD700';
+my $Goldenrod1 = 'DAA520';
+my $Gray00 = '7E7E7E';
+my $Gray47 = '787878';
+my $Gray96 = 'F5F5F5';
+my $Green1 = '00FF00';
+my $GreenYellow = 'ADFF2F';
+my $Honeydew1 = 'F0FFF0';
+my $HotPink1 = 'FF69B4';
+my $IndianRed1 = 'CD5C5C';
+my $Ivory1 = 'FFFFF0';
+my $Khaki1 = 'F0E68C';
+my $LavenderBlush1 = 'FFF0F5';
+my $LawnGreen = '7CFC00';
+my $LemonChiffon1 = 'FFFACD';
+my $LightBlue1 = 'ADD8E6';
+my $LightCoral = 'F08080';
+my $LightCyan1 = 'E0FFFF';
+my $Lightgoldenrod1 = 'EEDD82';
+my $LightGoldenrodYellow = 'FAFAD2';
+my $LightGray = 'D3D3D3';
+my $LightPink1 = 'FFB6C1';
+my $LightSalmon1 = 'FFA07A';
+my $LightSeaGreen = '20B2AA';
+my $LightLightSkyBlue1 = '87CEFA';
+my $LightSkyBlue2 = 'B0E2FF';
+my $LightSlateBlue = '8470FF';
+my $LightSlateGray = '778899';
+my $LightSteelBlue1 = 'B0C4DE';
+my $LightYellow1 = 'FFFFE0';
+my $LimeGreen = '32CD32';
+my $Linen = 'FAF0E6';
+my $Magenta1 = 'FF00FF';
+my $Maroon1 = 'B03060';
+my $MediumAquamarine = '66CDAA';
+my $MediumBlue = '0000CD';
+my $MediumOrchid1 = 'BA55D3';
+my $MediumPurple1 = '9370DB';
+my $MediumSeaGreen = '3CB371';
+my $MediumSlateBlue = '7B68EE';
+my $MediumSpringGreen = '00FA9A';
+my $MediumTurquoise = '48D1CC';
+my $MediumvioletRed = 'C71585';
+my $MidnightBlue = '191970';
+my $MintCreme = 'F5FFFA';
+my $Mistyrose1 = 'FFE4E1';
+my $Moccasin = 'FFE4B5';
+my $NavajoWhite1 = 'FFDEAD';
+my $NavyBlue000080 = '000080';
+my $Oldlace = 'FDF5E6';
+my $OliveDrab1 = '6B8E23';
+my $Orange1 = '0090FF';
+my $OrangeRed1 = 'FF4500';
+my $Orchid1 = 'DA70D6';
+my $PaleGoldenrod = 'EEE8AA';
+my $PaleGreen1 = '98FB98';
+my $PaleTurquoise1 = 'AFEEEE';
+my $PaleVioletred1 = 'DB7093';
+my $PapayaWhip = 'FFEFD5';
+my $Peachpuff1 = 'FFDAB9';
+my $Peru = 'CD853F';
+my $Pink1 = 'FFC0CB';
+my $Plum1 = 'DDA0DD';
+my $PowderBlue = 'B0E0E6';
+my $Purple1 = 'A020F0';
+my $Red1 = '0000FF';
+my $RoseGray = '706666';
+my $Roseybrown1 = 'FFC1C1';
+my $Royalblue1 = '4169E1';
+my $SaddleBrown = '8B4513';
+my $Salmon1 = 'FA8072';
+my $SandyBrown = 'F4A460';
+my $Seagreen1 = '2E8B57';
+my $Seashell1 = 'FFF5EE';
+my $SergeBlue = '0000B4';
+my $Sienna1 = 'A0522D';
+my $SkyBlue1 = '87CEEB';
+my $SlateBlue1 = '836FFF';
+my $SlateGray1 = '708090';
+my $Snow1 = 'FFFAFA';
+my $SpringGreen1 = '00FF7F';
+my $SteelBlue1 = '4682B4';
+my $Tan1 = 'D2B48C';
+my $Thsitle1 = 'D8BFD8';
+my $Thitle5 = '8B7B8B';
+my $TimGray = '615C5C';
+my $Tomato1 = 'FF6347';
+my $Turquoise1 = '40E0D0';
+my $Violet = 'EE82EE';
+my $VioletRed1 = 'D02090';
+my $Wheat1 = 'F5DEB3';
+my $Yellow1 = '00FFFF';
+
+my $RED = $Red1;
+my $ORANGE = $Orange1;
+my $YELLOW = $Yellow1;
+my $GREEN = $Green1;
+my $GREY = $Gray00;
+
+# channel colors
+my @CHANCOL = (
+ $AliceBlue,
+ $RED,
+ $ORANGE,
+ $YELLOW,
+ $GREEN,
+ $Aquamarine1,
+ $Azure1,
+ $Brown1,
+ $Burlywood1,
+ $Cadetblue1,
+ $Chartreuse1,
+ $Chocolate1,
+ $Coral1,
+ $CornFlowerBlue,
+ $Cornsilk1,
+ $Cyan1,
+ $DarkGoldenrod1,
+ $DarkGreen,
+ $DarkKhaki,
+ $DarkOliveGreen1,
+ $DarkOrange1,
+ $DarkOrchid1,
+ $DarkSalmon,
+ $DarkSeaGreen1,
+ $DarkSlateBlue,
+ $DarkSlateGray1,
+ $DarkTurquoise,
+ $DarkViolet,
+ $DeepPink1,
+ $DeepSkyBlue1,
+ $DimGray,
+ $DodgerBlue1,
+ $Firebrick1,
+ $FloralWhite,
+ $ForestGreen,
+ $Gainsboro,
+ $GhostWhite,
+ $Gold1,
+ $Goldenrod1,
+ $Gray00,
+ $Gray47,
+ $Gray96,
+ $Green1,
+ $GreenYellow,
+ $Honeydew1,
+ $HotPink1,
+ $IndianRed1,
+ $Ivory1,
+ $Khaki1,
+ $LavenderBlush1,
+ $LawnGreen,
+ $LemonChiffon1,
+ $LightBlue1,
+ $LightCoral,
+ $LightCyan1,
+ $Lightgoldenrod1,
+ $LightGoldenrodYellow,
+ $LightGray,
+ $LightPink1,
+ $LightSalmon1,
+ $LightSeaGreen,
+ $LightLightSkyBlue1,
+ $LightSkyBlue2,
+ $LightSlateBlue,
+ $LightSlateGray,
+ $LightSteelBlue1,
+ $LightYellow1,
+ $LimeGreen,
+ $Linen,
+ $Magenta1,
+ $Maroon1,
+ $MediumAquamarine,
+ $MediumBlue,
+ $MediumOrchid1,
+ $MediumPurple1,
+ $MediumSeaGreen,
+ $MediumSlateBlue,
+ $MediumSpringGreen,
+ $MediumTurquoise,
+ $MediumvioletRed,
+ $MidnightBlue,
+ $MintCreme,
+ $Mistyrose1,
+ $Moccasin,
+ $NavajoWhite1,
+ $NavyBlue000080,
+ $Oldlace,
+ $OliveDrab1,
+ $Orange1,
+ $OrangeRed1,
+ $Orchid1,
+ $PaleGoldenrod,
+ $PaleGreen1,
+ $PaleTurquoise1,
+ $PaleVioletred1,
+ $PapayaWhip,
+ $Peachpuff1,
+ $Peru,
+ $Pink1,
+ $Plum1,
+ $PowderBlue,
+ $Purple1,
+ $Red1,
+ $RoseGray,
+ $Roseybrown1,
+ $Royalblue1,
+ $SaddleBrown,
+ $Salmon1,
+ $SandyBrown,
+ $Seagreen1,
+ $Seashell1,
+ $SergeBlue,
+ $Sienna1,
+ $SkyBlue1,
+ $SlateBlue1,
+ $SlateGray1,
+ $Snow1,
+ $SpringGreen1,
+ $SteelBlue1,
+ $Tan1,
+ $Thsitle1,
+ $Thitle5,
+ $TimGray,
+ $Tomato1,
+ $Turquoise1,
+ $Violet,
+ $VioletRed1,
+ $Wheat1,
+ $Yellow1,
+ $AliceBlue,
+ $AntiqueWhite,
+ $Aquamarine1,
+ $Azure1,
+ $Beige,
+ $Bisque1,
+ $Black,
+ $BlanchedAlmond,
+ $Blue1,
+ $BlueViolet,
+ $Brown1,
+ $Burlywood1,
+ $Cadetblue1,
+ $Chartreuse1,
+ $Chocolate1,
+ $Coral1,
+ $CornFlowerBlue,
+ $Cornsilk1,
+ $Cyan1,
+ $DarkGoldenrod1,
+ $DarkGreen,
+ $DarkKhaki,
+ $DarkOliveGreen1,
+ $DarkOrange1,
+ $DarkOrchid1,
+ $DarkSalmon,
+ $DarkSeaGreen1,
+ $DarkSlateBlue,
+ $DarkSlateGray1,
+ $DarkTurquoise,
+ $DarkViolet,
+ $DeepPink1,
+ $DeepSkyBlue1,
+ $DimGray,
+ $DodgerBlue1,
+ $Firebrick1,
+ $FloralWhite,
+ $ForestGreen,
+ $Gainsboro,
+ $GhostWhite,
+ $Gold1,
+ $Goldenrod1,
+ $Gray00,
+ $Gray47,
+ $Gray96,
+ $Green1,
+ $GreenYellow,
+ $Honeydew1,
+ $HotPink1,
+ $IndianRed1,
+ $Ivory1,
+ $Khaki1,
+ $LavenderBlush1,
+ $LawnGreen,
+ $LemonChiffon1,
+ $LightBlue1,
+ $LightCoral,
+ $LightCyan1,
+ $Lightgoldenrod1,
+ $LightGoldenrodYellow,
+ $LightGray,
+ $LightPink1,
+ $LightSalmon1,
+ $LightSeaGreen,
+ $LightLightSkyBlue1,
+ $LightSkyBlue2,
+ $LightSlateBlue,
+ $LightSlateGray,
+ $LightSteelBlue1,
+ $LightYellow1,
+ $LimeGreen,
+ $Linen,
+ $Magenta1,
+ $Maroon1,
+ $MediumAquamarine,
+ $MediumBlue,
+ $MediumOrchid1,
+ $MediumPurple1,
+ $MediumSeaGreen,
+ $MediumSlateBlue,
+ $MediumSpringGreen,
+ $MediumTurquoise,
+ $MediumAquamarine,
+ $MediumvioletRed,
+ $MidnightBlue,
+ $MintCreme,
+ $RED,
+ $ORANGE,
+ $YELLOW,
+ $GREEN,
+ $Aquamarine1
+);
+
+# crypt state colors
+my @CRYPTCOL = (
+ $RED, # wpa2 -> AES-CCM
+ $ORANGE, # wpa -> TKIP || PSK
+ $YELLOW, # wep -> WEP
+ $GREEN # none -> None
+);
+
+# vaiable constants
+my $MSGLVL = 1; # global msg level
+my $ERROR = 0; # level for error msgs
+my $DEBUG = 3; # level for debug msgs
+my $VERBOSE = 2; # level for verbose msgs
+my $STANDARD = 1; # level for standard msgs
+
+# commandline opts variable constants
+my $QUIET = 0; # 0/1 quiet mode
+my $OPACITY = 127; # transparency
+my $ORDER = 0; # network order type
+my $NCOLORS = 0; # network coloring type
+my $INFOS = "all"; # export infos
+my $IPSEEN = 0; # ip-seen filter
+my $IIPSEEN = 0; # inverted ip-seen filter
+my $HAVECLIENTS = 0; # have-clients filter
+my $IHAVECLIENTS = 0; # inverted have-clients filter
+my $OUTFTYPE = ""; # output filetype
+my $OUTFNAME = ""; # outpur filename
+my $SSIDFILTER = ""; # ssid filter list
+my $ISSIDFILTER = ""; # inverted ssid filter list
+my $BSSIDFILTER = ""; # bssid filter list
+my $IBSSIDFILTER = ""; # inverted bssid filter list
+my $CHANFILTER = ""; # channel filter list
+my $ICHANFILTER = ""; # inverted channel filter list
+my $CARRFILTER = ""; # carrier filter list
+my $ICARRFILTER = ""; # inverted carrier filter list
+my $TYPEFILTER = ""; # type filter list
+my $ITYPEFILTER = ""; # inverted type filter list
+#my $PCKTFILTER = ""; # packet filter list
+#my $IPCKTFILTER = ""; # inverted packet filter list
+my $CALCRANGE = 0; # calculate network range
+my $USESIGNAL = 0; # use the signal strength for position
calculation
+my $DRAWCENTER = 1; # draw center of network
+my $CENTERSIZE = 1; # size for network center
+my $FROM = "0"; # started
+my $TO = "0"; # ended
+
+# global variables
+my @networks = ();
+my @GPSpoints = ();
+my @chanlist = ();
+my @ichanlist = ();
+my @carrlist = ();
+my @icarrlist = ();
+my @typelist = ();
+my @itypelist = ();
+my @tmp_channel = ();
+my $net_count = 0;
+my $gps_cnt = 0;
+my $kismet_xml_file = '';
+my $kismet_gps_file = '';
+
+# these are our structures ;)
+struct IPaddress => {
+ iptype => '$',
+ iprange => '$',
+};
+
+struct Packets => {
+ pLLC => '$',
+ pdata => '$',
+ pcrypt => '$',
+ pweak => '$',
+ ptotal => '$',
+ pivdupe => '$',
+};
+
+struct Gpsinfo => {
+ gunit => '$',
+ gminlat => '$',
+ gminlon => '$',
+ gminalt => '$',
+ gminspd => '$',
+ gmaxlat => '$',
+ gmaxlon => '$',
+ gmaxalt => '$',
+ gmaxspd => '$',
+};
+
+struct Network => {
+ nnumber => '$',
+ ntype => '$',
+ nwep => '$',
+ ncloaked => '$',
+ nfirsttime => '$',
+ nlasttime => '$',
+ nssid => '$',
+ nbssid => '$',
+ ninfo => '$',
+ nchannel => '$',
+ nmaxrate => '$',
+ nmaxseenrate => '$',
+ ncarrier => '$',
+ nencoding => '$',
+ nencryption => '@',
+ npackets => 'Packets',
+ ngpsinfo => 'Gpsinfo',
+ nipaddress => 'IPaddress',
+ ndatasize => '$',
+ nwclient => '$',
+ nwcisco => '$',
+ nmanuf => '$',
+};
+
+struct GPSpoint => {
+ bssid => '$',
+ source => '$',
+ timesec => '$',
+ timeusec => '$',
+ lat => '$',
+ lon => '$',
+ alt => '$',
+ spd => '$',
+ heading => '$',
+ fix => '$',
+ signal => '$',
+ quality => '$',
+ noise => '$',
+};
+
+# this is currently not in use!
+# is there an array or hash outta there ? ;)
+sub IsArray {
+
+ if($_[0] =~ m/(ARRAY|HASH)/) {
+ return 1;
+ }
+ return 0;
+
+} # sub IsArray
+
+# the usage ;)
+sub usage {
+
+ print STDOUT "$CODENAME $VERSION ( $WEBSITE )\n";
+ print STDOUT "USAGE: $0 [Options/Filter/Drawing Options] --
[Kismet.xml]\n";
+ print STDOUT "--\n";
+ print STDOUT "Options:\n";
+ print STDOUT " -h, --help This help\n";
+ print STDOUT " -v, --verbose Verbose output while running\n";
+ print STDOUT " -d, --debug Debug output while running\n";
+ print STDOUT " -q, --quiet Do not print anything on stdout
(should be used as 1st opt)\n";
+ print STDOUT " -V, --version KisGearth Version\n";
+ print STDOUT " -G, --gps <file> Also use the Kismet *.gps log.
(recommended)\n";
+ print STDOUT " more accurate AP
positioning.\n";
+ print STDOUT " -oN <file> Output converted data in GEarth
kml format to\n";
+ print STDOUT " the given filename\n";
+ #print STDOUT " -oZ <file> Output converted data in
GEarth kmz format to\n";
+ #print STDOUT " the given filename\n";
+ print STDOUT " -O, --order <order> Ordering hierarchy [Default:
0]\n";
+ print STDOUT " 0 is ordered based on
encryption status\n";
+ print STDOUT " 1 is ordered based on network
channel\n";
+ print STDOUT "\n";
+ print STDOUT "Filters:\n";
+ print STDOUT " -fS <SSID list> Comma-separated list of SSIDs
to filter\n";
+ print STDOUT " -iS <SSID list> Comma-separated list of SSIDs
to filter (Inverted!)\n";
+ print STDOUT " -fB <BSSID list> Comma-separated list of BSSIDs
to filter\n";
+ print STDOUT " -iB <BSSID list> Comma-separated list of BSSIDs
to filter (Inverted!)\n";
+ print STDOUT " -fC <Channel list> Comma-separated list of
Channels to filter\n";
+ print STDOUT " -iC <Channel list> Comma-separated list of
Channels to filter (Inverted!)\n";
+ print STDOUT " -fR <Carrier list> Comma-separated list of
Carriers to filter\n";
+ print STDOUT " -iR <Carrier list> Comma-separated list of
Carriers to filter (Inverted!)\n";
+ print STDOUT " Possible Carriers:
a,b,g,h,n\n";
+ print STDOUT " (normally it is the same you
used for scanning!)\n";
+ print STDOUT " -fT <Type list> Comma-separated list of Types
to filter\n";
+ print STDOUT " -iT <Type list> Comma-separated list of Types
to filter (Inverted!)\n";
+ print STDOUT " Possible Types:
infrastructure,ad-hoc,probe,data,\n";
+ print STDOUT "
turbocell,unknown\n";
+ print STDOUT " -fH, --have-clients Only shows networks with
clients seen\n";
+ print STDOUT " -iH, --i-have-clients Only shows networks with
clients seen (Inverted!)\n";
+ print STDOUT " -fI, --ip-seen Only shows networks with
ip-addresses seen\n";
+ print STDOUT " -iI, --i-ip-seen Only shows networks with
ip-addresses seen (Inverted!)\n";
+ print STDOUT "\n";
+ print STDOUT "Drawing Options:\n";
+ print STDOUT " -n, --network-colors <c> Network drawing colors
[Default: 0]\n";
+ print STDOUT " 0 is random colors\n";
+ print STDOUT " 1 is color based on encryption
status\n";
+ print STDOUT " 2 is color based on network
channel\n";
+ print STDOUT " -r, --calculate-range Rudimentary trys to calculate
the range of the wireless\n";
+ print STDOUT " network based on the min/max
coords\n";
+ print STDOUT " -s, --use-signal Enables the use of the signal
strength for\n";
+ print STDOUT " network position
calculation.\n";
+ print STDOUT " -c, --draw-center Draws each network as a single
dot [Default]\n";
+ print STDOUT " -cS, --center-size <s> Size of network center dot [1
to 4 ; Default 1]\n";
+ print STDOUT " -a, --alpha <h> Draw opacity [1 to 255 ;
Default: 127 (~50%)]\n";
+ #print STDOUT " -eI <Info list> Exports given Inforamtion into
kml/kmz network description\n";
+ #print STDOUT " [Default: all]\n";
+ #print STDOUT " Possible Infos:
ssid,bssid,type,wep,cloaked,firsttime,lasttime,\n";
+ #print STDOUT "
info,channel,maxrate,maxseenrate,carrier,\n";
+ #print STDOUT "
encoding,packets,gpsinfo,iptype,iprange,datasize\n";
+
+} # sub usage
+
+# own print function...
+sub my_print {
+
+ my $which = $_[0];
+ my $msg = $_[1];
+
+ if($which == 0) {
+ print STDERR "ERROR: $msg\n";
+ }elsif(($which <= $MSGLVL) and ($QUIET == 0)) {
+ print STDOUT "$msg\n";
+ }
+
+ return 0;
+
+} # sub my_print
+
+# prting the version
+sub print_version {
+
+ print STDOUT "$CODENAME $VERSION ( $WEBSITE )\n";
+ print STDOUT "$AUTHOR - $CONTACT\n";
+ print STDOUT "License: GNU General Public License (
http://www.gnu.org/licenses/gpl.txt )\n";
+
+} # sub print_version
+
+# processing commandline arguments
+# this is a very strange and rudimentary function ;)
+sub process_opts {
+
+ my $optcnt = 0;
+ my $optend = 0;
+ my $dummy = "";
+
+ if(($#ARGV == -1) or ($#ARGV > 256)) {
+ &usage();
+ return -1;
+ }
+
+ for( ; $optcnt <= $#ARGV ; $optcnt++) {
+ if(($ARGV[$optcnt] eq '-h') or ($ARGV[$optcnt] eq '--help')) {
+ &usage();
+ exit 0;
+ }elsif(($ARGV[$optcnt] eq '-V') or ($ARGV[$optcnt] eq '--version')) {
+ &print_version();
+ return 0;
+ }elsif(($ARGV[$optcnt] eq '-v') or ($ARGV[$optcnt] eq '--verbose')) {
+ if($MSGLVL < 2) {
+ $MSGLVL = 2;
+ }elsif($MSGLVL == 3) {
+ &my_print($DEBUG, "DEBUG > VERBOSE.");
+ }
+ }elsif(($ARGV[$optcnt] eq '-d') or ($ARGV[$optcnt] eq '--debug')) {
+ if($MSGLVL < 3) {
+ $MSGLVL = 3;
+ &my_print($DEBUG, "DEBUG mode enabled.");
+ }
+ }elsif(($ARGV[$optcnt] eq '-q') or ($ARGV[$optcnt] eq '--quiet')) {
+ $QUIET = 1;
+ }elsif(($ARGV[$optcnt] eq '-fI') or ($ARGV[$optcnt] eq '--ip-seen')) {
+ $IPSEEN = 1;
+ &my_print($DEBUG, "IP Seen filter activated!");
+ }elsif(($ARGV[$optcnt] eq '-fH') or ($ARGV[$optcnt]
eq '--have-clients')) {
+ $HAVECLIENTS = 1;
+ &my_print($DEBUG, "Have Clients filter activated!");
+ }elsif(($ARGV[$optcnt] eq '-iI') or ($ARGV[$optcnt] eq '--i-ip-seen'))
{
+ $IIPSEEN = 1;
+ &my_print($DEBUG, "Inverted IP Seen filter activated!");
+ }elsif(($ARGV[$optcnt] eq '-iH') or ($ARGV[$optcnt]
eq '--i-have-clients')) {
+ $IHAVECLIENTS = 1;
+ &my_print($DEBUG, "Inverted Have Clients filter activated!");
+ }elsif(($ARGV[$optcnt] eq '-r') or ($ARGV[$optcnt]
eq '--calculate-range')) {
+ $CALCRANGE = 1;
+ &my_print($DEBUG, "Calculate Network Range activated!");
+ }elsif(($ARGV[$optcnt] eq '-s') or ($ARGV[$optcnt] eq '--use-signal'))
{
+ $USESIGNAL = 1;
+ &my_print($DEBUG, "Calculate network position with the help of the
signal strength!");
+ }elsif(($ARGV[$optcnt] eq '-c') or ($ARGV[$optcnt]
eq '--draw-center')) {
+ $DRAWCENTER = 1;
+ &my_print($DEBUG, "Draw Network Center activated!");
+ }elsif(($ARGV[$optcnt] eq '-cS') or ($ARGV[$optcnt]
eq '--center-size')) {
+ if($ARGV[$optcnt+1] =~ m/^[1-4]$/) {
+ $CENTERSIZE = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Center Size: $CENTERSIZE");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "Format error in given -cS/--center-size
value!");
+ return -1;
+ }
+ }elsif(($ARGV[$optcnt] eq '-n') or ($ARGV[$optcnt]
eq '--network-colors')) {
+ if($ARGV[$optcnt+1] =~ m/^[0-2]$/) {
+ $NCOLORS = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Network Colors: $NCOLORS");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "Format error in given -n/--network-colors
value!");
+ return -1;
+ }
+ }elsif(($ARGV[$optcnt] eq '-O') or ($ARGV[$optcnt] eq '--order')) {
+ if($ARGV[$optcnt+1] =~ m/^[0-1]$/) {
+ $ORDER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Order: $ORDER");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "Format error in given -O/--order value!");
+ return -1;
+ }
+ }elsif(($ARGV[$optcnt] eq '-a') or ($ARGV[$optcnt] eq '--alpha')) {
+ if($ARGV[$optcnt+1] =~ m/^[0-9]{1,3}$/) {
+ $OPACITY = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Opacity/Alpha value: $OPACITY");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "Format error in given -a/--alpha value!");
+ return -1;
+ }
+ }elsif(($ARGV[$optcnt] eq '-G') or ($ARGV[$optcnt] eq '--gps')) {
+ if(-f $ARGV[$optcnt+1]) {
+ $kismet_gps_file = $ARGV[$optcnt+1];
+ &my_print($VERBOSE, "Using $kismet_gps_file as gps file ...");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "File not found (-G/--gps $kismet_gps_file)!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] eq '-oN') {
+ if($ARGV[$optcnt+1] =~ m/^\-$/i) {
+ $OUTFTYPE = "kml";
+ &my_print($DEBUG, "Using $OUTFTYPE output format ...");
+ $OUTFNAME = "$ARGV[$optcnt+1]";
+ &my_print($VERBOSE, "Using $OUTFNAME (STDOUT) as output file ...");
+ }elsif((!($ARGV[$optcnt+1] =~ m/^\-/i)) and (!(-f
$ARGV[$optcnt+1]))) {
+ $OUTFTYPE = "kml";
+ &my_print($DEBUG, "Using $OUTFTYPE output format ...");
+ $OUTFNAME = "$ARGV[$optcnt+1]";
+ &my_print($VERBOSE, "Using $OUTFNAME as output file ...");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "None/wrong filenamen given to -oN or file
already exists!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] =~ m/^\-(f|i)S$/) {
+ $dummy = $1;
+ if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ if($dummy eq 'f') {
+ $SSIDFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using SSID Filter: $SSIDFILTER");
+ $optcnt++;
+ }elsif($dummy eq 'i') {
+ $ISSIDFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using inverted SSID Filter: $ISSIDFILTER");
+ $optcnt++;
+ }
+ }else{
+ &my_print($ERROR, "Format error in given -${dummy}S filter list!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] =~ m/^\-(f|i)B$/) {
+ $dummy = $1;
+ if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ if($dummy eq 'f') {
+ $BSSIDFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using BSSID Filter: $BSSIDFILTER");
+ $optcnt++;
+ }elsif($dummy eq 'i') {
+ $IBSSIDFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using inverted BSSID Filter: $IBSSIDFILTER");
+ $optcnt++;
+ }
+ }else{
+ &my_print($ERROR, "Format error in given -${dummy}B filter list!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] =~ m/^\-(f|i)C$/) {
+ $dummy = $1;
+ if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ if($dummy eq 'f') {
+ $CHANFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Channel Filter: $CHANFILTER");
+ $optcnt++;
+ }elsif($dummy eq 'i') {
+ $ICHANFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using inverted Channel Filter: $ICHANFILTER");
+ $optcnt++;
+ }
+ }else{
+ &my_print($ERROR, "Format error in given -${dummy}C filter list!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] =~ m/^\-(f|i)R$/) {
+ $dummy = $1;
+ if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ if($dummy eq 'f') {
+ $CARRFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Carrier Filter: $CARRFILTER");
+ $optcnt++;
+ }elsif($dummy eq 'i') {
+ $ICARRFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using inverted Carrier Filter: $ICARRFILTER");
+ $optcnt++;
+ }
+ }else{
+ &my_print($ERROR, "Format error in given -${dummy}R filter list!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] =~ m/^\-(f|i)T$/) {
+ $dummy = $1;
+ if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ if($dummy eq 'f') {
+ $TYPEFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Type Filter: $TYPEFILTER");
+ $optcnt++;
+ }elsif($dummy eq 'i') {
+ $ITYPEFILTER = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using inverted Type Filter: $ITYPEFILTER");
+ $optcnt++;
+ }
+ }else{
+ &my_print($ERROR, "Format error in given -${dummy}T filter list!");
+ return -1;
+ }
+ #}elsif($ARGV[$optcnt] =~ m/^\-(f|i)P$/) {
+ # $dummy = $1;
+ # if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ # if($dummy eq 'f') {
+ # $PCKTFILTER = $ARGV[$optcnt+1];
+ # &my_print($DEBUG, "Using Packet Filter: $PCKTFILTER");
+ # $optcnt++;
+ # }elsif($dummy eq 'i') {
+ # $IPCKTFILTER = $ARGV[$optcnt+1];
+ # &my_print($DEBUG, "Using inverted Packet Filter: $IPCKTFILTER");
+ # $optcnt++;
+ # }
+ # }else{
+ # &my_print($ERROR, "Format error in given -${dummy}P filter
list!");
+ # return -1;
+ # }
+ }elsif($ARGV[$optcnt] eq '-eI') {
+ if($ARGV[$optcnt+1] =~ m/^[^\-](.)*$/i) {
+ $INFOS = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using Info list: $INFOS");
+ $optcnt++;
+ }else{
+ &my_print($ERROR, "Format error in given -eI list!");
+ return -1;
+ }
+ }elsif($ARGV[$optcnt] eq '--') {
+ if((defined $ARGV[$optcnt+1]) and (!(-f $ARGV[$optcnt+1]))) {
+ &my_print($ERROR, "File not found! ( $ARGV[$optcnt+1] )");
+ return -1;
+ }elsif((defined $ARGV[$optcnt+1]) and (-f $ARGV[$optcnt+1])) {
+ $kismet_xml_file = $ARGV[$optcnt+1];
+ &my_print($DEBUG, "Using $kismet_xml_file ...");
+ $optend = 1;
+ last;
+ }else{
+ &my_print($ERROR, "Did you miss to specify an output file?!");
+ return -1;
+ }
+ }
+ }
+
+ if(($OUTFTYPE eq "") or ($OUTFNAME eq "")) {
+ &my_print($ERROR, "No ouput file specified (-oN/-oZ)! Abortion!");
+ return -1;
+ }
+
+ if($optend == 0) {
+ &my_print($ERROR, "Optend (--) not found! Abortion!");
+ return -1;
+ }
+
+} # sub process_opts
+
+# reading the xml file/s
+sub read_k_xml {
+
+ my $xml_file = $_[0];
+ my $data = "";
+ my $procnt = 0;
+ my $N = "";
+ my $E = "";
+ my $xml = undef;
+
+ # create object
+ $xml = new XML::Simple (KeyAttr=>[]);
+
+ $data = $xml->XMLin("$xml_file");
+
+ &my_print($VERBOSE, "Storing data into our structures ...");
+
+ $FROM = $data->{'start-time'};
+ $TO = $data->{'end-time'};
+
+ foreach $N (@{$data->{'wireless-network'}}) {
+
+ $networks[$net_count] = Network->new();
+
+ $networks[$net_count]->nnumber($N->{'number'});
+
+ $networks[$net_count]->npackets(new Packets);
+ $networks[$net_count]->npackets->pcrypt($N->{'packets'}->{'crypt'});
+ $networks[$net_count]->npackets->pLLC($N->{'packets'}->{'LLC'});
+ $networks[$net_count]->npackets->pdata($N->{'packets'}->{'data'});
+ $networks[$net_count]->npackets->ptotal($N->{'packets'}->{'total'});
+ $networks[$net_count]->npackets->pweak($N->{'packets'}->{'weak'});
+ $networks[$net_count]->npackets->pivdupe($N->{'packets'}->{'ivdupe'});
+
+ $networks[$net_count]->nchannel($N->{'channel'});
+
+ $networks[$net_count]->nbssid($N->{'BSSID'});
+
+ $networks[$net_count]->ngpsinfo(new Gpsinfo);
+ $networks[$net_count]->ngpsinfo->gminlon($N->{'gps-info'}->{'min-lon'});
+ $networks[$net_count]->ngpsinfo->gmaxspd($N->{'gps-info'}->{'max-spd'});
+ $networks[$net_count]->ngpsinfo->gminlat($N->{'gps-info'}->{'min-lat'});
+ $networks[$net_count]->ngpsinfo->gminspd($N->{'gps-info'}->{'min-spd'});
+
$networks[$net_count]->ngpsinfo->gminalt($N->{'gps-info'}->{'min-alt'});
+ $networks[$net_count]->ngpsinfo->gmaxlat($N->{'gps-info'}->{'max-lat'});
+ $networks[$net_count]->ngpsinfo->gmaxlon($N->{'gps-info'}->{'max-lon'});
+ $networks[$net_count]->ngpsinfo->gmaxalt($N->{'gps-info'}->{'max-alt'});
+
+ $networks[$net_count]->ndatasize($N->{'datasize'});
+
+ $networks[$net_count]->nmanuf($N->{'manuf'});
+
+ $networks[$net_count]->nssid($N->{'SSID'}->{'essid'}->{'content'});
+ $networks[$net_count]->ntype($N->{'SSID'}->{'type'});
+ $networks[$net_count]->nwep($N->{'SSID'}->{'wep'});
+ $networks[$net_count]->ncloaked($N->{'SSID'}->{'essid'}->{'cloaked'});
+ $networks[$net_count]->nfirsttime($N->{'SSID'}->{'first-time'});
+ $networks[$net_count]->nlasttime($N->{'SSID'}->{'last-time'});
+ $networks[$net_count]->nmaxrate($N->{'SSID'}->{'maxrate'});
+
+ if(defined($N->{'SSID'}->{'encryption'})) {
+ if (($N->{'SSID'}->{'encryption'}) eq 'WEP') {
+ push(@{$networks[$net_count]->nencryption}, 'WEP');
+ } else {
+ foreach $E (@{$N->{'SSID'}->{'encryption'}}) {
+ push(@{$networks[$net_count]->nencryption}, $E);
+ }
+ }
+ }
+
+ $networks[$net_count]->ninfo($N->{'info'});
+ $networks[$net_count]->nmaxseenrate($N->{'maxseenrate'});
+ $networks[$net_count]->ncarrier($N->{'carrier'});
+ $networks[$net_count]->nencoding($N->{'encoding'});
+ $networks[$net_count]->nipaddress(new IPaddress);
+ $networks[$net_count]->nwclient($N->{'wireless-client'});
+
$networks[$net_count]->nipaddress->iptype($N->{'ip-address'}->{'type'});
+
$networks[$net_count]->nipaddress->iprange($N->{'ip-address'}->{'ip-range'});
+
+ $net_count++;
+
+ # if quiet is not set, we print some status
+ if(($QUIET == 0) and ($MSGLVL == 2)) {
+ if($procnt == 75) {
+ $procnt = 0;
+ print STDOUT "\b"x75;
+ }
+ print STDOUT "+";
+ $procnt++;
+ }
+ }
+
+ #&my_print($VERBOSE, "\n");
+ &my_print($VERBOSE, $net_count." networks imported.");
+
+ return 0;
+
+} # sub read_k_xml
+
+# reading the xml file/s
+sub read_g_xml {
+
+ my $xml_file = $_[0];
+ my $data = "";
+ my $procnt = 0;
+ my $N = "";
+ my $E = "";
+ my $xml = undef;
+
+ # create object
+ $xml = new XML::Simple (KeyAttr=>[]);
+
+ $data = $xml->XMLin("$xml_file");
+
+ &my_print($VERBOSE, "Storing data into our structures ...");
+
***The diff for this file has been truncated for email.***

Reply all
Reply to author
Forward
0 new messages