文章分类 -  CyberSpace Security / CTF / Crypto

摘要:题目给的CBC: #!/usr/bin/python2.7 # -*- coding: utf-8 -*- from Crypto.Cipher import AES from Crypto.Random import random from Crypto.Util.number import lo 阅读全文
posted @ 2023-10-05 14:32 N0zoM1z0 阅读(73) 评论(0) 推荐(0)
摘要:刚好昨天学习了feistel结构的加解密 题目给出的加密源码: from Crypto.Util.number import * round = 2 flag = open("./secret", "rb").read().strip() def f(m, key): m = m ^ (m >> 4 阅读全文
posted @ 2023-10-02 09:50 N0zoM1z0
摘要:希尔加密 这里猜测利用的矩阵n=2 然后根据 wznqca = utflag 解出ABCD (是mod26意义下的!) 然后对应变换即可: from string import * s = "duqopfkqnwofdbzgeu" def Find(a1,a2,a3,a4,a5,a6,b1,b2,b 阅读全文
posted @ 2023-10-01 22:39 N0zoM1z0
摘要:很有意思的一道题 题目源码: from string import ascii_letters from flag import flag ctoi = lambda x: ascii_letters.index(x) itoc = lambda x: ascii_letters[x] key = 阅读全文
posted @ 2023-10-01 21:55 N0zoM1z0
摘要:关于MT19937的攻击 32位的MT19937python代码: def _int32(x): return int(0xFFFFFFFF & x) class MT19937: # 根据seed初始化624的state def __init__(self, seed): self.mt = [0 阅读全文
posted @ 2023-10-01 21:20 N0zoM1z0
摘要:考察float存储小端序问题 72065910510177138000000000000000.000000, 71863209670811371000000.000000, 18489682625412760000000000000000.000000, 727232575880506870000 阅读全文
posted @ 2023-10-01 20:46 N0zoM1z0
摘要:学习DES 加解密思路 (由于python2 python3 兼容问题 代码很难实现...) 由于DES是对称加密算法 所以已知加密过程后 只需要将加密过程逆过来即可 借个图 而这题的关键就是怎么求出 InvS_box 这里有个算法(AES DES等都适用): new_contrary_sbox = 阅读全文
posted @ 2023-10-01 14:30 N0zoM1z0 阅读(175) 评论(0) 推荐(0)
摘要:初次接触流密码 学到了很多 题目给的加密源码: seed = 0x00000000 # you need to solve this flag = 'n1book{%x}' % seed state = seed mask = 0b10000000000000000000000001010111 d 阅读全文
posted @ 2023-10-01 13:10 N0zoM1z0
摘要:题目给了 m,c,n 求指数flag 离散对数问题可以用sympy自带的discrete_log求解(我还以为用(m,n)=1能有些性质直接推...) from Crypto.Util.number import * import sympy import random n = 2**512 m = 阅读全文
posted @ 2023-10-01 09:36 N0zoM1z0
摘要:这题给了 d,e 还知道 p,q相差很小 要我们求n 学到了新思路: 已知p,q差不多为1024位 n=pq就是2048bit左右 而 de-1用bin转换求长度发现是2066bit 所以 k <=20 bit 可以枚举求解 然后利用 sympy 的prevprime 和 nextprime计算验证 阅读全文
posted @ 2023-09-28 13:34 N0zoM1z0
摘要:# 维纳攻击 import gmpy2 import primefac from Crypto.Util.number import * def transform(x,y): #使用辗转相处将分数 x/y 转为连分数的形式 res=[] while y: res.append(x//y) x,y= 阅读全文
posted @ 2023-09-25 18:52 N0zoM1z0
摘要:低指数加密广播攻击 e选取的很小 对同一个明文 M 进行了多次加密 且知道 Ni 和 Ci 用中国剩余定理 结合 ni ci 算出 m^e 然后用小指数 e 开方即可 from Crypto.Util.number import * import primefac import gmpy2 e = 阅读全文
posted @ 2023-09-17 13:19 N0zoM1z0
摘要:An interesting problem. First we are come up with this .txt: 72143238992041641000000.000000, 77135357178006504000000000000000.000000, 1125868345616435 阅读全文
posted @ 2023-09-15 16:48 N0zoM1z0
摘要:It is a problem to learn how to solve AES's problem. In AES, we use key and vector iv and the mode(CBC)to encrypt the flag. We should first search for 阅读全文
posted @ 2023-09-15 16:15 N0zoM1z0
摘要:The source code: import sympy from gmpy2 import gcd, invert from random import randint from Crypto.Util.number import getPrime, isPrime, getRandomNBit 阅读全文
posted @ 2023-09-14 21:26 N0zoM1z0
摘要:We have n,e,dp,c. Assume that it is quite difficult to factorize n, but it can be easily divided in fact. What can we do with dp leak? dp ≡ d mod (p-1 阅读全文
posted @ 2023-09-14 14:37 N0zoM1z0
摘要:This is the problem that requires some math skills. We have p,q,dp,dq,c. Now let's start to solve it. dp ≡ d mod(p-1) dq ≡ d mod(q-1) m ≡ c^d mod n m 阅读全文
posted @ 2023-09-14 13:37 N0zoM1z0
摘要:Assume that we have 2 groups of data, we find that n is the same and m also is. What can we do to work out m without factorize n?(actually we cannot f 阅读全文
posted @ 2023-09-13 23:01 N0zoM1z0
摘要:To review some types of problems solved today. 1. Just using brute force to factorize the n, as long as we find the p and q, we can easily calculate t 阅读全文
posted @ 2023-09-12 22:19 N0zoM1z0