hgame-week1-crypto
Posted Rgylin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hgame-week1-crypto相关的知识,希望对你有一定的参考价值。
hgame-week1-crypto
随便看了一眼发现都是一些脚本题目,毕竟才第一周
密码还挺有意思, 就更新一下密码思路
密码1
仔细观察一下就是01变种题
向右走表示0 向下走表示1 ,走迷宫题了
写个算法即可
pos_x+1 或者pos_y+1即可
from PIL import Image
image= Image.open('Dancing Line.bmp')
pos_x=0
pos_y=0
w,h= image.size
s=''
flag=''
while pos_x<w or pos_y<h:
if(image.getpixel((pos_x,pos_y))[0]==0):
if(s!=''):
print(chr(int(s,2)),end='')
s=''
if(image.getpixel((pos_x+1,pos_y))[0]==84 or image.getpixel((pos_x+1,pos_y))[0]==0):
pos_x+=1
s+='0'
else:
pos_y+=1
s+='1'
最后越界了,但问题不大
密码2
简单rsa 求解
from Crypto.Util.number import *
import gmpy2
list1=[(12433, 149, 197, 104), (8147, 131, 167, 6633), (10687, 211, 197, 35594), (19681, 131, 211, 15710), (33577, 251, 211, 38798), (30241, 157, 251, 35973), (293, 211, 157, 31548), (26459, 179, 149, 4778), (27479, 149, 223, 32728), (9029, 223, 137, 20696), (4649, 149, 151, 13418), (11783, 223, 251, 14239), (13537, 179, 137, 11702), (3835, 167, 139, 20051), (30983, 149, 227, 23928), (17581, 157, 131, 5855), (35381, 223, 179, 37774), (2357, 151, 223, 1849), (22649, 211, 229, 7348), (1151, 179, 223, 17982), (8431, 251, 163, 30226), (38501, 193, 211, 30559), (14549, 211, 151, 21143), (24781, 239, 241, 45604), (8051, 179, 131, 7994), (863, 181, 131, 11493), (1117, 239, 157, 12579), (7561, 149, 199, 8960), (19813, 239, 229, 53463), (4943, 131, 157, 14606), (29077, 191, 181, 33446), (18583, 211, 163, 31800), (30643, 173, 191, 27293), (11617, 223, 251, 13448), (19051, 191, 151, 21676), (18367, 179, 157, 14139), (18861, 149, 191, 5139), (9581, 211, 193, 25595)]
for i in list1:
e,p,q,c=i
d=gmpy2.invert(e,(p-1)*(q-1))
print(long_to_bytes(gmpy2.powmod(c,d,p*q)))
密码3
转换成摩斯,逆序 维吉尼亚 栅栏 恺撒21位
密码4
写个脚本统计,一下所有句子符合规则的句段
import os
os.chdir('encrypt')
s=''
for i in os.listdir('./'):
with open(i,'r') as f:
s= f.read().split(' ')
if(len(s[0])==len('urveying') and len(s[1])==len('the')):
print(i)
也可才筛选为了方便弄两个就行 然后找到对应的
然后按脚本求出key 在求出flag即可
def encrypt(data, key):
assert len(data) <= len(key)
result = ""
for i in range(len(data)):
if data[i].isupper():
result += chr((ord(data[i]) - ord('A') -key[i]) % 26 + ord('A'))
elif data[i].islower():
result += chr((ord(data[i]) - ord('a') - key[i]) % 26 + ord('a'))
else:
result += data[i]
return result
orgin='xwnqzggq eif yehxzx, Crpfnayh ctchzafa hvdw tpay wvz eamc num rmuwd veq v qdwvwyvq, wnabo wxwoa qv cmav ga uswkdmb t dqsywu cxe cvpmxu tyy lthz pigd jrxqomajyx wmffx. Kuzj ljinh hohwh ths ftwfsh juh sizy hhzm ir zetzkz, dmc ckowz xstc uym s vikabvus vge, t uxvhg-iqzsll, e jgexhq-zxylpu, acj nl qlqvoxvb wivmerf bxripgu. Tst jdizkqv tab svkul krxgy by zfotbpww jr xdip wmff mywojv (kre pjt uwgn wbt fc xzd-fkwb'
new= 'urveying the ground, Snowball declared that this was just the place for a windmill, which could be made to operate a dynamo and supply the farm with electrical power. This would light the stalls and warm them in winter, and would also run a circular saw, a chaff-cutter, a mangel-slicer, and an electric milking machine. The animals had never heard of anything of this kind before (for the farm was an old-fash'
key=[]
for i in range(len(orgin)):
key.append(ord(orgin[i])-ord(new[i]))
print(key)
enc_flag="klsyfW0_j0v_ca0z_'Ks0ao-bln1qstxp_juqfqy'?"
print(encrypt(enc_flag,key))
以上是关于hgame-week1-crypto的主要内容,如果未能解决你的问题,请参考以下文章