Created
May 10, 2017 20:28
-
-
Save loretoparisi/61664b63b5d5e31cc554fac0cd861363 to your computer and use it in GitHub Desktop.
Telnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import re | |
import sys | |
import telnetlib | |
import time | |
import datetime | |
def read_until(cue, timeout=2): | |
print tn.read_until(cue, timeout) | |
fileName = sys.argv[1] | |
os.system("clear") | |
f = open(fileName) | |
lines = f.readlines() | |
f.close() | |
print "****Domains" | |
print lines | |
print "\n***Hit a key to start analyzing" | |
#input = raw_input() | |
host = "whois.internic.net" | |
port = "43" | |
count = 0 | |
n = datetime.datetime.now() | |
unix_time = time.mktime(n.timetuple()) | |
for site in lines: | |
tn = telnetlib.Telnet(host,port) | |
tn.write(site + "\n") | |
sess_op = tn.read_all() | |
# pattern = "Domain" | |
# prog = re.compile(pattern) | |
# result = prog.search(sess_op) | |
print "\n***Domain:" + site | |
print "Step:"+str(count) | |
nx = datetime.datetime.now() | |
c_time = time.mktime(nx.timetuple()) | |
elapsed = c_time - unix_time | |
print "Elapsed " + str(elapsed) | |
count=count+1 | |
fname = site.replace('\n','') + '.txt' | |
outputFile = open( fname, 'w') | |
outputFile.write( sess_op ) | |
outputFile.close() | |
# if result: | |
# print result.group(0) | |
tn.write("exit\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment