Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
d5db227c
Commit
d5db227c
authored
Aug 28, 2008
by
Phil
Browse files
Options
Downloads
Patches
Plain Diff
Added __repr__() to supersockets
parent
7f0bc767
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
scapy/arch/linux.py
+3
-0
3 additions, 0 deletions
scapy/arch/linux.py
scapy/arch/pcapdnet.py
+3
-0
3 additions, 0 deletions
scapy/arch/pcapdnet.py
scapy/layers/bluetooth.py
+2
-0
2 additions, 0 deletions
scapy/layers/bluetooth.py
scapy/supersocket.py
+12
-1
12 additions, 1 deletion
scapy/supersocket.py
with
20 additions
and
1 deletion
scapy/arch/linux.py
+
3
−
0
View file @
d5db227c
...
@@ -210,6 +210,7 @@ def _flush_fd(fd):
...
@@ -210,6 +210,7 @@ def _flush_fd(fd):
class
L3PacketSocket
(
SuperSocket
):
class
L3PacketSocket
(
SuperSocket
):
desc
=
"
read/write packets at layer 3 using Linux PF_PACKET sockets
"
def
__init__
(
self
,
type
=
ETH_P_ALL
,
filter
=
None
,
promisc
=
None
,
iface
=
None
,
nofilter
=
0
):
def
__init__
(
self
,
type
=
ETH_P_ALL
,
filter
=
None
,
promisc
=
None
,
iface
=
None
,
nofilter
=
0
):
self
.
type
=
type
self
.
type
=
type
self
.
ins
=
socket
.
socket
(
socket
.
AF_PACKET
,
socket
.
SOCK_RAW
,
socket
.
htons
(
type
))
self
.
ins
=
socket
.
socket
(
socket
.
AF_PACKET
,
socket
.
SOCK_RAW
,
socket
.
htons
(
type
))
...
@@ -307,6 +308,7 @@ class L3PacketSocket(SuperSocket):
...
@@ -307,6 +308,7 @@ class L3PacketSocket(SuperSocket):
class
L2Socket
(
SuperSocket
):
class
L2Socket
(
SuperSocket
):
desc
=
"
read/write packets at layer 2 using Linux PF_PACKET sockets
"
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
filter
=
None
,
nofilter
=
0
):
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
filter
=
None
,
nofilter
=
0
):
if
iface
is
None
:
if
iface
is
None
:
iface
=
conf
.
iface
iface
=
conf
.
iface
...
@@ -351,6 +353,7 @@ class L2Socket(SuperSocket):
...
@@ -351,6 +353,7 @@ class L2Socket(SuperSocket):
class
L2ListenSocket
(
SuperSocket
):
class
L2ListenSocket
(
SuperSocket
):
desc
=
"
read packets at layer 2 using Linux PF_PACKET sockets
"
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
promisc
=
None
,
filter
=
None
,
nofilter
=
0
):
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
promisc
=
None
,
filter
=
None
,
nofilter
=
0
):
self
.
type
=
type
self
.
type
=
type
self
.
outs
=
None
self
.
outs
=
None
...
...
This diff is collapsed.
Click to expand it.
scapy/arch/pcapdnet.py
+
3
−
0
View file @
d5db227c
...
@@ -71,6 +71,7 @@ if conf.use_pcap:
...
@@ -71,6 +71,7 @@ if conf.use_pcap:
class
L2pcapListenSocket
(
SuperSocket
):
class
L2pcapListenSocket
(
SuperSocket
):
desc
=
"
read packets at layer 2 using libpcap
"
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
promisc
=
None
,
filter
=
None
):
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
promisc
=
None
,
filter
=
None
):
self
.
type
=
type
self
.
type
=
type
self
.
outs
=
None
self
.
outs
=
None
...
@@ -158,6 +159,7 @@ if conf.use_dnet:
...
@@ -158,6 +159,7 @@ if conf.use_dnet:
if
conf
.
use_pcap
and
conf
.
use_dnet
:
if
conf
.
use_pcap
and
conf
.
use_dnet
:
class
L3dnetSocket
(
SuperSocket
):
class
L3dnetSocket
(
SuperSocket
):
desc
=
"
read/write packets at layer 3 using libdnet and libpcap
"
def
__init__
(
self
,
type
=
ETH_P_ALL
,
filter
=
None
,
promisc
=
None
,
iface
=
None
,
nofilter
=
0
):
def
__init__
(
self
,
type
=
ETH_P_ALL
,
filter
=
None
,
promisc
=
None
,
iface
=
None
,
nofilter
=
0
):
self
.
iflist
=
{}
self
.
iflist
=
{}
if
iface
is
None
:
if
iface
is
None
:
...
@@ -234,6 +236,7 @@ if conf.use_pcap and conf.use_dnet:
...
@@ -234,6 +236,7 @@ if conf.use_pcap and conf.use_dnet:
del
(
self
.
outs
)
del
(
self
.
outs
)
class
L2dnetSocket
(
SuperSocket
):
class
L2dnetSocket
(
SuperSocket
):
desc
=
"
read/write packets at layer 2 using libdnet and libpcap
"
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
filter
=
None
,
nofilter
=
0
):
def
__init__
(
self
,
iface
=
None
,
type
=
ETH_P_ALL
,
filter
=
None
,
nofilter
=
0
):
if
iface
is
None
:
if
iface
is
None
:
iface
=
conf
.
iface
iface
=
conf
.
iface
...
...
This diff is collapsed.
Click to expand it.
scapy/layers/bluetooth.py
+
2
−
0
View file @
d5db227c
...
@@ -155,6 +155,7 @@ bind_layers( L2CAP_CmdHdr, L2CAP_InfoReq, code=10)
...
@@ -155,6 +155,7 @@ bind_layers( L2CAP_CmdHdr, L2CAP_InfoReq, code=10)
bind_layers
(
L2CAP_CmdHdr
,
L2CAP_InfoResp
,
code
=
11
)
bind_layers
(
L2CAP_CmdHdr
,
L2CAP_InfoResp
,
code
=
11
)
class
BluetoothL2CAPSocket
(
SuperSocket
):
class
BluetoothL2CAPSocket
(
SuperSocket
):
desc
=
"
read/write packets on a connected L2CAP socket
"
def
__init__
(
self
,
peer
):
def
__init__
(
self
,
peer
):
s
=
socket
.
socket
(
socket
.
AF_BLUETOOTH
,
socket
.
SOCK_RAW
,
s
=
socket
.
socket
(
socket
.
AF_BLUETOOTH
,
socket
.
SOCK_RAW
,
socket
.
BTPROTO_L2CAP
)
socket
.
BTPROTO_L2CAP
)
...
@@ -167,6 +168,7 @@ class BluetoothL2CAPSocket(SuperSocket):
...
@@ -167,6 +168,7 @@ class BluetoothL2CAPSocket(SuperSocket):
class
BluetoothHCISocket
(
SuperSocket
):
class
BluetoothHCISocket
(
SuperSocket
):
desc
=
"
read/write on a BlueTooth HCI socket
"
def
__init__
(
self
,
iface
=
0x10000
,
type
=
None
):
def
__init__
(
self
,
iface
=
0x10000
,
type
=
None
):
s
=
socket
.
socket
(
socket
.
AF_BLUETOOTH
,
socket
.
SOCK_RAW
,
socket
.
BTPROTO_HCI
)
s
=
socket
.
socket
(
socket
.
AF_BLUETOOTH
,
socket
.
SOCK_RAW
,
socket
.
BTPROTO_HCI
)
s
.
setsockopt
(
socket
.
SOL_HCI
,
socket
.
HCI_DATA_DIR
,
1
)
s
.
setsockopt
(
socket
.
SOL_HCI
,
socket
.
HCI_DATA_DIR
,
1
)
...
...
This diff is collapsed.
Click to expand it.
scapy/supersocket.py
+
12
−
1
View file @
d5db227c
...
@@ -9,8 +9,17 @@ from packet import Raw
...
@@ -9,8 +9,17 @@ from packet import Raw
from
config
import
conf
from
config
import
conf
from
data
import
*
from
data
import
*
class
_SuperSocket_metaclass
(
type
):
def
__repr__
(
self
):
if
self
.
desc
is
not
None
:
return
"
<%s: %s>
"
%
(
self
.
__name__
,
self
.
desc
)
else
:
return
"
<%s>
"
%
self
.
__name__
class
SuperSocket
:
class
SuperSocket
:
__metaclass__
=
_SuperSocket_metaclass
desc
=
None
closed
=
0
closed
=
0
def
__init__
(
self
,
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_STREAM
,
proto
=
0
):
def
__init__
(
self
,
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_STREAM
,
proto
=
0
):
self
.
ins
=
socket
.
socket
(
family
,
type
,
proto
)
self
.
ins
=
socket
.
socket
(
family
,
type
,
proto
)
...
@@ -38,8 +47,8 @@ class SuperSocket:
...
@@ -38,8 +47,8 @@ class SuperSocket:
def
bind_out
(
self
,
addr
):
def
bind_out
(
self
,
addr
):
self
.
outs
.
bind
(
addr
)
self
.
outs
.
bind
(
addr
)
class
L3RawSocket
(
SuperSocket
):
class
L3RawSocket
(
SuperSocket
):
desc
=
"
Layer 3 using Raw sockets (PF_INET/SOCK_RAW)
"
def
__init__
(
self
,
type
=
ETH_P_IP
,
filter
=
None
,
iface
=
None
,
promisc
=
None
,
nofilter
=
0
):
def
__init__
(
self
,
type
=
ETH_P_IP
,
filter
=
None
,
iface
=
None
,
promisc
=
None
,
nofilter
=
0
):
self
.
outs
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_RAW
,
socket
.
IPPROTO_RAW
)
self
.
outs
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_RAW
,
socket
.
IPPROTO_RAW
)
self
.
outs
.
setsockopt
(
socket
.
SOL_IP
,
socket
.
IP_HDRINCL
,
1
)
self
.
outs
.
setsockopt
(
socket
.
SOL_IP
,
socket
.
IP_HDRINCL
,
1
)
...
@@ -55,12 +64,14 @@ class L3RawSocket(SuperSocket):
...
@@ -55,12 +64,14 @@ class L3RawSocket(SuperSocket):
log_runtime
.
error
(
msg
)
log_runtime
.
error
(
msg
)
class
SimpleSocket
(
SuperSocket
):
class
SimpleSocket
(
SuperSocket
):
desc
=
"
wrapper arround a classic socket
"
def
__init__
(
self
,
sock
):
def
__init__
(
self
,
sock
):
self
.
ins
=
sock
self
.
ins
=
sock
self
.
outs
=
sock
self
.
outs
=
sock
class
StreamSocket
(
SimpleSocket
):
class
StreamSocket
(
SimpleSocket
):
desc
=
"
transforms a stream socket into a layer 2
"
def
__init__
(
self
,
sock
,
basecls
=
Raw
):
def
__init__
(
self
,
sock
,
basecls
=
Raw
):
SimpleSocket
.
__init__
(
self
,
sock
)
SimpleSocket
.
__init__
(
self
,
sock
)
self
.
basecls
=
basecls
self
.
basecls
=
basecls
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment