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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • golang 基础编程

    golang 基础编程

    2022年2月19日
    41
  • 实现一个div的拖拽效果_js如何实现拖拽和上下移动

    实现一个div的拖拽效果_js如何实现拖拽和上下移动公司要开一个技术分享会,给我们出了几个简单的题去实现,其中有如何实现表格中列之间的拖拽,我知道html5中有个新方法可以实现,但是没有认真学习,现在闲了去学学,发现关于drag和drop的文章有很多,

    2022年8月3日
    4
  • aircrack和reaver破解路由器PIN码

    aircrack和reaver破解路由器PIN码使用aircrack,寻找附近开启wps的路由器,邪恶……嘻嘻airmon-ng start wlan0airodump-ng mon0CH 11 ][ Elapsed: 36 s ][ 2012-12-18 04:46                                          BSSID              PWR  Beacons    #Data

    2022年5月5日
    107
  • 后台 管理 系统

    后台 管理 系统课程/视频管理系统:https://item.taobao.com/item.htm?spm=a2oq0.12575281.0.0.50111deb1nO3pa&ft=t&id=643539140484教务管理系统:https://item.taobao.com/item.htm?spm=a2oq0.12575281.0.0.50111deb1nO3pa&ft=t&id=643539140484成绩管理系统:https://item.taobao.com/item.h

    2022年4月25日
    42
  • Hadoop博文目录

    Hadoop博文目录

    2021年8月26日
    53
  • java实现简单的图书管理系统「建议收藏」

    java实现简单的图书管理系统「建议收藏」一、项目分布Book类:定义了书的一些属性(书名,作者,价格,分类,状态)并且写了属性的get、set方法Library类:写了登录函数(1、普通用户,2、管理员,3、退出系统),Person类:定义的人的属性(姓名,性别,年龄)并且写了属性的get、set方法,定义了一些书。operate接口:操作的接口,操作方法:查询/查阅,删除/借阅,增加/还书,显示书籍列表Root类:继承…

    2022年7月13日
    17

发表回复

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

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