当前位置: 首页>>代码示例>>Python>>正文


Python utils.PcapWriter方法代码示例

本文整理汇总了Python中scapy.utils.PcapWriter方法的典型用法代码示例。如果您正苦于以下问题:Python utils.PcapWriter方法的具体用法?Python utils.PcapWriter怎么用?Python utils.PcapWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.utils的用法示例。


在下文中一共展示了utils.PcapWriter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def start(self):
        # Wireshark must be running first, because PcapWriter will block until
        # data has been read!
        with ContextManagerSubprocess(conf.prog.wireshark):
            args = [conf.prog.wireshark, "-Slki", "-"]
            if self.args:
                args.extend(self.args)

            proc = subprocess.Popen(
                args,
                stdin=subprocess.PIPE,
                stdout=None,
                stderr=None,
            )

        self.fname = proc.stdin
        WrpcapSink.start(self) 
开发者ID:secdev,项目名称:scapy,代码行数:19,代码来源:scapypipes.py

示例2: __init__

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def __init__(self, psk = None, essid = None, pcap = False):
        self.pt = PE.pt
        if psk is not None and essid is not None:
            if os.path.isfile('handshakes.sqlite'):
                os.remove('handshakes.sqlite')
            self.con = lite.connect('handshakes.sqlite')
            self.con.text_factory = str
            self.db = self.con.cursor()
            self.tgtInfo = {}
            self.availTgts = set()
            self.catchDict = {}
            self.encDict = {}
            self.alert = set()
            self.pke = 'Pairwise key expansion'
            self.pmk = PBKDF2(psk, essid, 4096).read(32)
            self.db.execute('CREATE TABLE IF NOT EXISTS\
                                "shakes"("pkt" TEXT,\
                                         "vmac" TEXT,\
                                         "bmac" TEXT,\
                                         "nonce" TEXT,\
                                         "e_num" TEXT,\
                                         UNIQUE(vmac, bmac, e_num));')
            self.con.commit()
            if pcap is True:
                self.eapolTrack = PcapWriter('eapols.pcap', sync = True)
                self.pcap = pcap
            else:
                self.eapolTrack = None
                self.pcap = None 
开发者ID:ICSec,项目名称:pyDot11,代码行数:31,代码来源:handshake.py

示例3: __init__

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def __init__(self, iface, save, file__, curses):
		self.iface=iface
		self.save=save
		self.file__ = PcapWriter(file__, append=True, sync=True) if self.save else ''
		self.handshakes = 0
		self.stop_hopper = False
		self.thread = self.chain_thread()
		self.curses = curses
		if self.curses:
			self.display = Display(self)
		signal.signal(signal.SIGINT, self.print_exit) 
开发者ID:hash3liZer,项目名称:airpydump,代码行数:13,代码来源:airpydump.py

示例4: pre_scanning

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def pre_scanning(self):
        self.packet_logger = PcapWriter(self.destination_folder + self.current_log_file,
                                        append=True, sync=True)
        SessionManager().log_event(NeutralEvent("Packet Logger initiated.")) 
开发者ID:Esser420,项目名称:EvilTwinFramework,代码行数:6,代码来源:packetlogger.py

示例5: refresh

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def refresh(self):
        self._nlogs = self._get_log_count()
        self.packet_logger = PcapWriter(self.destination_folder + "packet_log{n}.cap".format(n = self._nlogs),
        append=True, sync=True) 
开发者ID:Esser420,项目名称:EvilTwinFramework,代码行数:6,代码来源:packetlogger.py

示例6: __init__

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def __init__(self,
                 iface = '',
                 newiface = 'mon0',
                 filename = '',
                 outputmode = 1,
                 savingPkt = 0,
                 savingPcap = 0,
                 filtermode = '',
                 iHost = []):
	
        self.iface = iface #old interface 
        self.newiface = newiface #a new interface in monitor mode
        self.sign = ['—','\\' ,'|' ,'/'] #stupid thing :)
        self.filename = filename #local pcap filename
	self.sfilename = str(int(time.time()))
        self.outputmode = outputmode #0->don't output, 1->output
	self.savingPkt = savingPkt #0->don't save, 1->save
	self.savingPcap = savingPcap
	self.filtermode = '( tcp[13:1]==24 )' #'tcp[13:1]==24' #only sniff tcp
	self.iHost = iHost
	
	if filtermode: self.filtermode += ' and ( %s )' %filtermode #
	
	if self.savingPkt: InitPktsFile(self.sfilename)
	if savingPcap: self.pktdump = PcapWriter("./Pcaps/%s.pcap" %(self.sfilename), append=True, sync=True)
	    
        if self.iface == '' and filename: 
            print putColor('[!]Offline Mode!', 'green')
	    print '  [-]Filter:', putColor(self.filtermode, 'green')
            pkt = sniff(offline = './Pcaps/' + filename,    
	                prn = self.Collector,    
	                filter = self.filtermode,   
	                store = 0)#DO NOT USING store = 1!!! 
	                          #Or you'll see your memory BOOM
	    print 
	    
        else: self.Init()
	
        self.Exit() 
开发者ID:Macr0phag3,项目名称:Sniffer,代码行数:41,代码来源:sniffer-v1.0.py

示例7: __init__

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def __init__(self,
                 iface = '',
                 newiface = 'mon0',
                 filename = '',
                 outputmode = 1,
                 savingPkt = 0,
                 savingPcap = 0,
                 filtermode = '',
                 iHost = []):

        self.iface = iface #old interface 
        self.newiface = newiface #a new interface in monitor mode
        self.sign = ['—','\\' ,'|' ,'/'] #stupid thing :)
        self.filename = filename #local pcap filename
        self.sfilename = str(int(time.time()))
        self.outputmode = outputmode #0->don't output, 1->output
        self.savingPkt = savingPkt #0->don't save, 1->save
        self.savingPcap = savingPcap
        self.filtermode = '( tcp[13:1]==24 )' #'tcp[13:1]==24' -> only sniff tcp
        self.iHost = iHost
        
        if filtermode: self.filtermode += ' and ( %s )' %filtermode #

        if self.savingPkt: InitPktsFile(self.sfilename)
        if savingPcap: self.pktdump = PcapWriter("./Pcaps/%s.pcap" %(self.sfilename), append=True, sync=True)

        if self.iface == '' and filename: 
            print putColor('[!]Offline Mode!', 'green')
            print '  [-]Filter:', putColor(self.filtermode, 'green')
            print '  [-]',
            ClearLine() 
            pkt = sniff(offline = './Pcaps/' + filename,    
                        prn = self.Collector,    
                        filter = self.filtermode,   
                        store = 0)#DO NOT USING store = 1!!!              
                                  #Or you'll see your memory BOOM
            print 

        else: self.Init()

        self.Exit() 
开发者ID:Macr0phag3,项目名称:Sniffer,代码行数:43,代码来源:sniffer-v2.0.py

示例8: __init__

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def __init__(self,
                 iface = '',
                 newiface = 'mon0',
                 filename = '',
                 outputmode = 1,
                 savingPkt = 0,
                 savingPcap = 0,
                 filtermode = '',
                 iHost = []):

        self.iface = iface #old interface 
        self.newiface = newiface #a new interface in monitor mode
        self.sign = ['—','\\' ,'|' ,'/'] #stupid thing :)
        self.filename = filename #local pcap filename
        self.sfilename = str(int(time.time()))
        self.outputmode = outputmode #0->don't output, 1->output
        self.savingPkt = savingPkt #0->don't save, 1->save
        self.savingPcap = savingPcap
        self.filtermode = '( tcp[13:1]==24 )' #'tcp[13:1]==24' -> only sniff tcp
        self.iHost = iHost
        
        if filtermode: self.filtermode += ' and ( %s )' %filtermode #

        if self.savingPkt: InitPktsFile(self.sfilename)
        if savingPcap: self.pktdump = PcapWriter("./Pcaps/%s.pcap" %(self.sfilename), append=True, sync=True)

        if self.iface == '' and filename: 
            print(putColor('[!]Offline Mode!', 'green'))
            print('  [-]Filter:', putColor(self.filtermode, 'green'))
            print('  [-]', end='')
            ClearLine() 
            pkt = sniff(offline = './Pcaps/' + filename,    
                        prn = self.Collector,    
                        filter = self.filtermode,   
                        store = 0)#DO NOT USING store = 1!!!              
                                  #Or you'll see your memory BOOM
            print()

        else: self.Init()

        self.Exit() 
开发者ID:Macr0phag3,项目名称:Sniffer,代码行数:43,代码来源:sniffer-v2.0-Py3.x.py

示例9: save

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def save(self):
		global WRITE__
		
		if WRITE__:
			_wr = PcapWriter(WRITE__, append=False, sync=True)
			_wr.write(self.THEPOL)
			pull.use("Handshake >> [%s] Count [%s] %s[Saved]%s" % (pull.DARKCYAN+WRITE__+pull.END, str(len(self.THEPOL)), pull.GREEN, pull.END ))
		else:
			pull.error("Handshake not saved. Use -w, --write for saving handshakes. ") 
开发者ID:hash3liZer,项目名称:WiFiBroot,代码行数:11,代码来源:wifibroot.py

示例10: __init__

# 需要导入模块: from scapy import utils [as 别名]
# 或者: from scapy.utils import PcapWriter [as 别名]
def __init__(self):       
        parser = argparse.ArgumentParser(description='Version: 3.0; Running in Py2.x')
        parser.add_argument("-i", default='', help="the interface you want to use")
        parser.add_argument("-mi", default='mon0', help="name of the interface in monitor mode")
        parser.add_argument("-f", default='', help="local pcap filename(in the offline mode)")
        parser.add_argument("-o", default='1', help="show msg in the terminal? 0: No, 1: Yes")
        parser.add_argument("-sPkt", default='1', help="save Pkts during snifffing? 0: No, 1: Yes")
        parser.add_argument("-sPcap", default='0', help="save Pcap during snifffing? 0: No, 1: Yes")
        parser.add_argument("-fm", default='', help="filter syntax used in scapy")
        parser.add_argument("-iHF", default='iHost.txt', help="highlight these hosts when stop the sniffer(in the iHost.txt")
        parser.add_argument("-fHF", default='fHost.txt', help="filter these hosts when show msg in terminal(in the fHost.txt")
        args = parser.parse_args() 
        
        self.iface = args.i #old interface 
        self.newiface = args.mi #a new interface in monitor mode
        self.sign = ['—','\\' ,'|' ,'/'] #stupid thing :)
        self.filename = args.f #local pcap filename
        self.sfilename = str(int(time.time()))
        self.outputmode = args.o #0->don't output, 1->output
        self.savingPkt = args.sPkt #0->don't save, 1->save
        self.savingPcap = args.sPcap
        self.filtermode = '( tcp[13:1]==24 )'#'tcp[13:1]==24' -> only sniff tcp
        self.SrcIP = []
        self.fHF = args.fHF
        
        if args.fm: self.filtermode += ' and ( %s )' %args.fm #

        if self.savingPkt == '1': InitPktsFile(self.sfilename)
        if self.savingPcap == '1': self.pktdump = PcapWriter("./Pcaps/%s.pcap" %(self.sfilename), append=True, sync=True)
        
        try:
            with open(args.iHF, 'r') as fp:
                self.iHost = re.findall('(\S+)', fp.read())
        except:
            ErrorDog(self.Exit)
            
        if self.iface == '' and self.filename: 
            print putColor('[!]Offline Mode!', 'green')
            print '  [-]Filter:', putColor(self.filtermode, 'green')
            print '  [-]',
            ClearLine() 
            
            try:
                pkt = sniff(offline = './Pcaps/' + self.filename,    
                        prn = self.Collector,    
                        filter = self.filtermode,   
                        store = 0)#DO NOT USING store = 1!!!              
                                  #Or you'll see your memory BOOM
                print 
            except:
                ErrorDog(self.Exit)
                
        else: self.Init()

        self.Exit() 
开发者ID:Macr0phag3,项目名称:Sniffer,代码行数:57,代码来源:sniffer-v3.0.py


注:本文中的scapy.utils.PcapWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。