blade18 0 Newbie Poster

Hi Guys,

I need to modify this script so that is also scan a range of host.

import socket 
import sys 
import fileinput 
import re 
import time 
from optparse import OptionParser 
 
usage =  "./%prog -t target -p port -i input file -P proxy\nExample: ./%prog -t 74.52.252.187 -p 25 -f names.txt " 
parser = OptionParser(usage=usage) 
parser.add_option("-t", type="string", 
                  action="store", dest="target", 
                  help="Target Host") 
parser.add_option("-p", type="int", 
                  action="store", dest="port", 
                  help="Target Port") 
parser.add_option("-f", action="store", 
		  dest="filename",help="Input file") 
(options, args) = parser.parse_args() 
 
host = options.target 
port = options.port 
inputfile = options.filename 
try: 
	names = open(sys.argv[6], "r") 
except(IOError): 
	print "Error: Check your wordlist path\n" 
  	sys.exit(1) 
 
line = names.readline() 
counter = 0 
 
print "[+] Connecting to server" 
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) 
 
 
def connect(): 
	try: 
		connect=s.connect((host,port)) 
	except socket.timeout: 
  		print "\n[-] Server timed out" 
		sys.exit(1) 
	except socket.error: 
  		print "\n[-] There was an error with the server" 
		sys.exit(1) 
	print "[+] Connected on" +timer() 
	print "[+] Waiting for SMTP banner" 
	banner=s.recv(1024) 
	print banner 
 
def timer(): 
	now = time.localtime(time.time()) 
	return time.asctime(now) 
 
connect() 
 
for line in names: 
	s.send('VRFY '+line) 
        result=s.recv(1024) 
	print result 
	if counter == 20: 
		s.close() 
		print "[+] Resetting connection" 
		s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) 
		connect() 
		counter = 0 
	counter +=1 
 
s.close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.