Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 729 log http connect #101

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
22 changes: 11 additions & 11 deletions fakenet/diverters/diverterbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,16 +594,16 @@ def __init__(self, diverter_config, listeners_config, ip_addrs,

# Check active interfaces
if not self.check_active_ethernet_adapters():
self.logger.warning('WARNING: No active ethernet interfaces '
self.logger.critical('WARNING: No active ethernet interfaces '
'detected!')
self.logger.warning(' Please enable a network interface.')
self.logger.critical(' Please enable a network interface.')
sys.exit(1)

# Check configured ip addresses
if not self.check_ipaddresses():
self.logger.warning('ERROR: No interface had IP address '
self.logger.critical('ERROR: No interface had IP address '
'configured!')
self.logger.warning(' Please configure an IP address on a '
self.logger.critical(' Please configure an IP address on '
'network interface.')
sys.exit(1)

Expand All @@ -626,7 +626,7 @@ def __init__(self, diverter_config, listeners_config, ip_addrs,
# Check configured DNS servers
dns_ok = self.check_dns_servers()
if not dns_ok:
self.logger.warning('WARNING: No DNS servers configured!')
self.logger.debug('WARNING: No DNS servers configured!')
if self.is_set('fixdns'):
dns_ok = self.fix_dns()
if not dns_ok:
Expand All @@ -648,11 +648,11 @@ def start(self):
to the already-defined (and potentially some yet-to-be-defined)
abstract methods that handle the real OS-specific stuff.
"""
self.logger.info('Starting...')
self.logger.debug('Starting...')
return self.startCallback()

def stop(self):
self.logger.info('Stopping...')
self.logger.debug('Stopping...')
return self.stopCallback()

@abc.abstractmethod
Expand Down Expand Up @@ -1048,14 +1048,14 @@ def parse_diverter_config(self):
default_listener = self.getconfigval('defaulttcplistener').lower()
default_port = self.listeners_config[default_listener]['port']
self.default_listener['TCP'] = int(default_port)
self.logger.error('Using default listener %s on port %d',
self.logger.debug('Using default listener %s on port %d',
self.getconfigval('defaulttcplistener').lower(),
self.default_listener['TCP'])

default_listener = self.getconfigval('defaultudplistener').lower()
default_port = self.listeners_config[default_listener]['port']
self.default_listener['UDP'] = int(default_port)
self.logger.error('Using default listener %s on port %d',
self.logger.debug('Using default listener %s on port %d',
self.getconfigval('defaultudplistener').lower(),
self.default_listener['UDP'])

Expand Down Expand Up @@ -1147,7 +1147,7 @@ def handle_pkt(self, pkt, callbacks3, callbacks4):
logline = self.formatPkt(pkt, pid, comm)
self.pdebug(DGENPKTV, logline)
elif pid and (pid != self.pid) and crit.first_packet_new_session:
self.logger.info(' pid: %d name: %s' %
self.logger.debug(' pid: %d name: %s' %
(pid, comm if comm else 'Unknown'))

# 2: Call layer 3 (network) callbacks
Expand Down Expand Up @@ -1415,7 +1415,7 @@ def check_log_icmp(self, crit, pkt):
None
"""
if pkt.is_icmp:
self.logger.info('ICMP type %d code %d %s' % (
self.logger.debug('ICMP type %d code %d %s' % (
pkt.icmp_type, pkt.icmp_code, pkt.hdrToStr()))

def getOriginalDestPort(self, orig_src_ip, orig_src_port, proto):
Expand Down
4 changes: 3 additions & 1 deletion fakenet/diverters/linutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ def linux_capture_iptables(self):
break
self.iptables_captured += buf

# set logging level to debug because of erroneous output
#TODO confirm validity of this check
if self.iptables_captured == '':
self.logger.error('Null iptables-save output, likely not ' +
self.logger.debug('Null iptables-save output, likely not ' +
'privileged')
ret = p.wait()
except OSError as e:
Expand Down
19 changes: 10 additions & 9 deletions fakenet/diverters/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def init_diverter_linux(self):
slists = ['linuxredirectnonlocal', ]
self.reconfigure(portlists=[], stringlists=slists)

self.logger.info('Running in %s mode' % (self.network_mode))
self.logger.debug('Running in %s mode' % (self.network_mode))

self.nfqueues = list()

Expand Down Expand Up @@ -96,8 +96,8 @@ def init_diverter_linux(self):

def startCallback(self):
if not self.check_privileged():
self.logger.error('The Linux Diverter requires administrative ' +
'privileges')
self.logger.critical('The Linux Diverter requires ' +
'administrative privileges')
sys.exit(1)

ret = self.linux_capture_iptables()
Expand Down Expand Up @@ -132,7 +132,7 @@ def startCallback(self):
'numbers') % (nhooks))
qnos = self.linux_get_next_nfqueue_numbers(nhooks)
if len(qnos) != nhooks:
self.logger.error('Could not procure a sufficient number of ' +
self.logger.critical('Could not procure a sufficient number of ' +
'netfilter queue numbers')
sys.exit(1)

Expand All @@ -149,7 +149,8 @@ def startCallback(self):
self.nfqueues.append(q)
ok = q.start()
if not ok:
self.logger.error('Failed to start NFQUEUE for %s' % (str(q)))
self.logger.critical('Failed to start NFQUEUE for %s'
% (str(q)))
self.stop()
sys.exit(1)

Expand Down Expand Up @@ -181,13 +182,13 @@ def startCallback(self):
self.rules_added += rules

if not ok:
self.logger.error('Failed to process LinuxRedirectNonlocal')
self.logger.critical('Failed to process LinuxRedirectNonlocal')
self.stop()
sys.exit(1)

ok, rule = self.linux_redir_icmp()
if not ok:
self.logger.error('Failed to redirect ICMP')
self.logger.critical('Failed to redirect ICMP')
self.stop()
sys.exit(1)

Expand All @@ -212,7 +213,7 @@ def stopCallback(self):
self.pdebug(DPCAP, 'Closing pcap file %s' % (self.pcap_filename))
self.pcap.close() # Only after all queues are stopped

self.logger.info('Stopped Linux Diverter')
self.logger.debug('Stopped Linux Diverter')

if self.single_host_mode and self.is_set('modifylocaldns'):
self.linux_restore_local_dns()
Expand Down Expand Up @@ -311,7 +312,7 @@ def check_log_nonlocal(self, crit, pkt):
# Log when a new IP is observed OR if we are not restricted to
# logging only the first occurrence of a given nonlocal IP.
if first_sighting or (not self.log_nonlocal_only_once):
self.logger.info(
self.logger.debug(
'Received nonlocal IPv%d datagram destined for %s' %
(pkt.ipver, pkt.dst_ip))

Expand Down
26 changes: 13 additions & 13 deletions fakenet/diverters/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, diverter_config, listeners_config, ip_addrs,
self.running_on_windows = True

if not self.single_host_mode:
self.logger.error('Windows diverter currently only supports '
self.logger.critical('Windows diverter currently only supports '
'SingleHost mode')
sys.exit(1)

Expand All @@ -113,7 +113,7 @@ def __init__(self, diverter_config, listeners_config, ip_addrs,
if not self.external_ip:
self.external_ip = socket.gethostbyname(socket.gethostname())

self.logger.info('External IP: %s Loopback IP: %s' %
self.logger.debug('External IP: %s Loopback IP: %s' %
(self.external_ip, self.loopback_ip))

#######################################################################
Expand All @@ -129,19 +129,19 @@ def __init__(self, diverter_config, listeners_config, ip_addrs,
self.handle.open()
except WindowsError, e:
if e.winerror == 5:
self.logger.error('ERROR: Insufficient privileges to run '
self.logger.critical('ERROR: Insufficient privileges to run '
'windows diverter.')
self.logger.error(' Please restart with Administrator '
'privileges.')
self.logger.critical(' Please restart with '
'Administrator privileges.')
sys.exit(1)
elif e.winerror == 3:
self.logger.error('ERROR: Could not locate WinDivert DLL or '
'one of its components.')
self.logger.error(' Please make sure you have copied '
self.logger.critical('ERROR: Could not locate WinDivert DLL '
'or one of its components.')
self.logger.critical(' Please make sure you have copied '
'FakeNet-NG to the C: drive.')
sys.exit(1)
else:
self.logger.error('ERROR: Failed to open a handle to the '
self.logger.critical('ERROR: Failed to open a handle to the '
'WinDivert driver: %s', e)
sys.exit(1)

Expand All @@ -157,7 +157,7 @@ def startCallback(self):
if self.is_set('stopdnsservice'):
self.stop_service_helper('Dnscache')

self.logger.info('Diverting ports: ')
self.logger.debug('Diverting ports: ')

self.flush_dns()

Expand Down Expand Up @@ -298,11 +298,11 @@ def redirIcmpIpUnconditionally(self, crit, pkt):
"""
if (pkt.is_icmp and
pkt.dst_ip not in [self.loopback_ip, self.external_ip]):
self.logger.info('Modifying ICMP packet (type %d, code %d):' %
self.logger.debug('Modifying ICMP packet (type %d, code %d):' %
(pkt.icmp_type, pkt.icmp_code))
self.logger.info(' from: %s' % (pkt.hdrToStr()))
self.logger.debug(' from: %s' % (pkt.hdrToStr()))
pkt.dst_ip = self.getNewDestinationIp(pkt.src_ip)
self.logger.info(' to: %s' % (pkt.hdrToStr()))
self.logger.debug(' to: %s' % (pkt.hdrToStr()))

return pkt

Expand Down
Loading