Code Monkey home page Code Monkey logo

python-kismet-rest's People

Contributors

ashmastaflash avatar dragorn avatar ohad83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-kismet-rest's Issues

Improve timestamp handling

Improve timestamp handling:

Add a synthetic column for handling timestamps. This will add a column to output which will be a python datetime object (composed from ts_sec and ts_usec).

Provide functionality to make time-related queries using a Python datetime object instead of having to reduce query args to two timestamp-related fields.

Add the ability to query using ISO 8601-formatted timestamp. Prioritize so that if multiple timestamps are provided with kwargs, the priority (in order of importance) should be:

  1. ts_sec, ts_usec
  2. datetime object
  3. ISO 8601

json.loads failing to detect encoding under python3.5

under ubuntu 16.04 (vendor repo hosts python 3.5.2 as latest version) encountered error:

Traceback (most recent call last):
  File "./wifi-alarm.py", line 38, in <module>
    for device in devices.by_mac(devices=macs, fields=fields):
  File "/usr/local/lib/python3.5/dist-packages/kismet_rest/devices.py", line 62, in by_mac
    for result in self.interact_yield("POST", url, **call_settings):
  File "/usr/local/lib/python3.5/dist-packages/kismet_rest/base_interface.py", line 255, in interact_yield
    for result in self.process_response_stream(response, **kwargs):
  File "/usr/local/lib/python3.5/dist-packages/kismet_rest/base_interface.py", line 271, in process_response_stream
    yield json.loads(result)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

upgrade to python 3.6.8 solves.

other work arounds seem to be:

  • adding "; charset=utf8" to RegisterMimeType string for json and ekjson in kis_net_microhttpd.cc
  • setting response.encoding to 'utf-8' and calling response.iter_lines(decode_unicode=True) in affected function in base_interface.py (obviously would need to be added in other places as well)

i don't know if support for python 3.5 is a concern but i figured i would put the info out there.

New release ?

Even even there is only one commit since latest release, it would be good to make a new release. Indeed, master and current release are not backward compatibles as ekjson serialization modifies field names since October 2019.

Unable to raise alerts

using python-kismet-rest 2019.05.02 and kismet release 2019-09-01. I have been unable to raise an alert with the following code:

import kismet_rest

alert_conn = kismet_rest.Alerts(
        username=username, password=password, host_uri=host)
alert_conn.define(name="AN_ALERT", description="Something has happened")
alert_conn.raise_alert(name="AN_ALERT", text="success")

The connection to the kismet instance works and no error are thrown but no alert is displayed on the web gui. I'm sure its my code, please code you point me in the right direction?

any assistance would be greatfully recieved

Tao

alerts.url_template is incorrect

alerts.url_template = "alerts/last-time/{ts_sec}.{ts_usec}/alerts.itjson"

should be i think:

alerts.url_template = "alerts/last-time/{ts_sec}.{ts_usec}/alerts.json"

many thanks

tao

Error cannot use the Library

hello i have my kismet tool running on kali linux and i have downloaded your library using pip and when i run in py charm its giving me error

/root/PycharmProjects/BlueSnarf/venv/bin/python /root/PycharmProjects/BlueSnarf/DosAlert.py
Traceback (most recent call last):
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse
response.begin()
File "/usr/lib/python3.7/http/client.py", line 296, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.7/http/client.py", line 278, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: *KISMET: 0.0.0 1561387425 �kali� �pcapdump,netxml,nettxt,gpsxml,alert� 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse
response.begin()
File "/usr/lib/python3.7/http/client.py", line 296, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.7/http/client.py", line 278, in _read_status
raise BadStatusLine(line)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine('*KISMET: 0.0.0 1561387425 \x01kali\x01 \x01pcapdump,netxml,nettxt,gpsxml,alert\x01 0 \n'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/PycharmProjects/BlueSnarf/DosAlert.py", line 5, in
for device in conn.device_summary():
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/kismet_rest/legacy.py", line 105, in device_summary
return self.device_list(callback, cbargs)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/kismet_rest/legacy.py", line 127, in device_list
return self.interact("GET", url, True, **kwargs)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/kismet_rest/base_interface.py", line 142, in interact
response = self.session.get(full_url, stream=stream)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/root/PycharmProjects/BlueSnarf/venv/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('*KISMET: 0.0.0 1561387425 \x01kali\x01 \x01pcapdump,netxml,nettxt,gpsxml,alert\x01 0 \n'))

Process finished with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.