forked from tomh4x/osint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshadowsrv.py
More file actions
executable file
·37 lines (29 loc) · 798 Bytes
/
shadowsrv.py
File metadata and controls
executable file
·37 lines (29 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
import socket
import sys
def recvall(sock):
databuf = []
while 1:
data = sock.recv(1480)
if not data: break
databuf.append(data.decode('utf-8', errors='ignore')) #python3 requires decoding from byte to unicode, also ignore non-unicode chars
return ''.join(databuf).strip()
# MAIN:
# prepare socket for IP list
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
shadowserv = socket.gethostbyname( 'asn.shadowserver.org' )
s.connect((shadowserv, 43))
s.send('begin origin\r\n'.encode())
# load and send IPs
if len(sys.argv) > 1:
f = open( sys.argv[1], "r")
for line in f.readlines():
s.send(line.encode())
else:
for line in sys.stdin:
s.send(line.encode())
s.send('end origin\r\n'.encode())
# puke output!
retbuf = recvall(s)
print(retbuf)
s.close()