网站建设的流程该怎么确定,手机网站封装小程序,朋友圈广告代理商官网,房地产开发建设网站解压压缩包#xff0c;里面是一张图片和一个新的zip文件 图片放大后的图案是----. 考虑到为莫斯密码#xff0c;将其解密 密码为9#xff0c;继续解压缩包 又是一张莫斯密码图加压缩包#xff0c;写一段脚本去解密图片中的莫斯密码#xff0c;并自动解压缩包
import re
i…解压压缩包里面是一张图片和一个新的zip文件 图片放大后的图案是----. 考虑到为莫斯密码将其解密 密码为9继续解压缩包 又是一张莫斯密码图加压缩包写一段脚本去解密图片中的莫斯密码并自动解压缩包
import re
import os
import sys
import zipfile
from PIL import Imagedef get_pass(morse_list):password MORSE_CODE_DICT {.-: a, -...: b, -.-.: c, -..: d,.: e, ..-.: f, --.: g, ....: h,..: i, .---: j, -.-: k, .-..: l,--: m, -.: n, ---: o, .--.: p,--.-: q, .-.: r, ...: s, -: t,..-: u, ...-: v, .--: w, -..-: x,-.--: y, --..: z, -----: 0, .----: 1,..---: 2, ...--: 3, ....-: 4, .....: 5,-....: 6, --...: 7, ---..: 8, ----.: 9,-..-.: /, .-.-.-: ., -.--.-: ), ..--..: ?,-.--.: (, -....-: -, --..--: ,}for morse in morse_list:password MORSE_CODE_DICT.get(morse)return passworddef get_morse():fp open(./pwd.png, rb)image Image.open(fp)pixel list(image.getdata())background pixel[0]chars []for i,v in enumerate(pixel):if v background:chars.append( )else:chars.append(*)output .join(chars)正则匹配测试建议https://regex101.com/^ : asserts position at start of a line$ : asserts position at the end of a line\s : matches any whitespace character (equivalent to [\r\n\t\f\v ])* : matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)\* : matches the character *{3}: matches the previous token exactly 3 timesoutput re.sub(r^\s*, , output) #匹配开头的任意个空白字符并替换为空output re.sub(r\s*$, , output) #匹配结尾的任意个空白字符并替换为空output re.sub(r\*{3}, -, output) #匹配3个*号并替换为字符-output re.sub(r\*, ., output) #匹配单个*号并替换为字符.output re.sub(r\s{2,}, | , output) #(用于处理多行摩斯密码的情况)匹配两个以上空白字符如果存在就替换为|output re.sub(r\s, , output) #匹配空白字符并替换为空output output.split(|)fp.close()return outputdef unzip_file(path, number, password):zip_path flag_ str(1000-number) .zipfp zipfile.ZipFile(zip_path)for file in fp.namelist():fp.extract(file,./,pwdpassword.encode(utf-8))fp.close()def main():path sys.path[0] #当前脚本的运行目录for number in range(1,1001):print(Processing the str(number) th archive.)#print(os.listdir(.)) #显示当前目录下的所有文件morse_list get_morse()password get_pass(morse_list)unzip_file(path, number, password)path ./flagos.chdir(path) #切换当前工作目录(进入flag子目录)fp open(./flag, r)flag fp.readlines()print(flag)fp.close()if __name__ __main__:main()解压后查看最后一个压缩包中包含HTB的字段很多种方法这里就不赘述 答案HTB{D0_y0u_L1k3_m0r53??}