From: Russ Handorf Date: Tue, 20 Dec 2022 00:23:00 +0000 (-0500) Subject: moar X-Git-Url: http://russells-world.com/code/?a=commitdiff_plain;h=09502060aad90cd0ad638cf4ad3cb6560e2f646c;p=kismet-logviewer.git moar --- diff --git a/logviewer/dbview/__pycache__/views.cpython-38.pyc b/logviewer/dbview/__pycache__/views.cpython-38.pyc index a3dcda1..b7b9794 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/ssids.json b/logviewer/dbview/ssids.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/logviewer/dbview/ssids.json @@ -0,0 +1 @@ +[] diff --git a/logviewer/dbview/views.py b/logviewer/dbview/views.py index a7d0f9a..c84f38b 100644 --- a/logviewer/dbview/views.py +++ b/logviewer/dbview/views.py @@ -9,7 +9,7 @@ import pprint from django.views.decorators.csrf import csrf_exempt def load_db(query): - connection = sqlite3.connect("/home/rhandorf/kismet-logviewer/logviewer/logs/Kismet-20221208-22-56-36-1.kismet") + connection = sqlite3.connect("logs/Kismet-20221208-22-56-36-1.kismet") #connection.row_factory = lambda cursor, row: row[0] cursor = connection.cursor() rows = cursor.execute(query).fetchall() @@ -20,10 +20,10 @@ def index(request): #if request.method == 'POST': # print("GOT A POST") if request.path == "/devices/views/all_views.json": - all_views = open('/home/rhandorf/kismet-logviewer/logviewer/dbview/all_views.json') + all_views = open('dbview/all_views.json') return HttpResponse(all_views, content_type='text/json') elif request.path == "/system/user_status.json": - user_status = open('/home/rhandorf/kismet-logviewer/logviewer/dbview/user_status.json') + user_status = open('dbview/user_status.json') return HttpResponse(user_status, content_type='text/json') elif request.path == "/session/check_setup_ok": return HttpResponse('Login configured in user config') @@ -31,10 +31,10 @@ def index(request): return HttpResponse('Login valid') elif request.path == "/dynamic.js": devices = load_db("select distinct(typestring) from datasources") - load_file = open('/home/rhandorf/kismet-logviewer/logviewer/static/dynamic.js') + load_file = open('static/dynamic.js') return HttpResponse(load_file, content_type='application/javascript') elif request.path == "/gps/location.json": - user_status = open('/home/rhandorf/kismet-logviewer/logviewer/dbview/gps_status.json') + user_status = open('dbview/gps_status.json') return HttpResponse(user_status, content_type='text/json') elif request.path == "/alerts/wrapped/last-time/0/alerts.json": alerts = list(load_db("select cast(json as text) from alerts")) @@ -46,10 +46,10 @@ def index(request): alert_string = alert_string + "] ,\"kismet.alert.timestamp\": "+str(time.time())+"}" return HttpResponse(alert_string, content_type='text/json') elif request.path == "/phy/phy80211/ssids/views/ssids.json": - user_status = open('/home/rhandorf/kismet-logviewer/logviewer/dbview/ssids.json') + user_status = open('dbview/ssids.json') return HttpResponse(user_status, content_type='text/json') elif request.path == "/system/status.json": - user_status = open('/home/rhandorf/kismet-logviewer/logviewer/dbview/status.json') + user_status = open('dbview/status.json') return HttpResponse(user_status, content_type='text/json') elif request.path == "/alerts/alerts_view.json": #MAY NOT BE COMPLETE @@ -87,7 +87,7 @@ def index(request): message_string = message_string + "], \"kismet.messagebus.timestamp\": "+str(time.time())+" }" return HttpResponse(message_string, content_type='text/json') elif request.path == "/channels/channels.json": - user_status = open('/home/rhandorf/kismet-logviewer/logviewer/dbview/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 @@ -103,5 +103,11 @@ def index(request): return HttpResponse(dev_string, content_type='text/json') elif request.path == "/eventbus/events.ws": return HttpResponse("[]", content_type='text/json') - - + elif request.path == "/devices/multikey/as-object/devices.json": + print("here") + for key, value in request.POST.items(): + print("-----") + print(key) + print(value) + print("-----") + return HttpResponse("[]", content_type='text/json') diff --git a/logviewer/devices/__init__.py b/logviewer/devices/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/devices/__pycache__/__init__.cpython-38.pyc b/logviewer/devices/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..f9f6bb7 Binary files /dev/null and b/logviewer/devices/__pycache__/__init__.cpython-38.pyc differ diff --git a/logviewer/devices/__pycache__/urls.cpython-38.pyc b/logviewer/devices/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..1a74bdf Binary files /dev/null and b/logviewer/devices/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/devices/__pycache__/views.cpython-38.pyc b/logviewer/devices/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..6b59af7 Binary files /dev/null and b/logviewer/devices/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/devices/admin.py b/logviewer/devices/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/logviewer/devices/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/logviewer/devices/apps.py b/logviewer/devices/apps.py new file mode 100644 index 0000000..f1dad42 --- /dev/null +++ b/logviewer/devices/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DevicesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'devices' diff --git a/logviewer/devices/migrations/__init__.py b/logviewer/devices/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/devices/models.py b/logviewer/devices/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/logviewer/devices/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/logviewer/devices/tests.py b/logviewer/devices/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/logviewer/devices/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/logviewer/devices/urls.py b/logviewer/devices/urls.py new file mode 100644 index 0000000..88a9cac --- /dev/null +++ b/logviewer/devices/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] diff --git a/logviewer/devices/views.py b/logviewer/devices/views.py new file mode 100644 index 0000000..5451dc8 --- /dev/null +++ b/logviewer/devices/views.py @@ -0,0 +1,30 @@ +from django.shortcuts import render +from django.http import HttpResponse, HttpRequest +import os +import sqlite3 +import time +import json +import pprint + +from django.views.decorators.csrf import csrf_exempt + +def load_db(query): + connection = sqlite3.connect("logs/Kismet-20221208-22-56-36-1.kismet") + #connection.row_factory = lambda cursor, row: row[0] + cursor = connection.cursor() + rows = cursor.execute(query).fetchall() + return(rows) + +@csrf_exempt +def index(request,devicename): + dev=list(load_db("select cast(device as text) from devices where devkey = \""+devicename+"\"")) + (dev_info,) = dev[0] + #dev_string = "{ \"recordsTotal\": "+str(dev_count)+", \"data\": [" + #dev_list = list(load_db("select cast(device as text) from devices limit 50")) + #for device in dev_list: + # (dev,) = device + # dev_string = dev_string + dev + "," + #dev_string = dev_string[:-1] + #dev_string = dev_string + "],\"draw\": 5,\"recordsFiltered\": "+str(dev_count)+"}" + return HttpResponse(dev_info, content_type='text/json') + diff --git a/logviewer/kiscontent/.views.py.swp b/logviewer/kiscontent/.views.py.swp new file mode 100644 index 0000000..1ef3d78 Binary files /dev/null and b/logviewer/kiscontent/.views.py.swp differ diff --git a/logviewer/kiscontent/__pycache__/views.cpython-38.pyc b/logviewer/kiscontent/__pycache__/views.cpython-38.pyc index bcc842a..f5cd237 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 668b06e..8448629 100644 --- a/logviewer/kiscontent/views.py +++ b/logviewer/kiscontent/views.py @@ -3,7 +3,7 @@ from django.http import HttpResponse, HttpRequest import os def index(request, loadfile): - load_file = open('/home/rhandorf/kismet-logviewer/logviewer/static/'+request.path, mode='rb') + load_file = open('static/'+request.path, mode='rb') if loadfile[-2:] == "js": return HttpResponse(load_file, content_type='application/javascript') elif loadfile[-3:] == "css": diff --git a/logviewer/logs/Kismet-20221208-22-56-36-1.kismet b/logviewer/logs/Kismet-20221208-22-56-36-1.kismet new file mode 100644 index 0000000..4b080d0 Binary files /dev/null and b/logviewer/logs/Kismet-20221208-22-56-36-1.kismet differ diff --git a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc index 199b310..5fc6884 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 b23c30b..584a77c 100644 --- a/logviewer/logviewer/urls.py +++ b/logviewer/logviewer/urls.py @@ -40,4 +40,6 @@ urlpatterns = [ path('channels/channels.json', include('dbview.urls')), path('devices/views/all/devices.json', include('dbview.urls')), path('eventbus/events.ws', include('dbview.urls')), + path('devices/by-key//device.json', include('devices.urls')), + path('devices/multikey/as-object/devices.json', include('dbview.urls')), ]