-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cgi
executable file
·127 lines (113 loc) · 2.74 KB
/
index.cgi
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/zsh
DOCKER=true
cat /tmp/timewarp | read timewarp
if [ "$PATH_INFO" = "" ]
then
echo Content-type: text/html
echo
echo '
<html>
<head>
<script type="text/javascript">
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
document.getElementById("msg").innerHTML = xhr.responseText
}
function loop() {
xhr.open("GET", "/msg.txt", true)
xhr.send(null)
setTimeout(loop, 500)
}
</script>
</head>
<body>
<script type="text/javascript">
setTimeout(loop, 500)
</script>
<center><a href="/"><img border="0" src="/title.png"/></a><br/><font face="verdana" size="-1px">[<a href="/">home - root certificate (Apple profile)</a>]</font><p/></center>
<center><font face="verdana" id="msg">wait...</font><br/></center>
'
if [ $(cat /tmp/state) != 'S' ]
then
echo '
<center>
<table width="600">
<tr><td align="left">
<a href="http://my.hack/cgi-bin/index.cgi/S"><img src="/stop.png"/></a>
</td><td align="right">
<a href="http://my.hack/cgi-bin/index.cgi/T"><img src="/timewarp.png"/></a>
</td></tr>
</table>
<p/>
<font face="verdana" size="-1px">click <a href="http://my.hack/cgi-bin/index.cgi/U">here</a> to finish the Arena challenge right now</font>
</center>
'
else
echo '
<center>
<a href="http://my.hack/cgi-bin/index.cgi/P"><img src="/play.png"/></a>
</center>
'
fi
echo '
</body>
</html>
'
exit 0
fi
if [ "$PATH_INFO" = "/P" ]
then
echo Content-type: text/html
echo Location: http://my.hack/cgi-bin/index.cgi
echo
echo -n P > /tmp/state
cat /tmp/timewarp > /tmp/timewarp.value
if [ $DOCKER = true ]
then
sh -c "sleep .5; pkill python3.5" > /dev/null 2>&1 &
else
sh -c "sleep .5; pkill mitmproxy" > /dev/null 2>&1 &
fi
exit 0
fi
if [ "$PATH_INFO" = "/S" ]
then
echo Content-type: text/html
echo Location: http://my.hack/cgi-bin/index.cgi
echo
echo -n S > /tmp/state
echo -n 0 > /tmp/timewarp.value
if [ $DOCKER = true ]
then
sh -c "sleep .5; pkill python3.5" > /dev/null 2>&1 &
else
sh -c "sleep .5; pkill mitmproxy" > /dev/null 2>&1 &
fi
exit 0
fi
if [ "$PATH_INFO" = "/T" ]
then
echo Content-type: text/html
echo Location: http://my.hack/cgi-bin/index.cgi
echo
echo -n T > /tmp/state
exit 0
fi
if [ "$PATH_INFO" = "/U" ]
then
echo Content-type: text/html
echo Location: http://my.hack/cgi-bin/index.cgi
echo
echo -n U > /tmp/state
exit 0
fi
# debug the time warp
if [ "$PATH_INFO" = "/D" ]
then
echo Content-type: text/html
echo Location: http://my.hack/cgi-bin/index.cgi
echo
echo -n D > /tmp/state
exit 0
fi