方法一: #coding=utf-8
import urllib2
import threading
from time import ctime,sleep
print "Start-Time : %s" %ctime()
f = open("ip.txt","r")
lines = f.readlines()
for line in lines:
    url = 'http://'+line.strip('\n')+':10000'
    try:
        r = urllib2.urlopen(url,timeout=1)
        if r.getcode() == 200:
            print url
            infile = open("infiles.txt","a")
            infile.write(url+'\n')
            infile.close()
    except Exception as e :
        print e
f.close()
print "Stop--Time : %s" %ctime()  方法二:
#coding=utf-8
#port scan
import os
import subprocess
ip = open('ip.txt')
data = ip.readlines()
for line in data:
        line = line.strip()
        cmd = '/root/Desktop/tools/masscan/bin/masscan -p10000 %s' %line
        for i in os.popen(cmd):
                f = open("abc.txt","a")
                f.write(i)
                f.close()
ip.close() 批量探测域名列表中指定端口的开放情况(域名列表,只包含域名,例如www.baidu.com 而非http://www.baidu.com/pic)扫描完毕后在当前目录生产指定端口的文本文件。#coding=utf8
import os
import sys
import Queue
import socket
import getopt
import logging
import requests
import threading logging.basicConfig(
    level=logging.WARNING,
    format="[%(asctime)s] %(message)s"
) def test_port(host, port):
    logging.warning("trying %s" % host)     try:
        ip = socket.gethostbyname(host)
    except:
        pass
    else:
        if ip:
            try:
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                indicator = sock.connect_ex((ip, port))
            except:
                if sock:
                    sock.close()
            else:
                if indicator == 0:
                    sock.close()
                    with open(("%d.txt" % port), "a") as f:
                        f.write("%s:%d (%s) open!!\n" % (ip, port, host)) class BatchThreads(threading.Thread):
    def __init__(self, queue, _port):
        super(BatchThreads, self).__init__()
        self.queue = queue
        self.port = _port     def run(self):
        while True:
            if self.queue.empty():
                break
            else:
                try:
                    url = self.queue.get()
                    #struts2_all(url)
                    test_port(url, self.port)
                except:
                    break def batch_queue(_port, _file, _queue, _thread_number):
    with open(_file) as f:
        urls = [line.strip() for line in f.readlines()]
    urls = set(filter(lambda url: url and not url.startswith("#"), urls))     if urls:
        # with open("urls.txt", "w") as ft:
        #     ft.write("\n".join(urls))         for url in urls:
            queue.put(url)         logging.warning("total %d" % queue.qsize())         if _thread_number > (queue.qsize() / 2):
            _thread_number = queue.qsize() / 2         for _ in xrange(_thread_number):
            threads.append(BatchThreads(_queue, _port))         for t in threads:
            t.start()
        for t in threads:
            t.join() def usage():
    print '''Usage: python %s [option] All Struts2 Vulnerable Test -h         scan a single host
-f         scan from a file
-p         port
    ''' % os.path.basename(sys.argv[0]) if __name__ == '__main__':
    global threads
    threads = []
    queue = Queue.Queue()
    thread_number = 100
    port = 8080
    filename = ''
    target = ''
    if not len(sys.argv[1:]):
        exit(usage())     try:
        opts, args = getopt.getopt(sys.argv[1:], 'u:f:p:')
    except getopt.GetoptError as err:
        exit(usage())
    else:
        for name, value in opts:
            if name == '-u':
                target = value
                #struts2_all(value)
   
            if name == '-p':
                port = int(value)
            if name == '-f':
                filename = value
        if target:
            test_port(target,port)
        if filename :            batch_queue(port,filename, queue, thread_number)     

全网扫描扫描10000端口后的优化脚本&域名列表指定端口的批量测试的更多相关文章

  1. PHP微信支付开发之扫描支付(模式二)后如何回调

    其实在写这篇文章的时候感觉自己已经落伍了,不过笔者在百度上搜索"微信支付开发之扫描支付(模式二)后如何回调"寻找答案时,发现依旧有很多朋友没有解决这个问题,所以就把自己的解决思路分 ...

  2. Centos 6.4 x86_64 最小化安装后的优化——还需要整理

      Centos 6.4 x86_64 最小化安装后的优化   购买了服务器以后要做的第一件事就是安装操作系统了,这里推荐安装 Centos 6.4 x86_64,安装系统时要选择最小化安装(不需要图 ...

  3. 修改mysql端口后重启mysql报错:Can't start server: Bind on TCP/IP port. Got error...n denied

    1:错误信息:如下 [root@host ~]# systemctl status mariadb ● mariadb.service - MariaDB database server Loaded ...

  4. centos7虚拟机开启端口后 外部不能访问的问题

    转载 https://blog.csdn.net/u012045045/article/details/104219823 虚拟机新开了5005端口,系统内部是显示开了的(wget 192.168.4 ...

  5. scp命令需要指定端口时要紧跟在scp后

      问题来源:我本地是Ubuntu操作系统,有时需要更新一些文件到服务器.但是,为了安全起见我们都是将服务器的sshd端口修改的,通常不使用默认的22号端口. 如果我们使用scp命令时:scp upl ...

  6. 使用telnet测试指定端口的连通性

    大家好,我是良许. 大家知道,telnet 是一个阉割版的 ssh ,它数据不加密,数据容易被盗窃,也容易受中间人攻击,所以默认情况下 telnet 端口是必须要被关闭的. telnet为用户提供了在 ...

  7. iptables/mysql设置指定主机访问指定端口

    本周,运维告知部署的服务被扫描发现漏洞,涉及的软件分别为mysql,ZooKeeper与Elasticsearch. 因为最近任务繁重,人力资源紧张,因此无法抽出更多时间调整代码,添加权限认证. 与软 ...

  8. linux系统最小化安装后的初始化脚本

    作为运维人员,经常会初始化系统,系统在安装过程中基本都会选择最小化安装,这样安装好的系统里会缺少很多环境. 下面分享一个系统安装后的初始化脚本: #!/bin/bash #系统时最小化安装的,这里要安 ...

  9. Windows2008R2 一键安全优化脚本

      ::author vim ::QQ 82996821 ::filename Windows2008R2_safe_auto_set.bat   :start @echo off color 0a ...

随机推荐

  1. 【poj2828】Buy Tickets

    Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get ...

  2. storyboard自动布局时,代码修改 constraint 的值,没有反应

    从 width equalto 其他控件的 width   到  当前控件固定的 width, 再到不固定当前控件的 width, 只固定当前控件的 trailing 是一个不错的思想.

  3. LVS + KEEPAlived 配置 DIR模式

    1 .1 Lvs LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统.本项目在1998年5月由章文嵩博士成立,是中国国内最早出现的自由软件项目 ...

  4. jQuery延迟加载(懒加载)插件 – jquery.lazyload.js

    引入:<script type="text/javascript" src="${base}/resources/shop/js/jquery.lazyload.j ...

  5. javascript使用两个逻辑非运算符(!!)的原因

    javascript使用两个逻辑非运算符(!!)的原因: 在有些代码中可能大家可能会注意到有些地方使用了两个逻辑非运算符,第一感觉就是没有必要,比如操作数是true的话,使用两个逻辑非的返回值还是tr ...

  6. 使用explain查看mysql查询执行计划

    explain语句: 字段解释: type:     all(全表扫描)     ref() possible_keys:     预测使用什么列做为索引 key:     实际使用的key     ...

  7. PLSQL Developer注册码

    Product Code:4t46t6vydkvsxekkvf3fjnpzy5wbuhphqzserial Number:601769password:xs374ca

  8. HTML5标签简化写法

    基本页面格式 <!DOCTYPE> <html> <head> <meta charset="utf-8" /> <title ...

  9. hdu N皇后问题

    此题是很基本的dfs的题目 ,但是要打表,否则会超时. 这题的思路就是从第一行一直放到第n行,因此行方面的判断就可以省略了.因此只要判断列方面和斜线方面是否满足条件,列方面用一个vis数组来记录是否已 ...

  10. C++静态成员和静态成员函数

    一:静态数据成员: 类体中的数据成员的声明前加上static关键字,该数据成员就成为了该类的静态数据成员.和其他数据成员一样,静态数据成员也遵守public/protected/private访问规则 ...