From: Russ Handorf Date: Fri, 13 Jan 2023 20:55:14 +0000 (-0500) Subject: paging, searching, etc fixed X-Git-Url: http://russells-world.com/code/?a=commitdiff_plain;h=ee4713d17843248d605d9bc423c63248a474adb4;p=kismet-logviewer.git paging, searching, etc fixed --- diff --git a/logviewer/dbview/.views.py.swp b/logviewer/dbview/.views.py.swp index ef27fa1..9ce4e59 100644 Binary files a/logviewer/dbview/.views.py.swp and b/logviewer/dbview/.views.py.swp differ diff --git a/logviewer/dbview/__pycache__/views.cpython-38.pyc b/logviewer/dbview/__pycache__/views.cpython-38.pyc index 0c4f6fb..672d86b 100644 Binary files a/logviewer/dbview/__pycache__/views.cpython-38.pyc and b/logviewer/dbview/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/dbview/views.py b/logviewer/dbview/views.py index d224fa4..c3ee822 100644 --- a/logviewer/dbview/views.py +++ b/logviewer/dbview/views.py @@ -18,9 +18,11 @@ def load_db(query): return(rows) @csrf_exempt + def index(request): #if request.method == 'POST': - # print("GOT A POST") + # for key, value in request.POST.items(): + # print(key,value) if request.path == "/devices/views/all_views.json": uuid_members="[" dev_count=list(load_db("select count(device) from devices where type='Wi-Fi AP'")) @@ -167,18 +169,143 @@ def index(request): elif request.path == "/channels/channels.json": user_status = open('dbview/channels.json') return HttpResponse(user_status, content_type='text/json') - elif request.path == "/devices/views/all/devices.json": - #gotta figure out paging - + #elif request.path == "/devices/views/all/devices.json": + elif request.path.startswith("/devices/views") and request.path.endswith("devices.json"): + device_request=request.path[15:-13] + #print("POST INFO") + #print(request.POST.getlist('search[value]')) + search = str(request.POST.getlist('search[value]'))[2:-2] + draw = str(request.POST.getlist('draw'))[2:-2] + start = str(request.POST.getlist('start'))[2:-2] + limit = str(request.POST.getlist('length'))[2:-2] total_dev=list(load_db("select count(device) from devices")) (dev_count,) = total_dev[0] - dev_string = "{ \"recordsTotal\": "+str(dev_count)+", \"data\": [" - dev_list = list(load_db("select cast(device as text) from devices limit 126")) + dev_string = "" + dev_string = "{ \"recordsTotal\": "+str(dev_count)+", \"data\": [ " + if device_request == "all": + if search == "": + 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": + 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 cast(device as text) like '%"+search+"%' and phyname = 'ADSB' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phydot11_accesspoints": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where type = 'Wi-Fi AP' 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 type = 'Wi-Fi AP' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-BTLE": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'BTLE' 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 type = 'BTLE' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-Bluetooth": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'Bluetooth' 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 = 'Bluetooth' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-RTL433": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'RTL433' 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 = 'RTL433' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-IEEE802.11": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'IEEE802.11' 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 = 'IEEE802.11' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-RADIATION": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'RADIATION' 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 = 'RADIATION' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-802.15.4": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = '802.15.4' 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 = '802.15.4' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-RTLAMR": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'METER' 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 = 'METER' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-NrfMousejack": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'NrfMousejack' 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 = 'NrfMousejack' LIMIT "+limit+" OFFSET "+start)) + elif device_request == "phy-UAV": + if search == "": + 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": + if search == "": + dev_list = list(load_db("select cast(device as text) from devices where phyname = 'Z-Wave' 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 = 'Z-Wave' LIMIT "+limit+" OFFSET "+start)) for device in dev_list: (dev,) = device - dev_string = dev_string + dev + "," + dev_json = json.loads(dev) + newdev = {} + newdev['kismet.device.base.commonname'] = dev_json['kismet.device.base.commonname'] + newdev['kismet.device.base.type'] = dev_json['kismet.device.base.type'] + newdev['kismet.device.base.phyname'] = dev_json['kismet.device.base.phyname'] + newdev['kismet.device.base.crypt'] = dev_json['kismet.device.base.crypt'] + newdev['kismet.device.base.channel'] = dev_json['kismet.device.base.channel'] + newdev['kismet.device.base.datasize'] = dev_json['kismet.device.base.datasize'] + newdev['kismet.device.base.last_time'] = dev_json['kismet.device.base.last_time'] + newdev['kismet.device.base.first_time'] = dev_json['kismet.device.base.first_time'] + newdev['kismet.device.base.key'] = dev_json['kismet.device.base.key'] + newdev['kismet.device.base.macaddr'] = dev_json['kismet.device.base.macaddr'] + newdev['kismet.device.base.frequency'] = dev_json['kismet.device.base.frequency'] + newdev['kismet.device.base.manuf'] = dev_json['kismet.device.base.manuf'] + if newdev['kismet.device.base.phyname'] == "IEEE802.11": + newdev['adsb.device'] = 0 + newdev['bluetooth.device'] = 0 + newdev['uav.device'] = 0 + if newdev['kismet.device.base.phyname'] == "Bluetooth": + newdev['adsb.device'] = 0 + newdev['uav.device'] = 0 + newdev['buetooth.device'] = dev_json['bluetooth.device'] + if newdev['kismet.device.base.phyname'] == "ADSB": + newdev['bluetooth.device'] = 0 + newdev['uav.device'] = 0 + newdev['adsb.device'] = dev_json['adsb.device'] + if "kismet.common.rrd.last_time" in dev_json: + newdev['kismet.common.rrd.last_time'] = dev_json['kismet.common.rrd.last_time'] + if "dot11.device.num_associated_clients" in dev_json: + newdev['dot11.device.num_associated_clients'] = dev_json['dot11.device.num_associated_clients'] + if "dot11.device.last_bssid" in dev_json: + newdev['dot11.device.last_bssid'] = dev_json['dot11.device.last_bssid'] + if "dot11.advertisedssid.dot11e_channel_utilization_perc" in dev_json: + newdev['dot11.advertisedssid.dot11e_channel_utilization_perc'] = dev_json['dot11.advertisedssid.dot11e_channel_utilization_perc'] + if "dot11.advertisedssid.dot11e_qbss_stations" in dev_json: + newdev['dot11.advertisedssid.dot11e_qbss_stations'] = dev_json['dot11.advertisedssid.dot11e_qbss_stations'] + if "kismet.common.signal.last_signal" in dev_json: + newdev['kismet.common.signal.last_signal'] = dev_json['kismet.common.signal.last_signal'] + if "dot11.device.bss_timestamp" in dev_json: + newdev['dot11.device.bss_timestamp'] = dev_json['dot11.device.bss_timestamp'] + if "dot11.advertisedssid.dot11e_qbss" in dev_json: + newdev['dot11.advertisedssid.dot11e_qbss'] = dev_json['dot11.advertisedssid.dot11e_qbss'] + if "dot11.device.wpa_handshake_list" in dev_json: + newdev['dot11.device.wpa_handshake_list'] = dev_json['dot11.device.wpa_handshake_list'] + if "dot11.device.pmkid_packet" in dev_json: + newdev['dot11.device.pmkid_packet'] = dev_json['dot11.device.pmkid_packet'] + if "kismet.common.rrd.serial_time" in dev_json: + newdev['kismet.common.rrd.serial_time'] = dev_json['kismet.common.rrd.serial_time'] + + #print("====") + #print(json.dumps(newdev)) + #print(dev_json['kismet.device.base.commonname']) + #print("====") + #dev_string = dev_string + dev + "," + dev_string = dev_string + json.dumps(newdev) + "," dev_string = dev_string[:-1] - dev_string = dev_string + "],\"draw\": 5,\"recordsFiltered\": "+str(dev_count)+"}" + dev_string = dev_string + "],\"draw\": "+draw+",\"recordsFiltered\": "+str(dev_count)+"}" return HttpResponse(dev_string, content_type='text/json') elif request.path == "/eventbus/events.ws": return HttpResponse("[]", content_type='text/json') diff --git a/logviewer/kiscontent/__pycache__/views.cpython-38.pyc b/logviewer/kiscontent/__pycache__/views.cpython-38.pyc index f5cd237..979c6d6 100644 Binary files a/logviewer/kiscontent/__pycache__/views.cpython-38.pyc and b/logviewer/kiscontent/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/kiscontent/views.py b/logviewer/kiscontent/views.py index 8448629..7e05391 100644 --- a/logviewer/kiscontent/views.py +++ b/logviewer/kiscontent/views.py @@ -18,3 +18,5 @@ def index(request, loadfile): return HttpResponse(load_file, content_type='image/png') elif request.path[0:7] == "/images": return HttpResponse(load_file, content_type='image/png') + elif request.path == "/favicon.ico": + return HttpResponse(load_file, content_type='image/ico') diff --git a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc index df187d7..e31fe2f 100644 Binary files a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc and b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/logviewer/urls.py b/logviewer/logviewer/urls.py index bbe1f06..5758a5f 100644 --- a/logviewer/logviewer/urls.py +++ b/logviewer/logviewer/urls.py @@ -29,6 +29,7 @@ urlpatterns = [ path('css/', include('kiscontent.urls')), path('images/', include('kiscontent.urls')), path('fonts/', include('kiscontent.urls')), + path('favicon.ico', include('kiscontent.urls')), path('dynamic.js', include('dbview.urls')), path('gps/location.json', include('dbview.urls')), path('alerts/alerts_view.json', include('dbview.urls')), @@ -39,8 +40,24 @@ urlpatterns = [ path('messagebus/last-time/0/messages.json', include('dbview.urls')), path('channels/channels.json', include('dbview.urls')), path('devices/views/all/devices.json', include('dbview.urls')), + #path('devices/views//devices.json', include('dbview.urls')), + path('devices/views/phydot11_accesspoints/devices.json', include('dbview.urls')), + path('devices/views/phy-RADIATION/devices.json', include('dbview.urls')), + path('devices/views/phy-802.15.4/devices.json', include('dbview.urls')), + path('devices/views/phy-RTLADSB/devices.json', include('dbview.urls')), + path('devices/views/phy-RTLAMR/devices.json', include('dbview.urls')), + path('devices/views/phy-BTLE/devices.json', include('dbview.urls')), + path('devices/views/phy-NrfMousejack/devices.json', include('dbview.urls')), + path('devices/views/phy-UAV/devices.json', include('dbview.urls')), + path('devices/views/phy-Bluetooth/devices.json', include('dbview.urls')), + path('devices/views/phy-Z-Wave/devices.json', include('dbview.urls')), + path('devices/views/phy-RTL433/devices.json', include('dbview.urls')), + path('devices/views/phy-IEEE802.11/devices.json', include('dbview.urls')), path('devices/by-key//device.json', include('devices.urls')), path('devices/multikey/as-object/devices.json', include('dbview.urls')), + #path('devices/views/phydot11_accesspoints/devices.json', include('dbview.urls')), + #path('devices/views/phy-RADIATION/devices.json', include('dbviews.urls')), + #path('devices/views/phy-802.15.4/devices.json', include('dbviews.utls')), path('datasource/by-uuid//source.json', include('devices.urls')), path('phy/phy80211/ssids/by-hash//ssid.json', include('devices.urls')), path('eventbus/', include('eventbus.urls')),