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
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
04462497
Commit
04462497
authored
9 years ago
by
Guillaume Valadon
Browse files
Options
Downloads
Plain Diff
Merge pull request #43 from p-l-/fix-filters
Use the provided interface in attach_filter()
parents
7c485806
fb86938f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/arch/__init__.py
+1
-1
1 addition, 1 deletion
scapy/arch/__init__.py
scapy/arch/linux.py
+10
-5
10 additions, 5 deletions
scapy/arch/linux.py
with
11 additions
and
6 deletions
scapy/arch/__init__.py
+
1
−
1
View file @
04462497
...
@@ -69,7 +69,7 @@ ARM_64 = not WINDOWS and (os.uname()[4] == 'aarch64')
...
@@ -69,7 +69,7 @@ ARM_64 = not WINDOWS and (os.uname()[4] == 'aarch64')
# def get_if_raw_addr(iff):
# def get_if_raw_addr(iff):
# def get_if_list():
# def get_if_list():
# def get_working_if():
# def get_working_if():
# def attach_filter(s, filter):
# def attach_filter(s, filter
, iface
):
# def set_promisc(s,iff,val=1):
# def set_promisc(s,iff,val=1):
# def read_routes():
# def read_routes():
# def get_if(iff,cmd):
# def get_if(iff,cmd):
...
...
This diff is collapsed.
Click to expand it.
scapy/arch/linux.py
+
10
−
5
View file @
04462497
...
@@ -108,7 +108,8 @@ def get_working_if():
...
@@ -108,7 +108,8 @@ def get_working_if():
if
ifflags
&
IFF_UP
:
if
ifflags
&
IFF_UP
:
return
i
return
i
return
LOOPBACK_NAME
return
LOOPBACK_NAME
def
attach_filter
(
s
,
filter
):
def
attach_filter
(
s
,
bpf_filter
,
iface
):
# XXX We generate the filter on the interface conf.iface
# XXX We generate the filter on the interface conf.iface
# because tcpdump open the "any" interface and ppp interfaces
# because tcpdump open the "any" interface and ppp interfaces
# in cooked mode. As we use them in raw mode, the filter will not
# in cooked mode. As we use them in raw mode, the filter will not
...
@@ -118,7 +119,11 @@ def attach_filter(s, filter):
...
@@ -118,7 +119,11 @@ def attach_filter(s, filter):
if
not
TCPDUMP
:
if
not
TCPDUMP
:
return
return
try
:
try
:
f
=
os
.
popen
(
"
%s -i %s -ddd -s 1600
'
%s
'"
%
(
conf
.
prog
.
tcpdump
,
conf
.
iface
,
filter
))
f
=
os
.
popen
(
"
%s -i %s -ddd -s 1600
'
%s
'"
%
(
conf
.
prog
.
tcpdump
,
conf
.
iface
if
iface
is
None
else
iface
,
bpf_filter
,
))
except
OSError
,
msg
:
except
OSError
,
msg
:
log_interactive
.
warning
(
"
Failed to execute tcpdump: (%s)
"
)
log_interactive
.
warning
(
"
Failed to execute tcpdump: (%s)
"
)
return
return
...
@@ -323,7 +328,7 @@ class L3PacketSocket(SuperSocket):
...
@@ -323,7 +328,7 @@ class L3PacketSocket(SuperSocket):
else
:
else
:
filter
=
"
not (%s)
"
%
conf
.
except_filter
filter
=
"
not (%s)
"
%
conf
.
except_filter
if
filter
is
not
None
:
if
filter
is
not
None
:
attach_filter
(
self
.
ins
,
filter
)
attach_filter
(
self
.
ins
,
filter
,
iface
)
_flush_fd
(
self
.
ins
)
_flush_fd
(
self
.
ins
)
self
.
ins
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_RCVBUF
,
2
**
30
)
self
.
ins
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_RCVBUF
,
2
**
30
)
self
.
outs
=
socket
.
socket
(
socket
.
AF_PACKET
,
socket
.
SOCK_RAW
,
socket
.
htons
(
type
))
self
.
outs
=
socket
.
socket
(
socket
.
AF_PACKET
,
socket
.
SOCK_RAW
,
socket
.
htons
(
type
))
...
@@ -417,7 +422,7 @@ class L2Socket(SuperSocket):
...
@@ -417,7 +422,7 @@ class L2Socket(SuperSocket):
else
:
else
:
filter
=
"
not (%s)
"
%
conf
.
except_filter
filter
=
"
not (%s)
"
%
conf
.
except_filter
if
filter
is
not
None
:
if
filter
is
not
None
:
attach_filter
(
self
.
ins
,
filter
)
attach_filter
(
self
.
ins
,
filter
,
iface
)
self
.
promisc
=
conf
.
sniff_promisc
if
promisc
is
None
else
promisc
self
.
promisc
=
conf
.
sniff_promisc
if
promisc
is
None
else
promisc
if
self
.
promisc
:
if
self
.
promisc
:
set_promisc
(
self
.
ins
,
self
.
iface
)
set_promisc
(
self
.
ins
,
self
.
iface
)
...
@@ -473,7 +478,7 @@ class L2ListenSocket(SuperSocket):
...
@@ -473,7 +478,7 @@ class L2ListenSocket(SuperSocket):
else
:
else
:
filter
=
"
not (%s)
"
%
conf
.
except_filter
filter
=
"
not (%s)
"
%
conf
.
except_filter
if
filter
is
not
None
:
if
filter
is
not
None
:
attach_filter
(
self
.
ins
,
filter
)
attach_filter
(
self
.
ins
,
filter
,
iface
)
if
promisc
is
None
:
if
promisc
is
None
:
promisc
=
conf
.
sniff_promisc
promisc
=
conf
.
sniff_promisc
self
.
promisc
=
promisc
self
.
promisc
=
promisc
...
...
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