So, I just make simple python code. :)
Readme:
url.txt : you should have url lists in same directory.
import socket, sys, re
import string
def main():
# Fillter SSL PORT
ssl_port = 443
# Common Port Mode
port = ["80"]
# INTERNAL URL
urldata = open("url.txt", "r")
count = 0
for i in urldata:
count += 1
i = i.strip('\n')
for j in port:
isheader(i, int(j), count, ssl_port)
urldata.close()
print("\r\nFINISH. Thank you")
def savingR(port, num, url, msg):
fp_r = open("result_"+str(port)+".txt","a")
fp_r.write("["+str(num)+"]"+url+":"+str(port)+"-"+msg+"\r\n")
fp_r.flush()
fp_r.close()
def Msgprint(url, port, msg):
print("%s(%d): Done [%s]" %(url, port, msg))
def isheader(url, port, num, ssl_port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(10)
try:
if (ssl_port == port):
try:
s.connect((url, port))
except socket.error:
msg = "Closed port(ssl)"
Msgprint(url, port, msg)
s.close()
return 0
s_ssl = socket.ssl(s)
s_ssl.write('OPTIONS / HTTP/1.0\r\n\r\n')
buf = s_ssl.read()
s.close()
else:
try:
s.connect((url, port))
except socket.error:
msg = "Closed port"
Msgprint(url, port, msg)
s.close()
return 0
s.send("OPTIONS / HTTP/1.0\r\n\r\n".encode('utf-8'))
buf = (s.recv(1024)).decode('utf-8')
s.close()
if not buf:
msg = "Not Return from this server"
Msgprint(url, port, msg)
return 0
msg = ''.join(re.findall('Allow:.*', buf))
if (msg == ""):
msg = "Nothing"
if(''.join(re.findall('PUT', msg))) or (''.join(re.findall('COPY', msg))) or (''.join(re.findall('DELETE', msg)) or (''.join(re.findall('TRACE', msg)))):
# To save results
num = num+1
savingR(port, num, url, msg)
msg += "] [*FOUND"
Msgprint(url, port, msg)
except:
msg = "Timeout"
Msgprint(url, port, msg)
s.close()
return 0
main()
No comments:
Post a Comment