Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mptcp scapy(pt br) #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions NOTES
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
- Pour le MP_CAPABLE: il n'y a aucun requirement par rapport à la présence de
rcv_key et snd_key. Ils semblent obligatoires, mais ce n'est pas dit
explicitement, ni quand il le sont.
- Para opção MP_CAPABLE: Não há nenhuma exigência em relação à presença de
rcv_key e snd_key. Eles parecem obrigatório, mas não é declarada
explicitamente.

- Bug encore semble encore présent
- Bug ainda parece presente

- 192.135.167.249 semble ne pas répondre en mptcp (pas de mp_capable)
- 192.135.167.249 parece não responder mptcp (sem mp_capable)


============= 24/11/2011 =============

- Il semblerait que les traces mpTCP que j'ai reçues de Fabien ne suivent pas
exactement le draft. En l'occurence, dumps/badDSSpacket.pcap contient un
paquet utilisant l'option Data Sequence Signal avec une longueur de 8. Ce qui,
selon le draft, ne devrait pas être possible si les flags a et A sont activés
comme c'est le cas:
F=0 m=1 M=0 a=1 A=1
Cette erreur revient à plusieurs reprises dans le dump fourni.
-> Meeting 24/11: bug corrigé dans les dernières versions
- Conselho parece que não segue exatamente o projecto.
Neste caso, dumps/badDSSpacket.pcap contém um pacote usando a opção Data Sequence
Signal (DSS) com um comprimento de 8. Isso, de acordo com o projeto, não é
possível se as flags um e A são ativadas como é em casmble não responder
mptcp (sem mp_capable)
F=0 m=1 M=0 a=1 A=1

- Il y a quelque chose qui me perturbe avec le checksum de DSS. Le flag M
spécifie la présence du checksum ou pas. Cependant, à la fin du paragraphe de
la section 3.3, il est indiqué:
"The presence of the checksum can be inferred from the length of the option."
Est-ce que le fait que M=0 n'assure pas qu'il n'y ait pas de checksum ?
-> Meeting 24/11: checksum présent si "c" est set (négocié avec MP_CAPABLE)
-> Corrigé dans scapy en se référant à length pour déterminer la présence du
checksum.
Retorna este erro várias vezes no despejo fornecido.
-> Reunião 24/11: bug corrigido nas versões mais recentes

- Há uma coisa que me perturba com a soma de verificação de DSS. A flag M especifica
a presença da soma de verificação, ou não. No entanto, no final do aragraphe Secção 3.3,
afirma-se:
"A presença da soma de verificação pode ser inferida a partir da extensão da opção".
O fato de M=0, não garante que não há soma de verificação?
-> Reunião 24/11: soma de verificação se este "c" está definido (negociado com MP_CAPABLE)
-> Scapy corrigido no referente ao comprimento para determinar a presença de soma de verificação
22 changes: 13 additions & 9 deletions README
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
This version implements the support for Multipath TCP.
Esta versão implementa o suporte para Multipath TCP (MPTCP).

It affects the way TCP is handled by adding a packet type for TCP options. It
also adds a packet type MPTCP as subtype of a TCP option (see
scapy/layers/mptcp.py for details).

You can use the script "launcher" to start scapy with the modified script. It
works only if you are in the same directory that the python "scapy" module.

EXAMPLE RUN
===========
Nesta versão, é possível manipular um pacote MPTCP. Para isso, foi adicionado ao campo Options
do TCP uma opção para o pacote MPTCP (kind = MPTCP). Para maiores detalhes veja em
scapy/layers/mptcp.py para maiores detalhes.

Você deve usar o script "launcher" para iniciar o Scapy, caso queira utilizá-lo com o código
modificado para MPTCP. Lembre-se que Isso funciona apenas se estiver no mesmo diretório que
o modulo "Scapy" em python.


EXEMPLO DE USO
==============

$ ./launcher
Welcome to Scapy (2.2.0)
Bem vindo ao Scapy (2.2.0)
>>> a=rdpcap("dumps/mptcp-capable.pcap")
>>> a
<mptcp-capable.pcap: TCP:1 UDP:0 ICMP:0 Other:0>
Expand Down
26 changes: 13 additions & 13 deletions launcher
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

#############################################################################
## ##
## scapy.py --- Interactive packet manipulation tool ##
## see http://www.secdev.org/projects/scapy/ ##
## for more informations ##
## scapy.py --- Ferramenta Interativa de manipulacao de pacotes ##
## veja http://www.secdev.org/projects/scapy/ ##
## para maiores informacoes ##
## ##
## Copyright (C) Philippe Biondi <[email protected]> ##
## ##
## This program is free software; you can redistribute it and/or modify it ##
## under the terms of the GNU General Public License version 2 as ##
## published by the Free Software Foundation. ##
## Esse programa e um software livre; voce pode redistribui-lo e/ou ##
## modifica-lo sob os termos da General Public License versao 2 como ##
## publicado pela Free Software Foundation. ##
## ##
## This program is distributed in the hope that it will be useful, but ##
## WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
## General Public License for more details. ##
## Este programa e distribuido na esperanca que possa ser util, mas sem ##
## SEM NENHUMA GARANTIA; sem nenhuma garantia implicita de COMERCIALIZACAO ##
## ou ADEQUAÇÃO PARA UM PROPOSITO PARTICULAR. Veja a GNU General Public ##
## License para maiores detalhes. ##
## ##
#############################################################################
## ##
## This is a special version supporting Multipath TCP. ##
## See README for details. ##
## Esta é uma versao especial para suporte ao protocolo Multipath TCP ##
## Veja README para detalhes. ##
## ##
#############################################################################


import os
# use the local version (subdirectory "scapy" in the current directory)
# use versao local (subdiretorio "scapy" no diretorio corrente)
os.putenv("PYTHONPATH","%s:%s" % (os.getcwd(), os.getenv("PYTHONPATH")))

from scapy.main import interact
Expand Down
46 changes: 23 additions & 23 deletions scapy/arch/linux.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## This file is part of Scapy
## See http://www.secdev.org/projects/scapy for more informations
## Este arquivo e parte do Scapy
## Veja http://www.secdev.org/projects/scapy para maiores informacoes
## Copyright (C) Philippe Biondi <[email protected]>
## This program is published under a GPLv2 license
## Este programa e publicado sob a licenca GPLv2

"""
Linux specific functions.
Funcoes especificas do Linux.
"""

from __future__ import with_statement
Expand All @@ -21,7 +21,7 @@



# From bits/ioctls.h
# De bits/ioctls.h
SIOCGIFHWADDR = 0x8927 # Get hardware address
SIOCGIFADDR = 0x8915 # get PA address
SIOCGIFNETMASK = 0x891b # get network PA mask
Expand Down Expand Up @@ -71,7 +71,7 @@

with os.popen("tcpdump -V 2> /dev/null") as _f:
if _f.close() >> 8 == 0x7f:
log_loading.warning("Failed to execute tcpdump. Check it is installed and in the PATH")
log_loading.warning("Falhou ao executar tcpdump. Veja se este esta instalado em PATH")
TCPDUMP=0
else:
TCPDUMP=1
Expand Down Expand Up @@ -116,11 +116,11 @@ def attach_filter(s, filter):
try:
f = os.popen("%s -i %s -ddd -s 1600 '%s'" % (conf.prog.tcpdump,conf.iface,filter))
except OSError,msg:
log_interactive.warning("Failed to execute tcpdump: (%s)")
log_interactive.warning("Falhou ao executar tcpdump: (%s)")
return
lines = f.readlines()
if f.close():
raise Scapy_Exception("Filter parse error")
raise Scapy_Exception("Erro de analise no filtro")
nb = int(lines[0])
bpf = ""
for l in lines[1:]:
Expand Down Expand Up @@ -157,7 +157,7 @@ def read_routes():
ifaddr = scapy.utils.inet_ntoa(ifreq[20:24])
routes.append((dst, msk, "0.0.0.0", LOOPBACK_NAME, ifaddr))
else:
warning("Interface lo: unkown address family (%i)"% addrfamily)
warning("Interface lo: familia de enderecos desconhecida (%i)"% addrfamily)

for l in f.readlines()[1:]:
iff,dst,gw,flags,x,x,x,msk,x,x,x = l.split()
Expand All @@ -175,7 +175,7 @@ def read_routes():
if addrfamily == socket.AF_INET:
ifaddr = scapy.utils.inet_ntoa(ifreq[20:24])
else:
warning("Interface %s: unkown address family (%i)"%(iff, addrfamily))
warning("Interface %s: familia de enderecos desconhecida (%i)"%(iff, addrfamily))
continue
routes.append((socket.htonl(long(dst,16))&0xffffffffL,
socket.htonl(long(msk,16))&0xffffffffL,
Expand Down Expand Up @@ -301,7 +301,7 @@ def _flush_fd(fd):


class L3PacketSocket(SuperSocket):
desc = "read/write packets at layer 3 using Linux PF_PACKET sockets"
desc = "ler/escrever pacotes na camada 3 usando sockets Linux PF_PACKET"
def __init__(self, type = ETH_P_ALL, filter=None, promisc=None, iface=None, nofilter=0):
self.type = type
self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
Expand All @@ -312,9 +312,9 @@ def __init__(self, type = ETH_P_ALL, filter=None, promisc=None, iface=None, nofi
if not nofilter:
if conf.except_filter:
if filter:
filter = "(%s) and not (%s)" % (filter, conf.except_filter)
filter = "(%s) e nao (%s)" % (filter, conf.except_filter)
else:
filter = "not (%s)" % conf.except_filter
filter = "nao (%s)" % conf.except_filter
if filter is not None:
attach_filter(self.ins, filter)
self.ins.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2**30)
Expand Down Expand Up @@ -353,7 +353,7 @@ def recv(self, x=MTU):
lvl = 3
else:
cls = conf.default_l2
warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))
warning(" Impossivel saber o tipo (interface=%s protocol=%#x familia=%i). Usando %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))
lvl = 2

try:
Expand Down Expand Up @@ -399,7 +399,7 @@ def send(self, x):


class L2Socket(SuperSocket):
desc = "read/write packets at layer 2 using Linux PF_PACKET sockets"
desc = "ler/escrever pacotes na camada 2 usando sockets Linux PF_PACKET"
def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0):
if iface is None:
iface = conf.iface
Expand All @@ -409,9 +409,9 @@ def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0):
if not nofilter:
if conf.except_filter:
if filter:
filter = "(%s) and not (%s)" % (filter, conf.except_filter)
filter = "(%s) e nao (%s)" % (filter, conf.except_filter)
else:
filter = "not (%s)" % conf.except_filter
filter = "nao (%s)" % conf.except_filter
if filter is not None:
attach_filter(self.ins, filter)
self.ins.bind((iface, type))
Expand All @@ -425,7 +425,7 @@ def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0):
self.LL = conf.l3types[sa_ll[1]]
else:
self.LL = conf.default_l2
warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],self.LL.name))
warning("Impossivel saber o tipo (interface=%s protocol=%#x familia=%i). Usando %s" % (sa_ll[0],sa_ll[1],sa_ll[3],self.LL.name))

def recv(self, x=MTU):
pkt, sa_ll = self.ins.recvfrom(x)
Expand All @@ -444,7 +444,7 @@ def recv(self, x=MTU):


class L2ListenSocket(SuperSocket):
desc = "read packets at layer 2 using Linux PF_PACKET sockets"
desc = "ler pacotes na camada 2 usando sockets Linux PF_PACKET"
def __init__(self, iface = None, type = ETH_P_ALL, promisc=None, filter=None, nofilter=0):
self.type = type
self.outs = None
Expand All @@ -456,9 +456,9 @@ def __init__(self, iface = None, type = ETH_P_ALL, promisc=None, filter=None, no
if not nofilter:
if conf.except_filter:
if filter:
filter = "(%s) and not (%s)" % (filter, conf.except_filter)
filter = "(%s) e nao (%s)" % (filter, conf.except_filter)
else:
filter = "not (%s)" % conf.except_filter
filter = "nao (%s)" % conf.except_filter
if filter is not None:
attach_filter(self.ins, filter)
if promisc is None:
Expand Down Expand Up @@ -489,7 +489,7 @@ def recv(self, x):
cls = conf.l3types[sa_ll[1]]
else:
cls = conf.default_l2
warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))
warning("Impossivel saber o tipo (interface=%s protocol=%#x familia=%i). Usando %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))

try:
pkt = cls(pkt)
Expand All @@ -503,7 +503,7 @@ def recv(self, x):
return pkt

def send(self, x):
raise Scapy_Exception("Can't send anything with L2ListenSocket")
raise Scapy_Exception(" Nao pode enviar qualquer coisa com L2ListenSocket")


conf.L3socket = L3PacketSocket
Expand Down