项目作者: superjamie

项目描述 :
Multicast Sequence Decoder
高级语言: Python
项目地址: git://github.com/superjamie/mcsd.git
创建时间: 2019-06-21T11:43:55Z
项目社区:https://github.com/superjamie/mcsd

开源协议:GNU General Public License v3.0

下载


Multicast Sequence Decoder

A scapy script for pulling the sequence number out of a UDP multicast
packet payload. Used for troubleshooting packet captures of
applications which claim to be losing traffic due to missing sequence.

Usage

  1. usage: mcsd.py [-h] [-s SOURCE] [-d DEST] [-S SPORT] [-D DPORT] [-o OFFSET]
  2. [-l LENGTH] [-r]
  3. filename
  4. positional arguments:
  5. filename pcap filename to read
  6. optional arguments:
  7. -h, --help show this help message and exit
  8. -s SOURCE, --source SOURCE
  9. filter on source IP address
  10. -d DEST, --dest DEST filter on destination IP address
  11. -S SPORT, --sport SPORT
  12. filter on source port number
  13. -D DPORT, --dport DPORT
  14. filter on destination port number
  15. -o OFFSET, --offset OFFSET
  16. offset into packet to start reading
  17. -l LENGTH, --length LENGTH
  18. length of characters to read
  19. -r, --raw raw mode. only print payload data

Examples

Fields displayed are:

  1. frame src IP dst IP sport dport payload

A capture file with multiple streams:

  1. $ mcsd.py mcpackets.pcap
  2. 1 10.0.0.1 239.0.0.1 65535 9001 00000001
  3. 2 10.0.0.2 239.0.0.2 1111 9999 00000002
  4. 3 10.0.0.1 239.0.0.1 65535 9001 00000003
  5. 4 10.0.0.2 239.0.0.2 1111 9999 00000004
  6. 5 10.0.0.1 239.0.0.1 65535 9001 00000005
  7. 6 10.0.0.2 239.0.0.2 1111 9999 00000006
  8. 7 10.0.0.1 239.0.0.1 65535 9001 00000007
  9. 8 10.0.0.2 239.0.0.2 1111 9999 00000008
  10. 9 10.0.0.1 239.0.0.1 65535 9001 00000009
  11. 10 10.0.0.2 239.0.0.2 1111 9999 00000010
  12. 11 10.0.0.1 239.0.0.1 65535 9001 00000011
  13. 12 10.0.0.2 239.0.0.2 1111 9999 00000012
  14. 13 10.0.0.1 239.0.0.1 65535 9001 00000013
  15. 14 10.0.0.2 239.0.0.2 1111 9999 00000014
  16. 15 10.0.0.1 239.0.0.1 65535 9001 00000015
  17. 16 10.0.0.2 239.0.0.2 1111 9999 00000016
  18. 17 10.0.0.1 239.0.0.1 65535 9001 00000017
  19. 18 10.0.0.2 239.0.0.2 1111 9999 00000018
  20. 19 10.0.0.1 239.0.0.1 65535 9001 00000019
  21. 20 10.0.0.2 239.0.0.2 1111 9999 00000020

Filtering on source IP:

  1. $ mcsd.py -s 10.0.0.1 mcpackets.pcap
  2. 1 10.0.0.1 239.0.0.1 65535 9001 00000001
  3. 3 10.0.0.1 239.0.0.1 65535 9001 00000003
  4. 5 10.0.0.1 239.0.0.1 65535 9001 00000005
  5. 7 10.0.0.1 239.0.0.1 65535 9001 00000007
  6. 9 10.0.0.1 239.0.0.1 65535 9001 00000009
  7. 11 10.0.0.1 239.0.0.1 65535 9001 00000011
  8. 13 10.0.0.1 239.0.0.1 65535 9001 00000013
  9. 15 10.0.0.1 239.0.0.1 65535 9001 00000015
  10. 17 10.0.0.1 239.0.0.1 65535 9001 00000017
  11. 19 10.0.0.1 239.0.0.1 65535 9001 00000019

Filtering on destination port:

  1. $ mcsd.py -D 9999 mcpackets.pcap
  2. 2 10.0.0.2 239.0.0.2 1111 9999 00000002
  3. 4 10.0.0.2 239.0.0.2 1111 9999 00000004
  4. 6 10.0.0.2 239.0.0.2 1111 9999 00000006
  5. 8 10.0.0.2 239.0.0.2 1111 9999 00000008
  6. 10 10.0.0.2 239.0.0.2 1111 9999 00000010
  7. 12 10.0.0.2 239.0.0.2 1111 9999 00000012
  8. 14 10.0.0.2 239.0.0.2 1111 9999 00000014
  9. 16 10.0.0.2 239.0.0.2 1111 9999 00000016
  10. 18 10.0.0.2 239.0.0.2 1111 9999 00000018
  11. 20 10.0.0.2 239.0.0.2 1111 9999 00000020

Raw mode, just displaying payload:

  1. $ mcsd.py -D 9999 -r mcpackets.pcap
  2. 00000002
  3. 00000004
  4. 00000006
  5. 00000008
  6. 00000010
  7. 00000012
  8. 00000014
  9. 00000016
  10. 00000018
  11. 00000020

Reading further ahead into the packet:

  1. $ mcsd.py -D 9999 -r -o 4 -l 4 mcpackets.pcap
  2. 0002
  3. 0004
  4. 0006
  5. 0008
  6. 0010
  7. 0012
  8. 0014
  9. 0016
  10. 0018
  11. 0020

Analysis

Text processing tools can be used to iterate over printed sequence numbers and identify missing data.

The exact processing depends on the format of the packet data.

An example using awk to find missing sequence numbers which don’t increase by 1, starting at 1, using the above sample data:

  1. $ mcsd.py -D 9999 mcpackets.pcap | awk '$NF!=p+1{print p+1"-"$NF-1}{p=$NF}'
  2. 1-1
  3. 3-3
  4. 5-5
  5. 7-7
  6. 9-9
  7. 11-11
  8. 13-13
  9. 15-15
  10. 17-17
  11. 19-19

This output describes that we are missing sequence number 1, 3, 5, and so on.

Requirements

  • Python 3 (tested on v3.6.8)
  • scapy (tested on v2.4.2)

Installation

Put mcsd.py somewhere in $PATH, eg:

  1. mkdir -p ~/bin
  2. wget -O ~/bin/mcsd.py https://raw.githubusercontent.com/superjamie/mcsd/master/mcsd.py
  3. chmod +x ~/bin/mcsd.py

Author

Jamie Bainbridge - jamie.bainbridge@gmail.com

License

GPLv3 - https://www.gnu.org/licenses/gpl-3.0.en.html