From: Russ Handorf Date: Sat, 14 Jan 2023 02:38:40 +0000 (-0500) Subject: bix fixes and added adsb map X-Git-Url: https://handorf.org/code/?a=commitdiff_plain;h=56cb69d2e0dd567bcbbed653863fc38dfd12f756;p=kismet-logviewer.git bix fixes and added adsb map --- diff --git a/logviewer/adsbmap/__init__.py b/logviewer/adsbmap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/adsbmap/__pycache__/__init__.cpython-38.pyc b/logviewer/adsbmap/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..605e22a Binary files /dev/null and b/logviewer/adsbmap/__pycache__/__init__.cpython-38.pyc differ diff --git a/logviewer/adsbmap/__pycache__/urls.cpython-38.pyc b/logviewer/adsbmap/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..fbce56c Binary files /dev/null and b/logviewer/adsbmap/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/adsbmap/__pycache__/views.cpython-38.pyc b/logviewer/adsbmap/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..d2c9efa Binary files /dev/null and b/logviewer/adsbmap/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/adsbmap/admin.py b/logviewer/adsbmap/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/logviewer/adsbmap/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/logviewer/adsbmap/apps.py b/logviewer/adsbmap/apps.py new file mode 100644 index 0000000..276dc8b --- /dev/null +++ b/logviewer/adsbmap/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AdsbmapConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'adsbmap' diff --git a/logviewer/adsbmap/migrations/__init__.py b/logviewer/adsbmap/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/adsbmap/models.py b/logviewer/adsbmap/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/logviewer/adsbmap/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/logviewer/adsbmap/tests.py b/logviewer/adsbmap/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/logviewer/adsbmap/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/logviewer/adsbmap/urls.py b/logviewer/adsbmap/urls.py new file mode 100644 index 0000000..4c9189f --- /dev/null +++ b/logviewer/adsbmap/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] + diff --git a/logviewer/adsbmap/views.py b/logviewer/adsbmap/views.py new file mode 100644 index 0000000..a447c2c --- /dev/null +++ b/logviewer/adsbmap/views.py @@ -0,0 +1,16 @@ +from django.shortcuts import render +from django.http import HttpResponse, HttpRequest +import os + +def index(request): + print("===") + print(request) + print("====") + if request.method == 'POST': + for key, value in request.POST.items(): + print(key,value) + + load_file = open('static/'+request.path, mode='rb') + if request.path == "/adsb_map_panel.html": + print("here") + return HttpResponse(load_file, content_type='text/html') diff --git a/logviewer/dbview/.views.py.swp b/logviewer/dbview/.views.py.swp index 9ce4e59..bbf4106 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 672d86b..8d3e613 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 c3ee822..6a899ee 100644 --- a/logviewer/dbview/views.py +++ b/logviewer/dbview/views.py @@ -187,7 +187,7 @@ def index(request): 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: @@ -242,7 +242,7 @@ def index(request): 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: @@ -329,3 +329,53 @@ def index(request): 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') diff --git a/logviewer/kiscontent/__pycache__/views.cpython-38.pyc b/logviewer/kiscontent/__pycache__/views.cpython-38.pyc index 979c6d6..510d74d 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/logviewer/__pycache__/settings.cpython-38.pyc b/logviewer/logviewer/__pycache__/settings.cpython-38.pyc index 9f4c0d5..10c7562 100644 Binary files a/logviewer/logviewer/__pycache__/settings.cpython-38.pyc and b/logviewer/logviewer/__pycache__/settings.cpython-38.pyc differ diff --git a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc index e31fe2f..31bf70d 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/settings.py b/logviewer/logviewer/settings.py index 9f67ffd..2df18a0 100644 --- a/logviewer/logviewer/settings.py +++ b/logviewer/logviewer/settings.py @@ -148,3 +148,5 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' ALLOWED_HOSTS = ['sdr-cabinet', 'sdr-cabinet.dyn.spangdorfia.com'] ASGI_APPLICATION = 'logviewer.asgi.application' + +X_FRAME_OPTIONS = 'SAMEORIGIN' diff --git a/logviewer/logviewer/urls.py b/logviewer/logviewer/urls.py index 5758a5f..ae573ea 100644 --- a/logviewer/logviewer/urls.py +++ b/logviewer/logviewer/urls.py @@ -35,12 +35,12 @@ urlpatterns = [ path('alerts/alerts_view.json', include('dbview.urls')), path('phy/phy80211/ssids/views/ssids.json', include('dbview.urls')), path('css/images/', include('kiscontent.urls')), + path('adsb_map_panel.html', include('adsbmap.urls')), path('system/status.json', include('dbview.urls')), path('alerts/wrapped/last-time/0/alerts.json', include('dbview.urls')), 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')), @@ -53,11 +53,9 @@ urlpatterns = [ 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('phy/ADSB/map_data.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')), diff --git a/logviewer/static/dynamic.js b/logviewer/static/dynamic.js index d8e7b71..0bc785a 100644 --- a/logviewer/static/dynamic.js +++ b/logviewer/static/dynamic.js @@ -1,23 +1,23 @@ var local_uri_prefix = "./"; if (typeof(KISMET_URI_PREFIX) !== 'undefined') local_uri_prefix = KISMET_URI_PREFIX; +var kismet_ui_adsb; var kismet_ui_bluetooth; var kismet_ui_btle; var kismet_ui_datasources; var kismet_ui_dot11; +var kismet_ui_meter; var kismet_ui_rtl433; -//var kismet_ui_rtladsb; -//var kismet_ui_rtlamr; var kismet_ui_uav; var kismet_ui_zwave; async function load_dynamics() { +kismet_ui_adsb = await import(`${local_uri_prefix}js/kismet.ui.adsb.js`); kismet_ui_bluetooth = await import(`${local_uri_prefix}js/kismet.ui.bluetooth.js`); kismet_ui_btle = await import(`${local_uri_prefix}js/kismet.ui.btle.js`); kismet_ui_datasources = await import(`${local_uri_prefix}js/kismet.ui.datasources.js`); kismet_ui_dot11 = await import(`${local_uri_prefix}js/kismet.ui.dot11.js`); +kismet_ui_meter = await import(`${local_uri_prefix}js/kismet.ui.meter.js`); kismet_ui_rtl433 = await import(`${local_uri_prefix}js/kismet.ui.rtl433.js`); -//kismet_ui_rtladsb = await import(`${local_uri_prefix}js/kismet.ui.rtladsb.js`); -//kismet_ui_rtlamr = await import(`${local_uri_prefix}js/kismet.ui.rtlamr.js`); kismet_ui_uav = await import(`${local_uri_prefix}js/kismet.ui.uav.js`); kismet_ui_zwave = await import(`${local_uri_prefix}js/kismet.ui.zwave.js`); }