抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

BlackBird的博客

这世界上所有的不利状况,都是当事者能力不足导致的

这次的算法题,,,怎么说,,感觉真正考察算法的我都没写,就写了些不考察真正算法的题目

mess

image-20201009155437259
import random
flag = 'moectf{xxxxxxxxxxx}'
digit = ''
for i in flag:
    digit += str(ord(i))
i = 0
while i < len(digit):
    n = random.randint(0, 128)
    if ord('a') <= n <= ord('z') or ord('A') <= n <= ord('Z'):
        digit = digit[0:i] + chr(n) + digit[i:]
    i += 1
with open('puzzle.txt', 'w') as out:
    out.write(digit)

# 1091111A01ruVJl99hw11Qv6i102xCYC1c2B31DIsz1tm212l11A1l610448re11BQ09549115951n154V895F115d49109h1m1210810j11w2A5

这个题说人话就是把flag的每一项转化成ASCII码全部列一排,再往之间插入字母。所以第一步把字母全部去除掉,然后手动把得到的一串数字分开,首先moectf{}的格式是确定的,然后大概眼睛瞅着,,就出来:

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
		if(a[i]>='0' && a[i]<='9')
			cout<<a[i];
	return 0;
} 
//1091111A01ruVJl99hw11Qv6i102xCYC1c2B31DIsz1tm212l11A1l610448re11BQ09549115951n154V895F115d49109h1m1210810j11w2A5
//1091111019911610212311212111610448110954911595115489511549109112108101125
a=[109,111,101,99,116,102,123,112,121,116,104,48,110,95,49,115,95,115,48,95,115,49,109,112,108,101,125]
for i in a:
    print(chr(i),end='')
# 109,111,101,99,116,102,123,112,121,116,104,48,110,95,49,115,95,115,48,95,115,49,109,112,108,101,125
# moectf{pyth0n_1s_s0_s1mple}

Frank, 永远滴神

image-20201009175357736

u1s1,这个题就是学习一下python怎么遍历文件夹,,害~看脚本吧:

import os
from base64 import *
count = 0
path = "自己的目录\puzzle"
dirs1 = os.listdir(path)
for i in dirs1:
	path_1 = os.path.join(path,i)
	dirs2 = os.listdir(path_1)
	for j in dirs2:
		path_2 = os.path.join(path_1,j)
		dirs3 = os.listdir(path_2)
		for k in dirs3:
			path_3 = os.path.join(path_2,k)
			dirs4 = os.listdir(path_3)
			for m in dirs4:
				path_4 = os.path.join(path_3,m)
				print(path_4)
				f=open(path_4)
				file = f.read()
				f.close()
				count += file.count('FrankNB!')
print(count.b64encode())

#moectf{MjA1MjMy}

赤道企鹅, 永远滴神

image-20201009180540819

这个题就比前一个多一个数据处理,,,所以也没什么说的,直接贴脚本:

import os
from base64 import *
count_n = 0
count_y = 0
count = 0

path = "H:\Competitions\moectf\Algorithm\Eqqie\puzzle"
dirs1 = os.listdir(path)
for i in dirs1:
	path_1 = os.path.join(path,i)
	dirs2 = os.listdir(path_1)
	for j in dirs2:
		path_2 = os.path.join(path_1,j)
		dirs3 = os.listdir(path_2)
		for k in dirs3:
			path_3 = os.path.join(path_2,k)
			dirs4 = os.listdir(path_3)
			for m in dirs4:
				path_4 = os.path.join(path_3,m)
				print(path_4)                      #遍历文件
				f = open(path_4)
				file = f.read()
				f.close()                          #读取文件
				if file[7]=='?':
					count_n += 1
					continue
				count_y += 1
				a = ""
				a += file[7:]
				flag = 1
				for i in a:
					if ('9'>=i>='0' or 'z'>=i>='a' or 'Z'>=i>='A'):
						if flag==1:
							flag = 0
							count += 1
					else:
						flag=1

ans=str(count).encode()	
print(b64encode(ans))
#moectf{MTgyNDI2}

千层饼

image-20201009181151021

先放一下加密脚本吧:

from base64 import *
from random import Random
from flag import flag

alg = [b16encode, b32encode, b64encode, a85encode, b85encode]

r = Random()
for i in range(r.randrange(35,40)):
    er = r.choice(alg)
    flag = r.choice(alg)(str(alg.index(er)).encode()) + b'eqqie_is_god' + er(flag)

with open('secret.txt','wb') as out:
    out.write(flag)
with open('puzzle.txt', 'wb') as out:
    out.write(flag)

这个题的思路还是挺显而易见的,,,说白了就是“套娃”。这个题我先半手撕掉了,然后又写了全自动的脚本,半手撕的就不贴了,给个全自动的吧~~:

from base64 import *

dict={}

def ini():
	for i in range(len(alg)):
		for j in range(5):
			tmp = alg[i](str(j).encode())
			dict[tmp] = j

alg = [b16encode, b32encode, b64encode, a85encode, b85encode]
alg_s = [b16decode, b32decode, b64decode, a85decode, b85decode]

with open('puzzle.txt','r') as f:
	data = f.read()

print("index:")
for i in range(len(alg)):
	print("  ",i,": ",alg[i])

ini()
count = 0
print(dict)
while 1:
	if 'eqqie_is_god' not in data:
		print(data)
		break
	key = data.index('eqqie_is_god')
	print(data[:key])
	data = alg_s[int(dict[data[:key].encode()])](data[key+12:]).decode()
	count = count+1
	print(count)
	print()
# moectf{so00Oo0oO_d31ici0us}

emmm。。。我自认为我的代码还是比较容易理解的。就这样吧~~

评论