Open gparent opened 8 years ago
Code is merged. Are you using latest master? I accidentaly "re-merged" it again, but @sysengkm patch was in the code for some time already.
Check carefully above, I linked directly to the comment by @sysengkm where he literally includes the code that works* for me. I would suggest using diff
to check the differences in the code because they are rather minor.
EDIT: I guess I didn't link to the comment I thought. My bad: https://github.com/phaethon/scapy/issues/50#issuecomment-189493197
Here's the code in c57d444:
def get_windows_if_list():
ps = sp.Popen(['powershell', '-NoProfile', 'Get-WMIObject -class Win32_NetworkAdapter', '|', 'select Name, @{Name="InterfaceIndex";Expression={$_.Index}}, @{Name="InterfaceDescription";Expression={$_.Description}},@{Name="InterfaceGuid";Expression={$_.GUID}}, @{Name="MacAddress";Expression={$_.MacAddress.Replace(":","-")}} | where InterfaceGuid -ne $null', '|', 'fl'], stdout = sp.PIPE, universal_newlines = True)
stdout, stdin = ps.communicate(timeout = 10)
Here's the same function in a7cd488:
def get_windows_if_list():
# Windows 8+ way: ps = sp.Popen(['powershell', 'Get-NetAdapter', '|', 'select Name, InterfaceIndex, InterfaceDescription, InterfaceGuid, MacAddress', '|', 'fl'], stdout = sp.PIPE, universal_newlines = True)
ps = sp.Popen(['powershell', '-NoProfile', 'Get-WMIObject -class Win32_NetworkAdapter', '|', 'select Name, @{Name="InterfaceIndex";Expression={$_.Index}}, @{Name="InterfaceDescription";Expression={$_.Description}},@{Name="InterfaceGuid";Expression={$_.GUID}}, @{Name="MacAddress";Expression={$_.MacAddress.Replace(":","-")}} | where InterfaceGuid -ne $null', '|', 'fl'], stdout = sp.PIPE, universal_newlines = True)
stdout, stdin = ps.communicate(timeout = 10)
Here's the code that works for me:
def get_windows_if_list():
# Windows 8+ way: ps = sp.Popen(['powershell', 'Get-NetAdapter', '|', 'select Name, InterfaceIndex, InterfaceDescription, InterfaceGuid, MacAddress', '|', 'fl'], stdout = sp.PIPE, universal_newlines = True)
ps = sp.Popen(['powershell', '-NoProfile', 'Get-WMIObject -class Win32_NetworkAdapter', '|', 'select Name, @{Name="InterfaceIndex";Expression={$_.Index}}, @{Name="InterfaceDescription";Expression={$_.Description}},@{Name="InterfaceGuid";Expression={$_.GUID}}, @{Name="MacAddress";Expression={$_.MacAddress.Replace(":","-")}}', '|', 'fl'], stdout = sp.PIPE, universal_newlines = True)
stdout, stdin = ps.communicate(timeout = 10)
In this case, when I say "works", it means I can execute the sample code I provided above, but I have not tested live captures yet using the interfaces the functions are meant to detect since I'd like to tackle this problem first.
You mean it "works" only without | where InterfaceGuid -ne $null'
? Meaning it returns all interface Guids as null? I doubt that it is actually working. Please, perform further tests that you can really sniff and send packets. If it really works I would be interested in more information on your configuration. There was another issue why this code fragment was added.
Right, I did not need the live captures at the time. I will test them tomorrow during the day.
Either way, the current code in master doesn't allow me to do live captures either, so I'm sure we can make some progress on this regardless of outcome.
Thank you for your time.
EDIT: Unfortunately gonna be monday.
Live captures do not appear to work with this code:
from scapy.all import *
def pkt_callback(pkt):
pkt.show() # debug statement
sniff(prn=pkt_callback)
The code does not error but the callback is never called.
Thank you,
Maybe my pull request is something for you: https://github.com/phaethon/scapy/pull/96
Tried some basic sniffing for ICMP packets as well as sending/receiving.
Hi !
The original scapy fork, which now supports Python 3 ! This fork (scapy3k) is missing many updates, bug fixes and tweaks. You can have a look at https://github.com/secdev/scapy to get more support !
Have a good day
Still doesn't work, as explained in issue #50
Here's sample code:
With that code, an exception is thrown when importing the package: too many values to unpack (expected 2)
I'm reopening a new issue because the code provided by sysengkm works, so it would be nice to see if it can be merged in.