/images/zsm.jpg

格学习笔记

前言

用来记录我的格密码学习,参考资料是NSS工坊和一些blog

NTRU

1.入门题

task.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import gmpy2
from secret import flag
from Crypto.Util.number import *

f = bytes_to_long(flag)
p = getPrime(512)
g = getPrime(128)
h = gmpy2.invert(f+20192020202120222023, p) * g % p

print('h =', h)
print('p =', p)

想要flag就要求出f,f=f+20192020202120222023,最后减去这个数就好了,那么已知的式子就变成了

MT19937

算法描述

主要步骤

  1. 利用 seed 初始化寄存器状态
  2. 对寄存器状态进行旋转
  3. 根据寄存器状态提取伪随机数

初始化可能用的是固定的种子,也有可能是服务器时间戳,生成一个长度为624的状态数组,填充完后作为初始状态

云计算课设

云计算课设

这个课设是一个基于MapReduce的倒排索引系统,核心是Hadoop+docker+k8s

整体架构

前端 vue+nodejs

后端 nodejs+express+redis+sqlite3

部署方法 dockerfile+k8s

数据处理方法 Hadoop

课设灵感

自己blog的搜索功能很弱,采用的是js插件的全局遍历搜索,就在网上查了一下优化方法,顺便知道了倒排索引这种方法,结合云计算课堂的dockerHadoop知识,便有了这个课设

HNCTF2025

前言

rank18 我是fw

题目

哈基coke

task.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

import matplotlib.pyplot as plt
import cv2
import numpy as np
from PIL import Image
def arnold_encode(image, shuffle_times, a, b):
    """ Arnold shuffle for rgb image
    Args:
        image: input original rgb image
        shuffle_times: how many times to shuffle
    Returns:
        Arnold encode image
    """
    arnold_image = np.zeros(shape=image.shape)

    h, w = image.shape[0], image.shape[1]
    N = h

    for time in range(shuffle_times):
        for ori_x in range(h):
            for ori_y in range(w):

                new_x = (1*ori_x + b*ori_y)% N
                new_y = (a*ori_x + (a*b+1)*ori_y) % N

                arnold_image[new_x, new_y, :] = image[ori_x, ori_y, :]

        image = np.copy(arnold_image)

    cv2.imwrite('en_flag.png', arnold_image, [int(cv2.IMWRITE_PNG_COMPRESSION), 0])
    return arnold_image

img = cv2.imread('coke.png')
arnold_encode(img,6,9,1)

Arnold变换,我不是特别懂原理的,gpt一把梭了