Demo: Difference between revisions
From charlesreid1
(Created page with "=Wireless Networks= We will begin by gathering data about wireless networks around us. This can be done with a number of different programs. I'll use Aircrack's <code>airodu...") |
No edit summary |
||
| (20 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Demo for first meeting of [[Wireless Research Project]] | |||
=Wireless Networks= | =Wireless Networks= | ||
| Line 7: | Line 9: | ||
Start by putting the wireless card in monitor mode: | Start by putting the wireless card in monitor mode: | ||
< | <pre> | ||
iwconfig # without wireless card pluged in | iwconfig # without wireless card pluged in | ||
iwconfig # with wireless card plugged in | iwconfig # with wireless card plugged in | ||
ifconfig wlan1 down | ifconfig wlan1 down | ||
ifconfig wlan1 up | ifconfig wlan1 up | ||
</ | </pre> | ||
Now begin monitoring, and dump information from the wireless card: | Now begin monitoring, and dump information from the wireless card: | ||
< | <pre> | ||
airmon-ng start wlan1 | airmon-ng start wlan1 | ||
airodump-ng wlan1 | airodump-ng wlan1 -w output_file | ||
</ | </pre> | ||
Now you can open output_file.csv with a script or with a spreadsheet viewer. | |||
=SQLite Database= | |||
Use SQLite, and you don't have to install anything - it comes with [[Kali]]. | |||
==Insertion== | |||
In one window, running a script that inserts a random record every 2 seconds. | |||
Insertion script is as follows: | |||
<pre> | |||
import sqlite3 | |||
import time | |||
import string | |||
import random | |||
# define a function that generates random data (letters) | |||
def id_generator(size=6, chars=string.ascii_uppercase): | |||
"""This returns a random string""" | |||
return ''.join(random.choice(chars) for _ in range(size)) | |||
# define a functionthat generates random mac addresses | |||
def mac_generator(): | |||
"""This returns a random MAC address""" | |||
return ''.join([ id_generator(2)+':' for i in range(5) ]+[id_generator(2)]) | |||
if __name__=="__main__": | |||
# connect to sqlite database | |||
conn = sqlite3.connect('wifidata.db') | |||
# get a pointer in the database | |||
c = conn.cursor() | |||
try: | |||
# create the table | |||
c.execute("CREATE TABLE wifidata (device_key, device_mac, device_signalstr)") | |||
except sqlite3.OperationalError: | |||
pass | |||
# now insert 60 random records into the database | |||
for z in range(60): | |||
time.sleep(1) | |||
random_key = id_generator(size=8) | |||
random_mac = mac_generator() | |||
random_strength = random.randint(1,100) | |||
print "Inserting record (%s, %s, %d)"%(random_key, random_mac, random_strength) | |||
c.execute( "INSERT INTO wifidata VALUES ('%s', '%s', %d);"%(random_key, random_mac, random_strength) ) | |||
# save (commit) the changes | |||
conn.commit() | |||
# close the connection | |||
conn.close() | |||
</pre> | |||
and a screenshot of the script in action: | |||
[[Image:SqliteInsert.png|500px]] | |||
==Viewing== | |||
In another window, running a script that queries the database and shows its contents | |||
Display script is as follows: | |||
<pre> | |||
import sqlite3 | |||
import time | |||
# connect to sqlite database | |||
conn = sqlite3.connect('wifidata.db') | |||
c = conn.cursor() | |||
for row in c.execute('SELECT * FROM wifidata;'): | |||
print row | |||
conn.close() | |||
</pre> | |||
and that script in action: | |||
[[Image:SqliteView.png|500px]] | |||
=Data Analysis= | |||
The platform of data analysis will determine the kind of analysis that can be done. | |||
As a first-pass, the data dumped by airomon-ng was imported into Google Spreadsheets and I plotted a few histograms and scatter plots. | |||
[[Category:Wireless]] | |||
[[Category:Kali]] | |||
[[Category:SQL]] | |||
[[Category:Python]] | |||
[[Category:Wifi Data Project]] | |||
Latest revision as of 00:46, 28 February 2016
Demo for first meeting of Wireless Research Project
Wireless Networks
We will begin by gathering data about wireless networks around us.
This can be done with a number of different programs. I'll use Aircrack's airodump-ng utility.
Start by putting the wireless card in monitor mode:
iwconfig # without wireless card pluged in iwconfig # with wireless card plugged in ifconfig wlan1 down ifconfig wlan1 up
Now begin monitoring, and dump information from the wireless card:
airmon-ng start wlan1 airodump-ng wlan1 -w output_file
Now you can open output_file.csv with a script or with a spreadsheet viewer.
SQLite Database
Use SQLite, and you don't have to install anything - it comes with Kali.
Insertion
In one window, running a script that inserts a random record every 2 seconds.
Insertion script is as follows:
import sqlite3
import time
import string
import random
# define a function that generates random data (letters)
def id_generator(size=6, chars=string.ascii_uppercase):
"""This returns a random string"""
return ''.join(random.choice(chars) for _ in range(size))
# define a functionthat generates random mac addresses
def mac_generator():
"""This returns a random MAC address"""
return ''.join([ id_generator(2)+':' for i in range(5) ]+[id_generator(2)])
if __name__=="__main__":
# connect to sqlite database
conn = sqlite3.connect('wifidata.db')
# get a pointer in the database
c = conn.cursor()
try:
# create the table
c.execute("CREATE TABLE wifidata (device_key, device_mac, device_signalstr)")
except sqlite3.OperationalError:
pass
# now insert 60 random records into the database
for z in range(60):
time.sleep(1)
random_key = id_generator(size=8)
random_mac = mac_generator()
random_strength = random.randint(1,100)
print "Inserting record (%s, %s, %d)"%(random_key, random_mac, random_strength)
c.execute( "INSERT INTO wifidata VALUES ('%s', '%s', %d);"%(random_key, random_mac, random_strength) )
# save (commit) the changes
conn.commit()
# close the connection
conn.close()
and a screenshot of the script in action:
Viewing
In another window, running a script that queries the database and shows its contents
Display script is as follows:
import sqlite3
import time
# connect to sqlite database
conn = sqlite3.connect('wifidata.db')
c = conn.cursor()
for row in c.execute('SELECT * FROM wifidata;'):
print row
conn.close()
and that script in action:
Data Analysis
The platform of data analysis will determine the kind of analysis that can be done.
As a first-pass, the data dumped by airomon-ng was imported into Google Spreadsheets and I plotted a few histograms and scatter plots.