本文整理汇总了Python中viper.core.database.Database.rename方法的典型用法代码示例。如果您正苦于以下问题:Python Database.rename方法的具体用法?Python Database.rename怎么用?Python Database.rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viper.core.database.Database
的用法示例。
在下文中一共展示了Database.rename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Commands
# 需要导入模块: from viper.core.database import Database [as 别名]
# 或者: from viper.core.database.Database import rename [as 别名]
class Commands(object):
output = []
def __init__(self):
# Open connection to the database.
self.db = Database()
# Map commands to their related functions.
self.commands = dict(
help=dict(obj=self.cmd_help, description="Show this help message"),
open=dict(obj=self.cmd_open, description="Open a file"),
new=dict(obj=self.cmd_new, description="Create new file"),
close=dict(obj=self.cmd_close, description="Close the current session"),
info=dict(obj=self.cmd_info, description="Show information on the opened file"),
notes=dict(obj=self.cmd_notes, description="View, add and edit notes on the opened file"),
clear=dict(obj=self.cmd_clear, description="Clear the console"),
store=dict(obj=self.cmd_store, description="Store the opened file to the local repository"),
delete=dict(obj=self.cmd_delete, description="Delete the opened file"),
find=dict(obj=self.cmd_find, description="Find a file"),
tags=dict(obj=self.cmd_tags, description="Modify tags of the opened file"),
sessions=dict(obj=self.cmd_sessions, description="List or switch sessions"),
stats=dict(obj=self.cmd_stats, description="Viper Collection Statistics"),
projects=dict(obj=self.cmd_projects, description="List or switch existing projects"),
parent=dict(obj=self.cmd_parent, description="Add or remove a parent file"),
export=dict(obj=self.cmd_export, description="Export the current session to file or zip"),
analysis=dict(obj=self.cmd_analysis, description="View the stored analysis"),
rename=dict(obj=self.cmd_rename, description="Rename the file in the database"),
)
# Output Logging
def log(self, event_type, event_data):
self.output.append(dict(
type=event_type,
data=event_data
))
out.print_output([{'type': event_type, 'data': event_data}], console_output['filename'])
##
# CLEAR
#
# This command simply clears the shell.
def cmd_clear(self, *args):
os.system('clear')
##
# HELP
#
# This command simply prints the help message.
# It lists both embedded commands and loaded modules.
def cmd_help(self, *args):
self.log('info', "Commands")
rows = []
for command_name, command_item in self.commands.items():
rows.append([command_name, command_item['description']])
rows.append(["exit, quit", "Exit Viper"])
rows = sorted(rows, key=lambda entry: entry[0])
self.log('table', dict(header=['Command', 'Description'], rows=rows))
self.log('info', "Modules")
rows = []
for module_name, module_item in __modules__.items():
rows.append([module_name, module_item['description']])
rows = sorted(rows, key=lambda entry: entry[0])
self.log('table', dict(header=['Command', 'Description'], rows=rows))
##
# NEW
#
# This command is used to create a new session on a new file,
# useful for copy & paste of content like Email headers
def cmd_new(self, *args):
title = input("Enter a title for the new file: ")
# Create a new temporary file.
tmp = tempfile.NamedTemporaryFile(delete=False)
# Open the temporary file with the default editor, or with nano.
os.system('"${EDITOR:-nano}" ' + tmp.name)
__sessions__.new(tmp.name)
__sessions__.current.file.name = title
self.log('info', "New file with title \"{0}\" added to the current session".format(bold(title)))
##
# OPEN
#
# This command is used to open a session on a given file.
# It either can be an external file path, or a SHA256 hash of a file which
# has been previously imported and stored.
# While the session is active, every operation and module executed will be
# run against the file specified.
def cmd_open(self, *args):
parser = argparse.ArgumentParser(prog='open', description="Open a file", epilog="You can also specify a MD5 or SHA256 hash to a previously stored file in order to open a session on it.")
group = parser.add_mutually_exclusive_group()
group.add_argument('-f', '--file', action='store_true', help="Target is a file")
group.add_argument('-u', '--url', action='store_true', help="Target is a URL")
#.........这里部分代码省略.........