def __write_tcp_segment_verbose_output__(self, segment_data): ''' Formats the terminal verbose output for the TCP segment portion of the packets @param (segment_data) - Contents within the segment (i.e flags, ports, etc.) @return None ''' pk = Packet() cfg = Config() esp = Espionage() (segment_source_port, segment_destination_port, segment_sequence, segment_acknowledgment, __urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__, __syn_flag__, __fin_flag__) = pk.unpack_packet(cfg.ESPI_TCP_STRUCT_SEGMENT_FORMAT, segment_data, 24) esp.print_espionage_noprefix("\tTCP Segment {}".format( cfg.ESPI_ASCII_DOWN_ARROW)) esp.print_espionage_notab( "\t\tSource Port # {}, Destination Port # {}, [Sequence] {}". format(segment_source_port, segment_destination_port, segment_sequence)) # Write Flags esp.print_espionage_noprefix("\t\tTCP Segment Flags") esp.print_espionage_notab( "\t\tFLAG_URG: {}, FLAG_ACK: {}, FLAG_PSH: {}, FLAG_RST: {}". format(__urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__)) # SYN/FIN esp.print_espionage_notab("\t\tFLAG_SYN: {}, FLAG_FIN: {}".format( __syn_flag__, __fin_flag__))
def load_tcp_segment(self, segment_data): ''' Unpacks TCP segment of the IPv4 packet, sets flags @param (segment_data, bytes/string) @return string, int, array[element] : element -> segment offset value. ''' cfg = Config() pk = Packet() try: (reserved_byte_offset, source_port_value, destination_port_value, ack, seq) = pk.unpack_packet(cfg.ESPI_TCP_SEGMENT_FORMAT, segment_data, 8) __offset__ = (reserved_byte_offset >> 12) * cfg.__version_header_shifter_length__ __urg_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_urg_shift_value__ __ack_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_ack_shift_value__ __psh_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_psh_shift_value__ __rst_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_rst_shift_value__ __syn_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_syn_fin_shift_value__ __fin_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_syn_fin_shift_value__ return source_port_value, destination_port_value, seq, ack, __urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__, __syn_flag__, __fin_flag__, segment_data[ __offset__:] except: pass
def load_tcp_segment(self, segment_data): cfg = Config() pk = Packet() (reserved_byte_offset, source_port_value, destination_port_value, ack, seq) = pk.unpack_packet(cfg.ESPI_TCP_SEGMENT_FORMAT, segment_data, 8) __offset__ = ( reserved_byte_offset >> 12) * cfg.__version_header_shifter_length__ __urg_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_urg_shift_value__ __ack_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_ack_shift_value__ __psh_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_psh_shift_value__ __rst_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_rst_shift_value__ __syn_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_syn_fin_shift_value__ __fin_flag__ = (reserved_byte_offset & 32) >> cfg.__flag_syn_fin_shift_value__ return source_port_value, destination_port_value, seq, ack, __urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__, __syn_flag__, __fin_flag__, segment_data[ __offset__:]
def load_udp_segment(self, segment_data): cfg = Config() pk = Packet() udp_port_destination, udp_port_source, udp_size = pk.unpack_packet( cfg.ESPI_UDP_SEGMENT_FORMAT, segment_data, 8) return udp_port_source, udp_port_destination, udp_size, segment_data[ 8:]
def __init__(self, net, num_func, pos_func): """ :param num_func: def(int)->int 请求量生成函数, :param pos_func: def(int)->[nodename,...] 位置生成函数 """ self.name= Name(['']) self.ipacket= Packet(self.name, Packet.TYPE.INTEREST) self.dpacket= Packet(self.name, Packet.TYPE.DATA) self.net= net self.num_func= num_func self.pos_func= pos_func self.db_monitor= ExperimentMonitorDataBase(self.net) StoreProvider(self.net, self.db_monitor)
def unpack_ether_frame(self, frame_data): ''' @param (frame_data) - Contents of the ethernet frame @return None ''' cfg = Config() pk = Packet() nf = NetworkFrame() destination, source, protocol = pk.unpack_packet( cfg.ESPI_ETHERNET_FRAME_STR, frame_data, 14) return nf.retrieve_mac_address(destination), nf.retrieve_mac_address( source), socket.htons(protocol), frame_data[14:]
def load_udp_segment(self, segment_data): ''' Unpacks UDP datagram from the IPv4 packet header @param (segment_data, bytes/string) @return string, unsigned long, array[element(type=int)] ''' cfg = Config() pk = Packet() try: udp_port_source, udp_port_destination, udp_size = pk.unpack_packet( cfg.ESPI_UDP_SEGMENT_FORMAT, segment_data, 8) return udp_port_source, udp_port_destination, udp_size, segment_data[ 8:] except: pass
def __write_icmp_verbose_output__(self, packet_data): ''' Formats the verbose terminal output for ICMP Packet Data (only going to be exectuted in espionage.py conditional) @param (packet_data) - Contents of the ICMP packet @return None ''' pk = Packet() cfg = Config() esp = Espionage() try: icmp_packet_type, icmp_packet_code, icmp_check_summation, icmp_packet_data = pk.handle_icmp_packet(packet_data) esp.print_espionage_message("ICMP Contents {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) esp.print_espionage_notab("ICMP Checksum: {}, ICMP Type: {}, ICMP Code: {}".format(icmp_check_summation, icmp_packet_type, icmp_packet_code)) esp.print_espionage_notab("\t\tICMP Data: {}".format(icmp_packet_data)) except: pass
def __write_icmp_normal_output__(self, packet_data): ''' Formats the terminal output for ICMP Packet Data @param (packet_data) - Contents of the ICMP packet @return None ''' pk = Packet() cfg = Config() esp = Espionage() icmp_packet_type, icmp_packet_code, icmp_check_summation, icmp_packet_data = pk.handle_icmp_packet( packet_data) esp.print_espionage_message("ICMP Contents {}".format( cfg.ESPI_ASCII_DOWN_ARROW)) esp.print_espionage_notab( "ICMP Checksum: {}, ICMP Type: {}, ICMP Code: {}".format( icmp_check_summation, icmp_packet_type, icmp_packet_code))
def __write_ipv4_normal_output__(self, packet_data): ''' Formats the terminal output for IPv4 Packet Data @param (packet_data) - Contents of the IPv4 packet @return None ''' pk = Packet() cfg = Config() esp = Espionage() try: (packet_version, packet_header_length, packet_ttl, packet_protocol, packet_source, packet_destination, packet_data) = pk.handle_ipv4_packet(packet_data) esp.print_espionage_message("IPv4 Packet Contents {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) esp.print_espionage_notab("\t <-- Protocol: {}, Source: {}, Destination: {}".format(packet_protocol, packet_source, packet_destination)) except: pass
def __write_tcp_segment_normal_output__(self, segment_data): ''' Formats the terminal output for the TCP segment portion of the packets @param (segment_data) - Contents within the segment (i.e flags, ports, etc.) @return None ''' pk = Packet() cfg = Config() esp = Espionage() try: (segment_source_port, segment_destination_port, segment_sequence, segment_acknowledgment, __urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__, __syn_flag__, __fin_flag__) = pk.unpack_packet(cfg.ESPI_TCP_STRUCT_SEGMENT_FORMAT, segment_data, 24) esp.print_espionage_noprefix("\tTCP Segment {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) esp.print_espionage_notab("\t\tSource Port # {}, Destination Port # {}, [Sequence] {}".format(segment_source_port, segment_destination_port, segment_sequence)) except: pass
def main(): ''' The main control flow to run the simulation :return: None ''' TOTAL_SERVICE_CHAIN_NUM = 4 TOTAL_SIM_TIME = 1000 random.seed(4) # step1: create network topology t = Topology() t.load_network_graph(path='./topology/topology.txt') t.create_network_topology() for link in t.links.values(): env.process(link.run()) paths = cal_shortest_path(t.topology, t.links) # step2: initialize servers servers = Server.init_servers(t.get_nodes(), t.get_links()) # step3: create service chains service_chains = [ ServiceChain.random_gen() for _ in range(TOTAL_SERVICE_CHAIN_NUM) ] # step4: place service chains. single instance... multiple instance... for chain in service_chains: best_fit(servers, chain) # launch server processes for server in servers.values(): server.run() # step5: generate a packet pool packet_pool = Packet.gen_packet_pool(servers, paths, service_chains) # step6 create a packet from the packet pool and simulate routing process. # env.process(flow_generator(packet_pool, servers, t.links)) # single packet test # packet = random.choice(packet_pool) # print(packet.routing_path) # print(packet.vnf_server_addr) # packet.forward() # generating traffic flow env.process(flow_generator(packet_pool)) env.run(TOTAL_SIM_TIME)
def __write_ipv4_verbose_output__(self, packet_data): ''' Formats the verbose terminal output for IPv4 Packet Data @param (packet_data) - Contents of the IPv4 packet @return None ''' pk = Packet() cfg = Config() esp = Espionage() (packet_version, packet_header_length, packet_ttl, packet_protocol, packet_source, packet_destination, packet_data) = pk.handle_ipv4_packet(packet_data) esp.print_espionage_message("IPv4 Packet Contents {}".format( cfg.ESPI_ASCII_DOWN_ARROW)) esp.print_espionage_notab("Version: " + str(packet_version) + ", TTL: " + str(packet_ttl) + ", Header: " + str(packet_header_length)) esp.print_espionage_notab("\tProtocol: " + str(packet_protocol) + ", Source: " + str(packet_source) + ", Destination: " + str(packet_destination))
def flow_generator(packet_pool): ''' randomly generate a packet from the packet pool, and make it go through the placed service chain. :param packet_pool: :param servers: :param links: :return: None ''' # todo: consider to find a Poisson distribution for the packet generation or to use the wiki traffic trace. while True: yield env.timeout(1) packet = Packet.random_gen(packet_pool) packet.create_time = env.now env.process(packet.forward())
class Simulation: def __init__(self, net, num_func, pos_func): """ :param num_func: def(int)->int 请求量生成函数, :param pos_func: def(int)->[nodename,...] 位置生成函数 """ self.name= Name(['']) self.ipacket= Packet(self.name, Packet.TYPE.INTEREST) self.dpacket= Packet(self.name, Packet.TYPE.DATA) self.net= net self.num_func= num_func self.pos_func= pos_func self.db_monitor= ExperimentMonitorDataBase(self.net) StoreProvider(self.net, self.db_monitor) def setCSMode(self, mode):#配置CS类型 for node in self.net.nodes(): node.api['CS::setMode'](mode) def setCSTime(self, time):#配置CS时间 for node in self.net.nodes(): node.api['CS::setLifeTime'](time) def setSourceNode(self, nodename): self.net.node( nodename ).api['CS::setMode'](SimulatCSUnit.MODE.MANUAL)# 源节点: 替换 or 不被替换 self.net.node( nodename ).api['CS::store']( self.dpacket )# 要在CS类型配置之后,才会被正确驱逐 def asks(self, nodenames): for nodename in nodenames: self.net.node(nodename).api['APP::ask']( self.ipacket.fission() ) def simulate(self, steps): for i in range(0, steps): nodenum= self.num_func(i) # FIXME i 如何对应 t nodenames= self.pos_func( nodenum ) self.asks(nodenames) clock.step()
import cProfile import pstats def timeProfile(cmd): prof = cProfile.Profile() prof.run(cmd) pstats.Stats(prof).strip_dirs().sort_stats('tottime').print_stats( '', 20) # sort_stats: ncalls, tottime, cumtime log = Logger(Logger.LEVEL.TRACK) label = LabelTable() #全局标签 from core.packet import Packet from core.packet import Name debug_ip = Packet(Name(['DEBUG_PACKET']), Packet.TYPE.INTEREST) debug_ip1 = Packet(Name(['DEBUG_PACKET', 1]), Packet.TYPE.INTEREST) debug_ip2 = Packet(Name(['DEBUG_PACKET', 2]), Packet.TYPE.INTEREST) debug_dp = Packet(Name(['DEBUG_PACKET']), Packet.TYPE.DATA) debug_dp1 = Packet(Name(['DEBUG_PACKET', 1]), Packet.TYPE.DATA) debug_dp2 = Packet(Name(['DEBUG_PACKET', 2]), Packet.TYPE.DATA) else: log = Logger(Logger.LEVEL.NOLOG) label = NoLabelTable() # 全局变量 INF = 0x7FFFFFFF #无穷大 此处用4byte整形最大正数 #======================================================================================================================= import numpy
def espionage_main(): esp = Espionage() p = Platform() cfg = Config() nf = NetworkFrame() opt = ProtoOutput() pk = Packet() seg = Segment() so = SegmentOutput() p.EspionageClear() p.GetOperatingSystemDescriptor() time.sleep(0.7) LoadEspionageBanner() time.sleep(0.7) parser = argparse.ArgumentParser() parser.add_argument("--version", help="returns the packet sniffers version.", action="store_true") parser.add_argument("-n", "--normal", help="executes a cleaner interception, less sophisticated.", action="store_true") parser.add_argument("-v", "--verbose", help="(recommended) executes a more in-depth packet interception/sniff.", action="store_true") parser.add_argument("-url", "--urlonly", help="only sniffs visited urls using http/https.", action="store_true") parser.add_argument("-o", "--onlyhttp", help="sniffs only tcp/http data, returns urls visited.", action="store_true") parser.add_argument("-ohs", "--onlyhttpsecure", help="sniffs only https data, (port 443).", action="store_true") parser.add_argument("-hr", "--httpraw", help="displays raw packet data (byte order) recieved or sent on port 80.", action="store_true") file_arg_section = parser.add_argument_group('(Recommended) arguments for data output (.pcap)') file_arg_section.add_argument("-f", "--filename", help="name of file to store the output (make extension '.pcap').", type=str) required_arg_section = parser.add_argument_group('(Required) arguments required for execution') required_arg_section.add_argument("-i", "--iface", help="specify network interface (ie. wlan0, eth0, wlan1, etc.)", type=str, required=True) spoofer_section = parser.add_argument_group('(ARP Spoofing) required arguments in-order to use the ARP Spoofing utility') spoofer_section.add_argument("-t", "--target", required=False) args = parser.parse_args() pcap_file_name = str(args.filename) try: __socket__ = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0003)) if Interface(args.iface).is_interface_up(): __socket__.setsockopt(socket.SOL_SOCKET, 25, bytearray(str.encode(args.iface))) else: pass cfg.ESPIONAGE_PROCESS_ACTIVE = True except PermissionError as pe: cprint("Must be ran as root.", 'red', attrs=['bold']) sys.exit(cfg.ESPI_ERROR_CODE_STANDARD) if args.version: cprint("\t Version: {}\n".format(__version__), 'cyan', attrs=['bold']) elif args.normal: try: while cfg.ESPIONAGE_PROCESS_ACTIVE: raw_data, addr = __socket__.recvfrom(65536) dest_mac, src_mac, eth_proto, data = nf.unpack_ether_frame(raw_data) print(BOLD + G + "[espionage]>" + W + BOLD + 'Ethernet Frame: ') esp.print_espionage_notab('Destination: {}, Source: {}, Protocol: {}\n'.format(dest_mac, src_mac, eth_proto)) (packet_version, packet_header_length, packet_ttl, packet_protocol, packet_source, packet_destination, pkdata) = pk.handle_ipv4_packet(data) if eth_proto == 8: opt.__write_ipv4_normal_output__(data) if args.filename: PCAP(pcap_file_name).write_to_pcap_file("\nIPv4 Packet Contents {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("\t <-- Protocol: {}, Source: {}, Destination: {}".format(packet_protocol, packet_source, packet_destination)) else: pass if packet_protocol == 1: (icmp_packet_type, icmp_packet_code, icmp_check_summation, icmp_packet_data) = pk.handle_icmp_packet(data) opt.__write_icmp_normal_output__(data) if args.filename: PCAP(pcap_file_name).write_to_pcap_file("ICMP Contents {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("ICMP Checksum: {}, ICMP Type: {}, ICMP Code: {}".format(icmp_check_summation, icmp_packet_type,icmp_packet_code)) else: pass elif packet_protocol == 6: (segment_source_port, segment_destination_port, segment_sequence, segment_acknowledgment, __urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__, __syn_flag__, __fin_flag__) = pk.unpack_packet(cfg.ESPI_TCP_STRUCT_SEGMENT_FORMAT, data, 24) so.__write_tcp_segment_normal_output__(raw_data) if len(data) > cfg.ESPI_SUCCESS_CODE_STANDARD and args.httpraw: if segment_source_port == cfg.ESPI_HTTP_DEFAULT_PORT or segment_destination_port == cfg.ESPI_HTTP_DEFAULT_PORT: pk.handle_raw_http_packet(data) else: esp.print_espionage_noprefix('\t\t' + "Raw TCP/Raw-no-http Packet Bytes: ") print(espionage_textwrapper('\t\t\t', data)) else: pass if args.filename: PCAP(pcap_file_name).write_to_pcap_file("\n\tTCP Segment {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("\n\t\tSource Port # {}, Destination Port # {}, [Sequence] {}".format(segment_source_port, segment_destination_port, segment_sequence)) else: pass elif packet_protocol == 17: (segment_source_port, segment_destination_port, segment_length, segdata) = seg.load_udp_segment(data) so.__write_udp_segment_normal_verbose_output__(segdata) if args.filename: PCAP(pcap_file_name).write_to_pcap_file("\n\tUDP Segment (len={}) {}".format(segment_length, cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("\n\t\tSource Port: {}, Target Port: {}".format(segment_source_port, segment_destination_port)) else: pass except KeyboardInterrupt: if args.filename: print(BOLD + R + "\nExiting Espionage Interception.\n" + BOLD + G + "Packet capture saved to: {}".format(os.path.realpath(pcap_file_name)) + END) else: print(BOLD + R + "\nExiting Espionage Interception.\n" + BOLD + C + "Packet capture not written to file.\n" + END) elif args.verbose: try: while True: raw_data, addr = __socket__.recvfrom(65536) dest_mac, src_mac, eth_proto, data = nf.unpack_ether_frame(raw_data) print(BOLD + G + "[espionage]>" + W + BOLD + 'Ethernet Frame: ') esp.print_espionage_notab('Destination: {}, Source: {}, Protocol: {}\n'.format(dest_mac, src_mac, eth_proto)) (packet_version, packet_header_length, packet_ttl, packet_protocol, packet_source, packet_destination, pkdata) = pk.handle_ipv4_packet(data) if eth_proto == 8: opt.__write_ipv4_verbose_output__(data) if args.filename: PCAP(pcap_file_name).write_to_pcap_file("\nIPv4 Packet Contents {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("\t <-- Protocol: {}, Source: {}, Destination: {}".format(packet_protocol, packet_source, packet_destination)) else: pass if packet_protocol == 1: (icmp_packet_type, icmp_packet_code, icmp_check_summation, icmp_packet_data) = pk.handle_icmp_packet(data) opt.__write_icmp_verbose_output__(data) if args.filename: PCAP(pcap_file_name).write_to_pcap_file("ICMP Contents {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("ICMP Checksum: {}, ICMP Type: {}, ICMP Code: {}".format(icmp_check_summation, icmp_packet_type,icmp_packet_code)) PCAP(pcap_file_name).write_to_pcap_file("\t\tICMP Data: {}".format(icmp_packet_data)) else: pass elif packet_protocol == 6: (segment_source_port, segment_destination_port, segment_sequence, segment_acknowledgment, __urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__, __syn_flag__, __fin_flag__) = pk.unpack_packet(cfg.ESPI_TCP_STRUCT_SEGMENT_FORMAT, data, 24) so.__write_tcp_segment_verbose_output__(raw_data) if len(data) > cfg.ESPI_SUCCESS_CODE_STANDARD and args.httpraw: if segment_source_port == cfg.ESPI_HTTP_DEFAULT_PORT or segment_destination_port == cfg.ESPI_HTTP_DEFAULT_PORT: pk.handle_raw_http_packet(data) else: esp.print_espionage_noprefix('\t\t' + "Raw TCP/Raw-no-http Packet Bytes: ") print(espionage_textwrapper('\t\t\t', raw_data)) else: pass if args.filename: PCAP(pcap_file_name).write_to_pcap_file("\n\tTCP Segment {}".format(cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("\n\t\tSource Port # {}, Destination Port # {}, [Sequence] {}".format(segment_source_port, segment_destination_port, segment_sequence)) # Write TCP Segment flags to file PCAP(pcap_file_name).write_to_pcap_file("\n\t\tTCP Segment Flags") PCAP(pcap_file_name).write_to_pcap_file("\n\t\tFLAG_URG: {}, FLAG_ACK: {}, FLAG_PSH: {}, FLAG_RST: {}".format(__urg_flag__, __ack_flag__, __psh_flag__, __rst_flag__)) else: pass elif packet_protocol == 17: (segment_source_port, segment_destination_port, segment_length, segdata) = seg.load_udp_segment(data) so.__write_udp_segment_normal_verbose_output__(segdata) if args.filename: PCAP(pcap_file_name).write_to_pcap_file("\n\tUDP Segment (len={}) {}".format(segment_length, cfg.ESPI_ASCII_DOWN_ARROW)) PCAP(pcap_file_name).write_to_pcap_file("\n\t\tSource Port: {}, Target Port: {}".format(segment_source_port, segment_destination_port)) else: pass except KeyboardInterrupt: if args.filename: print(BOLD + R + "\nExiting Espionage Interception.\n" + BOLD + G + "Packet capture saved to: {}".format(os.path.realpath(pcap_file_name)) + END) else: print(BOLD + R + "\nExiting Espionage Interception.\n" + BOLD + C + "Packet capture not written to file.\n" + END) elif args.urlonly: cfg = Config() esp = Espionage() esp.print_espionage_message("Visited URLs will be displayed below.\n", True) sniff_url_from_http_packet(args.iface) elif args.onlyhttp: it = InterfaceHandle() cfg = Config() try: for sysiface in it.get_system_interfaces(): if args.iface in sysiface: if Interface(sysiface).is_interface_up(): pk = Packet() cprint("Interface: {} is active.".format(args.iface), 'green', attrs=['bold']) cfg.ESPI_NET_INTERFACE_ACTIVE = True break if Interface(args.iface).is_interface_up() == False: cprint("Interface: {} is not-active.".format(args.iface), 'red', attrs=['bold']) cfg.ESPI_NET_INTERFACE_ACTIVE = False if cfg.ESPI_NET_INTERFACE_ACTIVE: ESPHTTPHandle(sysiface, cfg.ESPI_HTTP_DEFAULT_PORT).sniff_basic_http() except KeyboardInterrupt: print(BOLD + R + "\n[!] Exiting Espionage HTTPS Interception.\n" + END) elif args.onlyhttpsecure: it = InterfaceHandle() cfg = Config() try: for sysiface in it.get_system_interfaces(): if args.iface in sysiface: if Interface(sysiface).is_interface_up(): pk = Packet() cprint("Interface: {} is active.".format(args.iface), 'green', attrs=['bold']) cfg.ESPI_NET_INTERFACE_ACTIVE = True break if Interface(args.iface).is_interface_up() == False: cprint("Interface: {} is not-active.".format(args.iface), 'red', attrs=['bold']) cfg.ESPI_NET_INTERFACE_ACTIVE = False if cfg.ESPI_NET_INTERFACE_ACTIVE: ESPHTTPSecureHandle(sysiface, cfg.ESPI_TCP_HTTPS_DEFAULT_PORT).sniff_basic_https() except KeyboardInterrupt: print(BOLD + R + "\n[!] Exiting Espionage HTTPS Interception.\n" + END) elif args.target: Route(cfg.ESPI_UNIX_LINUX_IP_ROUTE_PATH).ip_route_switch_on() default_gateway = Route(cfg.ESPI_UNIX_LINUX_IP_ROUTE_PATH).get_default_gateway() try: while True: ARPHandle(args.target, default_gateway).spoof_arp() ARPHandle(default_gateway, args.target).spoof_arp() time.sleep(1) except KeyboardInterrupt: print(BOLD + R + "\n[!] Quitting ARP Spoof. Restoring Network...\n" + END) ARPHandle(args.target, default_gateway).restore_network() ARPHandle(default_gateway, args.target).restore_network()