日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

httpscan 爬蟲掃描小工具推薦

 兔大爺?shù)酿^子 2016-04-11
httpscan是一個(gè)掃描指定網(wǎng)段的Web主機(jī)的小工具。和端口掃描器不一樣,httpscan是以爬蟲的方式進(jìn)行Web主機(jī)發(fā)現(xiàn),因此相對(duì)來說不容易被防火墻攔截。httpscan會(huì)返回IP http狀態(tài)碼 Web容器版本 以及網(wǎng)站標(biāo)題。

Usage:./httpscan IP/CIDR –t threads
Example:./httpscan.py 10.20.30.0/24 –t 10
地址:https://github.com/zer0h/httpscan
主要代碼:
#!/usr/bin/env python
#coding:utf-8
# Author: Zeroh
 
import re
import sys
import Queue
import threading
import optparse
import requests
from IPy import IP
 
printLock = threading.Semaphore(1)  #lock Screen print
TimeOut = 5  #request timeout
 
#User-Agent
header = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36','Connection':'close'}
 
class scan():
 
  def __init__(self,cidr,threads_num):
    self.threads_num = threads_num
    self.cidr = IP(cidr)
    #build ip queue
    self.IPs = Queue.Queue()
    for ip in self.cidr:
      ip = str(ip)
      self.IPs.put(ip)
 
  def request(self):
    with threading.Lock():
      while self.IPs.qsize() > 0:
        ip = self.IPs.get()
        try:
          r = requests.Session().get('http://'+str(ip),headers=header,timeout=TimeOut)
          status = r.status_code
          title = re.search(r'(.*)', r.text) #get the title
          if title:
            title = title.group(1).strip().strip("\r").strip("\n")[:30]
          else:
            title = "None"
          banner = ''
          try:
            banner += r.headers['Server'][:20] #get the server banner
          except:pass
          printLock.acquire()
          print "|%-16s|%-6s|%-20s|%-30s|" % (ip,status,banner,title)
          print "+----------------+------+--------------------+------------------------------+"
 
          #Save log
          with open("./log/"+self.cidr.strNormal(3)+".log",'a') as f:
            f.write(ip+"\n")
 
        except Exception,e:
          printLock.acquire()
        finally:
          printLock.release()
 
  #Multi thread
  def run(self):
    for i in range(self.threads_num):
      t = threading.Thread(target=self.request)
      t.start()
 
if __name__ == "__main__":
  parser = optparse.OptionParser("Usage: %prog [options] target")
  parser.add_option("-t", "--thread", dest = "threads_num",
    default = 1, type = "int",
    help = "[optional]number of  theads,default=10")
  (options, args) = parser.parse_args()
  if len(args)  1:
    parser.print_help()
    sys.exit(0)
 
  print "+----------------+------+--------------------+------------------------------+"
  print "|     IP         |Status|       Server       |            Title             |"
  print "+----------------+------+--------------------+------------------------------+"
 
  s = scan(cidr=args[0],threads_num=options.threads_num)
  s.run()
  

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多