Web
Misc1
今天放假,写了两篇,下午还有CTFShow的Web篇。后面还有笔记,笔记我打算从基础开始写起,有一些过程,从易到难,也希望写的过程中能加深一些理解。
题目附件是一大段编码
这些字符集有点像base,但是全都是小写字母。对了,题目说“低端”的base64,是不是意味着出题人把base64后的结果转成小写字母了?
编写脚本验证:
import itertools
import base64
with open('flag.txt', 'r') as fr:
content = fr.read()
result = [[] for i in range(len(content) // 4)]
for i in range(len(content) // 4):
base = content[i * 4 : i * 4 + 4]
temp = []
for b in base:
if b.isalpha():
temp.append((b, b.upper()))
else:
temp.append((b,))
for it in itertools.product(temp[0], temp[1], temp[2], temp[3]):
try:
temp = base64.b64decode(''.join(it)).decode()
result[i].append(temp)
except:
pass
for i in result:
print(i)
下面是输出的结果:
因为有很多生僻字,所以要自己组合一下,如果直接组合所有可能的话,电脑会炸的>︿<
如果组合错误,也可以把上面这一小段拿出来穷举,结合Hint的MD5得到flag
ctfshow{base64_1s太难了!!I服了U!}
自己拿官方WP运行的时候,发现运行好慢,可能是电脑问题,然后加了个跳帧发出来了。
虽然没看到这道题,不过我觉得就算看到了我也想不出来,就算想出来了,敲代码也敲不好。
原理就是用前后帧生成光流,然后判断是不是往左下走的。
import cv2
import numpy as np
import matplotlib.pyplot as plt
cap = cv2.VideoCapture('out_flag.mp4')
frameCount = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
frameHeight = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
frameWidth = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
mask = np.zeros((frameHeight, frameWidth))
def readGrayFrame():
ret, frame = cap.read()
if not ret:
return None
return cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
plt.figure(figsize=(8,6))
fr = 0
while True:
fr += 2
gray = readGrayFrame()
if gray is None:
break
gray_next = readGrayFrame()
if gray_next is None:
break
flow = cv2.calcOpticalFlowFarneback(gray, gray_next, None, 0.5, 3, 15, 3, 5, 1.2, 0)
h, w = gray.shape
y, x = np.mgrid[0:h:10, 0:w:10].reshape(2, -1).astype(int)
fx, fy = flow[y, x].T
lines = np.vstack([x, y, x + fx, y + fy]).T.reshape(-1, 2, 2)
lines = np.int32(lines + 0.5)
vis = np.zeros_like(gray)
for (x1, y1), (x2, y2) in lines:
if x1 > x2 and y1 < y2:
cv2.line(vis, (x1, y1), (x2, y2), 255 , 2)
mask += vis&gray
if fr % 100 ==0:
show=mask.copy()
cv2.putText(show,f'{fr}',(5,50), cv2.FONT_HERSHEY_SIMPLEX, 0.75, 255, 2)
cv2.imshow('frame2', show)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
print(fr)
# 跳帧
i = 29
while i:
_, frame = cap.read()
if not _:
break
i -= 1
fr += 1
plt.imshow(np.log(mask))
plt.imshow(np.log(mask+1))
plt.show()
cap.release()
cv2.destroyAllWindows()
CTFSHOW{AFOX_IS_VERY_MENGMENGDA}
这个是真不会了,声学什么的搞不懂
import torch,torchaudio,matplotlib.pyplot as plt,numpy as np,libnum
from scipy.signal import hilbert ,savgol_filter
wav,cyl = torchaudio.load('flag.mp3')
fw = wav[0]
hit = savgol_filter(np.abs(hilbert(fw.numpy())),500,1)
splitlist=[0]
hi = (hit[1:] - hit[:-1] )
i =0
while i < len(fw):
if len(np.where(hi[i-100:i]>=0)[0]) >80 and fw[i]>0.1 and (hit[i] - hit[i-100]) / hit[i] >0.1:
splitlist.append(i)
i=int(i+cyl*0.1)
i+=1
flag=''
for i in range(1,len(splitlist)-1):
fft=torch.abs(torch.fft.fft(fw[splitlist[i]: splitlist[i+1]]))[:(splitlist[i+1]-splitlist[i])//2]
maxs = torch.where(fft==fft.max())[0][0]//2
if fft[maxs*5] < fft[maxs*4]:
flag+='0'
else :
flag+='1'
print(libnum.b2s(flag))
还是要努力学