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)
上一篇 2025年9月2日 下午5:01
下一篇 2025年9月2日 下午5:22


相关推荐

  • 收音机fm和am的区别是什么_FM收音机

    收音机fm和am的区别是什么_FM收音机1、频率区别FM=FrequencyModulation调频,微波;微波传输,信号质量高,传输成本低,发射功率小,覆盖范围小,受地理因素影响较大,一般作为城市广播的首选。比如你的家乡城市台,

    2022年8月6日
    9
  • 移动APP开发之技术选择

    移动APP开发之技术选择APP开发种类目前主流的APP主要为iOS版本和Android版本。早期APP的开发,两个版本需要分开独立进行,分别使用Objective-C/swift和Java语言。这些APP也称为NativeAPP,即原生系统。由于NativeAPP开发成本高、难度大,随着技术的发展,出现了Hybrid(混合)APP开发,即支持跨平台或支持原生+H5相结合的APP。除此之外,还有一种称为WebAp…

    2022年5月30日
    36
  • 用ajax写注册页面_jquery的ajax请求写法

    用ajax写注册页面_jquery的ajax请求写法<!DOCTYPEhtml><htmllang=”zh-CN”xmlns:th=”http://www.thymeleaf.org”><head><metacharset=”utf-8″/><title>XXXX</title><metaname=”viewport”co…

    2026年4月15日
    5
  • 线性判别分析(LDA)基本原理及实现

    线性判别分析(LDA)基本原理及实现前言在主成分分析 PCA 原理总结 机器学习 27 降维 之主成分分析 PCA 详解 中对降维算法 PCA 做了总结 这里就对另外一种经典的降维方法线性判别分析 LinearDiscri 简称 LDA 做一个总结 LDA 在模式识别领域 比如人脸识别 舰艇识别等图形图像识别领域 中有非常广泛的应用 因此我们有必要了解下它的算法原理 在学习 LDA 之前 有必要将其自然语

    2026年3月20日
    2
  • Java设计专题及高级导向「建议收藏」

    Java设计专题及高级导向「建议收藏」Java设计专题及高级导向

    2022年4月22日
    33
  • ant的安装和使用

    ant的安装和使用1.ant的安装1.1添加环境变量:ANT_HOME=D:\software\ant\apache-ant-1.10.1在path中添加:%ANT_HOME%\bin1.2测试是否安装成功

    2022年7月1日
    21

发表回复

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

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