From 65a87440607d323bda034187c051759019fd840c Mon Sep 17 00:00:00 2001 From: Giulio Date: Thu, 8 Nov 2018 12:56:36 +0100 Subject: [PATCH] Wrote ripe class --- README.md | 0 acasown.py | 6 ++++++ bong/__init__.py | 0 censys/__init__.py | 15 +++++++++++++++ ripe/__init__.py | 22 ++++++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 README.md create mode 100644 acasown.py create mode 100644 bong/__init__.py create mode 100644 censys/__init__.py create mode 100644 ripe/__init__.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/acasown.py b/acasown.py new file mode 100644 index 0000000..6dff5c0 --- /dev/null +++ b/acasown.py @@ -0,0 +1,6 @@ +import ripe +import censys +import bong + +r = ripe.Ripe() +print(r.search("trenitalia")) \ No newline at end of file diff --git a/bong/__init__.py b/bong/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/censys/__init__.py b/censys/__init__.py new file mode 100644 index 0000000..fc7dc34 --- /dev/null +++ b/censys/__init__.py @@ -0,0 +1,15 @@ +import requests + +class Censys: + def __init__(self, login, secret): + self.login = login + self.gin = secret + + def login(self): + return True + + def build_query(self, targets): + return True + + def search(self, query): + return True \ No newline at end of file diff --git a/ripe/__init__.py b/ripe/__init__.py new file mode 100644 index 0000000..018d0c8 --- /dev/null +++ b/ripe/__init__.py @@ -0,0 +1,22 @@ +import requests +import logging + +class Ripe: + def __init__(self): + self.ranges = [] + + def search(self, target): + r = requests.get("https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=true&format=xml&hl=true&q=(" + target +")+AND+(object-type:inetnum)&start=0&wt=json", headers={"Accept": "application/json"}) + data = r.json() + total = data['result']['numFound'] + for i in range(0, total, 10): + r = requests.get("https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=true&format=xml&hl=true&q=(" + target +")+AND+(object-type:inetnum)&start=" + str(i) + "&wt=json", headers={"Accept": "application/json"}) + self.parse(r.json()) + return self.ranges + + def parse(self, data): + for entry in data['result']['docs']: + for field in entry['doc']['strs']: + if field['str']['name'] == 'inetnum': + self.ranges.append({'start': field['str']['value'].split('-')[0].strip(), 'end': field['str']['value'].split('-')[1].strip()}) +