Last active
August 29, 2015 14:27
-
-
Save typcn/b940fce41f54fc2a8832 to your computer and use it in GitHub Desktop.
Website Source IP Scanner
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
import socket , struct , time | |
from optparse import OptionParser | |
from threading import Thread | |
from multiprocessing.pool import ThreadPool | |
def scan(ip): | |
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) | |
s.connect((ip,80)) | |
s.send("GET / HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\nUser-Agent: fucksb\r\n\r\n") | |
resp = s.recv(12) # You can set it to a larger value , determine whether there is a specified string in resp | |
if resp == "": return | |
print resp + " " + ip | |
s.close() | |
def main(): | |
parser = OptionParser() | |
parser.add_option("-d", dest="host", help="Target host header") | |
parser.add_option("-t", dest="thread", help="Thread number") | |
parser.add_option("-s", dest="ipstart", help="Start IP") | |
parser.add_option("-e", dest="ipend", help="End IP") | |
(options, args) = parser.parse_args() | |
global host | |
host = options.host | |
startIP = struct.unpack("!I",socket.inet_aton(options.ipstart))[0] | |
endIP = struct.unpack("!I",socket.inet_aton(options.ipend))[0] | |
pool = ThreadPool(int(options.thread)) | |
print "Starting scan .... Press Ctrl+C to exit" | |
time.sleep(3) | |
for x in range(startIP, endIP): | |
ip = socket.inet_ntoa(struct.pack("!I",x)) | |
pool.apply_async(scan,[ip]) | |
pool.close() | |
time.sleep(99999999) | |
if __name__ == "__main__": | |
main() | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment