首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用python / layer2生成100%自定义python有效负载

使用python / layer2生成100%自定义python有效负载
EN

Stack Overflow用户
提问于 2019-03-28 04:55:07
回答 1查看 144关注 0票数 0

我想创建一个python3脚本,它使用无线活动连接(接口当前附加的bssid )发送一个100%自定义的第2层有效负载(或者换句话说,一个100%自定义的第3层或2.5层协议)。

我已经尝试了很多方法,使用如下所示的脚本:

代码语言:javascript
复制
from scapy.all import *
import os

interfaces = os.listdir('/sys/class/net')
interface = interfaces[1] # which is the wireless interface

send(Dot11(addr1 = 'aa:aa:aa:aa:aa:aa'), iface = str(interface)) # I pretend here to send an empty frame to addr1 destination, using the wireless card and the existing bssid on which i'm currently connected

我总是将目的MAC地址作为广播地址。当然,我不知道做我想做的事情的正确方式。

欢迎任何建议或澄清。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-07-01 23:32:39

答案是,关键是使用sendp而不是发送,例如IEEE1905以太网类型:

代码语言:javascript
复制
import os
from scapy.all import *

dest_MAC = aa:aa:aa:aa:aa:aa # the mac address you want to send it

interfaces = os.listdir('/sys/class/net') interface = interfaces[3] #select one interface from the array, it could be Ethernet or an existing Wireless STA connection

p = Ether(type=0x893a, dst = dest_MAC)/b"\x00\x00\x00" #we send just three "zero" bytes

sendp(p, iface=interface) #using sendp instead send, which is layer2 abstracted
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55386300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档