Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eb75a53

Browse files
committed
Add 2048 src
1 parent cd76309 commit eb75a53

39 files changed

+4727
-1
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| ------------------------------------------------------------ | ------------------------------------------------------- |
1717
| [签到](official/签到/README.md) ||
1818
| [猫咪问答++](official/猫咪问答++/README.md) ||
19-
| [2048](official/2048/README.md) | 暂无(之后会有) |
19+
| [2048](official/2048/README.md) | [文件、源代码](official/2048/src) |
2020
| [一闪而过的 Flag](official/一闪而过的%20Flag/README.md) | [文件、源代码](official/一闪而过的%20Flag/src) |
2121
| [从零开始的记账工具人](official/从零开始的记账工具人/README.md) | [文件、源代码](official/从零开始的记账工具人/src) |
2222
| [超简单的世界模拟器](official/超简单的世界模拟器/README.md) | [文件、源代码](official/超简单的世界模拟器/src) |

‎official/2048/src/Dockerfile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM tiangolo/uwsgi-nginx-flask:python3.8
2+
3+
RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
4+
RUN pip3 install pyopenssl
5+
6+
COPY ./app /app

‎official/2048/src/app/main.py‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from flask import Flask
2+
from flask import request, render_template, redirect, url_for, session, make_response
3+
4+
import OpenSSL
5+
import base64
6+
7+
8+
from secret import hg_dynamic_flag, secret_key
9+
10+
app = Flask(__name__)
11+
app.secret_key = secret_key
12+
13+
with open("cert.pem") as f:
14+
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, f.read())
15+
16+
17+
@app.before_request
18+
def check():
19+
if request.path.startswith('/static/'):
20+
return
21+
if request.args.get('token'):
22+
try:
23+
token = request.args.get('token')
24+
id, sig = token.split(":", 1)
25+
sig = base64.b64decode(sig, validate=True)
26+
OpenSSL.crypto.verify(cert, sig, id.encode(), "sha256")
27+
session['token'] = token
28+
except Exception:
29+
session['token'] = None
30+
return redirect(url_for('index'))
31+
if session.get("token") is None:
32+
return make_response(render_template("error.html"), 403)
33+
34+
@app.route('/', methods=['GET'])
35+
def index():
36+
return render_template('index.html')
37+
38+
39+
@app.route('/getflxg', methods=['GET'])
40+
def getflxg():
41+
if request.args.get('my_favorite_fruit') == 'banana':
42+
return hg_dynamic_flag(session['token'])
43+
else:
44+
return '还没有大成功,不能给你 flxg。'
45+
46+
47+
if __name__ == '__main__':
48+
app.run(host='127.0.0.1', port=10005, debug=True)

‎official/2048/src/app/secret.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import hashlib
2+
3+
flag_tpl = "flxg{8G6so5g-FLXG-%s}"
4+
secret_key = b"012uf:>FPL(!HNF128hf"
5+
6+
def hg_dynamic_flag(token):
7+
return flag_tpl % hashlib.sha256(('20486787gf'+token).encode()).hexdigest()[:10]

‎official/2048/src/app/static/bg.png‎

202 KB
Loading[フレーム]

‎official/2048/src/app/static/bootstrap/css/bootstrap.min.css‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎official/2048/src/app/static/bootstrap/js/bootstrap.min.js‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
html,
2+
body {
3+
height: 100%;
4+
}
5+
6+
body {
7+
display: -ms-flexbox;
8+
display: flex;
9+
-ms-flex-align: center;
10+
align-items: center;
11+
padding-top: 40px;
12+
padding-bottom: 40px;
13+
}
14+
15+
.form-token {
16+
width: 100%;
17+
max-width: 600px;
18+
padding: 15px;
19+
margin: auto;
20+
}
21+
22+
.form-token h1 {
23+
margin-bottom: 20px;
24+
color: #721c24;
25+
}
26+
27+
.form-token .form-control {
28+
position: relative;
29+
box-sizing: border-box;
30+
height: auto;
31+
padding: 10px;
32+
font-size: 16px;
33+
}

‎official/2048/src/app/static/jquery.min.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(function () {
2+
var lastTime = 0;
3+
var vendors = ['webkit', 'moz'];
4+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
5+
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
6+
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
7+
window[vendors[x] + 'CancelRequestAnimationFrame'];
8+
}
9+
10+
if (!window.requestAnimationFrame) {
11+
window.requestAnimationFrame = function (callback) {
12+
var currTime = new Date().getTime();
13+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
14+
var id = window.setTimeout(function () {
15+
callback(currTime + timeToCall);
16+
},
17+
timeToCall);
18+
lastTime = currTime + timeToCall;
19+
return id;
20+
};
21+
}
22+
23+
if (!window.cancelAnimationFrame) {
24+
window.cancelAnimationFrame = function (id) {
25+
clearTimeout(id);
26+
};
27+
}
28+
}());

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /