僵尸机的条件:

1.足够闲置,不与其他机器进行通讯

2.IPID必须是递增的,不然无法判断端口是否开放

本实验僵尸机选择的是Windows2003

from scapy.all import *
import optparse

def is_zombie(target,zombie):
    pktz=IP(dst=zombie)/TCP(flags='SA')
    pktt=IP(src=zombie,dst=target)/TCP(flags='S')
    res1=sr1(pktz,timeout=1,verbose=0)
    send(pktt,verbose=0)
    res2=sr1(pktz,timeout=1,verbose=0)
    try:
        if res2[IP].id-2==res1[IP].id:
            print('It is a zombie.')
            return 1
        else:
            print('It isn\'t a zombie.')
            return 0
    except:
        print('It isn\'t a zombie.')

def scan(target,zombie,port):
    pktz=IP(dst=zombie)/TCP(flags='SA',dport=int(port))
    pktt=IP(src=zombie,dst=target)/TCP(flags='S',dport=int(port))
    start=sr1(pktz,timeout=1,verbose=0)
    send(pktt,verbose=0)
    end=sr1(pktz,timeout=1,verbose=0)
    if end[IP].id-2==start[IP].id:
        print(port,' is online')

def main():
    parser=optparse.OptionParser("%prog "+'-t <target> -z <zombie> -p <port>')
    parser.add_option('-t',dest='target',type='string',help='Target')
    parser.add_option('-z',dest='zombie',type='string',help='Zombie')
    parser.add_option('-p',dest='port',type='string',help='Port(eg:22,80    or  1-100)')
    (options,args)=parser.parse_args()
    target=options.target
    zombie=options.zombie
    if(target==None) or (zombie==None):
        print('Please input target(-t) and zombie(-z)!')
        exit(0)
    res=is_zombie(target,zombie)
    if res==1:
        if(',' in options.port):
            ports=str(options.port).split(',')
            if ports[0]==None:
                print('Please input port(-p)!')
                exit(0)
            for port in ports:
                scan(target,zombie,port)
        elif('-' in options.port):
            ports=str(options.port).split('-')
            if ports[0]==None:
                print('Please input port(-p)!')
                exit(0)
            for port in range(int(ports[0]),int(ports[1])):
                scan(target,zombie,port)
    else:
        pass

if __name__=='__main__':
    main()

使用说明

程序开始

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

 

Python3 小工具-僵尸扫描的更多相关文章

  1. Python3 小工具-UDP扫描

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

  2. Python3 小工具-ICMP扫描

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

  3. Python3 小工具-ARP扫描

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

  4. python3 小工具

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

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

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

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

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

  7. Python3 小工具-UDP发现

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

  8. Python3 小工具-TCP发现

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

  9. Python3 小工具-MAC泛洪

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

随机推荐

  1. Oracle 备份恢复实例

    Oracle 备份恢复实例:三思笔记 1 shutdown abort 系统归档模式,有备份 create table xx as select * from emp; update xx set e ...

  2. Swift_闭包

    Swift_闭包 点击查看源码 闭包优化 //闭包优化 func testClosures() { //函数做参数 排序 let names = ["XuBaoAiChiYu", ...

  3. c#(IronPython)调用Python方法

    直接一段代码演示 public void StartTCP() { ScriptEngine engine = Python.CreateEngine(); var paths = engine.Ge ...

  4. 汇编中PSP是什么?为什么一般cs比ds大10h

    一般来说,PSP是256个字节,当程度生成了可执行文件以后,在执行的时候,先将程序调入内存, 这个时候DS中存入程序在内存中的段地址,紧接着是程序的一些说明,比如说程序占用多大空间等 等,这就是PSP ...

  5. ABAP术语-SAP GUI for HTML

    SAP GUI for HTML 原文:http://www.cnblogs.com/qiangsheng/archive/2008/03/14/1104996.html An ITS impleme ...

  6. Linux在线安装jdk8,并配置环境变量

    1.创建相关目录:下载目录.安装目录 下载目录: cd / 2.下载jdk8到目录 下载前先跳转到下载目录,比如希望最后压缩包下载到/home/bak/下, 则先创建bak目录,命令如下: 注意:如果 ...

  7. Django在windows系统下安装详情

    1. Django 下载地址:https://www.djangoproject.com/download/ 2. 解压到跟python安装目录平级目录: 如下图: 3.通过cmd控制台安装djang ...

  8. 单文件版本的netframework的net core 2.1

    如果你还在用net4.5,如果你还在用netframework,又想使用netcore2.1的库或者功能,又觉得nuget动不动就好大,可以试试下面的这个. https://pan.baidu.com ...

  9. 搭建Jupyter Notebook服务器

    昨天发了Jupyter的使用,补一篇Jupyter服务器的搭建~ 一.搭建Jupyter 1.安装 使用virtualenv建虚拟环境.在虚拟环境中安装jupyter.matplotlib等等需要的库 ...

  10. django配置虚拟环境-1

    目录 安装python 使用venv虚拟环境 使用Virtualenv虚拟环境 ### Windows安装 方案一 方案二 Linux安装 其他命令 安装django 安装python https:/ ...