diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py new file mode 100644 index 00000000..3cd2ed0d --- /dev/null +++ b/py-json/LANforge/LFRequest.py @@ -0,0 +1,36 @@ +#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Class holds default settings for json requests - +#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +import sys + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +import urllib.request +import json + +class LFRequest: + Default_Base_URL = "http://localhost:8080" + requested_urls = [] + default_headers = { + 'Accept': 'application/json' } + + + def __init__(self, urls): + self.requested_urls.append(urls) + + # request first url on stack + def get(self): + myrequest = urllib.request.Request(url=self.requested_urls.pop(0), headers=self.default_headers) + myresponse = urllib.request.urlopen(myrequest) + + #print(json_response) + return myresponse + + def getAsJson(self): + response = self.get(); + json_data = json.loads(response.read()) + return json_data + +# ~LFRequest diff --git a/py-json/LANforge/__init__.py b/py-json/LANforge/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/py-json/LANforge/__pycache__/LFRequest.cpython-36.pyc b/py-json/LANforge/__pycache__/LFRequest.cpython-36.pyc new file mode 100644 index 00000000..5eaa976c Binary files /dev/null and b/py-json/LANforge/__pycache__/LFRequest.cpython-36.pyc differ diff --git a/py-json/LANforge/__pycache__/__init__.cpython-36.pyc b/py-json/LANforge/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 00000000..b888f917 Binary files /dev/null and b/py-json/LANforge/__pycache__/__init__.cpython-36.pyc differ diff --git a/py-json/TODO.txt b/py-json/TODO.txt new file mode 100644 index 00000000..ed15eaa0 --- /dev/null +++ b/py-json/TODO.txt @@ -0,0 +1,20 @@ +Able to select ports + +Create client groups / single client: +Should be able to control MAC address, + client type(b/g/n/, ac), + encryption (WPA2, WPA3), + auth -( open, 802.1x , WebAuth, WISPR) + Tx power etc + +Able to control below failures with predetermined failure rate + +eg: + +Generate auth failure +Generate assoc failure +Generate EAP failure +Generate WIPSR/WebAuth failure +Generate Radius failure +Generate DHCP failure + diff --git a/py-json/__init__.py b/py-json/__init__.py new file mode 100644 index 00000000..09430889 --- /dev/null +++ b/py-json/__init__.py @@ -0,0 +1,2 @@ +from .LFRequest import LFRequest + diff --git a/py-json/show_ports.py b/py-json/show_ports.py new file mode 100644 index 00000000..727432ac --- /dev/null +++ b/py-json/show_ports.py @@ -0,0 +1,26 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# example of how to check a LANforge json url - +# - +# the syntax of the request is /port/// - +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +import sys +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +import json +from LANforge import LFRequest + + +def main(): + url = "http://localhost:8080/port/1/1/list" + timeout = 5 # seconds + + lf_r = LFRequest.LFRequest(url) + json_response = lf_r.getAsJson() + print(json_response) + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +if __name__ == "__main__": + main() +#