菜是真的菜。
就写出来一个,还是在结束后几分钟emmm
继续学吧。

MISC

Checkin

题意:验证码识别。

大概长这样

思路:
经过观察,发现每个数字/字母的形状不会改变,且无混淆。
考虑分割每个字,计算组成其形状所有符号的ASCII码总和,建立一个一一对应的映射。

首先,批量获取字符,计算其ASCii码之和。

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
#-*-coding :utf-8 -*-
import socket


def get_all_captcha():
i = 36
f = open('captcha.txt', 'a', encoding='utf-8')
while i:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('210.32.4.14', 13373))
captcha = ''
while True:
d = s.recv(1024).decode('utf-8')
if 'your captcha' in d:
f.write(captcha + d)
break
else:
captcha += d
i -= 1
print(captcha)
f.close()


if __name__ == '__main__':
get_all_captcha()
f = open('captcha.txt', 'r', encoding='utf-8')
captcha = []
flag = 0
for text in f:
if 'unCAPTCHA' in text:
flag = 1
elif flag == 1 and 'your captcha' not in text:
captcha.append(text.strip('\n'))
if 'your captcha' in text:
flag = 0
ans = []
while True:
try:
captcha.remove('')
except:
break
su = 0
for i in range(len(captcha[0])):
tmp = 0
for x in captcha:
if x[i] != ' ':
tmp += ord(x[i])
if tmp != 0:
su += tmp
if tmp == 0 and su != 0:
ans.append(su)
su = 0
#print('\n'.join(captcha) + '\n')
print(ans)

然后,利用dict构造一个映射

1
2
3
4
5
6
password = {3329: '0', 1498: '1', 2937: '2', 3041: '3', 2514: '4', 3406: '5', 3151: '6',
2137: '7', 3751: '8', 3063: '9',
2354: 'a', 3027: 'b', 2447: 'c', 3036: 'd', 2923: 'e', 2119: 'f', 4152: 'g',
3223: 'h', 1881: 'i', 3391: 'k', 2655: 'j', 1770: 'l', 4275: 'm', 2822: 'n',
2601: 'o', 3264: 'p', 3148: 'q', 1868: 'r', 2283: 's', 1592: 't',
2763: 'u', 2061: 'v', 3550: 'w', 2683: 'x', 2739: 'y', 2726: 'z'}

最后,利用脚本自动提交,获得flag

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
#-*-coding:utf-8 -*-
import socket
import os
password = {3329: '0', 1498: '1', 2937: '2', 3041: '3', 2514: '4', 3406: '5', 3151: '6',
2137: '7', 3751: '8', 3063: '9',
2354: 'a', 3027: 'b', 2447: 'c', 3036: 'd', 2923: 'e', 2119: 'f', 4152: 'g',
3223: 'h', 1881: 'i', 3391: 'k', 2655: 'j', 1770: 'l', 4275: 'm', 2822: 'n',
2601: 'o', 3264: 'p', 3148: 'q', 1868: 'r', 2283: 's', 1592: 't',
2763: 'u', 2061: 'v', 3550: 'w', 2683: 'x', 2739: 'y', 2726: 'z'}


def sent_captcha(s, captcha):
captcha = captcha + '\n'
s.send(captcha.encode('utf-8'))


def rev_captcha(s):
f = open('captcha.txt', 'w', encoding='utf-8')
captcha = ''
while True:
d = s.recv(1024).decode('utf-8')
print(d)
captcha += d
if 'your captcha' in d:
f.write(captcha)
return captcha
elif '{' in d:
return True
elif 'bad' in d or 'time' in d:
# print(d)
os._exit()


def solve_captache(context):
if 'unCAPTCHA' not in context:
context = 'A 20 rounds unCAPTCHA to get your flag! you may need a wider screen...\n' + context
f = context.split('\n')
# print('\n'.join(f))
captcha = []
flag = 0
for text in f:
if 'unCAPTCHA' in text:
flag = 1
elif flag == 1 and 'your captcha' not in text:
captcha.append(text.strip('\n'))
if 'your captcha' in text:
flag = 0
ans = []
while True:
try:
captcha.remove('')
except:
break
su = 0
for i in range(len(captcha[0])):
tmp = 0
for x in captcha:
if x[i] != ' ':
tmp += ord(x[i])
if tmp != 0:
su += tmp
if tmp == 0 and su != 0:
ans.append(su)
su = 0
#print(ans)
a = ''.join(list(map(lambda x: password[x], ans)))
print(a)
return a


if __name__ == '__main__':
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('210.32.4.14', 13373))
while True:
res = rev_captcha(s)
if res == True:
break
else:
ans = solve_captache(res)
sent_captcha(s, ans)

FLAG:
EIS{incompletely_nonautomated_private_turing_test}