dev_list = list(load_db("select cast(device as text) from devices LIMIT "+limit+" OFFSET "+start))
else:
dev_list = list(load_db("select cast(device as text) from devices where cast(device as text) like '%"+search+"%' LIMIT "+limit+" OFFSET "+start))
- elif device_request == "phy_RTLADSB":
+ elif device_request == "phy-RTLADSB":
if search == "":
dev_list = list(load_db("select cast(device as text) from devices where phyname = 'ADSB' LIMIT "+limit+" OFFSET "+start))
else:
dev_list = list(load_db("select cast(device as text) from devices where phyname = 'UAV' LIMIT "+limit+" OFFSET "+start))
else:
dev_list = list(load_db("select cast(device as text) from devices where cast(device as text) like '%"+search+"%' and phyname = 'UAV' LIMIT "+limit+" OFFSET "+start))
- elif device_request == "phy-Zwave":
+ elif device_request == "phy-Z-Wave":
if search == "":
dev_list = list(load_db("select cast(device as text) from devices where phyname = 'Z-Wave' LIMIT "+limit+" OFFSET "+start))
else:
return HttpResponse(dev_string, content_type='text/json')
elif request.path == "/eventbus/events.ws":
return HttpResponse("[]", content_type='text/json')
+ elif request.path == "/phy/DOT/map_data.json":
+ node_list = ""
+ link_list = ""
+ dev_list = list(load_db("select cast(device as text) from devices where phyname = 'IEEE802.11' and cast(device as text) like '%dot11.device.client_map%'"))
+ for device in dev_list:
+ (dev,) = device
+ dev_json = json.loads(dev)
+ newdev = {}
+ node_list = node_list + "{ \"id\": \""+dev_json["kismet.device.base.macaddr"]+"\", \"label\": \""+dev_json["kismet.device.base.macaddr"]+"\", \"level\": 1},"
+ for device in dev_json['dot11.device']['dot11.device.client_map']:
+ node_list = node_list + "{ \"id\": \""+device+"\", \"label\": \""+device+"\", \"level\": 2},"
+ link_list = link_list + "{ \"target\": \""+device+"\", \"source\": \""+dev_json["kismet.device.base.macaddr"]+"\" , \"strength\": 0.7 },"
+ node_list = node_list[:-1]
+ link_list = link_list[:-1]
+ thang="{ \"nodes\": [" +node_list+"], \"links\": [" +link_list+"] }"
+ return HttpResponse(thang, content_type='text/json')
+ elif request.path == "/phy/RUSS/map_data.json":
+ min_long = 361.0
+ max_long = 0.0
+ min_lat = 181.0
+ max_lat = 0.0
+ multikey = "{}"
+ russlist = "{ \"kismet.wireless.map.devices\": [ "
+ dev_list = list(load_db("select cast(device as text) from devices where (phyname = 'Bluetooth' or phyname = 'IEEE802.11') and cast(device as text) like '%kismet.common.location.geopoint%'"))
+ for device in dev_list:
+ (dev,) = device
+ dev_json = json.loads(dev)
+ newdev = {}
+ newdev['kismet.device.base.first_time'] = dev_json['kismet.device.base.first_time']
+ try:
+ (tmp_min_long,tmp_min_lat) = dev_json['kismet.device.base.location']['kismet.common.location.min_loc']['kismet.common.location.geopoint']
+ tmp_min_lat = round(tmp_min_lat + 91, 6)
+ tmp_min_long = round(tmp_min_long + 181, 6)
+ if (tmp_min_lat != 91 and tmp_min_long !=181):
+ if (tmp_min_lat < min_lat):
+ min_lat = tmp_min_lat
+ if (tmp_min_long < min_long):
+ min_long = tmp_min_long
+ (tmp_max_long,tmp_max_lat) = dev_json['kismet.device.base.location']['kismet.common.location.max_loc']['kismet.common.location.geopoint']
+ tmp_max_lat = round(tmp_max_lat + 91,6)
+ tmp_max_long = round(tmp_max_long +181,6)
+ if (tmp_max_lat != 91 and tmp_max_long !=181):
+ if (tmp_max_lat > max_lat):
+ max_lat = tmp_max_lat
+ if (tmp_max_long > max_long):
+ max_long = tmp_max_long
+ russlist = russlist + str(dev_json['kismet.device.base.location']['kismet.common.location.avg_loc']['kismet.common.location.geopoint']) + ","
+ except:
+ try:
+ (tmp_min_long,tmp_min_lat) = dev_json['dot11.device']['dot11.device.client_map']['dot11.client.location']['kismet.common.location.min_loc']['kismet.common.location.geopoint']
+ tmp_min_lat = round(tmp_min_lat + 91, 6)
+ tmp_min_long = round(tmp_min_long + 181, 6)
+ if (tmp_min_lat != 91 and tmp_min_long !=181):
+ if (tmp_min_lat < min_lat):
+ min_lat = tmp_min_lat
+ if (tmp_min_long < min_long):
+ min_long = tmp_min_long
+ (tmp_max_long,tmp_max_lat) = dev_json['dot11.device']['dot11.device.client_map']['dot11.client.location']['kismet.common.location.max_loc']['kismet.common.location.geopoint']
+ tmp_max_lat = round(tmp_max_lat + 91,6)
+ tmp_max_long = round(tmp_max_long +181,6)
+ if (tmp_max_lat != 91 and tmp_max_long !=181):
+ if (tmp_max_lat > max_lat):
+ max_lat = tmp_max_lat
+ if (tmp_max_long > max_long):
+ max_long = tmp_max_long
+ russlist = russlist + str(dev_json['dot11.device']['dot11.device.client_map']['dot11.client.location']['kismet.common.location.avg_loc']['kismet.common.location.geopoint']) + ","
+ except:
+ print("poop")
+ russlist = russlist[:-1]
+ min_lat = round(min_lat - 91, 6)
+ min_long = round(min_long - 181, 6)
+ max_lat = round(max_lat - 91, 6)
+ max_long = round(max_long - 181, 6)
+ russlist = russlist + " ], \"kismet.wireless.map.min_lon\": "+str(min_long) + ", \"kismet.wireless.map.max_lat\": "+str(max_lat)+", \"kismet.wireless.map.min_lat\": "+str(min_lat)+", \"kismet.wireless.map.max_lon\": "+str(max_long)+" }"
+ return HttpResponse(russlist, content_type='text/json')
elif request.path == "/devices/multikey/as-object/devices.json":
#ClientMap incomplete.... figure out where the rest of the JSON comes from
search_json = ""
multikey = multikey[:-1]
multikey = multikey + "}"
return HttpResponse(multikey, content_type='text/json')
+ elif request.path == "/phy/ADSB/map_data.json":
+ #I had to do a stupid lat/long offset to draw the map grid because for some stupid reason python wouldnt do number scales right?
+ #limiting to 100 until i figure out paging
+ min_long = 361.0
+ max_long = 0.0
+ min_lat = 181.0
+ max_lat = 0.0
+ adsblist = "{ \"kismet.adsb.map.devices\": [ "
+ dev_list = list(load_db("select cast(device as text) from devices where phyname = 'ADSB' limit 100"))
+ for device in dev_list:
+ (dev,) = device
+ dev_json = json.loads(dev)
+ newdev = {}
+ newdev['kismet.device.base.first_time'] = dev_json['kismet.device.base.first_time']
+ if "kismet.device.base.location" in dev_json:
+ newdev['kismet.device.base.location'] = dev_json['kismet.device.base.location']
+ (tmp_min_long,tmp_min_lat) = newdev['kismet.device.base.location']['kismet.common.location.min_loc']['kismet.common.location.geopoint']
+ tmp_min_lat = round(tmp_min_lat + 91, 6)
+ tmp_min_long = round(tmp_min_long + 181, 6)
+ if (tmp_min_lat != 91 and tmp_min_long !=181):
+ if (tmp_min_lat < min_lat):
+ min_lat = tmp_min_lat
+ if (tmp_min_long < min_long):
+ min_long = tmp_min_long
+ (tmp_max_long,tmp_max_lat) = newdev['kismet.device.base.location']['kismet.common.location.max_loc']['kismet.common.location.geopoint']
+ tmp_max_lat = round(tmp_max_lat + 91,6)
+ tmp_max_long = round(tmp_max_long +181,6)
+ if (tmp_max_lat != 91 and tmp_max_long !=181):
+ if (tmp_max_lat > max_lat):
+ max_lat = tmp_max_lat
+ if (tmp_max_long > max_long):
+ max_long = tmp_max_long
+ newdev['kismet.device.base.macaddr'] = dev_json['kismet.device.base.macaddr']
+ newdev['adsb.device'] = dev_json['adsb.device']
+ newdev['kismet.device.base.type'] = dev_json['kismet.device.base.type']
+ newdev['kismet.device.base.commonname'] = dev_json['kismet.device.base.commonname']
+ newdev['kismet.device.base.name'] = dev_json['kismet.device.base.name']
+ newdev['kismet.device.base.packets.data'] = dev_json['kismet.device.base.packets.data']
+ newdev['kismet.device.base.frequency'] = dev_json['kismet.device.base.frequency']
+ newdev['kismet.device.base.phyname'] = dev_json['kismet.device.base.phyname']
+ newdev['kismet.device.base.last_time'] = dev_json['kismet.device.base.last_time']
+ newdev['kismet.device.base.key'] = dev_json['kismet.device.base.key']
+ adsblist = adsblist + json.dumps(newdev) + ","
+ adsblist = adsblist[:-1]
+ min_lat = round(min_lat - 91, 6)
+ min_long = round(min_long - 181, 6)
+ max_lat = round(max_lat - 91, 6)
+ max_long = round(max_long - 181, 6)
+ adsblist = adsblist + " ], \"kismet.adsb.map.min_lon\": "+str(min_long) + ", \"kismet.adsb.map.max_lat\": "+str(max_lat)+", \"kismet.adsb.map.min_lat\": "+str(min_lat)+", \"kismet.adsb.map.max_lon\": "+str(max_long)+" }"
+ return HttpResponse(adsblist, content_type='text/json')