pythonweb扫描器_PYTHON自动化WEB旁注目录扫描器

#!/usr/bin/env python

#encoding = utf-8

import urllib,httplib

from urllib2 import Request, urlopen, URLError

import Queue,sys,time

import re

import socket

import sys

from urlparse import urlparse

class Scanner():

def __init__(self):

alldomains = self.getdomains()

print "There are %d website in the same server" % len(alldomains)

time.sleep(2)

print "Starting The Scanning[*.*]\n=============================="

for aim in alldomains:

if(self.verifydomain(aim)):

for path in paths:

url = 'http://'+aim+path

headers = { 'User-Agent' : 'Mozilla/5.0 (compatible; Googlebot/2.1; +[url]http://www.google.com/bot.html[/url])' }

req = Request(url, None, headers)

try:

response = urlopen(req)

except URLError, e:

#if hasattr(e, 'reason'):

#        print url,'[x] Not Found'

#elif hasattr(e,'code'):

#        print url,'[x]Not Found'

if hasattr(e, 'reason'):

print url,'[x] Not Found'

elif hasattr(e, "code") and e.code == 401:

record = "%s===>FOUND" % (url,url)

print url," [OK] Found"

self.writeresult(record)

elif hasattr(e, "code") and e.code == 403:

record = "%s===>FOUND" % (url,url)

print url," [OK] Found"

self.writeresult(record)

elif hasattr(e, "code") and e.code == 500:

record = "%s===>FOUND" % (url,url)

print url," [OK] Found"

self.writeresult(record)

else:

record = "%s===>FOUND" % (url,url)

print url," [OK] Found"

self.writeresult(record)

def getdomains(self):

doreq = Request('http://domains.yougetsignal.com/domains.php?remoteAddress='+ domain)

response = urlopen(doreq)

html = response.read()

response.close()

#domains = re.findall(r'(\[\".*?\",\s+\".*?\"\])',html)

domains = re.findall(r'\[\"(.*?)\"',html)

#print domains

#for val in domains:

#        print val

#        print self.verifydomain(domains[1])

return domains

def verifydomain(self,domains):

try:

Originalhost = socket.getaddrinfo(domain,None)[0][4][0]

#print Originalhost

domainip = socket.getaddrinfo(domains,None)[0][4][0]

#print domainip

if(domainip==Originalhost):

return True

else:

return False

except:

print domains+'        connect issue!'

def writeresult(self,record):

fp = open(domain+'.html','a+')

fp.writelines(record+'')

fp.close()

def usage(self):

print "Usage: WebGrabs.py domain dict \n"

print "\nExamples:WebGrabs.py [url]www.google.com[/url] dict.txt"

#domain = raw_input('Url Path>>')

#dic = raw_input("Wordlist Path>>")

domain = raw_input('Url   Path>>')

dic = raw_input('Wordlist Path>>')

paths = [line.rstrip() for line in open(dic)]

def main():

print('''

###########################

#                         #

#       WebGrabs Scanner  #

#                         #

###########################\n>>>

''')

Scanner()

if __name__ == '__main__':

main()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值