Demo: Difference between revisions
From charlesreid1
| Line 83: | Line 83: | ||
</pre> | </pre> | ||
== | ==Viewing== | ||
In another window, running a script that queries the database and shows its contents | In another window, running a script that queries the database and shows its contents | ||
| Line 90: | Line 90: | ||
<pre> | <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> | </pre> | ||
Revision as of 04:25, 13 January 2016
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.
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()
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()