Skip to content

Commit

Permalink
Quantify Causes Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
dheryta committed Jun 8, 2016
1 parent 3e70efc commit 3717cd2
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
13 changes: 11 additions & 2 deletions CausalAnalysis-Datasets/Quantify-Causes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@

#ssids_count= len(ssidTable)
#ssid_details= len(ssidTable[0])
ssidreader=csv.reader(ssids_file,delimiter=',',quotechar='\n')
ssidreader=csv.reader(ssids,delimiter=',',quotechar='\n')
for row in ssidreader:
availableSSIDs=availableSSIDs.join(','.join(row))

print "Available SSIDs" % availableSSIDs

current=-1
mac_state=0 #0-unassociated 1-associated
mac_bssid="EMPTY" #no bssid
Expand Down Expand Up @@ -251,7 +253,8 @@

if (currentFrameSSID == "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
c0=c0+1
elif (currentFrameSSID != "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
elif (currentFrameSSID != "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
print currentFrameSSID
if ( currentFrameSSID in availableSSIDs):
c1=c1+1
else:
Expand Down Expand Up @@ -335,6 +338,7 @@
if (currentFrameSSID == "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
probeRequestCount[waiting_for_probe][0]=probeRequestCount[waiting_for_probe][0]+1
elif (currentFrameSSID != "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
print currentFrameSSID
if ( currentFrameSSID in availableSSIDs):
probeRequestCount[waiting_for_probe][1]=probeRequestCount[waiting_for_probe][1]+1
else:
Expand All @@ -355,6 +359,9 @@
while (countUnicast <=3 and temp < frames_count and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
if(currentFrameSSID==mac_ssid and currentFrameSubType == "0x04" and currentFrameSA == mac):
countUnicast=countUnicast + 1
if ( countUnicast >= 3 and currentFrameSSID in availableSSIDs):
waiting_for_probe=1
probeRequestCount[waiting_for_probe][1]=countUnicast
currentFrameSubType=framesTable[temp][1]
currentFrameSSID=framesTable[temp][2]
currentFrameSA=framesTable[temp][7]
Expand Down Expand Up @@ -395,6 +402,7 @@
if (currentFrameSSID == "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
probeRequestCount[waiting_for_probe][0]=probeRequestCount[waiting_for_probe][0]+1
elif (currentFrameSSID != "EMPTY" and (currentFrameSA == mac and currentFrameSubType == "0x04" )):
print currentFrameSSID
if ( currentFrameSSID in availableSSIDs):
probeRequestCount[waiting_for_probe][1]=probeRequestCount[waiting_for_probe][1]+1
else:
Expand All @@ -409,6 +417,7 @@
if (currentFrameSSID == "EMPTY"):
probeRequestCount[waiting_for_probe][0]=probeRequestCount[waiting_for_probe][0]+1
else:
print currentFrameSSID
if ( currentFrameSSID in availableSSIDs):
probeRequestCount[waiting_for_probe][1]=probeRequestCount[waiting_for_probe][1]+1
else:
Expand Down
3 changes: 2 additions & 1 deletion CausalAnalysis-Datasets/Quantify-Causes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ fi
i=`expr $i + 1`
done


echo "Sanitizing $output_folder$output_file"
`$codePath/RemoveExtras.sh`

67 changes: 67 additions & 0 deletions CausalAnalysis-Datasets/Quantify-Causes.sh~
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh
<<COMMENT1
1 frame.time_epoch
2 frame.number
3 prism.did.frmlen
4 prism.did.channel
5 prism.did.mactime
6 prism.did.rate
7 wlan.fc.type_subtype
8 wlan_mgt.ssid
9 wlan.bssid
10 wlan_mgt.ds.current_channel
11 wlan_mgt.qbss.scount
12 wlan.fc.retry
13 wlan.fc.pwrmgt
14 wlan.fc.moredata
15 wlan.fc.frag
16 wlan.duration
17 wlan.ra
18 wlan.ta
19 wlan.sa
20 wlan.da
21 wlan.seq
22 wlan.qos.priority
23 wlan.qos.amsdupresent
24 wlan.fc.type
25 wlan_mgt.fixed.reason_code
26 wlan.fc.ds
COMMENT1


pcap_file=$1
output_folder=$2
output_file="/CausalAnalysis.csv"
mac_file=$3
ssid_file=$4
totalMAC=`cat $3|wc -l`
i=1
home_dir=`eval echo ~$USER/`
codePath=$home_dir"/Scripts/CausalAnalysis/CausalAnalysis-Datasets/"

if [ ! -d $output_folder ]; then
mkdir $output_folder
fi

echo "Warning: Delete if this file exists $output_folder$output_file"
touch $output_folder$output_file
while [ $i -le $totalMAC ]; do

SA=`head -n $i $mac_file|tail -1`
echo "Processing MAC: $SA"
echo
echo "Filtering Client Frames"
count_preq=`cat $pcap_file|grep "$SA"|grep "0x04"|wc -l`
if [ $count_preq -gt 0 ]; then
`awk -F"," 'BEGIN{OFS=",";} {print $1,$7,$8,$9,$13,$17,$18,$19,$20,$25,$26}' $pcap_file | grep "$SA" > /tmp/fileToProcess.csv`
echo "Filtering Beacon Frames"
`awk -F"," 'BEGIN{OFS=",";} {if ($7=="0x08") print $8,$9}' $pcap_file > /tmp/beacons.csv`

python $codePath/Quantify-Causes.py /tmp/fileToProcess.csv /tmp/beacons.csv $SA $ssid_file >> $output_folder$output_file
fi
i=`expr $i + 1`
done



0 comments on commit 3717cd2

Please sign in to comment.