From 3c31c86b8f24fcd9b066e6ab4388e8631fe4dd44 Mon Sep 17 00:00:00 2001 From: Phil <phil@secdev.org> Date: Mon, 28 Jul 2008 16:13:00 +0200 Subject: [PATCH] Fixed import dependency between config.py, themes.py and arch.py --- scapy/arch.py | 17 +++++++++-------- scapy/base_classes.py | 3 +++ scapy/config.py | 7 +++---- scapy/fields.py | 2 +- scapy/themes.py | 8 ++++---- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/scapy/arch.py b/scapy/arch.py index 7d1f7051..7e48272c 100644 --- a/scapy/arch.py +++ b/scapy/arch.py @@ -2,7 +2,8 @@ import sys,os,struct,socket,time from fcntl import ioctl from data import * -from config import conf + +import config try: import Gnuplot @@ -177,7 +178,7 @@ else: if not TCPDUMP: return try: - f = os.popen("%s -i %s -ddd -s 1600 '%s'" % (conf.prog.tcpdump,conf.iface,filter)) + f = os.popen("%s -i %s -ddd -s 1600 '%s'" % (config.conf.prog.tcpdump,config.conf.iface,filter)) except OSError,msg: log_interactive.warning("Failed to execute tcpdump: (%s)") return @@ -379,7 +380,7 @@ if 0 and DNET: ## XXX Can't use this because it does not resolve IPs not in cach tmp = map(ord, inet_aton(ip)) if (tmp[0] & 0xf0) == 0xe0: # mcast @ return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3]) - iff,a,gw = conf.route.route(ip) + iff,a,gw = config.conf.route.route(ip) if iff == "lo": return "ff:ff:ff:ff:ff:ff" if gw != "0.0.0.0": @@ -394,14 +395,14 @@ else: tmp = map(ord, inet_aton(ip)) if (tmp[0] & 0xf0) == 0xe0: # mcast @ return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3]) - iff,a,gw = conf.route.route(ip) - if ( (iff == "lo") or (ip == conf.route.get_if_bcast(iff)) ): + iff,a,gw = config.conf.route.route(ip) + if ( (iff == "lo") or (ip == config.conf.route.get_if_bcast(iff)) ): return "ff:ff:ff:ff:ff:ff" if gw != "0.0.0.0": ip = gw - if conf.arp_cache.has_key(ip): - mac, timeout = conf.arp_cache[ip] + if config.conf.arp_cache.has_key(ip): + mac, timeout = config.conf.arp_cache[ip] if not timeout or (time.time()-timeout < ARPTIMEOUT): return mac @@ -414,7 +415,7 @@ else: nofilter=1) if res is not None: mac = res.payload.hwsrc - conf.arp_cache[ip] = (mac,time.time()) + config.conf.arp_cache[ip] = (mac,time.time()) return mac return None diff --git a/scapy/base_classes.py b/scapy/base_classes.py index bf151bd5..30f91738 100644 --- a/scapy/base_classes.py +++ b/scapy/base_classes.py @@ -166,3 +166,6 @@ class BasePacket(Gen): class BasePacketList: pass + + + diff --git a/scapy/config.py b/scapy/config.py index 5d7872ff..e97ee34d 100644 --- a/scapy/config.py +++ b/scapy/config.py @@ -1,8 +1,7 @@ import os -from arch import * from data import * -from themes import * import base_classes +import arch,themes ############ ## Config ## @@ -138,7 +137,7 @@ extensions_paths: path or list of paths where extensions are to be looked for version = "2.0.0.1 alpha" session = "" stealth = "not implemented" - iface = get_working_if() + iface = arch.get_working_if() layers = LayersList() checkIPID = 0 checkIPsrc = 1 @@ -161,7 +160,7 @@ extensions_paths: path or list of paths where extensions are to be looked for route = None # Filed by arch auto_fragment = 1 debug_dissector = 0 - color_theme = DefaultTheme() + color_theme = themes.DefaultTheme() warning_threshold = 5 prog = ProgPath() resolve = Resolve() diff --git a/scapy/fields.py b/scapy/fields.py index b402ac39..6cf178f9 100644 --- a/scapy/fields.py +++ b/scapy/fields.py @@ -3,7 +3,7 @@ from config import conf from volatile import VolatileValue from data import * from utils import * -from base_classes import BasePacket +from base_classes import BasePacket,Gen,Net ############ diff --git a/scapy/themes.py b/scapy/themes.py index e7676cce..2dc6a860 100644 --- a/scapy/themes.py +++ b/scapy/themes.py @@ -1,4 +1,4 @@ -from config import conf +import config ################## ## Color themes ## @@ -237,12 +237,12 @@ class ColorPrompt: __prompt = ">>> " def __str__(self): try: - ct = conf.color_theme + ct = config.conf.color_theme if isinstance(ct, AnsiColorTheme): ## ^A and ^B delimit invisible caracters for readline to count right - return "\001%s\002" % ct.prompt("\002"+conf.prompt+"\001") + return "\001%s\002" % ct.prompt("\002"+config.conf.prompt+"\001") else: - return ct.prompt(conf.prompt) + return ct.prompt(config.conf.prompt) except: return self.__prompt -- GitLab