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
31c272ef
Commit
31c272ef
authored
7 years ago
by
gpotter2
Browse files
Options
Downloads
Patches
Plain Diff
Get ipv6 addresses using the pcap API
This will speed up the boot
parent
4e9f4e38
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/arch/pcapdnet.py
+3
-2
3 additions, 2 deletions
scapy/arch/pcapdnet.py
scapy/arch/windows/__init__.py
+8
-37
8 additions, 37 deletions
scapy/arch/windows/__init__.py
with
11 additions
and
39 deletions
scapy/arch/pcapdnet.py
+
3
−
2
View file @
31c272ef
...
...
@@ -18,6 +18,7 @@ from scapy.config import conf
from
scapy.utils
import
mac2str
from
scapy.supersocket
import
SuperSocket
from
scapy.error
import
Scapy_Exception
,
log_loading
,
warning
from
scapy.pton_ntop
import
inet_ntop
import
scapy.arch
import
scapy.consts
...
...
@@ -113,7 +114,7 @@ if conf.use_winpcapy:
pcap_freealldevs
(
devs
)
if
conf
.
use_winpcapy
:
get_if_list
=
winpcapy_get_if_list
def
in6_getifaddr
():
def
in6_getifaddr
_raw
():
err
=
create_string_buffer
(
PCAP_ERRBUF_SIZE
)
devs
=
POINTER
(
pcap_if_t
)()
ret
=
[]
...
...
@@ -128,7 +129,7 @@ if conf.use_winpcapy:
if
a
.
contents
.
addr
.
contents
.
sa_family
==
socket
.
AF_INET6
:
ap
=
a
.
contents
.
addr
val
=
cast
(
ap
,
POINTER
(
sockaddr_in6
))
addr
=
socket
.
inet_ntop
(
socket
.
AF_INET6
,
str
(
val
.
contents
.
sin6_addr
[:]))
addr
=
inet_ntop
(
socket
.
AF_INET6
,
""
.
join
(
chr
(
x
)
for
x
in
val
.
contents
.
sin6_addr
[:]))
scope
=
scapy
.
utils6
.
in6_getscope
(
addr
)
ret
.
append
((
addr
,
scope
,
p
.
contents
.
name
.
decode
(
'
ascii
'
)))
a
=
a
.
contents
.
next
...
...
This diff is collapsed.
Click to expand it.
scapy/arch/windows/__init__.py
+
8
−
37
View file @
31c272ef
...
...
@@ -293,7 +293,7 @@ def get_windows_if_list():
# Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
# ---- -------------------- ------- ------ ---------- ---------
# Ethernet Killer E2200 Gigabit Ethernet Contro... 13 Up D0-50-99-56-DD-F9 1 Gbps
query
=
exec_query
([
'
Get-NetAdapter
-Physical
'
],
query
=
exec_query
([
'
Get-NetAdapter
'
],
[
'
InterfaceDescription
'
,
'
InterfaceIndex
'
,
'
Name
'
,
'
InterfaceGuid
'
,
'
MacAddress
'
])
# It is normal that it is in this order
else
:
...
...
@@ -647,42 +647,13 @@ def in6_getifaddr():
"""
Returns all IPv6 addresses found on the computer
"""
if
is_new_release
():
ret
=
[]
ps
=
sp
.
Popen
([
conf
.
prog
.
powershell
,
'
Get-NetRoute
'
,
'
-AddressFamily IPV6
'
,
'
|
'
,
'
select ifIndex, DestinationPrefix
'
],
stdout
=
sp
.
PIPE
,
universal_newlines
=
True
)
stdout
,
stdin
=
ps
.
communicate
()
netstat_line
=
'
\s+
'
.
join
([
'
(\d+)
'
,
''
.
join
([
'
([A-z|0-9|:]+)
'
,
'
(\/\d+)
'
])])
pattern
=
re
.
compile
(
netstat_line
)
for
l
in
stdout
.
split
(
'
\n
'
):
match
=
re
.
search
(
pattern
,
l
)
if
match
:
try
:
if_index
=
match
.
group
(
1
)
iface
=
dev_from_index
(
if_index
)
except
:
continue
scope
=
scapy
.
utils6
.
in6_getscope
(
match
.
group
(
2
))
ret
.
append
((
match
.
group
(
2
),
scope
,
iface
))
# (addr,scope,iface)
continue
return
ret
else
:
ret
=
[]
# Get-WmiObject Win32_NetworkAdapterConfiguration | select InterfaceIndex, IpAddress
for
line
in
exec_query
([
'
Get-WmiObject
'
,
'
Win32_NetworkAdapterConfiguration
'
],
[
'
InterfaceIndex
'
,
'
IPAddress
'
]):
try
:
iface
=
dev_from_index
(
line
[
0
])
except
:
continue
_l_addresses
=
line
[
1
]
_inline
=
[]
if
_l_addresses
:
_inline
=
_l_addresses
[
1
:
-
1
].
split
(
"
,
"
)
for
_address
in
_inline
:
_a
=
_address
.
strip
()
if
"
.
"
not
in
_a
:
scope
=
scapy
.
utils6
.
in6_getscope
(
_a
)
ret
.
append
((
_a
,
scope
,
iface
))
# (addr,scope,iface)
return
ret
ifaddrs
=
[]
for
ifaddr
in
in6_getifaddr_raw
():
try
:
ifaddrs
.
append
((
ifaddr
[
0
],
ifaddr
[
1
],
dev_from_pcapname
(
ifaddr
[
2
])))
except
ValueError
:
pass
return
ifaddrs
def
_append_route6
(
routes
,
dpref
,
dp
,
nh
,
iface
,
lifaddr
):
cset
=
[]
# candidate set (possible source addresses)
...
...
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