from scapy.all import *
import optparse
import threading
import os

def scan(ip):
    pkt=IP(dst=ip)/TCP(flags='A')
    res=sr1(pkt,timeout=0.1,verbose=0)
    if res:
        print(ip,' is online')

def main():
    parser=optparse.OptionParser("%prog "+"-t <target> -f <filename>")
    parser.add_option('-t',dest='target',type='string',help='Target')
    parser.add_option('-f',dest='fil',type='string',help='Filename')
    (options,args)=parser.parse_args()
    target=options.target
    fil=options.fil
    if(target==None) and (fil==None):
        print('Please input target(-t) or file(-f)')
        exit(0)

    if target:
        iplist=target.split('.')
        ip=iplist[0]+'.'+iplist[1]+'.'+iplist[2]+'.'
        for t in range(1,255):
            ipt=ip+str(t)
            t=threading.Thread(target=scan,args=(ipt,))
            t.start()
    if fil:
        if os.path.exists(fil):
            with open(fil) as f:
                for i in f.readlines():
                    ipt=i.strip('\n')
                    t=threading.Thread(target=scan,args=(ipt,))
                    t.start()
        else:
            print('File is not exists!')
            exit(0)

if __name__=='__main__':
    main()

使用说明

程序开始

github:https://github.com/zmqq/pytools/tree/master/tcphost

 

Python3 小工具-TCP发现的更多相关文章

  1. Python3 小工具-TCP半连接扫描

    from scapy.all import * import optparse import threading def scan(ip,port): pkt=IP(dst=ip)/TCP(dport ...

  2. Python3 小工具-UDP发现

    from scapy.all import * import optparse import threading import os def scan(ip): pkt=IP(dst=ip)/UDP( ...

  3. python3 小工具

    扫描IP的端口是否开放:Porttest.py # -*- coding: utf-8 -*- import sys import os import socket #扫描 def scanport( ...

  4. ip地址查询python3小工具_V0.0.1

    看到同事在一个一个IP地址的百度来确认导出表格中的ip地址所对应的现实世界的地址是否正确,决定给自己新开一个坑.做一个查询ip“地址”的python小工具,读取Excel表格,在表格中的后续列输出尽可 ...

  5. Python写安全小工具-TCP全连接端口扫描器

    通过端口扫描我们可以知道目标主机都开放了哪些服务,下面通过TCP connect来实现一个TCP全连接端口扫描器. 一个简单的端口扫描器 #!/usr/bin/python3 # -*- coding ...

  6. Python3 小工具-僵尸扫描

    僵尸机的条件: 1.足够闲置,不与其他机器进行通讯 2.IPID必须是递增的,不然无法判断端口是否开放 本实验僵尸机选择的是Windows2003 from scapy.all import * im ...

  7. Python3 小工具-UDP扫描

    from scapy.all import * import optparse import threading def scan(target,port): pkt=IP(dst=target)/U ...

  8. Python3 小工具-MAC泛洪

    from scapy.all import * import optparse def attack(interface): pkt=Ether(src=RandMAC(),dst=RandMAC() ...

  9. Python3 小工具-ICMP扫描

    from scapy.all import * import optparse import threading import os def scan(ipt): pkt=IP(dst=ipt)/IC ...

随机推荐

  1. Context initialization failed org.springframework.beans.factory.BeanCreationException

    严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error cre ...

  2. 02 看懂Oracle执行计划

    看懂Oracle执行计划   最近一直在跟Oracle打交道,从最初的一脸懵逼到现在的略有所知,也来总结一下自己最近所学,不定时更新ing… 一:什么是Oracle执行计划? 执行计划是一条查询语句在 ...

  3. Magazine Ad CodeForces - 803D(二分 + 贪心,第一次写博客)

    Magazine Ad The main city magazine offers its readers an opportunity to publish their ads. The forma ...

  4. 竞赛题解 - Broken Tree(CF-758E)

    Broken Tree(CF-758E) - 竞赛题解 贪心复习~(好像暴露了什么算法--) 标签:贪心 / DFS / Codeforces 『题意』 给出一棵以1为根的树,每条边有两个值:p-强度 ...

  5. Filebeat使用模块收集日志

    1.先决条件 在运行Filebeat模块之前: 安装并配置Elastic stack 完成Filebeat的安装 检查Elasticsearch和Kibana是否正在运行,以及Elasticsearc ...

  6. 在tornado中使用异步mysql操作

    在使用tornado框架进行开发的过程中,发现tornado的mysql数据库操作并不是一步的,造成了所有用户行为的堵塞.tornado本身是一个异步的框架,要求所有的操作都应该是异步的,但是数据库这 ...

  7. 【淘宝客】PHPMailer-v6.0.5版 发送邮件dome

    话不多说,根据官方dome修改下,官方更新地址:https://github.com/PHPMailer/PHPMailer <?php use PHPMailer\PHPMailer\PHPM ...

  8. 【C】三目运算符(先是问号之后又是冒号的那个)

    // 看这个例子就可以懂了 a = b == c ? d : e ; //如果 b==c,执行 a=d //否则执行 a=e //为了方便阅读,也可以改成下方代码 a = (b == c) ? d : ...

  9. Git项目管理

    参考 参考书籍 <git学习指南> 参考网站 https://git-scm.com/ Git局限性讨论 高复杂度 两张图看懂集中式版本管理系统和分布式管理系统的区别-集中式vs分布式 g ...

  10. 两步搞定一台电脑同时开启多个tomcat

    1. 修改tomcat中的某些参数,为了避免启动tomcat时出现冲突,编辑bin/startup.bat, 在文件第一行添加如下两行(必须第一行才有效) SET JAVA_HOME=C:\webso ...