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
a3859f1b
Commit
a3859f1b
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Windows: code clean-up, fix iface repr, fix get_working_if()
parent
1fd18614
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/arch/windows/__init__.py
+10
-18
10 additions, 18 deletions
scapy/arch/windows/__init__.py
with
10 additions
and
18 deletions
scapy/arch/windows/__init__.py
+
10
−
18
View file @
a3859f1b
...
...
@@ -259,10 +259,7 @@ class NetworkInterface(object):
raise
PcapNameNotFoundError
def
__repr__
(
self
):
return
"
<%s %s: %s %s %s description=%r>
"
%
(
self
.
__class__
.
__name__
,
self
.
name
,
self
.
guid
,
self
.
ip
,
self
.
mac
,
self
.
description
,
)
return
"
<%s %s %s>
"
%
(
self
.
__class__
.
__name__
,
self
.
name
,
self
.
guid
)
from
UserDict
import
UserDict
...
...
@@ -394,15 +391,15 @@ def read_routes_7():
return
routes
def
read_routes
():
routes
=
[]
routes
=
[]
release
=
platform
.
release
()
try
:
if
release
in
[
"
post2008Server
"
,
"
8
"
]:
routes
=
read_routes_post2008
()
routes
=
read_routes_post2008
()
elif
release
==
"
XP
"
:
routes
=
read_routes_xp
()
routes
=
read_routes_xp
()
else
:
routes
=
read_routes_7
()
routes
=
read_routes_7
()
except
Exception
as
e
:
log_loading
.
warning
(
"
Error building scapy routing table : %s
"
%
str
(
e
))
else
:
...
...
@@ -663,17 +660,12 @@ import scapy.sendrecv
scapy
.
sendrecv
.
sniff
=
sniff
def
get_working_if
():
# XXX get the interface associated with default route instead
try
:
if
'
Ethernet
'
in
IFACES
and
IFACES
[
'
Ethernet
'
].
ip
!=
'
0.0.0.0
'
:
return
'
Ethernet
'
elif
'
Wi-Fi
'
in
IFACES
and
IFACES
[
'
Wi-Fi
'
].
ip
!=
'
0.0.0.0
'
:
return
'
Wi-Fi
'
elif
len
(
IFACES
)
>
0
:
return
IFACES
.
itervalues
().
next
()
else
:
return
LOOPBACK_NAME
except
:
# return the interface associated with the route with smallest
# mask (route by default if it exists)
return
min
(
read_routes
(),
key
=
lambda
x
:
x
[
1
])[
2
]
except
ValueError
:
# no route
return
LOOPBACK_NAME
conf
.
iface
=
get_working_if
()
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