Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
iCTF 2018 - Hack The Planet
#!/usr/bin/env python2
# This code was written 10 hours before the competition, yikes
# Any bugs are your problem
import socks # pip install PySocks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '', 4444)
socket.socket = socks.socksocket
from pwn import * # pip install pwntools
from swpag_client import Team # pip install swpag_client
import time
def team_ip(team_host):
# (team1) ... (team254) ... (team255) ...
team_number = int(team_host[4:])
minor = ((team_number - 1) % 254) + 1
major = (team_number / 255) + 129
return '172.31.{major}.{minor}'.format(major=major, minor=minor)
services = team.get_service_list()
service_flag_ids = dict()
while True:
for service in services:
print("Going to attack", service['service_name'])
if service['service_name'] not in service_flag_ids:
service_flag_ids[service['service_name']] = set()
targets = team.get_targets(service['service_id'])
for target in targets['targets']:
flag_id = target['flag_id']
ip = team_ip(target['hostname'])
port = target['port']
if flag_id not in service_flag_ids[service['service_name']]:
conn = remote(ip, port, timeout=3)
# insert pwnage here
flag = "GET_THE_FLAG"
# result = team.submit_flag(flag)
# print(result)
except Exception as e:
print("Error connecting to", target['team_name'], target['hostname'], ip, port)
time.sleep(10) # DOS is against the rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.