基本命令

ls()

List all available protocols and protocol options

lsc()

List all available scapy command functions

conf

Show/set scapy configuration parameters

生成数据包

# Setting protocol fields
>>> ip=IP(src="10.0.0.1")
>>> ip.dst="10.0.0.2"
# Combining layers
>>> l3=IP()/TCP()
>>> l2=Ether()/l3
# Splitting layers apart
>>> l2.getlayer(1)
<IP frag=0 proto=tcp |<TCP |>>
>>> l2.getlayer(2)
<TCP |>

显示数据包

# Show an entire packet
>>> (Ether()/IPv6()).show()
###[ Ethernet ]###
dst= ff:ff:ff:ff:ff:ff
src= 00:00:00:00:00:00
type= 0x86dd
###[ IPv6 ]###
version= 6
tc= 0
fl= 0
plen= None
nh= No Next Header
hlim= 64
src= ::1
dst= ::1
# Show field types with default values
>>> ls(UDP())
sport : ShortEnumField = 1025 (53)
dport : ShortEnumField = 53 (53)
len : ShortField = None (None)
chksum : XShortField = None (None)

指定地址和值(Specifying Addresses and Values)

指定IP值 Explicit IP address (use quotation marks)

>>> IP(dst="192.0.2.1")

指定域名 DNS name to be resolved at time of transmission

>>> IP(dst="example.com")
# IP network (results in a packet template)
>>> IP(dst="192.0.2.0/24")

随机生成ip和mac Random addresses with RandIP() and RandMAC()


>>> IP(dst=RandIP())
>>> Ether(dst=RandMAC())

指定TTL范围 Set a range of numbers to be used (template)

>>> IP(ttl=(1,30))
# Random numbers with RandInt() and RandLong()
>>> IP(id=RandInt())

发送包(Sending Packets)

send(pkt, inter=0, loop=0, count=1, iface=N)

发送三层包(Send one or more packets at layer three)

sendp(pkt, inter=0, loop=0, count=1, iface=N)

发送二层包(Send one or more packets at layer two)

sendpfast(pkt, pps=N, mbps=N, loop=0, iface=N)

Send packets much faster at layer two using tcpreplay

>>> send(IP(dst="192.0.2.1")/UDP(dport=53))
.
Sent 1 packets.
>>> sendp(Ether()/IP(dst="192.0.2.1")/UDP(dport=53))
.
Sent 1 packets.

发送和接受包(Sending and Receiving Packets)

sr(pkt, filter=N, iface=N), srp(…)

Send packets and receive replies

sr1(pkt, inter=0, loop=0, count=1, iface=N), srp1(…)

Send packets and return only the first reply

srloop(pkt, timeout=N, count=N), srploop(…)

Send packets in a loop and print each reply

>>> srloop(IP(dst="packetlife.net")/ICMP(), count=3)
RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140
RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140
RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140

嗅探包(Sniffing Packets)

sniff(count=0, store=1, timeout=N)

Record packets off the wire; returns a list of packets when stopped

# Capture up to 100 packets (or stop with ctrl-c)
>>> pkts=sniff(count=100, iface="eth0")
>>> pkts
<Sniffed: TCP:92 UDP:7 ICMP:1 Other:0>

python scapy的使用总结的更多相关文章

  1. python scapy的用法之ARP主机扫描和ARP欺骗

    python scapy的用法之ARP主机扫描和ARP欺骗 目录: 1.scapy介绍 2.安装scapy 3.scapy常用 4.ARP主机扫描 5.ARP欺骗 一.scapy介绍 scapy是一个 ...

  2. 从Linux内核角度看中间人攻击(ARP欺骗)并利用Python scapy实现

    邻居子系统与ARP协议 邻居子系统的作用就是将IP地址,转换为MAC地址,类似操作系统中的MMU(内存管理单元),将虚拟地址,转换为物理地址. 其中邻居子系统相当于地址解析协议(IPv4的ARP协议, ...

  3. [源码]python Scapy Ftp密码嗅探

    [源码]python Scapy Ftp密码嗅探 原理很简单,FTP密码明文传输的 截取tcp 21端口User和Pass数据即可 Scapy框架编译程序较大(一个空程序都25M),所以就不提供exe ...

  4. 利用python scapy包进行抓包发包与ARP扫描

    小技巧 通过在交互式的python解释器下,可以通过help()函数查看函数或模块的用途. dir() 函数不带参数时,返回当前范围内的变量.方法和定义的类型列表:带参数时,返回参数的属性.方法列表 ...

  5. Python——scapy模块实现tcp探测目标服务器路由轨迹

      scapy模块的安装 484 yum install tcpdump graphviz ImageMagick -y 485 wget http://www.secdev.org/projects ...

  6. Python scapy 实现一个简易 arp 攻击脚本

    原文链接:http://www.jianshu.com/p/df5918069612 scapy 是 python 写的一个功能强大的交互式数据包处理程序,可用来发送.嗅探.解析和伪造网络数据包,常常 ...

  7. python scapy 网卡发包

    from scapy.all import * pkt = Ether(src='11:22:33:44:55:77', dst='11:22:33:44:55:66')/ARP(op="w ...

  8. python scapy 网卡抓包

    首先需要安装scapy包,点击下载 from scapy.all import * def pack_callback(packet): print packet.show() if packet[' ...

  9. python scapy dns 包字段解析

    qr:   0表示查询报文,1表示响应报文opcode: 通常值为0(标准查询),其他值为1(反向查询)和2(服务器状态请求).aa: 表示授权回答(authoritative answer)tc: ...

随机推荐

  1. liunx查看日志 | 最实用命令和方法

    1.业务系统访问量不是很大的时候,使用这个,有bug的地方操作下,直接看最后操作的日志 tail  -fn100  catalina.log   查询日志尾部最后100行的日志,并且随文件;   2. ...

  2. Zabbix日志监控插件

    #!/usr/bin/env python # coding:utf-8 import re import os import sys import logging logging.basicConf ...

  3. Unity 简记(1)--TileMap

    ## Tilemap是unity中自带的快速构建2D场景的工具,优点是省时省力, 1 使用方法 在场景创建一个Tilemap 打开TilePalette ​ 3.创建一个新的Palette,将地图切割 ...

  4. 斐波那契数列的实现(C语言)

    int fibonacci(int positon){ if(position==1||position==2){ return 1; } return fibonacci(position-1)+f ...

  5. 2019年PHP面试题附答案(实战经验)

    出于一些原因近期做了一次工作变动,在职交接近一个半月时间大概面试了十五家公司,并且得到了自己比较满意的offer,最后基本上无缝衔接了新工作.总体来说,虽然准备的很充分,但面试期间还是暴露了许多问题, ...

  6. hdu 1530 Maximum Clique (最大包)

    Maximum CliqueTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. nyoj 596-谁是最好的Coder (greater, less)

    596-谁是最好的Coder 内存限制:64MB 时间限制:1000ms 特判: No 通过数:15 提交数:28 难度:0 题目描述: 计科班有很多Coder,帅帅想知道自己是不是综合实力最强的co ...

  8. 力扣(LeetCode)找不同 个人题解

    给定两个字符串 s 和 t,它们只包含小写字母. 字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母. 请找出在 t 中被添加的字母. 示例: 输入: s = "abcd&quo ...

  9. 阿里云ECS服务器部署HADOOP集群(三):ZooKeeper 完全分布式集群搭建

    本篇将在阿里云ECS服务器部署HADOOP集群(一):Hadoop完全分布式集群环境搭建的基础上搭建,多添加了一个 datanode 节点 . 1 节点环境介绍: 1.1 环境介绍: 服务器:三台阿里 ...

  10. ubuntu server 1604 设置笔记本盒盖 不操作

    sudo vim /etc/systemd/logind.conf   //打开配置文件 找到 #HandleLidSwitch=suspend  改为 HandleLidSwitch=ignore  ...