flag = '****_****_****_****' b = 'PUALAKLVV]TQ[}QD' c = '' for i in range(len(flag)): c += chr(ord(flag[i]) ^ ord(b[i])) else: print(c) ------------------------------------------------------------------------------------------------ flag='' b = 'PUALAKLVV]TQ[}QD' c = 'cd2512d512d5123e' for i in range(len(c)): flag += chr(ord(c[i]) ^ ord(b[i])) else: print(flag) 再按位加上'_'得 31sy_py(c_go0d_jOb!
easy_cpp
hl师傅写的源码比我强多了,这里就不放源码了,简单给一下exp
import base64 flag=''; base64flag = ''; dict = {}; orgin = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for i in range(len(orgin)): dict[orgin[i]] = orgin[i] for i in range(6, 15): dict[orgin[i]] , dict[orgin[i+10]] = dict[orgin[i+10]] , dict[orgin[i]] # 恢复base64密钥表 print(dict) secret = 'ZmxhZ3tiGNXlXjHfaDTzN2FfK3LycRTpc2L9' for i in range(len(secret)): base64flag += dict[secret[i]]#根据恢复后的base64密钥表进行部分字符转化,想当于G~O的字符转为Q~Y,Q~Y转为G~O print(base64flag)
#base64解码 flag = base64.b64decode(base64flag) print(flag)
#恢复base64密钥表相当于以下算法 secret1 = 'ZmxhZ3tiGNXlXjHfaDTzN2FfK3LycRTpc2L9' a='' for i in range(len(secret1)): if ord(secret1[i])<80and ord(secret1[i])>=71: a += chr(ord(secret1[i]) + 10) else: if ord(secret1[i])<90and ord(secret1[i])>=81: a += chr(ord(secret1[i]) - 10) else: a += chr(ord(secret1[i])) print(a)
大三才学的密码学
这道题,在上一篇博客有详细题解,可以参考。
0x03 密码
最最最基础密码
仿射密码,澳神直接手算!
Rsa
from Crypto.Util.number import * from gmpy2 import * from sympy.ntheory.residue_ntheory import nthroot_mod n = 7941371739956577280160664419383740967516918938781306610817149744988379280561359039016508679365806108722198157199058807892703837558280678711420411242914059658055366348123106473335186505617418956630780649894945233345985279471106888635177256011468979083320605103256178446993230320443790240285158260236926519042413378204298514714890725325831769281505530787739922007367026883959544239568886349070557272869042275528961483412544495589811933856131557221673534170105409 d = 7515987842794170949444517202158067021118454558360145030399453487603693522695746732547224100845570119375977629070702308991221388721952258969752305904378724402002545947182529859604584400048983091861594720299791743887521228492714135449584003054386457751933095902983841246048952155097668245322664318518861440 cipher = 1618155233923718966393124032999431934705026408748451436388483012584983753140040289666712916510617403356206112730613485227084128314043665913357106301736817062412927135716281544348612150328867226515184078966397180771624148797528036548243343316501503364783092550480439749404301122277056732857399413805293899249313045684662146333448668209567898831091274930053147799756622844119463942087160062353526056879436998061803187343431081504474584816590199768034450005448200 p = 102634610559478918970860957918259981057327949366949344137104804864768237961662136189827166317524151288799657758536256924609797810164397005081733039415393 q = 7534810196420932552168708937019691994681052660068275906973480617604535381306041583841106383688654426129050931519275383386503174076258645141589911492908993 r = 10269028767754306217563721664976261924407940883784193817786660413744866184645984238866463711873380072803747092361041245422348883639933712733051005791543841 phn = (p-1)*(q-1)*(r-1) e = 0x10001 dec = invert(e,phn) print(dec) c = pow(cipher,dec,n) print(c) m = nthroot_mod(c,2,r) print(m) print(long_to_bytes(m))