僵尸机的条件:

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. 严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component

    自己写了个最简单的springMVC项目练练手,没有用maven,在WebContent中新建了lib文件夹,将jar包复制到这里面,然后add to build path到项目里. 启动Tomcat ...

  2. 【最新】LuaJIT 32/64 位字节码,从编译到使用全纪录

    网上关于 LuaJIT 的讨论,已经显得有些陈旧.如果你对 LuaJIT 编译 Lua 源文件为具体的 32位或64位字节码,极其具体使用感兴趣的话,不妨快速读一下这篇文章.此文章针对尝试在 iOS ...

  3. 学习笔记 - 中国剩余定理&扩展中国剩余定理

    中国剩余定理&扩展中国剩余定理 NOIP考完回机房填坑 ◌ 中国剩余定理 处理一类相较扩展中国剩余定理更特殊的问题: 在这里要求 对于任意i,j(i≠j),gcd(mi,mj)=1 (就是互素 ...

  4. SQL:登录、连接数据库基本操作

    使用MySQL 登录.连接数据库 win+R打开控制台,cmd进入控制台,输入mysql -u root -p,后输入密码,进入数据库: 首先可以查看原有的数据库,输入 show databases; ...

  5. Ldap实现AD域认证

    1.java Ldap基础类 package com.common; import java.io.FileInputStream; import java.io.IOException; impor ...

  6. 【Spark】算子

    1. mapWith mapWith(i => i*10)((a,b) => b+2) (拿到分区号)(a是每次取到的RDD中的元素,b接收i*10的结果) 2. flatMapWith ...

  7. spark sql cache时发现的空字符串问题

    博客园首发,转帖请注明地址:https://www.cnblogs.com/tzxxh/p/10267202.html 图一 图1未做cache,直接过滤expression列的 null 和空字符串 ...

  8. centos7.3 vsftpd 多用户配置

    1. 安装vsftpd及pam认证服务软件 yum install vsftpd* -y yum install pam* libdb-utils libdb* --skip-broken -y #设 ...

  9. python逻辑判断 () not and or

    python逻辑判断 () not and or 优先级关系:()>not>and>or 运算符示意 not –表示取反运算. and –表示取与运算. or –表示取或运算. or ...

  10. 牛客小白月赛4-E-浮点数输出 字符串

    #include <bits/stdc++.h> int main() { ]; scanf("%s",a); printf("%s\n",a); ...