cmd_icmp.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:habu 作者: portantier 项目源码 文件源码
def cmd_icmp(ip, verbose):

    conf.verb = False

    #pkts = IP(dst=ip) / TCP(flags=(0, 255), dport=port)
    pkt = IP(dst=ip) / ICMP()# , proto=(0, 255)) # / TCP(flags=(0, 255), dport=port)


    messages = [
        (8, 0),  # echo request
        (13, 0), # timestamp
        (15, 0), # info request
        #(), #
        #(), #
    ]

    #print(pkts.summary())
    #print(pkts.show2())

    #print(icmpcodes)

    for itype, icode in messages:
        pkt[ICMP].type = itype
        pkt[ICMP].code = icode
        ans = sr1(pkt, timeout=0.2)
        if ans:
            print(ans.show())
    #    for icode in range(0, 256):
    #        print(itype, icode)
        else:
            print("NOT ANSWER!!!")

    out = "{:>8} -> {:<8}"



    '''
    for pkt in pkts:
        #if not flags or all(i in pkt.sprintf(r"%TCP.flags%") for i in flags):
        print(pkt.show2())
        ans = sr1(pkt, timeout=0.2)
        if ans:
            #if not rflags or all(i in ans.sprintf(r"%TCP.flags%") for i in rflags):
            #print(out.format(pkt.sprintf(r"%TCP.flags%"), ans.sprintf(r"%TCP.flags%")))
            print(ans.show())
    '''

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号