首页 > 其他分享 >青少年CTF-Crypto(新手版本2.0,无factor1)

青少年CTF-Crypto(新手版本2.0,无factor1)

时间:2024-03-05 14:46:31浏览次数:21  
标签:factor1 list flag Crypto CTF &# str print import

凯撒大帝的征讨之路

题目:

lnixoa{1x2azz7w8axyva7y1z2320vxy6v97v9a}

知识点:凯撒加密

我的题解:

import base64
#shift得出移位多少,移位后的字母-移位前的字母
def caesar_decrypt(ciphertext, shift=ord('l')-ord('q')):
    str_list = list(ciphertext)
    i = 0
    while i < len(ciphertext):
        if str_list[i].isalpha():
            a = "A" if str_list[i].isupper() else "a"
            str_list[i] = chr((ord(str_list[i]) - ord(a) - shift) % 26 + ord(a))
        i += 1
    return ''.join(str_list)
str='lnixoa{1x2azz7w8axyva7y1z2320vxy6v97v9a}'
#放入需要解密的凯撒加密过的flag

kstr = caesar_decrypt(str)
print("凯撒解密后的字符串:", kstr)
#qsnctf{1c2fee7b8fcdaf7d1e2320acd6a97a9f}

PigPig

题目:

知识点:猪圈密码

我的题解:

 解个方程

题目:

欢迎来到青少年CTF,领取你的题目,进行解答吧!这是一道数学题!!
    p = 285938619572571413831422228101124163683
    q = 105729283011633484980933962485160648857
    e = 65537
    d = ?
    

知识点:大素数分解中求d

我的题解:

import gmpy2
from Crypto.Util.number import *
import math

p = 285938619572571413831422228101124163683
q = 105729283011633484980933962485160648857
e = 65537

n = p*q
phi = (p-1) * (q-1)
d = gmpy2.invert(e,phi)
print(d)
#5844184015344558481149339489808793528798898400213145852462349005651020126577

ez_log

题目:

from Crypto.Util.number import *
from random import *
flag=b'key{xxxxxxx}'
m=bytes_to_long(flag)
p=3006156660704242356836102321001016782090189571028526298055526061772989406357037170723984497344618257575827271367883545096587962708266010793826346841303043716776726799898939374985320242033037
g=3
c=pow(g,m,p)
print(f'c=',c)

c=2558016376919340744861283143131342116530097815936201928079539498968035304172458942066482394126279568644520885275321026125136755531717057526144375105028343943707485572136532741715583512444233

我的题解:

 c = g^m mod p

g很小,m作为flag处于次方的位置

可以用sage

from Crypto.Util.number import *
import gmpy2
c=2558016376919340744861283143131342116530097815936201928079539498968035304172458942066482394126279568644520885275321026125136755531717057526144375105028343943707485572136532741715583512444233
p=3006156660704242356836102321001016782090189571028526298055526061772989406357037170723984497344618257575827271367883545096587962708266010793826346841303043716776726799898939374985320242033037
e=3
flag = discrete_log(Mod(c,p),Mod(g,p))
print(long_to_bytes(flag))
#b'key{f73ra1}'

 ezrsa

题目:

from Crypto.Util.number import *
flag = b'qsnctf{xxx-xxxx-xxxx-xxxx-xxxxxxxxx}'
m = bytes_to_long(flag)
p = getPrime(512)
q = getPrime(512)
r = getPrime(512)
n = p * q * r
leak = p * q
e = 0x10001
c = pow(m, e, n)
print(f'c = {c}')
print(f'n = {n}')
print(f'leak = {leak}')
# c = 173595148273920891298949441727054328036798235134009407863895058729356993814829340513336567479145746034781201823694596731886346933549577879568197521436900228804336056005940048086898794965549472641334237175801757569154295743915744875800647234151498117718087319013271748204766997008772782882813572814296213516343420236873651060868227487925491016675461540894535563805130406391144077296854410932791530755245514034242725719196949258860635915202993968073392778882692892
# n = 1396260492498511956349135417172451037537784979103780135274615061278987700332528182553755818089525730969834188061440258058608031560916760566772742776224528590152873339613356858551518007022519033843622680128062108378429621960808412913676262141139805667510615660359775475558729686515755127570976326233255349428771437052206564497930971797497510539724340471032433502724390526210100979700467607197448780324427953582222885828678441579349835574787605145514115368144031247
# leak = 152254254502019783796170793516692965417859793325424454902983763285830332059600151137162944897787532369961875766745853731769162511788354655291037150251085942093411304833287510644995339391240164033052417935316876168953838783742499485868268986832640692657031861629721225482114382472324320636566226653243762620647

我的题解:

n分解出q、p、r,但是多因子解码不可信。

可以得出单个r,进行r的简单RSA计算

from Crypto.Util.number import *
import gmpy2
c = 173595148273920891298949441727054328036798235134009407863895058729356993814829340513336567479145746034781201823694596731886346933549577879568197521436900228804336056005940048086898794965549472641334237175801757569154295743915744875800647234151498117718087319013271748204766997008772782882813572814296213516343420236873651060868227487925491016675461540894535563805130406391144077296854410932791530755245514034242725719196949258860635915202993968073392778882692892
n = 1396260492498511956349135417172451037537784979103780135274615061278987700332528182553755818089525730969834188061440258058608031560916760566772742776224528590152873339613356858551518007022519033843622680128062108378429621960808412913676262141139805667510615660359775475558729686515755127570976326233255349428771437052206564497930971797497510539724340471032433502724390526210100979700467607197448780324427953582222885828678441579349835574787605145514115368144031247
leak = 152254254502019783796170793516692965417859793325424454902983763285830332059600151137162944897787532369961875766745853731769162511788354655291037150251085942093411304833287510644995339391240164033052417935316876168953838783742499485868268986832640692657031861629721225482114382472324320636566226653243762620647
e = 0x10001
r = n // leak r=9170584408726584113673965972648240491689635118606416619099032606248549219208315227501144611402976054161705877934617690915635968224924300539749199425819801 phr = r - 1 d = gmpy2.invert(e,phr) m = pow(c,d,r) print(long_to_bytes(m)) #qsnctf{12ff81e0-7646-4a96-a7eb-6a509ec01c9e}

四重加密

题目:

我的题解:

需要找出密码,在边上有

 CyberChef解码

 打开后出现编码

 

&#122;&#99;&#121;&#101;&#123;&#109;&#120;&#109;&#101;&#109;&#116;&#120;&#114;&#122;&#116;&#95;&#108;&#122;&#98;&#104;&#97;&#95;&#107;&#119;&#109;&#113;&#122;&#101;&#99;&#125;&#124;&#107;&#101;&#121;&#61;&#104;&#101;&#108;&#108;&#111;

HTNL解码:http://www.hiencode.com/html_en.html

 zcye{mxmemtxrzt_lzbha_kwmqzec}|key=hello

然后进行维吉尼亚解密,我用了随波逐流

synt{yqitbfqnoixsxwpwpifoqv}

最后进行rot13解码

flag{ldvgosdabvkfkjcjcvsbdi}

(我最后两次解密使用了随波逐流暴力破解,嘻嘻#^.^#)

 

标签:factor1,list,flag,Crypto,CTF,&#,str,print,import
From: https://www.cnblogs.com/Ninedayneverlostroad/p/18053762

相关文章

  • CTFshow pwn47-48
    CTFshowpwn47-48ret2libc的两道简单练习。还是很不熟练。pwn47已经给出了\bin\sh的字符串,还有输出了许多函数的地址,所以很容易拿到libc。frompwnimport*fromLibcSearcherimport*context(os='linux',arch='i386',log_level='debug')io=remote("pwn.challe......
  • 青少年CTF平台练习密码学
    凯撒大帝的征讨之路题目凯撒大帝在出征之路上留下了这样一串字符,你能通过这串字符得到FLAG并提交吗?lnixoa{1x2azz7w8axyva7y1z2320vxy6v97v9a}我的解答:凯撒密码qsnctf{1c2fee7b8fcdaf7d1e2320acd6a97a9f}PigPig题目这是什么密码呢?得到的结果请加上qsnctf{}后提交。我的......
  • ctfshow刷题记录-社工篇-1
    0x00题目来源:ctfshow-网络谜踪(社工类)题目描述:flag格式为ctfshow{纬度(精确到小数点后四位,不用进位),经度(精确到小数点后四位,不用进位)}例如若找到的经纬度为(11.45149,19.19810)则flag为ctfshow{11.4514,19.1981}(附件地址:https://ctfshow.lanzoui.com/iRHlmtek0ra)......
  • ctfshow刷题记录-cry方向-1
    0x00题目来源:ctfshow菜狗杯crypto方向base47题目描述:神必字符:E9CVT+HT5#X36RF4@LAU703+F$E-0N$@68LMXCVDRJJD5@MP#7MUZDTE?WWLG1S#L@+66H@59KTWYK8TW0RV神必字典:0123456789ABCDEFGHJKLMNPQRSTUVWXYZ?!@#$%^&*-+0x01第一次做这种base换表的题目,在网上查了查相关wp,感觉自......
  • HNCTF 2022 WEEK1
    [HNCTF2022Week1]超级签到str2是编写脚本str2='{hello_world}'print(str2.replace(chr(111),chr(48)))#{hell0_w0rld}[HNCTF2022Week1]贝斯是什么乐器啊?enc为码表为脚本为a="NRQ@PAu;8j[+(R:2806.i"flag=""foriinrange(len(a)):fla......
  • [GWCTF 2019]pyre
    首先是简单的pyc-py这题唯一要注意的一个点就是遇到%务必进行爆破爆破exp`code=['\x1f','\x12','\x1d','(','0','4','\x01','\x06','\x14','4',',','\x1......
  • CRYPTO入门
    月月的爱情故事txt.txt提示txt,把后缀改成txt,得到文本看到加密文本,丢去解密得到如下U2FsdGVkX1/bVF45zytlkeEhefAqkpHQdMqtULk2OibLq79NHJMm9rP3CtkKrE41CaBJmMIVcUVSb3IzpHeuWw==一眼看上去像Rabbit1.特点:Rabbit加密开头部分通常为U2FsdGVkX1(AES、DES、RC4、Rabbit......
  • 杂七杂八wp(NewStar_Week1和BeginCTF2024的部分pwn)
    碎碎念咱就一纯小白,以为带了Begin这一单词的CTF能对我仁慈一点,结果吧,太喜欢了,被狠狠拷打,从头自闭到尾,属于是从这次比赛又狠狠学习到不少知识了废话不多说,上正文嘞BeginCTFOne_bytechecksec嗯,基本啥都开了,喜欢捏。但是尊贵的CTFer,该“源审,启动!”了可以看到两个read,一个是......
  • 青少年CTF擂台挑战赛 2024 #Round 1-MISC
    一、CTFerRevenge1.得到txt,一眼某个文件的十六进制,前部分字符串,中间十六进制,最后是行数标识,先提取出全部的十六进制defclean_remove_spaces_and_last_chars(input_file,output_file):withopen(input_file,'r')asf:lines=f.readlines()cleaned_lines=[]......
  • cyi青少年CTF擂台挑战赛 2024 #Round 1 wp
    WEBEasyMD5靶机真不敢恭维一个文件上传界面,得上传pdf传两个pdfhttps://www.cnblogs.com/wysngblogs/p/15905398.html这篇文章看到md5碰撞,找到个工具fastcoll_v1.0.0.5https://www.win.tue.nl/hashclash/后续写的wp,flag可能不同PHP的后门https://blog.csdn.net/Sha......