httpscan是一个扫描指定网段的Web主机的小工具。和端口扫描器不一样,httpscan是以爬虫的方式进行Web主机发现,因此相对来说不容易被防火墙拦截。
httpscan会返回IP http状态码 Web容器版本 以及网站标题。

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'<title>(.*)</title>', 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()

来源:http://www.rootat.net/2016/03/29/httpscan/

httpscan 爬虫式的网段Web主机发现小工具的更多相关文章

  1. 新手篇丨Python任意网段Web端口信息探测工具

    你学习Python的目的是什么?是想写爬虫爬取数据(数据.图片等内容),还是想自写自动化的小工具,又或是作为一个新手小白单纯的欣赏这门语言呢? 今天i春秋分享的是一篇关于多线程工具的文章,工具使用效率 ...

  2. Python任意网段Web端口信息探测工具

    此篇关于多线程工具的文章,非常适合新手学习,工具效率也挺高的,代码也比较完善,如题. 本文作者:i春秋签约作家——Aedoo 0×00 前言 笔者前一段时间发布了原创文章,“[Python黑客] Py ...

  3. Web压力测试小工具:webbench、http_load、Siege、ab

    webbench 安装 下载地址:http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz 或者 http://soft.vpser ...

  4. web图片转换小工具制作

    HTML <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  5. 前端学HTTP之Web主机托管

    前面的话 对内容资源的存储.协调以及管理的职责统称为Web主机托管.主机托管是Web服务器的主要功能之一.保存并提供内容,记录对内容的访问以及管理内容都离不开服务器.如果不想自行管理服务器所需的软硬件 ...

  6. asp.net core 系列 16 Web主机 IWebHostBuilder

    一.概述 在asp.net core中,Host主机负责应用程序启动和生存期管理.host主机包括Web 主机(IWebHostBuilder)和通用主机(IHostBuilder).Web 主机是适 ...

  7. (15)ASP.NET Core Web主机(IWebHostBuilder)

    1.前言 ASP.NET Core应用程序可以配置和启动主机(Host).主机负责应用程序启动和生存期管理,配置服务器和请求处理管道.主机还可以设置日志记录.依赖关系注入和配置.而host主机又包括W ...

  8. Nmap强大在哪之主机发现

    1.概述 博主前段时间刚入坑渗透测试,随着学习的深入,越来越发现Nmap简直无所不能.今天先从主机发现功能入手分析. 2.Nmap主机发现 nmap --help #nmap帮助 3.参数分析 3.1 ...

  9. 工程师技术(三):独立Web站点的快速部署、虚拟Web主机的部署、配置网页内容访问、使用自定Web根目录、配置安全Web服务、部署并测试WSGI站点

    一.独立Web站点的快速部署 目标: 本例要求为 http://server0.example.com 配置Web站点,要求如下: 1> 从http://classroom/pub/materi ...

随机推荐

  1. XSS注入常用语句(整理)

    <script>alert('hello,gaga!');</script> //经典语句,哈哈! >"'><img src="javas ...

  2. 关于golang select的用法

    1 go的信道 1.1 什么是信道 信道可以理解为go协程之间进行通信的通道. 1.2 信道的声明 所有的信道都关联一个类型,一旦关联了类型,该信道就只能传输该类型的数据,传输其它类型的数据的话就是非 ...

  3. QButtonGroup

    单选按钮和多选按钮,存放进QButtonGroup中 QButtonGroup方法来实现分组:将相同功能的按键,设为一个分组,然后可以进行 单选 或 多选 或 互斥单选 QAbstractButton ...

  4. python文件打包/导入 .so 文件

    打包so文件 见: http://www.cnblogs.com/ke10/p/py2so.html 导入so文件 import sys sys.path.append(r'/home/project ...

  5. C++关于erase的复杂度(转载)

    被这个问题困扰了很多次,有必要整理一下. 当然最好的参考资料就是http://www.cplusplus.com/reference/set/set/erase/ 里的Complexcity部分了,但 ...

  6. STL容器概述

    STL容器 1.容器概述 1.1.容器分类 1.1.1.顺序容器:提供对元素序列的访问,顺序容器为元素连续分配内存或将元素组织为链表,元素的类型是容器成员value_type. 顺序容器 说明 vec ...

  7. 03-Django-models

    # Models 模型 - ORM - ObjectRelationMap : 把面向对象思想转换成关系数据库思想.操作上把类等价于表格 - 类对应表格 - 类中的属性对应表中的字段 - 在应用中的m ...

  8. Hive配置日志

    1. 重命名hive/conf文件夹下的hive-log4j 2. 修改hive.log.dir参数,如果不修改默认hive.log位于/tmp/{user}下面,一般来说使用在hive目录下自己创建 ...

  9. CF 937

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  10. eclipse多个项目提交到同一个仓库(码云)

    参考博客:Eclipse提交多个项目到同一个仓库 https://blog.csdn.net/qq_30764991/article/details/80379365 步骤一:码云建立个远程仓库 步骤 ...