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
ed9886ac
Commit
ed9886ac
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Fix global variable case
parent
f0d48351
No related branches found
Branches containing commit
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
+14
-13
14 additions, 13 deletions
scapy/arch/windows/__init__.py
with
14 additions
and
13 deletions
scapy/arch/windows/__init__.py
+
14
−
13
View file @
ed9886ac
...
@@ -314,15 +314,15 @@ class NetworkInterfaceDict(UserDict):
...
@@ -314,15 +314,15 @@ class NetworkInterfaceDict(UserDict):
mac
=
conf
.
manufdb
.
_resolve_MAC
(
mac
)
mac
=
conf
.
manufdb
.
_resolve_MAC
(
mac
)
print
"
%s %s %s %s
"
%
(
str
(
dev
.
win_index
).
ljust
(
5
),
str
(
dev
.
name
).
ljust
(
35
),
str
(
dev
.
ip
).
ljust
(
15
),
mac
)
print
"
%s %s %s %s
"
%
(
str
(
dev
.
win_index
).
ljust
(
5
),
str
(
dev
.
name
).
ljust
(
35
),
str
(
dev
.
ip
).
ljust
(
15
),
mac
)
ifaces
=
NetworkInterfaceDict
()
IFACES
=
NetworkInterfaceDict
()
ifaces
.
load_from_powershell
()
IFACES
.
load_from_powershell
()
def
pcap_name
(
devname
):
def
pcap_name
(
devname
):
"""
Return pypcap device name for given libdnet/Scapy device name
"""
"""
Return pypcap device name for given libdnet/Scapy device name
"""
if
type
(
devname
)
is
NetworkInterface
:
if
type
(
devname
)
is
NetworkInterface
:
return
devname
.
pcap_name
return
devname
.
pcap_name
try
:
try
:
pcap_name
=
ifaces
.
pcap_name
(
devname
)
pcap_name
=
IFACES
.
pcap_name
(
devname
)
except
ValueError
:
except
ValueError
:
# pcap.pcap() will choose a sensible default for sniffing if iface=None
# pcap.pcap() will choose a sensible default for sniffing if iface=None
pcap_name
=
None
pcap_name
=
None
...
@@ -330,21 +330,21 @@ def pcap_name(devname):
...
@@ -330,21 +330,21 @@ def pcap_name(devname):
def
devname
(
pcap_name
):
def
devname
(
pcap_name
):
"""
Return libdnet/Scapy device name for given pypcap device name
"""
"""
Return libdnet/Scapy device name for given pypcap device name
"""
return
ifaces
.
devname
(
pcap_name
)
return
IFACES
.
devname
(
pcap_name
)
def
devname_from_index
(
if_index
):
def
devname_from_index
(
if_index
):
"""
Return Windows adapter name for given Windows interface index
"""
"""
Return Windows adapter name for given Windows interface index
"""
return
ifaces
.
devname_from_index
(
if_index
)
return
IFACES
.
devname_from_index
(
if_index
)
def
show_interfaces
(
resolve_mac
=
True
):
def
show_interfaces
(
resolve_mac
=
True
):
"""
Print list of available network interfaces
"""
"""
Print list of available network interfaces
"""
return
ifaces
.
show
(
resolve_mac
)
return
IFACES
.
show
(
resolve_mac
)
_orig_open_pcap
=
pcapdnet
.
open_pcap
_orig_open_pcap
=
pcapdnet
.
open_pcap
pcapdnet
.
open_pcap
=
lambda
iface
,
*
args
,
**
kargs
:
_orig_open_pcap
(
pcap_name
(
iface
),
*
args
,
**
kargs
)
pcapdnet
.
open_pcap
=
lambda
iface
,
*
args
,
**
kargs
:
_orig_open_pcap
(
pcap_name
(
iface
),
*
args
,
**
kargs
)
_orig_get_if_raw_hwaddr
=
pcapdnet
.
get_if_raw_hwaddr
_orig_get_if_raw_hwaddr
=
pcapdnet
.
get_if_raw_hwaddr
pcapdnet
.
get_if_raw_hwaddr
=
lambda
iface
,
*
args
,
**
kargs
:
(
ARPHDR_ETHER
,
''
.
join
([
chr
(
int
(
i
,
16
))
for
i
in
ifaces
[
iface
].
mac
.
split
(
'
:
'
)
]))
pcapdnet
.
get_if_raw_hwaddr
=
lambda
iface
,
*
args
,
**
kargs
:
(
ARPHDR_ETHER
,
''
.
join
([
chr
(
int
(
i
,
16
))
for
i
in
IFACES
[
iface
].
mac
.
split
(
'
:
'
)
]))
get_if_raw_hwaddr
=
pcapdnet
.
get_if_raw_hwaddr
get_if_raw_hwaddr
=
pcapdnet
.
get_if_raw_hwaddr
...
@@ -357,7 +357,7 @@ def read_routes_7():
...
@@ -357,7 +357,7 @@ def read_routes_7():
except
ValueError
:
except
ValueError
:
continue
continue
routes
.
append
((
atol
(
line
[
0
]),
atol
(
line
[
1
]),
line
[
2
],
iface
,
routes
.
append
((
atol
(
line
[
0
]),
atol
(
line
[
1
]),
line
[
2
],
iface
,
ifaces
[
iface
].
ip
))
IFACES
[
iface
].
ip
))
return
routes
return
routes
def
read_routes
():
def
read_routes
():
...
@@ -392,7 +392,7 @@ def read_routes_post2008():
...
@@ -392,7 +392,7 @@ def read_routes_post2008():
if
match
:
if
match
:
try
:
try
:
iface
=
devname_from_index
(
int
(
match
.
group
(
1
)))
iface
=
devname_from_index
(
int
(
match
.
group
(
1
)))
addr
=
ifaces
[
iface
].
ip
addr
=
IFACES
[
iface
].
ip
except
:
except
:
continue
continue
dest
=
atol
(
match
.
group
(
2
))
dest
=
atol
(
match
.
group
(
2
))
...
@@ -630,13 +630,14 @@ import scapy.sendrecv
...
@@ -630,13 +630,14 @@ import scapy.sendrecv
scapy
.
sendrecv
.
sniff
=
sniff
scapy
.
sendrecv
.
sniff
=
sniff
def
get_working_if
():
def
get_working_if
():
# XXX get the interface associated with default route instead
try
:
try
:
if
'
Ethernet
'
in
ifaces
and
ifaces
[
'
Ethernet
'
].
ip
!=
'
0.0.0.0
'
:
if
'
Ethernet
'
in
IFACES
and
IFACES
[
'
Ethernet
'
].
ip
!=
'
0.0.0.0
'
:
return
'
Ethernet
'
return
'
Ethernet
'
elif
'
Wi-Fi
'
in
ifaces
and
ifaces
[
'
Wi-Fi
'
].
ip
!=
'
0.0.0.0
'
:
elif
'
Wi-Fi
'
in
IFACES
and
IFACES
[
'
Wi-Fi
'
].
ip
!=
'
0.0.0.0
'
:
return
'
Wi-Fi
'
return
'
Wi-Fi
'
elif
len
(
ifaces
)
>
0
:
elif
len
(
IFACES
)
>
0
:
return
ifaces
[
list
(
ifaces
.
keys
())[
0
]]
return
IFACES
[
list
(
IFACES
.
keys
())[
0
]]
else
:
else
:
return
LOOPBACK_NAME
return
LOOPBACK_NAME
except
:
except
:
...
...
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