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


Python utils.get_csv_writer函数代码示例

本文整理汇总了Python中utils.utils.get_csv_writer函数的典型用法代码示例。如果您正苦于以下问题:Python get_csv_writer函数的具体用法?Python get_csv_writer怎么用?Python get_csv_writer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _csv_list_scheduled_jobs

    def _csv_list_scheduled_jobs(self):
        self.logger.info('Health : Listing scheduled jobs')
        file_tasks = self.output_dir + '_tasks.csv'
        with open(file_tasks, 'wb') as tasks_logs:
            proc = subprocess.Popen(["schtasks.exe", '/query', '/fo', 'CSV'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            res = proc.communicate()
            res = get_terminal_decoded_string(res[0])
            # clean and write the command output
            write_to_output('"TASK_NAME","NEXT_SCHEDULE","STATUS"\r\n', tasks_logs, self.logger)
            column_names = None
            for line in res.split('\r\n'):
                if line == "":
                    continue
                if line[0] != '"':
                    continue
                if not column_names:
                    column_names = line
                    continue
                elif column_names == line:
                    continue
                write_to_output(line+"\r\n", tasks_logs, self.logger)

        self.logger.info('Health : Listing scheduled jobs')
        with open(file_tasks, "r") as fr, open(self.output_dir + "_scheduled_jobs.csv", 'wb') as fw:
            csv_writer = get_csv_writer(fw)
            write_to_csv(["COMPUTER_NAME", "TYPE", "JOB_NAME", "TIME", "STATE"], csv_writer)
            for l in fr.readlines():
                l = l.decode('utf8')
                if l.find('\\') > 0:
                    l = l[:-1].replace('"', '')  # remove the end of line
                    arr_write = [self.computer_name, 'scheduled_jobs'] + l.split(',')
                    write_to_csv(arr_write, csv_writer)
        self.logger.info('Health : Listing scheduled jobs')
        record_sha256_logs(self.output_dir + '_scheduled_jobs.csv', self.output_dir + '_sha256.log')
开发者ID:friedbutter,项目名称:Fastir_Collector,代码行数:34,代码来源:statemachine.py

示例2: _csv_event_logs

 def _csv_event_logs(self, is_win_xp):
     """Prints the event logs in a csv, the called method is different for WinXP and lower"""
     server = None  # name of the target computer to get event logs, None to get logs from current computer
     with open(self.output_dir + '\\' + self.computer_name + '_evts.csv', 'wb') as fw:
         csv_writer = get_csv_writer(fw)
         if is_win_xp:
             for eventCategory, sourceName, eventID, eventType, date, log in self._list_evt_xp(server, 'Security'):
                 write_to_csv([self.computer_name, 'Logs', 'Security', eventCategory, sourceName, eventID, eventType,
                               date] + log, csv_writer)
             for eventCategory, sourceName, eventID, eventType, date, log in self._list_evt_xp(server,
                                                                                               'Application'):
                 write_to_csv(
                     [self.computer_name, 'Logs', 'Application', eventCategory, sourceName, eventID, eventType,
                      date] + log, csv_writer)
             for eventCategory, sourceName, eventID, eventType, date, log in self._list_evt_xp(server, 'System'):
                 write_to_csv([self.computer_name, 'Logs', 'System', eventCategory, sourceName, eventID, eventType,
                               date] + log, csv_writer)
         else:
             # Exports everything from the event viewer
             evt_handle = win32evtlog.EvtOpenChannelEnum()
             os.mkdir(self.output_dir + r"\evt")
             while True:
                 # opening channel for enumeration
                 logtype = win32evtlog.EvtNextChannelPath(evt_handle)
                 if logtype is None:
                     break
                     # fw.write('"Computer Name"|"Type"|"Date"|"logtype"|"log data"\n')
                 self._list_evt_vista(server, logtype)
开发者ID:fo0nikens,项目名称:Fastir_Collector,代码行数:28,代码来源:logs.py

示例3: csv_custom_registry_keys

    def csv_custom_registry_keys(self):

            with open(self.output_dir + "\\" + self.computer_name + "_custom_registry_keys" + self.rand_ext, "wb") as output:
                csv_writer = get_csv_writer(output)
                to_csv_list = self.__get_custom_registry_keys()
                if to_csv_list:
                    write_list_to_csv(to_csv_list, csv_writer)
开发者ID:supercsq,项目名称:Fastir_Collector,代码行数:7,代码来源:reg.py

示例4: _csv_list_share

 def _csv_list_share(self, share):
     with open(self.output_dir + '_shares.csv', 'wb') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "SHARE_NAME", "SHARE_PATH"], csv_writer)
         for name, path in share:
             write_to_csv([self.computer_name, 'shares', name, path], csv_writer)
     record_sha256_logs(self.output_dir + '_shares.csv', self.output_dir + '_sha256.log')
开发者ID:Nervous,项目名称:certitude,代码行数:7,代码来源:statemachine.py

示例5: csv_clipboard

 def csv_clipboard(self):
     """Exports the clipboard contents"""
     # TODO : what happens if clipboard contents is a CSV string ?
     self.logger.info('Getting clipboard contents')
     with open(self.output_dir + '\\' + self.computer_name + '_clipboard.csv', 'wb') as output:
         csv_writer = get_csv_writer(output)
         write_to_csv(["COMPUTER_NAME", "TYPE", "DATA"], csv_writer)
         try:
             r = Tk()  # Using Tk instead because it supports exotic characters
             data = r.selection_get(selection='CLIPBOARD')
             r.destroy()
             write_to_csv([self.computer_name, 'clipboard', unicode(data)], csv_writer)
         except:
             r.destroy()
             win32clipboard.OpenClipboard()
             clip = win32clipboard.EnumClipboardFormats(0)
             while clip:
                 try:
                     format_name = win32clipboard.GetClipboardFormatName(clip)
                 except win32api.error:
                     format_name = "?"
                 self.logger.info('format ' + unicode(clip) + ' ' + unicode(format_name))
                 if clip == 15:  # 15 seems to be a list of filenames
                     filenames = win32clipboard.GetClipboardData(clip)
                     for filename in filenames:
                         write_to_csv([self.computer_name, 'clipboard', filename], csv_writer)
                 clip = win32clipboard.EnumClipboardFormats(clip)
             win32clipboard.CloseClipboard()
     record_sha256_logs(self.output_dir + '\\' + self.computer_name + '_clipboard.csv',
                        self.output_dir + '\\' + self.computer_name + '_sha256.log')
开发者ID:fo0nikens,项目名称:Fastir_Collector,代码行数:30,代码来源:mem.py

示例6: csv_custom_registry_keys

 def csv_custom_registry_keys(self):
     """
     Extracts custom registry keys, the user specifies whether it should be recursive or not.
     The list of registry keys to extract should be comma-separated
     """
     if self.exec_custom_registry_keys:
         self.logger.info("Extracting custom registry keys")
         to_csv_list = [
             ("COMPUTER_NAME", "TYPE", "LAST_WRITE_TIME", "HIVE", "KEY_PATH", "ATTR_NAME", "REG_TYPE",
              "ATTR_TYPE", "ATTR_DATA")]
         for paths in reader([self.custom_registry_keys]):  # used as a kind of unpack
             for path in paths:
                 temp = path.split("\\")
                 hive = temp[0].upper()
                 path = "\\".join(temp[1:])
                 if hive in ("HKLM", "HKEY_LOCAL_MACHINE"):
                     self._generate_hklm_csv_list(to_csv_list, "custom_registry_key", path,
                                                  is_recursive=self.registry_recursive)
                 elif hive in ("HKU", "HKEY_USERS"):
                     self._generate_hku_csv_list(to_csv_list, "custom_registry_key", path,
                                                 is_recursive=self.registry_recursive)
                 else:  # error
                     self.logger.warn("Must specify HKLM/HKEY_LOCAL_MACHINE or HKU/HKEY_USERS as hive")
                     return
         with open(self.output_dir + "\\" + self.computer_name + "_custom_registry_keys" + self.rand_ext, "wb") as output:
             csv_writer = get_csv_writer(output)
             write_list_to_csv(to_csv_list, csv_writer)
开发者ID:SeungGiJeong,项目名称:SK_FastIR,代码行数:27,代码来源:reg.py

示例7: _csv_list_route_table

 def _csv_list_route_table(self, routes):
     with open(self.output_dir + "_routes_tables.csv", 'ab') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "NAME", "MASK"], csv_writer)
         for ip, mask in routes:
             write_to_csv([self.computer_name, 'routes_tables', unicode(ip), unicode(mask)], csv_writer)
     record_sha256_logs(self.output_dir + '_routes_tables.csv', self.output_dir + '_sha256.log')
开发者ID:Nervous,项目名称:certitude,代码行数:7,代码来源:statemachine.py

示例8: _csv_firefox_history

 def _csv_firefox_history(self, fhistory):
     with open(self.output_dir + '\\' + self.computer_name + '_firefox_history' + self.rand_ext, 'wb') as output:
         csv_writer = get_csv_writer(output)
         for time, url, user, profile in fhistory:
             write_to_csv([self.computer_name, 'firefox_history', time, url, user, profile], csv_writer)
     record_sha256_logs(self.output_dir + '\\' + self.computer_name + '_firefox_history' + self.rand_ext,
                        self.output_dir + '\\' + self.computer_name + '_sha256.log')
开发者ID:supercsq,项目名称:Fastir_Collector,代码行数:7,代码来源:fs.py

示例9: _csv_list_network_drives

 def _csv_list_network_drives(self, drives):
     with open(self.output_dir + '_list_networks_drives.csv', 'wb') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "DISK", "FILESYSTEM", "PARTITION_NAME"], csv_writer)
         for diskCapt, diskFs, diskPName in drives:
             write_to_csv([self.computer_name, 'list_networks_drives', diskCapt, diskFs, diskPName], csv_writer)
     record_sha256_logs(self.output_dir + '_list_networks_drives.csv', self.output_dir + '_sha256.log')
开发者ID:Nervous,项目名称:certitude,代码行数:7,代码来源:statemachine.py

示例10: _csv_list_drives

 def _csv_list_drives(self, drives):
     with open(self.output_dir + '_list_drives.csv', 'wb') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "FAB", "PARTITIONS", "DISK", "FILESYSTEM"], csv_writer)
         for phCapt, partCapt, logicalCapt, fs in drives:
             write_to_csv([self.computer_name, 'list_drives', phCapt, partCapt, logicalCapt, fs], csv_writer)
     record_sha256_logs(self.output_dir + '_list_drives.csv', self.output_dir + '_sha256.log')
开发者ID:Nervous,项目名称:certitude,代码行数:7,代码来源:statemachine.py

示例11: _csv_networks_list

 def _csv_networks_list(self, key):
     with open(os.path.join(self.output_dir,'%s_network_list_%s' % (self.computer_name, self.rand_ext)), 'wb') as output:
         csv_writer = get_csv_writer(output)
         network_list_result = self._get_network_list(key)
         arr_data = [v.values() for v in network_list_result.values()]
         arr_data.insert(0,network_list_result.values()[0].keys())
         write_list_to_csv(arr_data, csv_writer)
开发者ID:supercsq,项目名称:Fastir_Collector,代码行数:7,代码来源:reg.py

示例12: _csv_list_route_table

 def _csv_list_route_table(self, routes):
     self.logger.info('Health : Listing routes tables')
     with open(self.output_dir + '_routes_tables' + self.rand_ext, 'ab') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "NAME", "MASK"], csv_writer)
         for ip, mask in routes:
             write_to_csv([self.computer_name, 'routes_tables', unicode(ip), unicode(mask)], csv_writer)
     record_sha256_logs(self.output_dir + '_routes_tables' + self.rand_ext, self.output_dir + '_sha256.log')
开发者ID:SeungGiJeong,项目名称:SK_FastIR,代码行数:8,代码来源:statemachine.py

示例13: _csv_list_share

 def _csv_list_share(self, share):
     self.logger.info("Health : Listing shares")
     with open(self.output_dir + '_shares' + self.rand_ext, 'wb') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "SHARE_NAME", "SHARE_PATH"], csv_writer)
         for name, path in share:
             write_to_csv([self.computer_name, 'shares', name, path], csv_writer)
     record_sha256_logs(self.output_dir + '_shares' + self.rand_ext, self.output_dir + '_sha256.log')
开发者ID:SeungGiJeong,项目名称:SK_FastIR,代码行数:8,代码来源:statemachine.py

示例14: _csv_list_sessions

 def _csv_list_sessions(self, sessions):
     with open(self.output_dir + '_sessions.csv', 'ab') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "LOGON_ID", "AUTH_PACKAGE", "START_TIME", "LOGON_TYPE"], csv_writer)
         for logonID, authenticationPackage, startime, logontype in sessions:
             write_to_csv([self.computer_name, 'sessions', unicode(logonID),
                           authenticationPackage, unicode(startime.split('.')[0]), unicode(logontype)], csv_writer)
     record_sha256_logs(self.output_dir + '_sessions.csv', self.output_dir + '_sha256.log')
开发者ID:Nervous,项目名称:certitude,代码行数:8,代码来源:statemachine.py

示例15: _csv_list_drives

 def _csv_list_drives(self, drives):
     self.logger.info("Health : Listing drives")
     with open(self.output_dir + '%s_list_drives' % self.computer_name + self.rand_ext, 'wb') as fw:
         csv_writer = get_csv_writer(fw)
         write_to_csv(["COMPUTER_NAME", "TYPE", "FAB", "PARTITIONS", "DISK", "FILESYSTEM"], csv_writer)
         for phCapt, partCapt, logicalCapt, fs in drives:
             write_to_csv([self.computer_name, 'list_drives', phCapt, partCapt, logicalCapt, fs], csv_writer)
     record_sha256_logs(self.output_dir + '_list_drives' + self.rand_ext, self.output_dir + '_sha256.log')
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:8,代码来源:statemachine.py


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