From 8a0e31a66a795136138837656f933aa49305ada0 Mon Sep 17 00:00:00 2001 From: Giulio Date: Fri, 9 Nov 2018 00:30:20 +0100 Subject: [PATCH] First working rel --- acasown.py | 19 +++++++++++++++++-- bong/__init__.py | 39 ++++++++++++++++++++++++++------------- bong/__init__.pyc | Bin 603 -> 0 bytes censys/__init__.py | 14 ++++++++++---- censys/__init__.pyc | Bin 4780 -> 0 bytes ripe/__init__.pyc | Bin 1674 -> 0 bytes 6 files changed, 53 insertions(+), 19 deletions(-) delete mode 100644 bong/__init__.pyc delete mode 100644 censys/__init__.pyc delete mode 100644 ripe/__init__.pyc diff --git a/acasown.py b/acasown.py index 60d64c0..4662586 100644 --- a/acasown.py +++ b/acasown.py @@ -1,12 +1,27 @@ import ripe import censys import bong +import sys +import json r = ripe.Ripe() c = censys.Censys_WEB("dummyuser", "dummypass") -targets = r.search("trenitalia") +b = bong.Bing() +targets = r.search(sys.argv[1]) print("Found " + str(len(targets)) + " ranges from Ripe") hosts = c.search_ipv4(c.build_query_ipv4(targets)) print("Found " + str(len(hosts)) + " hosts from Censys") +hosts_bing = b.search_hosts(hosts) +result = [] for host in hosts: - print(host) \ No newline at end of file + result_ip = host['ip'] + result_vhosts = host['vhosts'] + result_urls = [] + for host_bing in hosts_bing: + if host_bing['ip'] == result_ip: + result_urls = host_bing['urls'] + for vhost in host_bing['vhosts']: + if vhost not in result_vhosts: + result_vhosts.append(vhost) + result.append({'ip': result_ip, 'urls': result_urls, 'vhosts': result_vhosts, 'protocols': host['protocols']}) +print(json.dumps(result)) \ No newline at end of file diff --git a/bong/__init__.py b/bong/__init__.py index badb7ec..e032bca 100644 --- a/bong/__init__.py +++ b/bong/__init__.py @@ -2,29 +2,42 @@ import requests import xml.etree.ElementTree as ET class Bing: - def __init__(self): self.url = 'https://www.bing.com/search' -''' + self.hosts = [] + + def search_hosts(self, hosts): for host in hosts: - parse(search(host['ip'])) + self.search(host['ip'], 1) + return self.hosts + def search(self, ip, first): + for first in range(1, 200, 10): + urls = [] + vhosts = [] + r = requests.get(self.url, params={'q': 'ip:' + ip, 'format': 'rss', 'first': first}) + tree = ET.fromstring(r.content) + urls = self.parse(tree) + if len(urls) < 10: + break + for u in urls: + vhost = u.rsplit('/')[2] + if vhost not in vhosts: + vhosts.append(vhost) - def search(self, ip,): - r = requests.get(self.url, params={'q': 'ip:' + ip, 'format': 'rss', 'first': first}); - tree = ET.fromstring(r.content) - return tree + #print({'ip': ip, 'vhosts': vhosts, 'urls': urls}) + self.hosts.append({'ip': ip, 'vhosts': vhosts, 'urls': urls}) def parse(self, tree): + urls = [] + vhosts = [] count = 0 for i in tree[0]: if i.tag == 'item': count += 1 - print(i[1].text) + url = i[1].text + if url not in urls: + urls.append(url) - if count == 10: - return 1 - else: - return 0 -''' \ No newline at end of file + return urls \ No newline at end of file diff --git a/bong/__init__.pyc b/bong/__init__.pyc deleted file mode 100644 index fc5a9265e46e2a177487780b19e9a0fdcd8352fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 603 zcmbVJJx{|h5WOTVLM!zUT9u{ob=2eDpfq!TWtmn-O5WLfA7vhUrm36mN5n=042>id&TVlmP>JBYGve zi`#N~6t;0Q|HK$@3+Z)UO}F%(6cBbFU_k7N2nb@IhNDp0sepu!xIx$+0L(8$+W8oT z(i+$k;EZ`;&y{MLCYnGgO6yWtlPuGjV`F*HYFVr|;>VieA;d}!>?txet4pJ%>NaPU zq=~JYN=@o&sC8g1tJE&+~*4e7Sb|?pa1plTw z#9eZ(MQz7l^N75YT$;y~v26JWm8Y_Z3@?p|`h_V?#be|wzu~IfMfSTRjQz1w_^&-@ T;$r>MOZhV^*7m#u|M2(=W!`%7 diff --git a/censys/__init__.py b/censys/__init__.py index 03580ca..59e0d8a 100644 --- a/censys/__init__.py +++ b/censys/__init__.py @@ -88,15 +88,21 @@ class Censys_WEB: def parse_ipv4(self, data): html = BeautifulSoup(data, "lxml") - vhosts = [] - protocols = [] results = html.find_all('div', {'class': 'SearchResult result'}) for raw in results: + vhosts = [] + urls = [] + protocols = [] ip = raw.find_all('span', {'class': 'dns'})[0].get('id') vhosts_html = raw.find_all('i', {'title': 'names on certificate'}) if vhosts_html: l = vhosts_html[0].next_sibling.replace(' ', '') for vhost in l.split(','): vhosts.append(vhost) - self.ipv4.append({'ip': ip, 'protocols': protocols, 'vhosts': vhosts}) - return True \ No newline at end of file + protocols_html = raw.find_all('i', {'title': 'public protocols'}) + if protocols_html: + l = protocols_html[0].next_sibling.replace(' ', '') + for protocol in l.split(','): + protocols.append(protocol) + self.ipv4.append({'ip': ip, 'protocols': protocols, 'vhosts': vhosts, 'urls': urls}) + return True diff --git a/censys/__init__.pyc b/censys/__init__.pyc deleted file mode 100644 index 5ab086f680d8df5c85ab66547e89a630042e6374..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4780 zcmcgwU2h~u6}>g%8PE7*Ke9{AECMDQSO$sgup1``X9J1Xkc~i2RE}igm1*^Mx9#?} zd&XTg-dV|hTAuk2Jn@8(fH(dC{11LWBqVqM3C_7Swijnn$SA_&E>~6Gx>a@Wx%ZxN z{jZC2|M>M^9wsvRspIcEc$`I(;@3zavK9I@DU2M{WUD4-@~$phbxH9%E9s2tH~4m0<&(mi$2yC1%P zb}&k>;&E@F$#5jY<6%P_2AbKyDQeom_I2%GQ$5sHQ|v~sft3j_$ft(qJ|1@$4HO)U zL?XwbgSMtK+V0nRE3=E&5Q1{SMYw+5eHrbZ_d~bR?>{yO0-}Uf>#@#}%zc)C@`n&!2a^H`W z*bSbPlimAKl$W`WqT9o#z6H_Kv2IJ#ifQX-&LlJ`ufcQN$KyUk<3;w>2>WW+C72Yq zh6&it$WBe38FK;&Bl|FKT^`q^`YG-F-UD22A2?`0L`(@?Ef|VBuRHG1Ph%hJ?cndd z{7>BSWi*@Bpxo`kB&qA}461JMe$L}5Ui2bWb~wtMcWTJp%v+xP+(Ley+Ms^qqGXU} zDh3SccG)=h+WDv&W$HOQ3vtgKs;O*ic^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>Jj`w7(T&P{U{clDyR4f1h diff --git a/ripe/__init__.pyc b/ripe/__init__.pyc deleted file mode 100644 index 85bbdde5b964a261597ecdb93f15bfa6e4e2027b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1674 zcmbVMPjBN?5T6$(-L~5^}7oHJ!!N&Q*JvcTHe1YXZ1aWW)HzW>P zV_^buEKHZ;^H4I$#7b5N>q{)Z4>BQI6D69{c__ytrMv~UPRoh&?Y=7(t{8`SlM;Ub zE}B+z7fqtCbB@w1_0@G5)yOqUlDy10Nlq3wybZ&ZqdL#p}}pJRtcebcAM5p z?*ck|^9|kh{uN_~`rM;+PdxPP?%N}_QSRePtmXG~A;GsWt*1zQ|I)C(+KT#8GklTGsi=&8+SOa>Uqk; z)x0>I7OiMG4E+(}ygYh6Iy(xhs~K#L`DWoxbA&0I`O8DkY0blr4zGDQ^Hs^x->FNj ztG#~?9=R2HmU3Q|kt)a#UT2wGa65PBn}T(0@b^{Kls4amivIxQzXN-j_kHkCf~%|A zEgMwrIe=v1SaGf41rv+3_6}p%piY%M*Ren{l>A~ri>8O_#9U5lbz)Oa)s!nv3q8mm zgHs99&O$2CR*^X{duHD}GXwLn>9?4byCAxX+26pdeigI=vjYHjaQ5aG0!UXs2~L6D z0k8|?mpvK+;dblb5iYv*9AOa*AQkL81)yE2_SMa>3M+T0)0qH)^X;~a{l zLWLTxC$=(HSK3gzqhr%y0c#Mpx(cR)6I8Cic1m}Kqtw(vQ2?)EZN8J3K0kY1Xk{Uf9hh`k~F|etGCQfu(R9x iQvcf!YF~?LGRez{sy{ZCmh(wlz^5_+FM;>WUgvLnYF1wW