#!/usr/bin/perl use Math::BigInt; $verb = 0 ; $verb2 = 0 ; # show time # http://www.stumbler.net/ns1files.html # C uint8 S uint16 L uint32 l int32 Q uint64 d double # Flags (HEx) # 0001 ESS extended service set # 0002 IBSS ad hod/P2P # 0004 CF Pollable # 0008 CF-Poll request # 0010 WEP # 0020 Short Preamble # 0040 PBCC # 0080 Channel Agility # 0400 Short slot time # 2000 DSSS-OFDM $type = 'BSS' ; $bcni = 100 ; $quiet = 0 ; while ($ARGV[0] =~ /-([nedv])/) { if ($1 eq 'n') { shift ; $legend = 1 ; } if ($1 eq 'e') { shift ; $doe = 1 ; } if ($1 eq 'd') { shift ; $dp1 = 1 ; } if ($1 eq 'v') { shift ; $verb = 1 ; } } $file = shift ; open (IN,$file) or die "Usage: $0 [-nedv] \n" ; read (IN,$in,4) ; unless ($in eq 'NetS') { die "$file has no NetStumbler magic\n" ; } read (IN,$in,4) ; $fv = unpack("L",$in) ; print<$xmax) { $xmax = $x ; } if ($y>$ymax) { $ymax = $y ; } if ($x<$xmin) { $xmin = $x ; } if ($y<$ymin) { $ymin = $y ; } $x = int($x * $scale2 + 0.5 ) ; $y = int($y * -$scale2 + 0.5 ) ; # from ps2fig $x{$bssid} = $x ; $y{$bssid} = $y ; if ($verb) { $rate10 = $maxrate * 10 ; $snr = $sig - $noise ; print "$lat\t$long\t( $ssid )\t$type\t( $bssid )\t$date\t[ $snr $sig $noise ]\t\# ( $name )\t$hflags\t$cbits\t$bcni\t$rate10\t$lchan\n" ; } } else { #if ($verb) { print "\n" ; } } } read (IN,$in,1) ; $len = unpack("C",$in) ; read (IN,$in,$len) ; $name = $in ; $name{$bssid} = $name ; if ($fv >= 8) { read (IN,$in,8) ; @chan = unpack("L2",$in) ; read (IN,$in,4) ; $lchan = unpack("L",$in) ; $lchan{$bssid} = $lchan ; read (IN,$in,4) ; $ip = unpack("L",$in) ; @ip = unpack("C4",$in) ; #printf ("channelbits %4.4x%4.4x",$chan[1], $chan[0]) ; #printf ("\tip %i.%i.%i.%i lastchan %i\n",$ip[0],$ip[1],$ip[2],$ip[3],$lchan) ; } if ($fv >= 11 ) { read (IN,$in,4) ; $minsig = unpack("l",$in) ; $minsig{$bssid} = $minsig ; read (IN,$in,4) ; $maxns = unpack("l",$in) ; $maxns{$bssid} = $maxns ; read (IN,$in,4) ; $maxrate = unpack("L",$in)/10 ; $maxrate{$bssid} = $maxrate ; read (IN,$in,4) ; $subnet = unpack("L",$in) ; @subnet = unpack("C4",$in) ; read (IN,$in,4) ; $mask = unpack("L",$in) ; @mask = unpack("C4",$in) ; #printf ("min sig %i max noise %i max rate %i subnet %i.%i.%i.%i mask %i.%i.%i.%i\n",$minsig,$maxns,$maxrate,$subnet[0],$subnet[1],$subnet[2],$subnet[3], $mask[0],$mask[1],$mask[2],$mask[3]) ; } if ($fv >= 12) { read (IN,$in,4) ; $miscflags = unpack("L",$in) ; #if ($miscflags) { printf ("misc flags %4.4x\n", $miscflags) ; } read (IN,$in,4) ; $ielength = unpack("L",$in) ; read (IN,$in,$ielength) ; @ie = unpack("C*",$in) ; #if ($ielength) { print "ie length $ielength\n" ; } } unless ($verb) { $rate10 = $maxrate * 10 ; $snr = $sig - $noise ; print "$lat\t$long\t( $ssid )\t$type\t( $bssid )\t$date\t[ $snr $sig $noise ]\t\# ( $name )\t$hflags\t$cbits\t$bcni\t$rate10\t$lchan\n" ; } } exit ; sub filetotime { my ($h,$l,$t,$r) ; ($l,$h) = unpack("L2",$_[0]) ; my $t = Math::BigInt->new($h); $t->blsft(32) ; $t->badd($l) ; $t->bdiv(10000000) ; # convert 100ns ticks to seconds $t->bsub("11644473600") ; # 134774 days = 369 years 1601 - 1970 return $t ; }