def teardown_tunnels(self, tunnels, work_dir, config_file):
"""Function destroys the created tunnels
Args:
tunnels : list of existing tunnels
work_dir : working directory path where the configuration files are located
config_file : name of the honeypot configuration file
"""
logging.debug('Destroying tunnel interfaces.')
config_file_location = os.path.join(work_dir, config_file)
parser = ConfigParser()
parser.read(config_file)
try:
tunnel_id = int(parser.getint("tunnel", "startid"))
except (NoSectionError, NoOptionError):
logger.error('Error: Incomplete honeyd.cfg configuration.')
sys.exit(1)
for i in range(0, len(tunnels)):
tunnel_id += 1
name = 'tun' + str(tunnel_id)
subprocess.Popen(['ip', 'link', 'set', name, 'down'])
subprocess.Popen(['ip', 'tunnel', 'del', name])
for mode in ['ipip', 'ip_gre']:
subprocess.Popen(['modprobe', '-r', mode])
评论列表
文章目录