Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate DLL based methods/functions #67

Merged
merged 50 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
05f91ce
removal of functions that supports DLL payloads
rootm0s May 26, 2020
767eb89
removal of functions that supports DLL payloads
rootm0s May 26, 2020
03cc5c3
Delete persistMethod1.py
rootm0s May 26, 2020
c2aa672
Update and rename persistMethod2.py to persistMethod1.py
rootm0s May 26, 2020
532b50a
removal of functions that supports DLL payloads
rootm0s May 26, 2020
51242b2
Rename persistMethod3.py to persistMethod2.py
rootm0s May 26, 2020
01003fd
removal of functions that supports DLL payloads
rootm0s May 27, 2020
02af7bc
removal of functions that supports DLL payloads
rootm0s May 27, 2020
314e021
removal of functions that supports DLL payloads
rootm0s May 27, 2020
4c80398
removal of functions that supports DLL payloads
rootm0s May 27, 2020
034e6db
removal of functions that supports DLL payloads
rootm0s May 27, 2020
d5a239f
removal of functions that supports DLL payloads
rootm0s May 27, 2020
351dbd3
removal of functions that supports DLL payloads
rootm0s May 27, 2020
17b5e69
removal of functions that supports DLL payloads
rootm0s May 27, 2020
adb95c9
removal of functions that supports DLL payloads
rootm0s May 27, 2020
923a209
removal of functions that supports DLL payloads
rootm0s May 27, 2020
33d0ff6
removal of functions that supports DLL payloads
rootm0s May 27, 2020
b6d69a0
removal of functions that supports DLL payloads
rootm0s May 27, 2020
b0604db
removal of functions that supports DLL payloads
rootm0s May 27, 2020
55f6ba0
removal of functions that supports DLL payloads
rootm0s May 27, 2020
ecd9c33
removal of functions that supports DLL payloads
rootm0s May 27, 2020
802b646
removal of functions that supports DLL payloads
rootm0s May 27, 2020
7fbde13
removal of functions that supports DLL payloads
rootm0s May 27, 2020
95cf790
removal of functions that supports DLL payloads
rootm0s May 27, 2020
68cf531
removal of functions that supports DLL payloads
rootm0s May 27, 2020
adddf22
removal of functions that supports DLL payloads
rootm0s May 27, 2020
57b526e
removal of functions that supports DLL payloads
rootm0s May 27, 2020
5118087
removal of functions that supports DLL payloads
rootm0s May 27, 2020
efc19f7
removal of functions that supports DLL payloads
rootm0s May 27, 2020
8b024bd
re-adding updated uac functions
rootm0s May 27, 2020
e806c23
removal of functions that supports DLL payloads
rootm0s May 27, 2020
378cccc
removal of functions that supports DLL payloads
rootm0s May 27, 2020
9723ad3
removal of functions that supports DLL payloads
rootm0s May 27, 2020
c93e499
removal of functions that supports DLL payloads
rootm0s May 27, 2020
8b9211c
removal of functions that supports DLL payloads
rootm0s May 27, 2020
3a79834
removal of functions that supports DLL payloads
rootm0s May 27, 2020
a70df8c
removal of functions that supports DLL payloads
rootm0s May 27, 2020
220e7c3
removal of functions that supports DLL payloads
rootm0s May 27, 2020
875a31b
removal of functions that supports DLL payloads
rootm0s May 27, 2020
5993085
removal of functions that supports DLL payloads
rootm0s May 27, 2020
82e5306
removal of functions that supports DLL payloads
rootm0s May 27, 2020
2632c30
removal of functions that supports DLL payloads
rootm0s May 27, 2020
98baa4e
removal of functions that supports DLL payloads
rootm0s May 27, 2020
333a370
re-adding updated persist functions
rootm0s May 27, 2020
f5de4ce
removal of "Syntax" inside function information
rootm0s May 27, 2020
b85cfc3
Update persistMethod9.py
rootm0s May 27, 2020
9bd0fa2
Add files via upload
rootm0s May 27, 2020
2bbe9ff
Add files via upload
rootm0s May 27, 2020
6cd4541
Add files via upload
rootm0s May 27, 2020
e672b89
Update README.md
rootm0s May 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
681 changes: 319 additions & 362 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def main():
if args.scan:
if not all([_ in scan_cmds for _ in args.scan]):
parser.print_help()

scanner(**{scan_cmds[_]: scan_cmds[_] in args.scan for _ in range(3)}).start()

if args.use and args.id:
Expand Down
19 changes: 2 additions & 17 deletions winpwnage/core/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
from winpwnage.functions.uac.uacMethod13 import *
from winpwnage.functions.uac.uacMethod14 import *
from winpwnage.functions.uac.uacMethod15 import *
from winpwnage.functions.uac.uacMethod16 import *
from winpwnage.functions.uac.uacMethod17 import *
from winpwnage.functions.uac.uacMethod18 import *
from winpwnage.functions.uac.uacMethod19 import *
from winpwnage.functions.uac.uacMethod20 import *
from winpwnage.functions.uac.uacMethod21 import *
from winpwnage.functions.persist.persistMethod1 import *
from winpwnage.functions.persist.persistMethod2 import *
from winpwnage.functions.persist.persistMethod3 import *
Expand All @@ -33,7 +27,6 @@
from winpwnage.functions.persist.persistMethod10 import *
from winpwnage.functions.persist.persistMethod11 import *
from winpwnage.functions.persist.persistMethod12 import *
from winpwnage.functions.persist.persistMethod13 import *
from winpwnage.functions.elevate.elevateMethod1 import *
from winpwnage.functions.elevate.elevateMethod2 import *
from winpwnage.functions.elevate.elevateMethod3 import *
Expand All @@ -58,13 +51,7 @@
uacMethod12_info,
uacMethod13_info,
uacMethod14_info,
uacMethod15_info,
uacMethod16_info,
uacMethod17_info,
uacMethod18_info,
uacMethod19_info,
uacMethod20_info,
uacMethod21_info
uacMethod15_info
),
"persist": (
persistMethod1_info,
Expand All @@ -77,9 +64,7 @@
persistMethod8_info,
persistMethod9_info,
persistMethod10_info,
persistMethod11_info,
persistMethod12_info,
persistMethod13_info
persistMethod11_info
),
"elevate": (
elevateMethod1_info,
Expand Down
130 changes: 119 additions & 11 deletions winpwnage/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import ctypes
import platform
from subprocess import check_output

try:
import _winreg # Python 2
Expand Down Expand Up @@ -34,8 +35,37 @@ def exe(self, payload):
else:
return False

def dll(self, payload):
return bool(os.path.isfile(os.path.join(payload[0])) and payload[0].endswith(".dll"))
#def dll(self, payload):
# return bool(os.path.isfile(os.path.join(payload[0])) and payload[0].endswith(".dll"))

class makecab():
def makecab(self, source, destination):
if not os.path.exists(source):
return False

exit_code = process().create("makecab.exe", params="{source} {destination}".format(source=source,
destination=destination), window=False, get_exit_code=True)
if exit_code == 0:
return True
else:
return False

class wusa():
def extract(self, cabinet, destination):
if not os.path.exists(cabinet):
return False

results = process().create("wusa.exe", params="{cabinet} /extract:{destination} /quiet".format(cabinet=cabinet,
destination=destination), window=False, get_exit_code=True)
if results == 0:
try:
os.remove(cabinet)
except Exception as error:
pass
finally:
return True
else:
return False

class process():
def create(self, payload, params="", window=False, get_exit_code=False):
Expand Down Expand Up @@ -155,16 +185,93 @@ def remove_key(self, hkey, path, name="", delete_key=False):
except Exception as e:
return False

class whoami():
def __init__(self):
self.privs = {"SeIncreaseQuotaPrivilege" : "Adjust memory quotas for a process",
"SeSecurityPrivilege" : "Manage auditing and security log",
"SeTakeOwnershipPrivilege" : "Take ownership of files or other objects",
"SeLoadDriverPrivilege" : "Load and unload device drivers",
"SeSystemProfilePrivilege" : "Profile system performance",
"SeSystemtimePrivilege" : "Change the system time",
"SeProfileSingleProcessPrivilege" : "Profile single process",
"SeIncreaseBasePriorityPrivilege" : "Increase scheduling priority",
"SeCreatePagefilePrivilege" : "Create a pagefile",
"SeBackupPrivilege" : "Back up files and directories",
"SeRestorePrivilege" : "Restore files and directories",
"SeShutdownPrivilege" : "Shut down the system",
"SeDebugPrivilege" : "Debug programs",
"SeSystemEnvironmentPrivilege" : "Modify firmware environment values",
"SeChangeNotifyPrivilege" : "Bypass traverse checking",
"SeRemoteShutdownPrivilege" : "Force shutdown from a remote system",
"SeUndockPrivilege" : "Remove computer from docking station",
"SeManageVolumePrivilege" : "Perform volume maintenance tasks",
"SeImpersonatePrivilege" : "Impersonate a client after authentication",
"SeCreateGlobalPrivilege" : "Create global objects",
"SeIncreaseWorkingSetPrivilege" : "Increase a process working set",
"SeTimeZonePrivilege" : "Change the time zone",
"SeCreateSymbolicLinkPrivilege" : "Create symbolic links",
"SeDelegateSessionUserImpersonatePrivilege" : "Obtain an impersonation token for another user in same session"}

self.sids = {"S-1-2-0" : "Local",
"S-1-0-0" : "Nobody",
"S-1-1-0" : "Everyone",
"S-1-5-32-545" : "Users",
"S-1-5-32-546" : "Guests",
"S-1-0" : "Null Authority",
"S-1-1" : "World Authority",
"S-1-2" : "Local Authority",
"S-1-5-4" : "Interactive",
"S-1-2-1" : "Console Logon",
"S-1-5-18" : "Local System",
"S-1-5-19" : "Local Service",
"S-1-5-20" : "Network Service",
"S-1-5-32-547" : "Power Users",
"S-1-5-15" : "This Organization",
"S-1-5-32-544" : "Administrators",
"S-1-5-11" : "Authenticated Users",
"S-1-5-32-549" : "Server Operators",
"S-1-5-32-550" : "Print Operators",
"S-1-5-32-551" : "Backup Operators",
"S-1-5-32-548" : "Account Operators",
"S-1-5-64-10" : "NTLM Authentication",
"S-1-5-32-559" : "Builtin\Performance Log Users",
"S-1-5-32-582" : "Storage Replica Administrators"}

def elevated(self):
return bool(ctypes.windll.shell32.IsUserAnAdmin())

def privileges(self):
return check_output(["whoami", "/priv", "/fo", "table",
"|", "findstr", "Enabled"], shell=True).decode("latin1")
def groups(self):
return check_output(["whoami", "/groups"], shell=True).decode("latin1")

def getgroups(self):
result = []
groups = self.groups()
for sid in self.sids:
if sid in groups:
result.append(self.sids[sid])
return result

def getprivileges(self):
result = []
privs = self.privileges()
for priv in self.privs:
if priv in privs:
result.append(priv)
return result

class information():
def system_directory(self):
return os.path.join(os.environ.get("windir"), "system32")

def system_drive(self):
return os.environ.get("systemdrive")

def windows_directory(self):
return os.environ.get("windir")

def architecture(self):
return platform.machine()

Expand All @@ -176,8 +283,8 @@ def admin(self):

def build_number(self):
try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, os.path.join(
"Software\\Microsoft\\Windows NT\\CurrentVersion"), 0, _winreg.KEY_READ)
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
os.path.join("Software\\Microsoft\\Windows NT\\CurrentVersion"), 0, _winreg.KEY_READ)
cbn = _winreg.QueryValueEx(key, "CurrentBuildNumber")
_winreg.CloseKey(key)
except Exception as error:
Expand All @@ -187,13 +294,14 @@ def build_number(self):

def uac_level(self):
try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, os.path.join(
"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"), 0, _winreg.KEY_READ)
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
os.path.join("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"), 0, _winreg.KEY_READ)
cpba = _winreg.QueryValueEx(key, "ConsentPromptBehaviorAdmin")
cpbu = _winreg.QueryValueEx(key, "ConsentPromptBehaviorUser")
posd = _winreg.QueryValueEx(key, "PromptOnSecureDesktop")
_winreg.CloseKey(key)
except Exception as error:
return False
cpba_cpbu_posd = (cpba[0], cpbu[0], posd[0])
return {(0, 3, 0): 1, (5, 3, 0): 2, (5, 3, 1): 3, (2, 3, 1): 4}.get(cpba_cpbu_posd, False)
else:
cpba_cpbu_posd = (cpba[0], cpbu[0], posd[0])
return {(0, 3, 0): 1, (5, 3, 0): 2, (5, 3, 1): 3, (2, 3, 1): 4}.get(cpba_cpbu_posd, False)
Loading