Scapy常用操作和命令(2)

Scapy常用操作和命令(2)send 方法用来在 3 层发送报文 send IP dst 1 2 3 4 ICMP Sent1packets 使用 loop 参数循环发送 Ctrl C 终止 inter 表示发送时间间隔 send IP ICMP loop 1 inter 0 5 CSent



send方法用来在3层发送报文

>>> send(IP(dst=”1.2.3.4″)/ICMP())

.

Sent 1 packets.

使用loop参数循环发送(Ctrl+C终止),inter表示发送时间间隔

>>> send(IP()/ICMP(),loop=1,inter=0.5)

……^C

Sent 6 packets.

 

sendp方法用来在2层发送报文

>>> sendp(Ether()/IP(dst=”1.2.3.4″,ttl=(1,4)), iface=”eth1″)

….

Sent 4 packets.

>>> sendp(“I’m travelling on Ethernet”, iface=”eth1″, loop=1, inter=0.2)

…………….^C

Sent 16 packets.

 

sr1方法在3层发送报文并返回第一个响应报文

>>> ans=sr1(IP()/ICMP())

Begin emission:

Finished to send 1 packets.

……………………………………………………………………………………….^C

Received 100 packets, got 0 answers, remaining 1 packets

>>> ans=sr1(IP(dst=”www.baidu.com”)/ICMP())

Begin emission:

….Finished to send 1 packets.

..*

Received 7 packets, got 1 answers, remaining 0 packets

 

sr方法在3层发送报文并返回所有响应报文

>>> ans, unans=sr(IP(dst=”www.baidu.com”, src=”172.31.100.0/24″)/ICMP())

Begin emission:

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………*…………………………………………………………*………………………………………………………………………………………………………Finished to send 256 packets.

……………………………………………………………………………………………………………………………………………………………………………………………………………….^C

Received 714 packets, got 2 answers, remaining 254 packets

>>> ans

<Results: TCP:0 UDP:0 ICMP:2 Other:0>

>>> unans

<Unanswered: TCP:0 UDP:0 ICMP:254 Other:0>

 

srpsrp1方法为srsr1方法对应的2层方法

>>> ans, unans=srp(Ether()/IP(dst=”www.baidu.com”, src=”172.31.100.0/24″)/ICMP())

.Begin emission:

………………………………………………………………………………………………………………………………………………………………………………………………………………………….*..Finished to send 256 packets.

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………..^C

Received 568 packets, got 1 answers, remaining 255 packets

 

srloop方法循环发送3层报文并打印结果

>>> ans, unans=srloop(IP(dst=”www.baidu.com”)/ICMP())

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

RECV 1: IP / ICMP 119.75.218.70 > 172.31.100.222 echo-reply 0 / Padding

^C       

Sent 8 packets, received 8 packets. 100.0% hits.

>>> ans

<Results: TCP:0 UDP:0 ICMP:8 Other:0>

 

srploop方法循环发送2层报文并打印结果

>>> ans, unans=srloop(Ether()/IP(dst=”www.baidu.com”)/ICMP())

WARNING: Mac address to reach destination not found. Using broadcast.

fail 1: Ether / IP / ICMP 172.31.100.222 > 119.75.217.109 echo-request 0

WARNING: Mac address to reach destination not found. Using broadcast.

fail 1: Ether / IP / ICMP 172.31.100.222 > 119.75.217.109 echo-request 0

WARNING: Mac address to reach destination not found. Using broadcast.

fail 1: Ether / IP / ICMP 172.31.100.222 > 119.75.217.109 echo-request 0

WARNING: Mac address to reach destination not found. Using broadcast.

fail 1: Ether / IP / ICMP 172.31.100.222 > 119.75.217.109 echo-request 0

WARNING: Mac address to reach destination not found. Using broadcast.

fail 1: Ether / IP / ICMP 172.31.100.222 > 119.75.217.109 echo-request 0

WARNING: Mac address to reach destination not found. Using broadcast.

send…  

Sent 5 packets, received 0 packets. 0.0% hits.

 

srflood方法使用flooding的方式快速发包并接收回包

>>> ans, unans=srflood(IP(dst=”www.baidu.com”)/ICMP())

IP / ICMP 119.75.217.109 > 172.31.100.222 echo-reply 0 / Padding

IP / ICMP 119.75.217.109 > 172.31.100.222 echo-reply 0 / Padding

IP / ICMP 119.75.217.109 > 172.31.100.222 echo-reply 0 / Padding

IP / ICMP 119.75.217.109 > 172.31.100.222 echo-reply 0 / Padding

IP / ICMP 119.75.217.109 > 172.31.100.222 echo-reply 0 / Padding

IP / ICMP 119.75.217.109 > 172.31.100.222 echo-reply 0 / Padding

……

>>> ans

<Results: TCP:0 UDP:0 ICMP:1 Other:0>

>>> unans

<Unanswered: TCP:0 UDP:0 ICMP:255 Other:0>

>>> unans.summary()

Ether / IP / ICMP 172.31.100.84 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.78 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.71 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.104 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.98 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.64 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.3 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.36 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.117 > 119.75.218.70 echo-request 0

Ether / IP / ICMP 172.31.100.30 > 119.75.218.70 echo-request 0

……

 

发包的方法可以使用下面的3个参数

inter:定义发包时相邻两个包的时间间隔(单位s

retry:定义重传次数(可正可负,例如3表示重传3次,-3表示scapy会尝试依次重传unanswered直到没有任何新的answer报文,但是最多重试3次)

timeout:定义认为丢包的timeout时间(单位s

>>> ans, unans = sr(IP(src=”172.31.100.149/30″, dst=”www.baidu.com”)/TCP(dport=80), inter=0.5, retry=-3, timeout=1)

.Begin emission:

………………………………………………………………………………………………………………………………………………………………*……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………..Finished to send 4 packets.

……………………………………………………………………………………………………………………………………………………………………………………………………Begin emission:

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………Finished to send 3 packets.

……………………………………………………………………………………………………………………………………………………………………………………………………………Begin emission:

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………Finished to send 3 packets.

……………………………………………………………………………………………………………………………………………………………………………………………….Begin emission:

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………Finished to send 3 packets.

……………………………………………………………………………………………………………………………………………………………………………………………………

Received 2393 packets, got 1 answers, remaining 3 packets

 

 

fuzz方法可以修改对象中不参与计算的属性的默认值(例如校验和)为一个随机值,通过fuzz方法可以在循环中快速构建大量随机报文。

>>> send(IP(dst=”target”)/fuzz(UDP()/NTP(version=4)),loop=1)

…………….^C

Sent 16 packets.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232892.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • OPKG命令执行过程分析

    OPKG命令执行过程分析一、简介Opkg是一个基于ipkg的轻量级的软件包管理系统,主要用于嵌入式系统,目前应用opkg的有OpenWRT和OpenEmbedded。1Opkg的详细使用方法可以参考OpenWRT的WIKI页面2,不再赘述,本文将重点解释opkg的工作原理。Opkg的源代码可以在GoogleCode3或YoctoProject4上找到。Opkg的版本目前到了0.3.05,我使用的

    2022年6月6日
    41
  • 考研数学二常用公式_考研数学写公式有分吗

    考研数学二常用公式_考研数学写公式有分吗面(体)积公式一元二次方程基础极坐标方程与直角坐标转换切线与法线方程因式分解公式阶乘与双阶乘函数的奇偶性排列组合等差数列等比数列常用数列前n项和不等式三角函数公式诱导公式平方关系两角和与差的三角函数积化和差公式和差化积公式倍角公式半角公式万能公式其他公式反三角函数恒等式极限相关公式数列极限递推式重要极限公式常用等价无穷小1^∞型导数相关公式导数定义微分定义连续,可导及可微关系一元函数多元函数导数四则运算复合函数求导反函数求导参数方程

    2022年8月11日
    25
  • python利用cookie登录(python爬虫教程pdf)

    http://blog.csdn.net/pipisorry/article/details/47948065实战1:使用cookie登录哈工大ACM网站获取网站登录地址http://acm.hit.edu.cn/hoj/system/login查看要传送的post数据user和passwordCode:#!/usr/bin/envpython#-*-

    2022年4月17日
    47
  • 2019最新版Eclipse下载与安装

    2019最新版Eclipse下载与安装首先:eclispe提供了两种下载方式。一种是下载安装程序,下载后直接运行安装程序,根据安装程序的提示选择安装选项并完成安装;一种是下载eclispe压缩包,下载后手动解压即可。下面分别介绍两种安装方式。一、首先进入Eclipse下载页面1.下载地址:https://www.eclipse.org/downloads/二、安装程序的方式如果是64位的Windows操作系统,可以直接单击图…

    2022年5月29日
    151
  • SQL中的聚合函数使用总结

    SQL中的聚合函数使用总结一般在书写sql的是时候很多时候会误将聚合函数放到where后面作为条件查询,事实证明这样是无法执行的,执行会报【此处不允许使用聚合函数】异常。为什么会报异常呢?其原因很简单:having放在groupby的后面 groupby后面只能放非聚合函数的列 where子句的作用是在对查询结果进行分组前,将不符合where条件的行去掉,即在分组之前过滤数据,条件中不能包含聚组函数,使…

    2022年6月21日
    33
  • 邮箱正则表达式

    邮箱正则表达式正则提取国内外所有的邮箱经过测试准确率100%python代码块res=re.search(r’\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,8}\b’,description)ifres:emailAddress=res.group()else:emailAddr…

    2022年6月15日
    29

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号