Skip to content
Snippets Groups Projects
Commit 83c748ef authored by gpotter2's avatar gpotter2 Committed by Pierre Lalet
Browse files

[Windows/Networking] Support no wpcap.dll (#406)

parent a454ef48
No related branches found
No related tags found
No related merge requests found
......@@ -39,11 +39,11 @@ if conf.use_winpcapy:
pcap_freealldevs(devs)
except OSError as e:
def winpcapy_get_if_list():
return []
conf.use_winpcapy = False
if conf.interactive:
log_loading.error("Unable to import libpcap library: %s" % e)
conf.use_winpcapy = False
else:
raise
log_loading.warning("wpcap.dll is not installed. You won't be able to send/recieve packets. Visit the scapy's doc to install it")
# From BSD net/bpf.h
#BIOCIMMEDIATE=0x80044270
......@@ -99,7 +99,8 @@ if conf.use_winpcapy:
return ret
finally:
pcap_freealldevs(devs)
get_if_list = winpcapy_get_if_list
if conf.use_winpcapy:
get_if_list = winpcapy_get_if_list
def in6_getifaddr():
err = create_string_buffer(PCAP_ERRBUF_SIZE)
devs = POINTER(pcap_if_t)()
......@@ -320,10 +321,7 @@ if conf.use_winpcapy:
conf.L2socket=L2pcapSocket
conf.L3socket=L3pcapSocket
if conf.use_pcap:
if conf.use_pcap:
try:
import pcap
except ImportError,e:
......
......@@ -248,3 +248,7 @@ L2socket: use the provided L2socket
import scapy.sendrecv
scapy.sendrecv.sniff = sniff
# If wpcap.dll is not available
if not (conf.use_winpcapy or conf.use_pcap or conf.use_dnet):
from scapy.arch.windows.disable_sendrecv import *
## This file is part of Scapy
## See http://www.secdev.org/projects/scapy for more informations
## Copyright (C) Philippe Biondi <phil@secdev.org>
## This program is published under a GPLv2 license
"""
When wpcap.dll is not available, replace all sendrecv functions that won't work.
"""
from scapy.error import log_runtime
import scapy.sendrecv as sendrecv
import scapy.config as conf
from scapy.supersocket import SuperSocket
def not_available(*args, **kwargs):
log_runtime.warning("Function not available")
return None
class not_available_socket(SuperSocket):
desc = "wpcap.dll missing"
def __init__(self, type=None, promisc=None, filter=None, iface=None, nofilter=0):
log_runtime.warning("Function not available")
return
def send(self, x):
return
def recv(self,x=None):
return
def nonblock_recv(self):
return
def close(self):
return
sendrecv.send = not_available
sendrecv.sendp = not_available
sendrecv.sendpfast = not_available
sendrecv.sr = not_available
sendrecv.sr1 = not_available
sendrecv.srflood = not_available
sendrecv.srloop = not_available
sendrecv.srp = not_available
sendrecv.srp1 = not_available
sendrecv.srpflood = not_available
sendrecv.srploop = not_available
sendrecv.sniff = not_available
sendrecv.sndrcv = not_available
sendrecv.sndrcvflood = not_available
sendrecv.tshark = not_available
conf.L3socket=not_available_socket
conf.L2socket=not_available_socket
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment