├── .gitignore
├── kml_export_test.kml
├── README.md
├── Kismet-test.netxml
├── kis2kml.py
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | wireless.db
3 |
--------------------------------------------------------------------------------
/kml_export_test.kml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Wireless Networks
5 | Wireless networks parsed from Kismet xml
6 |
15 |
24 |
33 |
42 |
43 | Placemarks
44 | Wireless network locations
45 |
46 | Network 1
47 | #WPA broadcasting
48 | Mon Dec 12 13:19:41 2016
Encryption: WPA+TKIP/PSK
Channel: 6
Signal: -55
Current Clients: 1
]]>
49 |
50 | 115.824046,-31.985735,0
51 |
52 |
53 |
54 |
55 | #WEP cloaked
56 | Mon Dec 12 13:19:41 2016
Encryption: WEP
Channel: 6
Signal: -63
Current Clients: 1
]]>
57 |
58 | 115.742122,-32.056992,0
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # kis2kml
2 |
3 | **This repository is now archived**. I am in the process of migrating away from
4 | GitHub altogether.
5 |
6 | A python script to parse wireless networks into a sqlite3 database
7 | 'wireless.db' and query this database to generate Google Earth KML files.
8 |
9 | The script takes input from the wardriving suite Kismet, saved in netxml format,
10 | and produces a kml file that allows easy visualization of the network data
11 | inside Google Earth.
12 |
13 | kis2kml is essentially a rewrite in Python of some of the functionality of
14 | GISKismet (https://github.com/xtr4nge/giskismet), which is written in Perl
15 | and comes bundled in with Kali Linux.
16 |
17 | I don't mind GISKismet, it does the job relatively well, but I wanted to be
18 | able to make use of signal strength information in SQL queries, which GISKismet
19 | ignores, to be able to filter networks that one can realistically attach to. I
20 | also don't think GISKismet handles clients well. I found Perl too hard to
21 | learn, so I taught myself Python and wrote a script to do the job.
22 |
23 | When exporting databased networks, you can export the whole database to a kml
24 | file, or pass the program an optional SQL query to select networks that conform
25 | with the given query. The SQL query must be inside double quotation marks.
26 |
27 | The Author in no way advocates the cracking of WiFi encryption or connecting to
28 | private networks without permission. Mapping of wireless access points does not
29 | violate any laws in the author's area, though I cannot comment on the legality
30 | or illegality of wardriving in your country or area. Please keep this in mind
31 | before using this program to parse wardriving data.
32 |
33 | ```
34 | USAGE:
35 |
36 | kis2kml [options]
37 |
38 | Options:
39 | -i Imports Kismet network data from a
40 | netxml file into a sqlite3 database
41 | ('wireless.db')
42 | -x Exports all network data to a Google
43 | Earth KML file.
44 | -q <'SQL query'> Optional SQL query to restrict results
45 | to networks matching this query. Query
46 | has to be a valid SQL query and inside
47 | quote marks ('SQL query').
48 | -c Restrict export to networks that have
49 | clients attached.
50 | ```
51 |
52 | ### Usage examples:
53 |
54 | ```
55 | kis2kml -i kismet-output-file.netxml
56 |
57 | kis2kml -x all-database-contents.kml
58 |
59 | kis2kml -x wep-only.kml -q "SELECT * FROM networks WHERE encryption = 'WEP'"
60 |
61 | kis2kml -x strong_nets.kml \
62 | -q "SELECT * FROM networks WHERE max_signal_dbm > -60"
63 |
64 | kis2kml -x strong_wep.kml \
65 | -q "SELECT * FROM networks WHERE max_signal_dbm > -60 AND \
66 | encryption = 'WEP'" -c
67 |
68 | kis2kml -x open_but_cloaked.kml \
69 | -q "SELECT * FROM networks WHERE cloaked = 'true' AND \
70 | encryption = 'OPEN'"
71 | ```
72 |
73 | ### Tables in database ('wireless.db')
74 |
75 | - networks
76 | - clients
77 | - run
78 |
79 | ### Table columns in networks:
80 |
81 | - 'wn_num'
82 | - 'bssid'
83 | - 'essid'
84 | - 'encryption'
85 | - 'ssid_wpa_version'
86 | - 'ssid_type'
87 | - 'packets'
88 | - 'beaconrate'
89 | - 'wps'
90 | - 'wps_manuf'
91 | - 'dev_name'
92 | - 'model_name'
93 | - 'model_num'
94 | - 'cloaked'
95 | - 'manuf'
96 | - 'channel'
97 | - 'numclients'
98 | - 'first_seen'
99 | - 'last_seen'
100 | - 'max_speed'
101 | - 'maxseenrate'
102 | - 'max_signal_dbm'
103 | - 'max_noise_dbm'
104 | - 'peak_lat'
105 | - 'peak_lon'
106 |
107 | ### Table columns in clients:
108 |
109 | - 'bssid'
110 | - 'client_mac'
111 | - 'client_max_sig'
112 |
113 | ### Table columns in run:
114 |
115 | - 'start_time'
116 |
--------------------------------------------------------------------------------
/Kismet-test.netxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | wlan0:name=Name,
8 | Name
9 | wlan0mon
10 | rt2800usb
11 | 2772
12 | true
13 | 1,5,9,13,2,6,10,14,3,7,11,4,8,12
14 |
15 |
16 | 00:00:00:00:00:00
17 | Unknown
18 | 0
19 | 2437 3
20 | 9000
21 | IEEE 802.11b+
22 | CCK
23 |
24 | 0
25 | 3
26 | 0
27 | 3
28 | 0
29 | 0
30 |
31 | 102
32 |
33 | -55
34 | 0
35 | 0
36 | 0
37 | -79
38 | 0
39 | 1024
40 | 1024
41 | -55
42 | -256
43 | 0
44 | 0
45 |
46 |
47 | -31.956367
48 | 115.8613464
49 | 22.000000
50 | 0.014000
51 | -31.956367
52 | 115.8613464
53 | 22.000000
54 | 0.349000
55 | -31.956367
56 | 115.8613464
57 | 22.000000
58 | -31.956367
59 | 115.8613464
60 | 22.000000
61 |
62 | Dec 12 13:18:46
63 |
64 |
65 |
66 | f6c260aa-c010-11e6-bd5b-de041023e201
67 | Mon Dec 12 13:18:46 2016
68 | 3
69 |
70 |
71 | 00:00:00:00:00:00
72 | Unknown
73 | 0
74 | 2437 3
75 | 9000
76 | IEEE 802.11b+
77 | CCK
78 |
79 | 0
80 | 3
81 | 0
82 | 3
83 | 0
84 | 0
85 |
86 | 102
87 |
88 | -55
89 | 0
90 | 0
91 | 0
92 | -79
93 | 0
94 | 1024
95 | 1024
96 | -55
97 | -256
98 | 0
99 | 0
100 |
101 |
102 | -31.956367
103 | 115.861346
104 | 22.000000
105 | 0.014000
106 | -31.956367
107 | 115.861346
108 | 22.000000
109 | 0.349000
110 | -31.956367
111 | 115.861346
112 | 22.000000
113 | -31.956367
114 | 115.861346
115 | 22.000000
116 |
117 |
118 | f6c260aa-c010-11e6-bd5b-de041023e201
119 | Mon Dec 12 13:18:46 2016
120 | 3
121 |
122 |
123 |
124 |
125 |
126 | Beacon
127 | 54.000000
128 | 138
129 | 10
130 | No
131 | WPA+TKIP
132 | WPA+PSK
133 | WPA+AES-CCM
134 | WPA2
135 | Network 1
136 |
137 | 00:00:00:00:00:01
138 | NetManuf1
139 | 6
140 | 2432 1
141 | 2437 133
142 | 2442 4
143 | 6000
144 | IEEE 802.11b+
145 | CCK
146 |
147 | 138
148 | 0
149 | 0
150 | 138
151 | 0
152 | 0
153 |
154 | 0
155 |
156 | -73
157 | 0
158 | 0
159 | 0
160 | -81
161 | 0
162 | 1024
163 | 1024
164 | -55
165 | -256
166 | 0
167 | 0
168 |
169 |
170 | -31.985735
171 | 115.824046
172 | 4.000000
173 | 0.001000
174 | -31.985735
175 | 115.824046
176 | 5.000000
177 | 0.794000
178 | -31.985735
179 | 115.824046
180 | 5.000000
181 | -31.985735
182 | 115.824046
183 | 4.500000
184 |
185 | Dec 12 06:28:40
186 |
187 |
188 |
189 | f6c260aa-c010-11e6-bd5b-de041023e201
190 | Mon Dec 12 13:19:41 2016
191 | 138
192 |
193 |
194 | 00:00:00:00:00:01
195 | ClientManuf1
196 | 6
197 | 2432 1
198 | 2437 133
199 | 2442 4
200 | 6000
201 | IEEE 802.11b+
202 | CCK
203 |
204 | 138
205 | 0
206 | 0
207 | 138
208 | 0
209 | 0
210 |
211 | 0
212 |
213 | -73
214 | 0
215 | 0
216 | 0
217 | -81
218 | 0
219 | 1024
220 | 1024
221 | -67
222 | -256
223 | 0
224 | 0
225 |
226 |
227 | -31.985735
228 | 115.824046
229 | 5.000000
230 | 0.001000
231 | -31.985735
232 | 115.824046
233 | 5.000000
234 | 0.794000
235 | -31.985735
236 | 115.824046
237 | 5.000000
238 | -31.985735
239 | 115.824046
240 | 5.000000
241 |
242 |
243 | f6c260aa-c010-11e6-bd5b-de041023e201
244 | Mon Dec 12 13:19:41 2016
245 | 138
246 |
247 |
248 |
249 | 00:00:00:00:01:01
250 | ClientManuf1
251 | 6
252 | 2432 1
253 | 2437 133
254 | 2442 4
255 | 6000
256 | IEEE 802.11b+
257 | CCK
258 |
259 | 138
260 | 0
261 | 0
262 | 138
263 | 0
264 | 0
265 |
266 | 0
267 |
268 | -73
269 | 0
270 | 0
271 | 0
272 | -81
273 | 0
274 | 1024
275 | 1024
276 | -55
277 | -256
278 | 0
279 | 0
280 |
281 |
282 | -31.985735
283 | 115.824046
284 | 5.000000
285 | 0.001000
286 | -31.985735
287 | 115.824046
288 | 5.000000
289 | 0.794000
290 | -31.985735
291 | 115.824046
292 | 5.000000
293 | -31.985735
294 | 115.824046
295 | 5.000000
296 |
297 |
298 | f6c260aa-c010-11e6-bd5b-de041023e201
299 | Mon Dec 12 13:19:41 2016
300 | 138
301 |
302 |
303 |
304 |
305 |
306 | Beacon
307 | 54.000000
308 | 177
309 | 10
310 | No
311 | WEP
312 |
313 |
314 | 00:00:00:00:00:02
315 | NetManuf2
316 | 6
317 | 2432 4
318 | 2437 162
319 | 2442 11
320 | 6000
321 | IEEE 802.11b+
322 | CCK
323 |
324 | 177
325 | 0
326 | 0
327 | 177
328 | 0
329 | 0
330 |
331 | 0
332 |
333 | -73
334 | 0
335 | 0
336 | 0
337 | -81
338 | 0
339 | 1024
340 | 1024
341 | -63
342 | -256
343 | 0
344 | 0
345 |
346 |
347 | -32.056992
348 | 115.742122
349 | 43.000000
350 | 0.001000
351 | -32.056992
352 | 115.7421221
353 | 55.599998
354 | 0.794000
355 | -32.056992
356 | 115.742122
357 | 53.400002
358 | -32.056992
359 | 115.742122
360 | 51.456400
361 |
362 | Dec 11 23:06:09
363 |
364 |
365 |
366 | f6c260aa-c010-11e6-bd5b-de041023e201
367 | Mon Dec 12 13:19:41 2016
368 | 177
369 |
370 |
371 | 00:00:00:00:00:02
372 | ClientManuf2
373 | 6
374 | 2432 4
375 | 2437 162
376 | 2442 11
377 | 6000
378 | IEEE 802.11b+
379 | CCK
380 |
381 | 177
382 | 0
383 | 0
384 | 177
385 | 0
386 | 0
387 |
388 | 0
389 |
390 | -73
391 | 0
392 | 0
393 | 0
394 | -81
395 | 0
396 | 1024
397 | 1024
398 | -63
399 | -256
400 | 0
401 | 0
402 |
403 |
404 | -32.056992
405 | 115.742122
406 | 10.000000
407 | 0.001000
408 | -32.056992
409 | 115.742122
410 | 10.000000
411 | 0.794000
412 | -32.056992
413 | 115.742122
414 | 10.000000
415 | -32.056992
416 | 115.742122
417 | 10.000000
418 |
419 |
420 | f6c260aa-c010-11e6-bd5b-de041023e201
421 | Mon Dec 12 13:19:41 2016
422 | 177
423 |
424 |
425 |
426 |
427 |
--------------------------------------------------------------------------------
/kis2kml.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python
2 | # kis2kml.py is a Python 2.7 script to process Kismet netxml files into
3 | # Google Earth KML for visualization.
4 |
5 | import xml.etree.cElementTree as xml
6 | import sqlite3 as sql
7 | import sys, getopt
8 | from os.path import exists
9 | from datetime import datetime
10 | from xml.sax.saxutils import escape
11 |
12 | database = 'wireless.db'
13 | runtime = ""
14 | total_discovered = 0
15 | total_saved = 0
16 | total_updated = 0
17 | total_exported = 0
18 |
19 | def welcome():
20 | print "\n*****************************************************************"
21 | print "* kis2kml, a Kismet netxml file parser *"
22 | print "* Use this script to import networks from a Kismet .netxml file *"
23 | print "* or to export them to a Google Earth .kml file *"
24 | print "*****************************************************************\n"
25 |
26 | def usage():
27 | print "Usage: kis2kml [options]"
28 | print " Options: can be either import (-i) or export (-x)."
29 | print (
30 | " -i # Input file has to be "
31 | "Kismet .netxml")
32 | print (" -x # Export file can have "
33 | "optional -q SQL query (formatted for Sqlite)")
34 | print (" -q ''")
35 | print (" -c [Restricts export to networks with attached"
36 | "clients]\n")
37 | print ("Examples:\n"
38 | " kis2kml -i kismet-output-file.netxml\n"
39 | " kis2kml -x all-database-contents.kml\n"
40 | " kis2kml -x strong_wep.kml -c \\\n"
41 | " -q \"SELECT * FROM networks WHERE"
42 | "max_signal_dbm > -60 AND encryption = \'WEP\'\"")
43 |
44 | ### SECTION 1: Loading networks from Kismet netxml
45 |
46 | # Open xml file and load it into a etree.ElementTree object
47 | # Create a list of tree nodes that contain infrastructure networks
48 | # Parse xml into a list of dictionaries with all important network data
49 | def load_nets_from_xml(xfile):
50 | global total_discovered, runtime
51 | netnodes = []
52 | netlist_dicts = []
53 | clientlist = []
54 |
55 | print "Reading network information from %s\n" %xfile
56 |
57 | # Open Kismet .netxml file and load into list of nodes
58 | try:
59 | with open(xfile, 'rt') as kismet:
60 | try:
61 | tree = xml.parse(kismet)
62 | except xml.ParseError as xmlerr:
63 | print "\n*** ERROR *** Problem parsing input file."
64 | print " Is it a Kismet netxml file?"
65 | print " Python says: %s\n" % xmlerr
66 | usage()
67 | sys.exit(2)
68 | except IOError as ioerr:
69 | print "\n*** ERROR *** Cannot read input file. Does it exist?"
70 | print "\tPython says: %s\n" % ioerr
71 | usage()
72 | sys.exit(2)
73 |
74 | for node in tree.iter('detection-run'):
75 | runtime = node.attrib.get('start-time')
76 |
77 | if runtime_exists():
78 | print "This detection run (%s) has already been imported" %runtime
79 | sys.exit()
80 |
81 | netnodes = pop_xml_netlist(tree)
82 | # For each wireless network node, create a dictionary, and append it to
83 | # a list of network dictionaries
84 | for node in netnodes:
85 | netlist_dicts.append(populate_net_dict(node))
86 | populate_client_list(node, clientlist)
87 | total_discovered = len(netnodes)
88 | print ""
89 |
90 | return netlist_dicts, clientlist
91 |
92 | # Check if the Kismet run being imported has a start-time that is already
93 | # in the database
94 | def runtime_exists():
95 | exists = False
96 | con = sql.connect(database)
97 | with con:
98 | cur = con.cursor()
99 | try:
100 | cur.execute("SELECT * FROM run")
101 | db_run_time = cur.fetchall()
102 | for rtime in db_run_time:
103 | if (runtime != "") and (runtime in rtime):
104 | exists = True
105 | except sql.OperationalError as err:
106 | if "no such table" in err:
107 | exists = False
108 |
109 | return exists
110 |
111 | # Function to return a list of eTree nodes. Takes the whole XML tree as the
112 | # argument and returns a list[] of nodes containing only infrastructire networks
113 | def pop_xml_netlist(whole_tree):
114 | nodelist = []
115 | for node in whole_tree.findall('.//wireless-network'):
116 | if (node.attrib.get('type') == 'infrastructure'):
117 | nodelist.append(node)
118 | if len(nodelist) == 0:
119 | print ("\n+++ WARNING +++ "
120 | "There don't seem to be any wireless networks in your "
121 | "input file\n")
122 | usage()
123 | sys.exit()
124 | return nodelist
125 |
126 | # Create a list of clients. Each client is a list of the router bssid,
127 | # the client MAC and the client max_signal
128 | def populate_client_list(wireless_node, client_list):
129 |
130 | for lev1 in wireless_node:
131 | if lev1.tag == 'BSSID':
132 | bssid = lev1.text
133 | if lev1.tag == 'wireless-client':
134 | cldata = []
135 | if lev1.attrib['type'] != 'fromds':
136 | cldata.append(bssid)
137 | for clientinfo in lev1:
138 | if clientinfo.tag == 'client-mac':
139 | cldata.append(clientinfo.text)
140 | if clientinfo.tag == 'snr-info':
141 | for snr in clientinfo:
142 | if snr.tag == 'max_signal_dbm':
143 | cldata.append(snr.text)
144 | if len(cldata) > 0:
145 | client_list.append(cldata)
146 |
147 | # Populate values of network dictionary from xml node
148 | def populate_net_dict(wireless_node):
149 | wn = make_net_dict()
150 | wn['wn_num'] = wireless_node.attrib['number']
151 | wn['first_seen'] = wireless_node.attrib['first-time']
152 | wn['last_seen'] = wireless_node.attrib['last-time']
153 | wn['placeholder_encryption'] = []
154 | wn['clients'] = []
155 |
156 | # Iterate through first-level nodes and fill values into empty dictionary
157 | for lev1 in wireless_node:
158 |
159 | # Append the MAC address of clients as a list
160 | if lev1.tag == 'wireless-client':
161 | for cinfo in lev1:
162 | for ctag in cinfo.iter('client-mac'):
163 | wn['clients'].append(ctag.text)
164 |
165 | # Loop through second-level nodes in SSID
166 | if lev1.tag == 'SSID':
167 | for ssid_info in lev1:
168 | # assign multiple ecryption fields to a temporary list
169 | for e in ssid_info.iter('encryption'):
170 | wn['placeholder_encryption'].append(e.text)
171 |
172 | if ssid_info.tag == 'type':
173 | wn['ssid_type'] = ssid_info.text
174 | if ssid_info.tag == 'max-rate':
175 | wn['max_speed'] = ssid_info.text
176 | if ssid_info.tag == 'packets':
177 | wn['packets'] = ssid_info.text
178 | if ssid_info.tag == 'beaconrate':
179 | wn['beaconrate'] = ssid_info.text
180 | if ssid_info.tag == 'wps':
181 | wn['wps'] = ssid_info.text
182 | if ssid_info.tag == 'wps-manuf':
183 | wn['wps_manuf'] = ssid_info.text
184 | if ssid_info.tag == 'dev-name':
185 | wn['dev_name'] = ssid_info.text
186 | if ssid_info.tag == 'model-name':
187 | wn['model_name'] = ssid_info.text
188 | if ssid_info.tag == 'model-num':
189 | wn['model_num'] = ssid_info.text
190 | if ssid_info.tag == 'wpa-version':
191 | wn['ssid_wpa_version'] = ssid_info.text
192 | if ssid_info.tag == 'essid':
193 | if ssid_info.attrib['cloaked'] == 'true':
194 | wn['essid'] = ""
195 | else: # Replace some characters that cause problems in KML
196 | tempessid = ssid_info.text
197 | wn['essid'] = tempessid.replace('&', '').replace('<', \
198 | '').replace('>', '')
199 | wn['cloaked'] = ssid_info.attrib['cloaked']
200 |
201 | if lev1.tag == 'BSSID':
202 | wn['bssid'] = lev1.text
203 | if lev1.tag == 'manuf':
204 | wn['manuf'] = lev1.text
205 | if lev1.tag == 'channel':
206 | wn['channel'] = lev1.text
207 | if lev1.tag == 'maxseenrate':
208 | wn['maxseenrate'] = lev1.text
209 |
210 | # Loop through snr information
211 | if lev1.tag == 'snr-info':
212 | for snr_info in lev1:
213 | if snr_info.tag == 'max_signal_dbm':
214 | wn['max_signal_dbm'] = snr_info.text
215 | if snr_info.tag == 'max_noise_dbm':
216 | wn['max_noise_dbm'] = snr_info.text
217 |
218 | # Loop through GPS information
219 | if lev1.tag == 'gps-info':
220 | for gps_info in lev1:
221 | if gps_info.tag == 'peak-lat':
222 | wn['peak_lat'] = gps_info.text
223 | if gps_info.tag == 'peak-lon':
224 | wn['peak_lon'] = gps_info.text
225 | # select appropriate text for encryption field
226 | wn['encryption'] = populate_encryption(wn['placeholder_encryption'])
227 |
228 | print "Found infrastructure network with BSSID: %s - encryption: %s" \
229 | % (wn['bssid'], wn['encryption'])
230 | return wn
231 |
232 | # Create an empty network dictionary with all needed keys
233 | def make_net_dict():
234 | keys = ['wn_num',
235 | 'first_seen',
236 | 'last_seen',
237 | 'ssid_type',
238 | 'max_speed',
239 | 'packets',
240 | 'beaconrate',
241 | 'wps',
242 | 'wps_manuf',
243 | 'dev_name',
244 | 'model_name',
245 | 'model_num',
246 | 'placeholder_encryption',
247 | 'encryption',
248 | 'ssid_wpa_version',
249 | 'cloaked',
250 | 'essid',
251 | 'bssid',
252 | 'manuf',
253 | 'channel',
254 | 'maxseenrate',
255 | 'max_signal_dbm',
256 | 'max_noise_dbm',
257 | 'clients',
258 | 'peak_lat',
259 | 'peak_lon']
260 | net_dict = {key: None for key in keys}
261 | return net_dict
262 |
263 | # based in the entries in placeholder_encryption, return correct text
264 | def populate_encryption(placeholder_list):
265 | encryption = 'UNKNOWN'
266 |
267 | if 'WEP' in placeholder_list and 'WPA' in placeholder_list:
268 | encryption = 'WEP + WPA'
269 | elif 'WEP' in placeholder_list:
270 | encryption = 'WEP'
271 | elif 'WPA+TKIP' in placeholder_list and 'WPA+PSK' in placeholder_list:
272 | encryption = 'WPA+TKIP/PSK'
273 | elif 'WPA+TKIP' in placeholder_list:
274 | encryption = 'WPA+TKIP'
275 | elif 'WPA+PSK' in placeholder_list:
276 | encryption = 'WPA+PSK'
277 | elif 'WPA+AES-CCM' in placeholder_list:
278 | encryption = 'WPA-MGT'
279 | else:
280 | encryption = 'OPEN'
281 |
282 | return encryption
283 |
284 |
285 | ### SECTION 2: Saving networks to a sqlite3 database
286 |
287 | # Open connection to database and loop through networks,
288 | # adding appropriate ones to the database. Mostly self-explanatory
289 | def save_nets_to_db(netlist, clientlist, dfile):
290 | global total_saved
291 | con = sql.connect(dfile)
292 | with con:
293 | create_tables(con)
294 | for net in netlist:
295 | process_network(net, con)
296 | for client in clientlist:
297 | save_client(client, con)
298 | save_detection_run(dfile, con)
299 |
300 | # If networks table does not exist, create empty table in database
301 | def create_tables(con):
302 | cur = con.cursor()
303 | cur.execute("""
304 | CREATE TABLE IF NOT EXISTS networks(
305 | wn_num INT,
306 | bssid TEXT,
307 | essid TEXT,
308 | encryption TEXT,
309 | ssid_wpa_version TEXT,
310 | ssid_type TEXT,
311 | packets INT,
312 | beaconrate INT,
313 | wps TEXT,
314 | wps_manuf TEXT,
315 | dev_name TEXT,
316 | model_name TEXT,
317 | model_num TEXT,
318 | cloaked TEXT,
319 | manuf TEXT,
320 | channel INT,
321 | first_seen TEXT,
322 | last_seen TEXT,
323 | max_speed INT,
324 | maxseenrate INT,
325 | max_signal_dbm INT,
326 | max_noise_dbm INT,
327 | peak_lat TEXT,
328 | peak_lon TEXT)
329 | """)
330 | cur.execute("CREATE TABLE IF NOT EXISTS run(start_time TEXT)")
331 | cur.execute("""CREATE TABLE IF NOT EXISTS clients(
332 | bssid TEXT,
333 | client_mac TEXT,
334 | client_max_sig INT
335 | )""")
336 |
337 | # Insert a client into the database if it doesn't already exist
338 | def save_client(client, con):
339 | exists = check_if_client_exists(client, con)
340 | if not exists:
341 | cur = con.cursor()
342 | cur.execute("""INSERT INTO clients VALUES(?, ?, ?)""", client)
343 | print "Adding client with MAC: %s to database" % client[1]
344 |
345 | # Check if client already exists in database
346 | def check_if_client_exists(client, con):
347 | bssid, mac = client[0], client[1]
348 | exists = False
349 |
350 | cur = con.cursor()
351 | cur.execute("SELECT bssid,client_mac FROM clients")
352 | rows = cur.fetchall()
353 | for row in rows:
354 | if bssid in row and mac in row:
355 | exists = True
356 |
357 | return exists
358 |
359 | # Check if network exists in database.
360 | # If it exists, and stored network is weaker, erase it and save new data.
361 | def process_network(netdict, con):
362 | global total_saved, total_updated
363 |
364 | exists = check_if_net_exists(netdict, con)
365 |
366 | if not exists:
367 | add_it_to_db(netdict, con)
368 | print "Adding wireless network with BSSID: %s to database" \
369 | %netdict['bssid']
370 | total_saved += 1
371 |
372 | elif exists:
373 | stronger = netpower(netdict, con)
374 | newer = xml_newer_than_db(netdict, con)
375 | total_updated += 1
376 | if newer:
377 | if stronger:
378 | new_net_stronger(netdict, con)
379 | else:
380 | new_net_weaker(netdict, con)
381 | else:
382 | if stronger:
383 | old_net_stronger(netdict, con)
384 | else:
385 | old_net_weaker(netdict, con)
386 |
387 | # Check if MAC address of network already in DB
388 | def check_if_net_exists(netdict, con):
389 | newmac = netdict['bssid']
390 | exists = False
391 |
392 | cur = con.cursor()
393 | cur.execute("SELECT bssid FROM networks")
394 | for row in cur:
395 | if newmac in row:
396 | exists = True
397 |
398 | return exists
399 |
400 | # Check if xml network datestamp is more recent than in the database
401 | def xml_newer_than_db(netdict, con):
402 | xml_newer = False
403 | # Load xml date fields into datetime objects
404 | xml_first_seen = datetime.strptime(netdict['first_seen'], \
405 | "%a %b %d %H:%M:%S %Y")
406 | xml_last_seen = datetime.strptime(netdict['last_seen'], \
407 | "%a %b %d %H:%M:%S %Y")
408 | cur = con.cursor()
409 | cur.execute("SELECT first_seen,last_seen FROM networks WHERE bssid = ?",
410 | (netdict['bssid'],))
411 | db_dates = cur.fetchall()[0]
412 |
413 | # Load DB date fields into datetime objects
414 | db_first_seen = datetime.strptime(db_dates[0], "%a %b %d %H:%M:%S %Y")
415 | db_last_seen = datetime.strptime(db_dates[1], "%a %b %d %H:%M:%S %Y")
416 |
417 | if xml_last_seen > db_last_seen:
418 | xml_newer = True
419 |
420 | return xml_newer
421 |
422 | # Check if xml network signal is stronger than in the database
423 | def netpower(netdict, con):
424 | xml_mac = netdict['bssid']
425 | maxsig = int(netdict['max_signal_dbm'])
426 | db_strength = None
427 | is_more_powerful = False
428 |
429 | # compare max_signal_dbm of two networks
430 | if exists:
431 | cur = con.cursor()
432 | cur.execute("SELECT max_signal_dbm FROM networks WHERE bssid = ?",
433 | (xml_mac,))
434 | db_strength = int(cur.fetchone()[0])
435 |
436 | if maxsig > db_strength:
437 | is_more_powerful = True
438 |
439 | return is_more_powerful
440 |
441 | # When wireless network is not already in the DB, save it
442 | def add_it_to_db(netdict, con):
443 | global total_saved
444 | netlist = make_ordered_netlist(netdict)
445 | cur = con.cursor()
446 | cur.execute("""
447 | INSERT INTO networks VALUES(?, ?, ?, ?, ?, ?, ?,
448 | ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
449 | )""", netlist)
450 |
451 | # When wireless network is newer and weaker than same bssid in DB
452 | # then update 'last_seen' to latest timestamp
453 | def new_net_weaker(netdict, con):
454 | global total_saved
455 |
456 | cur = con.cursor()
457 | cur.execute("UPDATE networks SET last_seen = ? where bssid = ?", \
458 | (netdict['last_seen'], netdict['bssid'],))
459 | print "Updating 'last_seen' field on %s to newer timestamp" \
460 | % netdict['bssid']
461 |
462 | # When wireless network is newer and stronger than same bssid in DB
463 | # then overwrite db with all new data except 'first_seen'
464 | def new_net_stronger(netdict, con):
465 | xml_first_seen = netdict['first_seen']
466 | cur = con.cursor()
467 | cur.execute('''SELECT first_seen FROM networks WHERE bssid = ?''', \
468 | (netdict['bssid'],))
469 | db_first_seen = cur.fetchone()
470 |
471 | delete_net_from_db(netdict, con)
472 | netdict['first_seen'] = str(db_first_seen[0])
473 | add_it_to_db(netdict, con)
474 | print "Updating wireless network with BSSID: %s to stronger version" \
475 | %netdict['bssid']
476 |
477 | # When wireless network is older and weaker than same bssid in DB
478 | # then update 'first_seen' to earliest timestamp
479 | def old_net_weaker(netdict, con):
480 | global total_saved
481 |
482 | cur = con.cursor()
483 | cur.execute("UPDATE networks SET first_seen = ? where bssid = ?", \
484 | (netdict['first_seen'], netdict['bssid'],))
485 | print "Updating 'first_seen' field on %s to older timestamp" \
486 | % netdict['bssid']
487 |
488 | # When wireless network is older and stronger than same bssid in DB
489 | # then overwrite db with all new data except 'last_seen'
490 | def old_net_stronger(netdict, con):
491 | xml_last_seen = netdict['last_seen']
492 | cur = con.cursor()
493 | cur.execute('''SELECT last_seen FROM networks WHERE bssid = ?''', \
494 | (netdict['bssid'],))
495 | db_last_seen = cur.fetchone()
496 |
497 | delete_net_from_db(netdict, con)
498 | netdict['last_seen'] = str(db_last_seen[0])
499 | add_it_to_db(netdict, con)
500 | print "Updating wireless network with BSSID: %s to stronger version" \
501 | %netdict['bssid']
502 |
503 | # Save detection run start time
504 | def save_detection_run(dfile, con):
505 | with con:
506 | cur = con.cursor()
507 | cur.execute("INSERT INTO run VALUES(?)", (runtime,))
508 | print "Added runtime (%s) to database" % runtime
509 |
510 | # Turn each net dictionary into a list, return list
511 | def make_ordered_netlist(netdict):
512 | netl = (
513 | int(netdict['wn_num']),
514 | netdict['bssid'],
515 | netdict['essid'],
516 | netdict['encryption'],
517 | netdict['ssid_wpa_version'],
518 | netdict['ssid_type'],
519 | netdict['packets'],
520 | netdict['beaconrate'],
521 | netdict['wps'],
522 | netdict['wps_manuf'],
523 | netdict['dev_name'],
524 | netdict['model_name'],
525 | netdict['model_num'],
526 | netdict['cloaked'],
527 | netdict['manuf'],
528 | int(netdict['channel']),
529 | netdict['first_seen'],
530 | netdict['last_seen'],
531 | netdict['max_speed'],
532 | int(netdict['maxseenrate']),
533 | int(netdict['max_signal_dbm']),
534 | int(netdict['max_noise_dbm']),
535 | netdict['peak_lat'],
536 | netdict['peak_lon']
537 | )
538 | return netl
539 |
540 | # Erase existing weaker networks from db
541 | def delete_net_from_db(netdict, con):
542 | cur = con.cursor()
543 | cur.execute('''DELETE from networks WHERE bssid = ?''', \
544 | (netdict['bssid'],))
545 |
546 |
547 | ### SECTION 3: Loading networks from database to create KML
548 |
549 | # Load every network in the database.
550 | def load_all_nets_from_db(dfile, clist, conly):
551 | netlist = []
552 | client_bssids = []
553 | for client in clist:
554 | client_bssids.append(client[0])
555 | con = sql.connect(dfile)
556 | with con:
557 | con.row_factory = sql.Row
558 | cur = con.cursor()
559 | cur.execute("SELECT * from networks")
560 | rows = cur.fetchall()
561 | for row in rows:
562 | if conly:
563 | if row['bssid'] in client_bssids:
564 | rowdic = parse_db_row(row, conly)
565 | netlist.append(rowdic)
566 | else:
567 | rowdic = parse_db_row(row, conly)
568 | netlist.append(rowdic)
569 | return netlist
570 |
571 | # Load networks that match a specific SQL query
572 | def load_from_db_with_sql_arg(dfile, sql_arg, clist, conly):
573 | query = sql_arg
574 | netlist = []
575 | client_bssids = []
576 | for client in clist:
577 | client_bssids.append(client[0])
578 |
579 | con = sql.connect(dfile)
580 | with con:
581 | con.row_factory = sql.Row
582 | cur = con.cursor()
583 | try: # In case SQL can't be understood
584 | cur.execute(query)
585 | rows = cur.fetchall()
586 |
587 | except sql.OperationalError as err:
588 | print "Error: Your SQL query could not be interpreted"
589 | print "--->\t %s\n" % query
590 | print "Python says: \'%s\'\n" % str(err)
591 | usage()
592 | sys.exit(2)
593 |
594 | for row in rows:
595 | if conly:
596 | if row['bssid'] in client_bssids:
597 | rowdic = parse_db_row(row, conly)
598 | netlist.append(rowdic)
599 | else:
600 | rowdic = parse_db_row(row, conly)
601 | netlist.append(rowdic)
602 |
603 | return netlist
604 |
605 | # Load all clients in the database into a list
606 | def load_clients(dfile):
607 | clientlist = []
608 | con = sql.connect(dfile)
609 | with con:
610 | cur = con.cursor()
611 | cur.execute("SELECT * from clients")
612 | rows = cur.fetchall()
613 | for row in rows:
614 | client = []
615 | for column in row:
616 | client.append(column)
617 | clientlist.append(client)
618 | return clientlist
619 |
620 | # Parse rows of database into dictionary
621 | def parse_db_row(row, conly):
622 | wndb = make_net_dict()
623 | for item in row.keys():
624 | wndb[item] = row[item]
625 | return wndb
626 |
627 | ### SECTION 4: Crafting KML
628 | # Assemble all the KML pieces into a list with one line per list item
629 | def make_kml(netlist, clientlist, query):
630 | kmllist = []
631 | kmllist = create_kml_headers(kmllist, query)
632 | kmllist = append_kml_styles(kmllist, netlist)
633 | kmllist = append_kml_placemarks(kmllist, netlist, clientlist)
634 | kmllist = close_kml(kmllist)
635 | return kmllist
636 |
637 | # Create header rows
638 | def create_kml_headers(kmllist, query):
639 | kmllist.append('')
640 | kmllist.append('')
641 | kmllist.append('\t')
642 | kmllist.append('\t\tWireless Networks')
643 | if len(query) > 0:
644 | kmllist.append('\t\t%s' % escape(query))
645 | else:
646 | kmllist.append('\t\tWireless networks '
647 | 'parsed from Kismet xml')
648 | return kmllist
649 |
650 | # For every encryption type found in query, create a style
651 | def append_kml_styles(kmllist, netlist):
652 | netcolours = {'WEP':'0090FF', 'WPA':'0000FF', 'OPEN':'00FF00'}
653 | encryptions = []
654 | for n in netlist:
655 | if 'WEP' in n['encryption'] and 'WEP' not in encryptions:
656 | encryptions.append('WEP')
657 | if 'WPA' in n['encryption'] and 'WPA' not in encryptions:
658 | encryptions.append('WPA')
659 | if 'OPEN' in n['encryption'] and 'OPEN' not in encryptions:
660 | encryptions.append('OPEN')
661 |
662 | for e in encryptions:
663 | kmllist.append('\t\t')
673 | kmllist.append('\t\t')
683 |
684 | return kmllist
685 |
686 | # Create KML Placemark text and append to list for every network in query
687 | def append_kml_placemarks(kmllist, netlist, clientlist):
688 | global total_exported
689 | kmllist.append('\t\t')
690 | kmllist.append('\t\t\tPlacemarks')
691 | kmllist.append('\t\t\tWireless network locations'
692 | '')
693 | for net in netlist:
694 | clients_in_net = []
695 | for client in clientlist:
696 | if client[0] == net['bssid']:
697 | clients_in_net.append(client)
698 |
699 | client_html = 'Clients: %d
' % len(clients_in_net)
700 | if len(clients_in_net) > 0:
701 | for client in clients_in_net:
702 | client_html += '%s (%d)
' % (client[1], client[2])
703 |
704 | kmllist.append('\t\t\t')
705 | if net['essid']:
706 | kmllist.append('\t\t\t\t%s' % escape(net['essid']))
707 | else:
708 | kmllist.append('\t\t\t\t')
709 | if 'WEP' in net['encryption']:
710 | if net['cloaked'] == 'true':
711 | kmllist.append('\t\t\t\t#WEP cloaked')
712 | else:
713 | kmllist.append('\t\t\t\t#WEP broadcasting'
714 | '')
715 |
716 | if 'WPA' in net['encryption']:
717 | if net['cloaked'] == 'true':
718 | kmllist.append('\t\t\t\t#WPA cloaked')
719 | else:
720 | kmllist.append('\t\t\t\t#WPA broadcasting'
721 | '')
722 |
723 | if 'OPEN' in net['encryption']:
724 | if net['cloaked'] == 'true':
725 | kmllist.append('\t\t\t\t#OPEN cloaked')
726 | else:
727 | kmllist.append('\t\t\t\t#OPEN broadcasting'
728 | '')
729 | kmllist.append('\t\t\t\t%s
'
730 | 'Encryption: %s
Channel: %d
Signal: %d
'
731 | '%s]]>' \
732 | % (net['bssid'],net['last_seen'], net['encryption'], \
733 | net['channel'], net['max_signal_dbm'], \
734 | client_html))
735 | kmllist.append('\t\t\t\t')
736 | kmllist.append('\t\t\t\t\t%s,%s,0' \
737 | % (net['peak_lon'], net['peak_lat']))
738 | kmllist.append('\t\t\t\t')
739 | kmllist.append('\t\t\t')
740 | print "Found network with BSSID: %s ** Exporting to KML file" \
741 | % net['bssid']
742 | total_exported += 1
743 |
744 | kmllist.append('\t\t')
745 | return kmllist
746 |
747 | # Add the closing lines
748 | def close_kml(kmllist):
749 | kmllist.append('\t')
750 | kmllist.append('')
751 | return kmllist
752 |
753 | # Save KML list to file one row at a time
754 | def kml_to_file(kml, filename):
755 | writeable = check_write(filename)
756 | if writeable: # This is probably obsolete
757 | with open(filename, "w") as f:
758 | for line in kml:
759 | f.write("%s\n" % line)
760 |
761 | # Check if KML file already exists. If so, ask if OK to overwrite.
762 | def check_write(filename):
763 | if exists(filename):
764 | print "\nFile %s already exists at this location." % filename
765 | action = raw_input("Overwrite? (y/N)\t")
766 | if action in ('Y','y','Yes','yes'):
767 | return True
768 | elif action in ('N','n','No','no'):
769 | print "Ok (quitting)"
770 | sys.exit(2)
771 | else:
772 | return True
773 |
774 | ### SECTION 5: Main
775 | def main(argv):
776 | xmlsource = ''
777 | query = ''
778 | with_clients_only = False
779 | welcome()
780 |
781 | try:
782 | opts, args = getopt.getopt(argv,"hi:x:q:c")
783 |
784 | except getopt.GetoptError as err:
785 | print str(err)
786 | usage()
787 | sys.exit(2)
788 |
789 | if len(argv) == 0:
790 | usage()
791 | sys.exit()
792 |
793 | for opt, arg in opts:
794 | if opt == "-q":
795 | query = arg
796 | if opt == "-c":
797 | with_clients_only = True
798 |
799 | for opt, arg in opts:
800 | if opt == '-h':
801 | usage()
802 | sys.exit()
803 |
804 | elif opt == "-i":
805 | inputfile = arg
806 | netlist, clientlist = load_nets_from_xml(inputfile)
807 | save_nets_to_db(netlist, clientlist, database)
808 | print "\nFound %d wireless networks in Kismet netxml file" \
809 | % total_discovered
810 | print "Added %d wireless networks to SQL database" % total_saved
811 | print "Updated %d wireless networks in SQL database\n" \
812 | % total_updated
813 |
814 | elif opt == "-x":
815 | exportfile = arg
816 | if len(query) > 0:
817 | clientlist = load_clients(database)
818 | db_list = load_from_db_with_sql_arg(database, query, \
819 | clientlist, \
820 | with_clients_only)
821 | else:
822 | clientlist = load_clients(database)
823 | db_list = load_all_nets_from_db(database, \
824 | clientlist, \
825 | with_clients_only)
826 | kml_content = make_kml(db_list, clientlist, query)
827 | kml_to_file(kml_content, exportfile)
828 | print "\nExported %d networks to KML file" % total_exported
829 |
830 | elif opt == "-q":
831 | pass
832 |
833 | if __name__ == "__main__":
834 | main(sys.argv[1:])
835 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------