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

def scan(ipt):
    pkt=IP(dst=ipt)/ICMP()
    res=sr1(pkt,timeout=0.1,verbose=0)
    if res:
        print(ipt,' 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/icmpscan

 

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

  1. Python3 小工具-UDP扫描

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

  2. Python3 小工具-僵尸扫描

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

  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 小工具-MAC泛洪

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

  8. Python3 小工具-UDP发现

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

  9. Python3 小工具-TCP发现

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

随机推荐

  1. stl学习之namespace

    一.为什么需要命名空间(问题提出) 命名空间是ANSIC++引入的可以由用户命名的作用域,用来处理程序中常见的同名冲突. 在 C语言中定义了3个层次的作用域,即文件(编译单元).函数和复合语句.C++ ...

  2. systemd的新特性及常见的systemd unit类型分析

    systemd概述 )systemd是一种新的linux系统服务管理器,用于替换init系统,能够管理系统启动过程和系统服务,一旦启动起来,就将监管整个系统.在centos7系统中,PID1被syst ...

  3. 【Java】abstract,final,static,private,protected,public的区别

    [abstract]抽象的 1. abstract可以修饰类和成员方法,被abstract修饰的类称为抽象类,被abstract修饰成员方法叫抽象方法.抽象类不一定有抽象方法,但拥有抽象方法的类一定是 ...

  4. 帝国cms教程父栏目和子栏目都能在当前栏目高亮

    首先在/e/class/userfun.php这个文件里面加上下面代码.上面父栏目的,下面子栏目的.红色代表css样式.自定义吧 function currentPage($classid,$this ...

  5. Python3练习:对员工信息文件,实现增删改查操作

    1.练习要求: 2.数据文件(data_staff.txt) 1,Alex Li,22,13651054684,运维,2013-02-04 2,Jack Wang,20,13312331232,HR, ...

  6. web頁面優化以及SEO

    轉載:https://blog.csdn.net/xustart7720/article/details/79960591 浏览器访问优化浏览器请求处理流程如下图: Etag:實體標籤.ETag是HT ...

  7. Go语言入门(一)特性、安装、环境搭建、第一个程序等

    Go语言是谷歌推出的一种全新的编程语言,可以在不损失应用程序性能的情况下降低代码的复杂性.谷歌首席软件工程师罗布派克(Rob Pike)说:我们之所以开发Go,是因为过去10多年间软件开发的难度令人沮 ...

  8. GeekOS课程设计-project1

    参考:https://blog.csdn.net/qq_35008279/article/details/78984561?tdsourcetag=s_pcqq_aiomsg 补充:如果按照参考博客还 ...

  9. Git Status 中文乱码解决

    现象: jb@H39:~/doc$ git statusOn branch masterYour branch is up-to-date with 'origin/master'. Untracke ...

  10. angularjs transitions

    http://angular-transitions.mgechev.com/#/view/page1 https://scotch.io/tutorials http://stackoverflow ...