NSSCTF


NSSCTF

[SWPUCTF 2021 新生赛]简简单单的逻辑

题目:

1
2
3
4
5
6
7
8
9
flag = 'xxxxxxxxxxxxxxxxxx'
list = [47, 138, 127, 57, 117, 188, 51, 143, 17, 84, 42, 135, 76, 105, 28, 169, 25]
result = ''
for i in range(len(list)):
key = (list[i]>>4)+((list[i] & 0xf)<<4)
result = result + str(hex(ord(flag[i])^key))[2:].zfill(2)

print(result)
# result=bcfba4d0038d48bd4b00f82796d393dfec

SWPUCTF 2021 新生赛]简简单单的逻辑 - 哔哩哔哩 (bilibili.com)

首先要掌握的知识点:

字符串转ASCII

print(ord(‘a’)) #97

ASCII转字符串

print(chr(97)) #a

切片:https://www.jianshu.com/p/15715d6f4dad

十进制转十六进制

print(hex(10)) #a

十六进制转十进制

print(int(‘a’,16)) #10

1
2
3
4
5
6
7
8
9
10
flag = ''
list = [47, 138, 127, 57, 117, 188, 51, 143, 17, 84, 42, 135, 76, 105, 28, 169, 25]
result = 'bcfba4d0038d48bd4b00f82796d393dfec'
for i in range(len(list)):
key = (list[i]>>4)+((list[i] & 0xf)<<4)
#result += str(hex(ord(flag[i])^key))[2:].zfill(2)
flag+=chr(int((result[2*i:2*i+2]),16)^key)
print(flag)
# result=bcfba4d0038d48bd4b00f82796d393dfec
# flag = NSSCTF{EZEZ_RERE}

[SWPUCTF 2021 新生赛]re1

就是,变一下,3–e 4–a

NSSCTF{easy_reverse}

[HGAME 2023 week1]a_cup_of_tea

45678901345678902345678912345678

放个TEA小轮子:

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

def decrypt(v, k):
v0 = v[0]
v1 = v[1]
x = 0xABCDEF23 * 32
delta = 0xABCDEF23 @@@
k0 = k[0]
k1 = k[1]
k2 = k[2]
k3 = k[3]
for i in range(32):
v1 -= ((v0 << 4) + k2) ^ (v0 + x) ^ ((v0 >> 5) + k3)
v1 = v1 & 0xFFFFFFFF
v0 -= ((v1 << 4) + k0) ^ (v1 + x) ^ ((v1 >> 5) + k1)
v0 = v0 & 0xFFFFFFFF
x -= delta
x = x & 0xFFFFFFFF
v[0] = v0
v[1] = v1
return v

if __name__ == '__main__':
c = [0x2E63829D, 0xC14E400F, 0x9B39BFB9, 0x5A1F8B14, 0x61886DDE, 0x6565C6CF, 0x9F064F64, 0x236A43F6, 0x7D6B]
cc = [long_to_bytes(k)[::-1] for k in c]
key = [0x12345678, 0x23456789, 0x34567890, 0x45678901]
flag = b''
for i in range(len(c)//2):
d = decrypt(c[2*i:2*(i+1)], key)
flag += long_to_bytes(d[0])[::-1]+long_to_bytes(d[1])[::-1]
flag += long_to_bytes(c[-1])[::-1]
print(flag)

# b'hgame{Tea_15_4_v3ry_h3a1thy_drlnk}'

crypto

小轮子RSA

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from Crypto.Util.number import *

flag = open('flag.txt', 'rb').read()

p = getPrime(512)
q = getPrime(512)
n=p*q
e = 65537
m = bytes_to_long(flag)
c = pow(m, e, n)
print(f"c={c}")
print(f"n={n}")

"""
c=110674792674017748243232351185896019660434718342001686906527789876264976328686134101972125493938434992787002915562500475480693297360867681000092725583284616353543422388489208114545007138606543678040798651836027433383282177081034151589935024292017207209056829250152219183518400364871109559825679273502274955582
n=135127138348299757374196447062640858416920350098320099993115949719051354213545596643216739555453946196078110834726375475981791223069451364024181952818056802089567064926510294124594174478123216516600368334763849206942942824711531334239106807454086389211139153023662266125937481669520771879355089997671125020789
"""
1
2
3
4
5
6
7
8
9
10
11
12
13
p = 11239134987804993586763559028187245057652550219515201768644770733869088185320740938450178816138394844329723311433549899499795775655921261664087997097294813
q = 12022912661420941592569751731802639375088427463430162252113082619617837010913002515450223656942836378041122163833359097910935638423464006252814266959128953
n = p*q
c = 110674792674017748243232351185896019660434718342001686906527789876264976328686134101972125493938434992787002915562500475480693297360867681000092725583284616353543422388489208114545007138606543678040798651836027433383282177081034151589935024292017207209056829250152219183518400364871109559825679273502274955582
e = 65537

f = (p-1)*(q-1)
d = inverse_mod(e,f)
m = pow(c,d,n)
print(bytes.fromhex(hex(m)[2:]))

# hgame{factordb.com_is_strong!}


文章作者: W3nL0u
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 W3nL0u !
  目录