from scapy.all import *
import optparse
import threading

def scan(ip,port):
    pkt=IP(dst=ip)/TCP(dport=int(port))
    res=sr1(pkt,timeout=0.1,verbose=0)
    try:
        if int(res[TCP].flags)==18:
            print(port,' is open')
    except:
        pass

def main():
    parser=optparse.OptionParser('%prog '+"xxx")
    parser.add_option('-t',dest='target',type='string',help='Target')
    parser.add_option('-p',dest='port',type='string',help='Port(eg:22,80    1-500)')
    (options,args)=parser.parse_args()
    target=options.target
    if(',' in options.port):
        ports=str(options.port).split(',')
        if ((target==None) or (ports[0]==None)):
            print('Please input target(-t) and port(-p)!')
            exit(0)
        for port in ports:
            t=threading.Thread(target=scan,args=(target,port))
            t.start()
    elif('-' in options.port):
        ports=str(options.port).split('-')
        for port in range(int(ports[0]),int(ports[1])):
            t=threading.Thread(target=scan,args=(target,port))
            t.start()

if __name__=='__main__':
    main()

使用说明

程序开始

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

Python3 小工具-TCP半连接扫描的更多相关文章

  1. Python3 小工具-TCP发现

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

  2. python3 小工具

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

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

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

  4. Python3 小工具-僵尸扫描

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

  5. Python3 小工具-UDP扫描

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

  6. Python3 小工具-ICMP扫描

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

  7. Python3 小工具-ARP扫描

    from scapy.all import * import optparse import threading import os def scan(ipt): pkt=Ether(dst='ff: ...

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

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

  9. Python3 小工具-UDP发现

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

随机推荐

  1. 浅谈Jquery和常用框架Vue变化

    区别 Vue数据与视图的分离 Vue数据驱动视图 Jquery 简单示例: <!DOCTYPE html> <html lang="en"> <hea ...

  2. js实现点击按钮可实现编辑

    <script type="text/javascript">//修改密码//抓取到的数据 function edit() { document.getElementB ...

  3. Qt5连接Mysql环境配置

    已安装的环境:Mysql5.7 64bit ,Qt5.12 64bit. 到mysql官方下载mysql5.7 64bit的压缩包,解压,复制下图框内四个文件. 将四个文件复制到Qt安装目录下bin目 ...

  4. chromium之at_exit

    // This class provides a facility similar to the CRT atexit(), except that // we control when the ca ...

  5. springboot-自定义起步依赖

    自定义起步依赖步骤: 1.  添加configuration注解文件 -          指定什么情况下加载配置 -          使用enableconfigurationProperties ...

  6. Jquery复选框的全选全不选及选择所有复选框实现全选的复选框

    Jquery代码 $(function () { $(":checkbox.parentfunc").click(function () { //如何获取被点击的那个复选框 $(t ...

  7. JSP工作流程

    情况1:第一次请求一个页面 情况2:该页虽然是再次请求,但已经过修改 情况3:该页面是再次请求且未被修改

  8. html5 video获取当前时间和视频总时间长度

    html: <video id="video-active" class="video-active" width="640" hei ...

  9. react-router 4.0版本使用笔记

    react-router 4变化还是挺大的,看网上很多人遇到问题,都是基本用法的改变,所以这里记录一下. http://www.jianshu.com/p/d6727e8d81c4 1.react-r ...

  10. 基于Geomesa服务查询轨迹数据无法根据空间和时间范围进行结果查询

    一.Geomesa - QuickStart(教程工程包)   百度网盘下载地址:geomesa-tutorials-master.7z 二.解压后,IDEA编译如下 百度网盘下载地址:IDEA201 ...