Crypto 日记 Day1 [AFCTF2018]补题
前言
今天正好休息一天给平台(www.ctfer.vip)上上题,顺便补点题,看着这个Crypto很像Misc就试了下,正好写一篇日记
Morse
这个不用多说,直接摩斯
-…./.----/-…./-…./-…./…--/--…/….-/-…./-…./--…/-…/…--/.----/--…/…--/..---/--…/--…/….-/…../..-./--…/…--/…--/-----/…../..-./…--/…--/…--/….-/…--/…../--…/----./--…/-..
用https://morsecode.world/international/translator.html转换下
6 1 6 6 6 3 7 4 6 6 7 B 3 1 7 3 2 7 7 4 5 F 7 3 3 0 5 F 3 3 3 4 3 5 7 9 7 D
应该是ascii码转一下试试
afctf{1s't_s0_345y}
BASE
是一大串BASE16丢web直接out of memory,行吧我老老实实写脚本
或者用ciphey试试,结果文本太长ciphey也炸了
然后看到下一层之后好家伙搁着套娃呢
对于BASE16 BASE32 BASE64分辨方法比较简单,如果只有A-E的英文字母出现大概率是只有BASE16
如果只有大写+数字应该是BASE32,大小写占全了应该就是BASE64,但不排除有些奇奇怪该的base家族
然后因为这道题套娃过于离谱,甚至原本要写自动分析了,后面还是套出来了上脚本
import base64 with open('flag_encode.txt','r+') as f: data16 = f.read() print(base64.b64decode(base64.b64decode(base64.b16decode(base64.b64decode(base64.b64decode(base64.b32decode(base64.b16decode(base64.b32decode(base64.b32decode(base64.b64decode(base64.b64decode(base64.b32decode(base64.b64decode(base64.b32decode(base64.b32decode(base64.b16decode(base64.b32decode(base64.b32decode(base64.b32decode(base64.b32decode(base64.b32decode(base64.b16decode(base64.b32decode(base64.b32decode(base64.b32decode(base64.b64decode(base64.b16decode(base64.b64decode(base64.b64decode(base64.b16decode(data16)))))))))))))))))))))))))))))))
无语反正最后套出来了
afctf{U_5h0u1d_Us3_T00l5}
MagicNum
其实看到东西的时候有点懵 ,感觉又是个进制转换,但是浮点数转字节码(或者内存流)因为我自己不是计科专业的所以基础不行,去借了本计算机系统看了下现学现用,但是为了不祸害大家我给下资料和其他人的wp应该比我讲的清楚,什么时候我完全弄懂了再回来补吧。
浮点数:https://www.bilibili.com/video/BV1cD4y1D7uR?p=11
参考wp:https://blog.csdn.net/MikeCoke/article/details/113802168
flag:afctf{sec_is_everywhere}
Single
其实看名字我知道是单表替换,但是好死不死我去看了眼wp,说是维吉尼亚爆破,我傻了我折腾了半个小时后来想想不太对我又换回单表替换用了下单表替换神器(应该)https://quipqiup.com/
flag:afctf{Oh_U_found_it_nice_tRy}
Vigenère
对啊这个才是正儿八经的维吉尼亚不管上工具
不过上工具之前不如先看看维吉尼亚:https://ctf-wiki.org/crypto/classical/polyalphabetic/#vigenere
工具连接:https://www.guballa.de/vigenere-solver
可怜的RSA
菜鸡不配做RSA,这道题就不写详细题解了(吧?)
from Crypto.PublicKey import RSA with open('public.key','rb') as f: pub = RSA.importKey(f.read()) print(pub.n,pub.e)
先把key解密一下获得n和e
n = 79832181757332818552764610761349592984614744432279135328398999801627880283610900361281249973175805069916210179560506497075132524902086881120372213626641879468491936860976686933630869673826972619938321951599146744807653301076026577949579618331502776303983485566046485431039541708467141408260220098592761245010678592347501894176269580510459729633673468068467144199744563731826362102608811033400887813754780282628099443490170016087838606998017490456601315802448567772411623826281747245660954245413781519794295336197555688543537992197142258053220453757666537840276416475602759374950715283890232230741542737319569819793988431443
e = 65537
n的话先试试能不能直接分http://factordb.com/index.php
查的出来
p = 3133337 q = 25478326064937419292200172136399497719081842914528228316455906211693118321971399936004729134841162974144246271486439695786036588117424611881955950996219646807378822278285638261582099108339438949573034101215141156156408742843820048066830863814362379885720395082318462850002901605689761876319151147352730090957556940842144299887394678743607766937828094478336401159449035878306853716216548374273462386508307367713112073004011383418967894930554067582453248981022011922883374442736848045920676341361871231787163441467533076890081721882179369168787287724769642665399992556052144845878600126283968890273067575342061776244939
参考了下RSA的基础脚本
https://xz.aliyun.com/t/6459#toc-47
又借助了下解析enc的base64的脚本https://www.cnblogs.com/vict0r/p/13192535.html
import gmpy2 from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP import base64 p = 3133337 q = 25478326064937419292200172136399497719081842914528228316455906211693118321971399936004729134841162974144246271486439695786036588117424611881955950996219646807378822278285638261582099108339438949573034101215141156156408742843820048066830863814362379885720395082318462850002901605689761876319151147352730090957556940842144299887394678743607766937828094478336401159449035878306853716216548374273462386508307367713112073004011383418967894930554067582453248981022011922883374442736848045920676341361871231787163441467533076890081721882179369168787287724769642665399992556052144845878600126283968890273067575342061776244939 e = 65537 n = p * q phi = (p-1)*(q-1) d = int(gmpy2.invert(e, phi)) f = open('flag.enc', 'r').read() c = base64.b64decode(f) key_info = RSA.construct((n, e, d, p, q)) key = RSA.importKey(key_info.exportKey()) key = PKCS1_OAEP.new(key) flag = key.decrypt(c) print(flag)
获得flag:afctf{R54_|5_$0_B0rin9}
你能看出这是什么加密么
p=0x928fb6aa9d813b6c3270131818a7c54edb18e3806942b88670106c1821e0326364194a8c49392849432b37632f0abe3f3c52e909b939c91c50e41a7b8cd00c67d6743b4f
q=0xec301417ccdffa679a8dcc4027dd0d75baf9d441625ed8930472165717f4732884c33f25d4ee6a6c9ae6c44aedad039b0b72cf42cab7f80d32b74061
e=0x10001
c=0x70c9133e1647e95c3cb99bd998a9028b5bf492929725a9e8e6d2e277fa0f37205580b196e5f121a2e83bc80a8204c99f5036a07c8cf6f96c420369b4161d2654a7eccbdaf583204b645e137b3bd15c5ce865298416fd5831cba0d947113ed5be5426b708b89451934d11f9aed9085b48b729449e461ff0863552149b965e22b6
这不是RSA吗?用刚刚的脚本梭一下
import gmpy2 #这边我用yafu分解了n from Crypto.Util.number import long_to_bytes p=0x928fb6aa9d813b6c3270131818a7c54edb18e3806942b88670106c1821e0326364194a8c49392849432b37632f0abe3f3c52e909b939c91c50e41a7b8cd00c67d6743b4f q=0xec301417ccdffa679a8dcc4027dd0d75baf9d441625ed8930472165717f4732884c33f25d4ee6a6c9ae6c44aedad039b0b72cf42cab7f80d32b74061 e=0x10001 c=0x70c9133e1647e95c3cb99bd998a9028b5bf492929725a9e8e6d2e277fa0f37205580b196e5f121a2e83bc80a8204c99f5036a07c8cf6f96c420369b4161d2654a7eccbdaf583204b645e137b3bd15c5ce865298416fd5831cba0d947113ed5be5426b708b89451934d11f9aed9085b48b729449e461ff0863552149b965e22b6 n = p*q phi=(p-1)*(q-1) d=gmpy2.invert(e,phi) m=pow(c,d,n) print(long_to_bytes(m))
获得flag afctf{R54_|5_$0_$imp13}
Crypto 日记 Day1 [AFCTF2018]补题
https://www.wd-ljt.com/post/1202/747.html
来源于问谛居,转载记得联系作者哟~
共有 0 条评论