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
3dc7c113
Commit
3dc7c113
authored
9 years ago
by
Amedeo
Browse files
Options
Downloads
Patches
Plain Diff
Fixed count and stop_filter in sniff() (plus minor changes)
parent
1d2ebbf1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/sendrecv.py
+17
-12
17 additions, 12 deletions
scapy/sendrecv.py
with
17 additions
and
12 deletions
scapy/sendrecv.py
+
17
−
12
View file @
3dc7c113
...
...
@@ -565,9 +565,9 @@ interfaces)
"""
c
=
0
label
=
{}
l
s
=
[]
sniff_socket
s
=
[]
if
opened_socket
is
not
None
:
l
s
=
[
opened_socket
]
sniff_socket
s
=
[
opened_socket
]
else
:
if
offline
is
None
:
if
L2socket
is
None
:
...
...
@@ -576,24 +576,25 @@ interfaces)
for
i
in
iface
:
s
=
L2socket
(
type
=
ETH_P_ALL
,
iface
=
i
,
*
arg
,
**
karg
)
label
[
s
]
=
i
l
s
.
append
(
s
)
sniff_socket
s
.
append
(
s
)
else
:
ls
=
[
L2socket
(
type
=
ETH_P_ALL
,
iface
=
iface
,
*
arg
,
**
karg
)]
sniff_sockets
=
[
L2socket
(
type
=
ETH_P_ALL
,
iface
=
iface
,
*
arg
,
**
karg
)]
else
:
l
s
=
[
PcapReader
(
offline
)]
sniff_socket
s
=
[
PcapReader
(
offline
)]
lst
=
[]
if
timeout
is
not
None
:
stoptime
=
time
.
time
()
+
timeout
remain
=
None
try
:
stop_event
=
0
stop_event
=
False
while
not
stop_event
:
if
timeout
is
not
None
:
remain
=
stoptime
-
time
.
time
()
if
remain
<=
0
:
break
sel
=
select
(
l
s
,
[],
[],
remain
)
sel
=
select
(
sniff_socket
s
,
[],
[],
remain
)
for
s
in
sel
[
0
]:
p
=
s
.
recv
()
if
p
is
not
None
:
...
...
@@ -609,9 +610,11 @@ interfaces)
if
r
is
not
None
:
print
r
if
stop_filter
and
stop_filter
(
p
):
stop_event
=
1
stop_event
=
True
break
if
count
>
0
and
c
>=
count
:
stop_event
=
1
stop_event
=
True
break
except
KeyboardInterrupt
:
pass
if
opened_socket
is
None
:
...
...
@@ -654,7 +657,7 @@ stop_filter: python function applied to each packet to determine
stoptime
=
time
.
time
()
+
timeout
remain
=
None
try
:
stop_event
=
0
stop_event
=
False
while
not
stop_event
:
if
timeout
is
not
None
:
remain
=
stoptime
-
time
.
time
()
...
...
@@ -676,9 +679,11 @@ stop_filter: python function applied to each packet to determine
if
r
is
not
None
:
print
r
if
stop_filter
and
stop_filter
(
p
):
stop_event
=
1
stop_event
=
True
break
if
count
>
0
and
c
>=
count
:
stop_event
=
1
stop_event
=
True
break
except
KeyboardInterrupt
:
pass
finally
:
...
...
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