← Back to list

247/CTF — TIPS AND TRICKS

247/CTF — TIPS AND TRICKS

Raj Upadhyay · 2020-09-02 05:35 · 3 claps · 0.7 min read
#ctf #ctf-writeup #247ctf #ctf-tips-and-tricks #penetration-testing
Open on Medium ↗

247/CTF — TIPS AND TRICKS

Question :

Utilise a programming language to interface with the socket and automate solving 500 simple addition problems to receive the flag. Take care when interfacing with unknown remote services — ‘\n’ is not the only way to end a line!

My Solution :

from pwn import * #pip install pwntools
import re
Host="6452548db3f26c16.247ctf.com" #change this  accordingly
Port=50038 #change this accordingly
conn = remote(Host,Port)
print(conn.recvline())
print(conn.recvline())
for i in range(500):
    try:
        print("We are at question : {0}".format(i))
        data = conn.recvline().decode("utf-8")
        l = re.findall(r'\d+',data)
        a = int(l[0])
        b = int(l[1])
        ans = (str(a+b)+'\r\n').encode("utf-8")
        conn.sendline(ans)
        conn.recvline()
    except Exception as e:
        print(e)
print(conn.recvline())
conn.close()

This was my approach to solve this challenge. we can also complete this challenge by using sockets library.

Flag Image

Flag Image

Code Link : https://github.com/raj1997/CTF-Write-up/tree/master/247ctf_com/Tips%20and%20Tricks


메타데이터
post_id
e009febfc869
slug
247-ctf-tips-and-tricks-e009febfc869
url
https://medium.com/@upadhyayraj/247-ctf-tips-and-tricks-e009febfc869
canonical_url
https://medium.com/@upadhyayraj/247-ctf-tips-and-tricks-e009febfc869
author_url
https://medium.com/@upadhyayraj
status
ok
fetched_at
2026-07-28 20:49:58