[NewStarCTF 2023 公开赛道] week1 Crypto

brainfuck

题目描述:

++++++++[>>++>++++>++++++>++++++++>++++++++++>++++++++++++>++++++++++++++>++++++++++++++++>++++++++++++++++++>++++++++++++++++++++>++++++++++++++++++++++>++++++++++++++++++++++++>++++++++++++++++++++++++++>++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++<<<<<<<<<<<<<<<<-]>>>>>>>++++++.>----.<-----.>-----.>-----.<<<-.>>++..<.>.++++++.....------.<.>.<<<<<+++.>>>>+.<<<+++++++.>>>+.<<<-------.>>>-.<<<+.+++++++.--..>>>>---.-.<<<<-.+++.>>>>.<<<<-------.+.>>>>>++.

题目分析:
brainfuck直接解
flag{Oiiaioooooiai#b7c0b1866fe58e12}

Caesar’s Secert

题目描述:

kqfl{hf3x4w'x_h1umjw_n5_a4wd_3fed}

题目分析:
凯撒解密
flag{ca3s4rs_c1pher_i5_v4ry_3azy}

Fence

题目描述:

fa{ereigtepanet6680}lgrodrn_h_litx#8fc3

题目分析:
w型栅栏解密
flag{reordering_the_plaintext#686f8c03}

Vigenère

题目描述:

 pqcq{qc_m1kt4_njn_5slp0b_lkyacx_gcdy1ud4_g3nv5x0}

题目分析:
维吉尼亚解密
flag 对应 pqcq,得到密钥kfc
flag{la_c1fr4_del_5ign0r_giovan_batt1st4_b3ll5s0}
用不知密钥维吉尼亚解密直接秒

babyencoding

题目描述:

part 1 of flag: ZmxhZ3tkYXp6bGluZ19lbmNvZGluZyM0ZTBhZDQ=
part 2 of flag: MYYGGYJQHBSDCZJRMQYGMMJQMMYGGN3BMZSTIMRSMZSWCNY=
part 3 of flag: =8S4U,3DR8SDY,C`S-F5F-C(S,S<R-C`Q9F8S87T` 

题目分析:
1.base64得到flag{dazzling_encoding#4e0ad4
2.base32得到f0ca08d1e1d0f10c0c7afe422fea7
3.uuencode得到c55192c992036ef623372601ff3a}
flag{dazzling_encoding#4e0ad4f0ca08d1e1d0f10c0c7afe422fea7c55192c992036ef623372601ff3a}
在这里插入图片描述

babyrsa

题目描述:

from Crypto.Util.number import *
from flag import flagdef gen_prime(n):res = 1for i in range(15):res *= getPrime(n)return resif __name__ == '__main__':n = gen_prime(32)e = 65537m = bytes_to_long(flag)c = pow(m,e,n)print(n)print(c)
n = 17290066070594979571009663381214201320459569851358502368651245514213538229969915658064992558167323586895088933922835353804055772638980251328261
c = 14322038433761655404678393568158537849783589481463521075694802654611048898878605144663750410655734675423328256213114422929994037240752995363595

题目分析:
分解n后直接常规rsa

from Crypto.Util.number import *
n = 17290066070594979571009663381214201320459569851358502368651245514213538229969915658064992558167323586895088933922835353804055772638980251328261
c = 14322038433761655404678393568158537849783589481463521075694802654611048898878605144663750410655734675423328256213114422929994037240752995363595
phi = euler_phi(n)
d = inverse_mod(65537,phi)
m = pow(c,d,n)
long_to_bytes(int(m))
# flag{us4_s1ge_t0_cal_phI}

small d

题目描述:

from secret import flag
from Crypto.Util.number import *p = getPrime(1024)
q = getPrime(1024)d = getPrime(32)
e = inverse(d, (p-1)*(q-1))
n = p*q
m = bytes_to_long(flag)c = pow(m,e,n)print(c)
print(e)
print(n)c = 6755916696778185952300108824880341673727005249517850628424982499865744864158808968764135637141068930913626093598728925195859592078242679206690525678584698906782028671968557701271591419982370839581872779561897896707128815668722609285484978303216863236997021197576337940204757331749701872808443246927772977500576853559531421931943600185923610329322219591977644573509755483679059951426686170296018798771243136530651597181988040668586240449099412301454312937065604961224359235038190145852108473520413909014198600434679037524165523422401364208450631557380207996597981309168360160658308982745545442756884931141501387954248
e = 8614531087131806536072176126608505396485998912193090420094510792595101158240453985055053653848556325011409922394711124558383619830290017950912353027270400567568622816245822324422993074690183971093882640779808546479195604743230137113293752897968332220989640710311998150108315298333817030634179487075421403617790823560886688860928133117536724977888683732478708628314857313700596522339509581915323452695136877802816003353853220986492007970183551041303875958750496892867954477510966708935358534322867404860267180294538231734184176727805289746004999969923736528783436876728104351783351879340959568183101515294393048651825
n = 19873634983456087520110552277450497529248494581902299327237268030756398057752510103012336452522030173329321726779935832106030157682672262548076895370443461558851584951681093787821035488952691034250115440441807557595256984719995983158595843451037546929918777883675020571945533922321514120075488490479009468943286990002735169371404973284096869826357659027627815888558391520276866122370551115223282637855894202170474955274129276356625364663165723431215981184996513023372433862053624792195361271141451880123090158644095287045862204954829998614717677163841391272754122687961264723993880239407106030370047794145123292991433

题目分析:
大e,维纳攻击

from Crypto.Util.number import *
def continuedFra(x, y):cf = []while y:cf.append(x // y)x, y = y, x % yreturn cfdef gradualFra(cf):numerator = 0 # 分子denominator = 1 # 分母for x in cf[::-1]:numerator, denominator = denominator, x * denominator + numeratorreturn numerator, denominatordef getGradualFra(cf):gf = []for i in range(1, len(cf) + 1):gf.append(gradualFra(cf[:i]))return gfdef wienerAttack(e, n):cf = continuedFra(e, n)gf = getGradualFra(cf)for d, k in gf: # 不得不说最后要倒一下呀!if d.bit_length() == 32:return dc = 6755916696778185952300108824880341673727005249517850628424982499865744864158808968764135637141068930913626093598728925195859592078242679206690525678584698906782028671968557701271591419982370839581872779561897896707128815668722609285484978303216863236997021197576337940204757331749701872808443246927772977500576853559531421931943600185923610329322219591977644573509755483679059951426686170296018798771243136530651597181988040668586240449099412301454312937065604961224359235038190145852108473520413909014198600434679037524165523422401364208450631557380207996597981309168360160658308982745545442756884931141501387954248
e = 8614531087131806536072176126608505396485998912193090420094510792595101158240453985055053653848556325011409922394711124558383619830290017950912353027270400567568622816245822324422993074690183971093882640779808546479195604743230137113293752897968332220989640710311998150108315298333817030634179487075421403617790823560886688860928133117536724977888683732478708628314857313700596522339509581915323452695136877802816003353853220986492007970183551041303875958750496892867954477510966708935358534322867404860267180294538231734184176727805289746004999969923736528783436876728104351783351879340959568183101515294393048651825
n = 19873634983456087520110552277450497529248494581902299327237268030756398057752510103012336452522030173329321726779935832106030157682672262548076895370443461558851584951681093787821035488952691034250115440441807557595256984719995983158595843451037546929918777883675020571945533922321514120075488490479009468943286990002735169371404973284096869826357659027627815888558391520276866122370551115223282637855894202170474955274129276356625364663165723431215981184996513023372433862053624792195361271141451880123090158644095287045862204954829998614717677163841391272754122687961264723993880239407106030370047794145123292991433
d=wienerAttack(e, n)
m=pow(c, d, n)
print(long_to_bytes(m))
# flag{learn_some_continued_fraction_technique#dc16885c}

babyxor

爆破key

a = 'e9e3eee8f4f7bffdd0bebad0fcf6e2e2bcfbfdf6d0eee1ebd0eabbf5f6aeaeaeaeaeaef2'
c = bytes.fromhex(a)
for i in range(256):flag = []for j in c:flag.append(j ^ i)if b'flag' in bytes(flag):print(bytes(flag))
# flag{x0r_15_symm3try_and_e4zy!!!!!!}

或直接求key,key = ord(‘f’) ^ (密文第一个字节)

a = 'e9e3eee8f4f7bffdd0bebad0fcf6e2e2bcfbfdf6d0eee1ebd0eabbf5f6aeaeaeaeaeaef2'
c = bytes.fromhex(a)
key = ord('f') ^ c[0]
flag = []
for j in c:flag.append(j ^ key)
print(bytes(flag))
# flag{x0r_15_symm3try_and_e4zy!!!!!!}

Affine

题目描述:

from flag import flag, keymodulus = 256ciphertext = []for f in flag:ciphertext.append((key[0]*f + key[1]) % modulus)print(bytes(ciphertext).hex())# dd4388ee428bdddd5865cc66aa5887ffcca966109c66edcca920667a88312064

题目分析:
解方程求key0,key1,求出key0,key1后逆一下加密函数结果也就出来了
flag这几个字母有的有解,有的没解,自行尝试即可

from gmpy2 import *
a = 'dd4388ee428bdddd5865cc66aa5887ffcca966109c66edcca920667a88312064'
cipher = bytes.fromhex(a)from z3 import *
s = Solver()
k0,k1 = Int('k0'),Int('k1')s.add(k0 * ord('g') + k1 == cipher[3])
s.add(k0 * ord('f') + k1 == cipher[0])
if s.check() == sat:print(s.model())k0 = 17
# k1 = -1513 % 256
k1 = 23
flag = []
for c in cipher:flag.append((c - k1) * invert(k0,256) % 256)
print(bytes(flag))
# flag{4ff1ne_c1pher_i5_very_3azy}

babyaes

题目描述:

from Crypto.Cipher import AES
import os
from flag import flag
from Crypto.Util.number import *def pad(data):return data + b"".join([b'\x00' for _ in range(0, 16 - len(data))])def main():flag_ = pad(flag)key = os.urandom(16) * 2iv = os.urandom(16)print(bytes_to_long(key) ^ bytes_to_long(iv) ^ 1)aes = AES.new(key, AES.MODE_CBC, iv)enc_flag = aes.encrypt(flag_)print(enc_flag)if __name__ == "__main__":main()
'''
a = 3657491768215750635844958060963805125333761387746954618540958489914964573229
c = b'>]\xc1\xe5\x82/\x02\x7ft\xf1B\x8d\n\xc1\x95i'
'''

题目分析:
我记得buu上有一道与这题超类似的题
key等于字节a的前16位 * 2
iv = 字节a后16位 ^ key的前一半 ^ 1
key,iv都出来了,那么flag也就出来了

from Crypto.Util.number import *
from Crypto.Cipher import AESa = 3657491768215750635844958060963805125333761387746954618540958489914964573229
c = b'>]\xc1\xe5\x82/\x02\x7ft\xf1B\x8d\n\xc1\x95i'
key = long_to_bytes(a)[:16]
iv = bytes_to_long(key) ^ bytes_to_long(long_to_bytes(a)[16:]) ^ 1aes = AES.new(key * 2,AES.MODE_CBC,long_to_bytes(iv))
flag = aes.decrypt(c)
print(flag)
# flag{firsT_cry_Aes}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/129951.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Oracle】Oracle系列十九--Oracle的体系结构

文章目录 往期回顾前言1. 物理结构2. 内存结构2.1 SGA2.2 后台进程 3. 逻辑结构 往期回顾 【Oracle】Oracle系列之一–Oracle数据类型 【Oracle】Oracle系列之二–Oracle数据字典 【Oracle】Oracle系列之三–Oracle字符集 【Oracle】Oracle系列之四–用户管理 【Oracle】Or…

centos7 配置coreboot编译环境 以及编译问题解决

需要的配置 (有的资源在国外可能需要翻墙) 操作系统: centos7.9 参考文章 coreboot源码分析之编译和运行coreboot - 知乎 //coreboot编译总说明 https://www.coreboot.org/Build_HOWTO#Requirements https://poe.com/ChatGPT 注意: 因为github不稳定 所以gitee为主 1. 下载…

Transformer预测 | Python实现基于Transformer的股票价格预测(tensorflow)

文章目录 效果一览文章概述程序设计参考资料效果一览 文章概述 Transformer预测 | Python实现基于Transformer的股票价格预测(tensorflow) 程序设计 import numpy as np import matplotlib.pyplot

SpringBoot 实现EMQ设备的上下线告警

前言 上下线通知 我遇到了一个难题&#xff0c;即在使用EMQ X 4.4.10的开源版本时&#xff0c;我需要实现设备的上下线状态监控&#xff0c;但该4.4.10开源版本并未内置设备上下线提醒模块&#xff0c;只有企业版才内置了该模块。这为我带来了一些技术上的难题&#xff0c;迫…

记录宝塔面板申请ssl证书报错 Invalid version. The only valid version for X509Req is 0

问题 宝塔面板申请ssl证书报错 Invalid version. The only valid version for X509Req is 0。 原因是由于服务器端使用了不兼容的 OpenSSL 版本导致的&#xff0c;服务器端的X509Req 版本只支持 0&#xff0c;而宝塔这边默认的版本为2。 我的是之前可以申请ssl&#xff0c;过…

玄子Share- IDEA 2023 SpringBoot 热部署

玄子Share- IDEA 2023 SpringBoot 热部署 修改 IDEA 部署设置 IDEA 勾选如下选项 新建 SpringBoot 项目 项目构建慢的将 Spring Initializr 服务器 URL 改为阿里云&#xff1a;https://start.aliyun.com/ 在这里直接勾选Spring Boot Devtools插件即可 测试 切出 IDEA 项目文…

HTML5+CSSday4综合案例二——banner效果

bannerCSS展示图&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content"wi…

【C++】List -- 详解

一、list的介绍及使用 https://cplusplus.com/reference/list/list/?kwlist list 是可以在常数范围内在任意位置进行插入和删除的序列式容器&#xff0c;并且该容器可以前后双向迭代。 list 的底层是双向链表结构&#xff0c;双向链表中每个元素存储在互不相关的独立节点中&…

Redis AOF重写原原理

重写aof之前 appendonly.aof.1.base.aof appendonly.aof.1.incr.aof appendonly.aof.manifest 重写aof 一次 appendonly.aof.2.base.aof 大小变化 appendonly.aof.2.incr.aof 大小o appendonly.aof.manifest 大小不变 AOF文件重写并不是对原文件进行重新整理&#xff0c;而是直…

Elasticsearch:什么是检索增强生成 - RAG?

在人工智能的动态格局中&#xff0c;检索增强生成&#xff08;Retrieval Augmented Generation - RAG&#xff09;已经成为游戏规则的改变者&#xff0c;彻底改变了我们生成文本和与文本交互的方式。 RAG 使用大型语言模型 (LLMs) 等工具将信息检索的能力与自然语言生成无缝结合…

hive add columns 后查询不到新字段数据的问题

分区表add columns 查询不到新增字段数据的问题&#xff1b; 5.1元数据管理 &#xff08;1&#xff09;基本架构 Hive的2个重要组件&#xff1a;hiveService2 和metastore,一个负责转成MR进行执行&#xff0c;一个负责元数据服务管理 beeline-->hiveService2/spar…

软件企业找第三方软件测评机构做确认测试有什么优势?

软件确认测试是一个在软件开发过程中十分重要的环节。它确保了软件的功能符合预期&#xff0c;达到了用户的需求和期望。确认测试主要验证软件的功能、性能、易用性、稳定性等方面&#xff0c;旨在发现和修复潜在的问题和缺陷。通过进行全面的确认测试&#xff0c;软件企业可以…