N = 77483692467084448965814418730866278616923517800664484047176015901835675610073 e = 65537 c = 43711206624343807006656378470987868686365943634542525258065694164173101323321
N = 77483692467084448965814418730866278616923517800664484047176015901835675610073 e = 65537 c = 43711206624343807006656378470987868686365943634542525258065694164173101323321 p = 1025252665848145091840062845209085931 q = N // p
d = inverse(e,(p-1)*(q-1)) print(long_to_bytes(pow(c,d,N))) # utflag{just_send_plaintext}
print("Thanks for using our encryption service! To get the encrypted flag, type 1. To encrypt a message, type 2.") whileTrue: print("What would you like to do (1 - get encrypted flag, 2 - encrypt a message)?") user_input = int(input()) if(user_input == 1): break
print("What is your message?") message = input() print("Here is your encrypted message:", encrypt(message.encode()))
flag = open('./src/flag.txt', 'r').read() print("Here is the encrypted flag:", encrypt(flag.encode()))
sh.recvuntil(b"What would you like to do (1 - get encrypted flag, 2 - encrypt a message)?") sh.sendline(b"1") sh.recvline() data = sh.recvline() c = data.decode().split(":")[-1].strip() c = bytes.fromhex(c) sh.close() end = int(time.time() * 1000) % (10 ** 6)
defget_random_number(): global seed seed = int(str(seed * seed).zfill(12)[3:9]) return seed
for seed in trange(start,end): key = b'' for i inrange(8): key += (get_random_number() % (2 ** 16)).to_bytes(2, 'big') aes = AES.new(key, AES.MODE_ECB) flag = aes.decrypt(c) ifb"utflag"in flag: print(flag)
print("Thanks for using our encryption service! To get the encrypted flag, type 1. To encrypt a message, type 2.") whileTrue: print("What would you like to do (1 - get encrypted flag, 2 - encrypt a message)?") user_input = int(input()) if(user_input == 1): break
print("What is your message?") message = input() print("Here is your encrypted message:", encrypt(message.encode()))
flag = open('/src/flag.txt', 'r').read(); print("Here is the encrypted flag:", encrypt(flag.encode()))
from tqdm import * from pwn import * from Crypto.Cipher import AES
sh = remote("betta.utctf.live",7356)
sh.recvuntil(b"What would you like to do (1 - get encrypted flag, 2 - encrypt a message)?") sh.sendline(b"1") sh.recvline() data = sh.recvline() c = data.decode().split(":")[-1].strip() c = bytes.fromhex(c) sh.close()
defget_random_number(): global seed seed = int(str(seed * seed).zfill(12)[3:9]) return seed
for seed in trange(10**6): key = b'' for i inrange(8): key += (get_random_number() % (2 ** 16)).to_bytes(2, 'big') aes = AES.new(key, AES.MODE_ECB) flag = aes.decrypt(c) ifb"utflag"in flag: print(flag) break # utflag{deep_seated_and_recurring_self-doubts}
print("Thanks for using our encryption service! To get the start guessing, type 1. To encrypt a message, type 2.") print("You will need to guess the key (you get 250 guesses for one key). You will do this 3 times!")
for i inrange(3): seed = random.randint(0, 10 ** 6) print("Find the key " + str(i + 1) + " of 3!") key = encrypt(b"random text to initalize key")[0] whileTrue: print("What would you like to do (1 - guess the key, 2 - encrypt a message)?") user_input = int(input()) if(user_input == 1): break
print("What is your message?") message = input() key, ciphertext = encrypt(message.encode()) print("Here is your encrypted message:", ciphertext) print("You have 250 guesses to find the key!") found = False for j inrange(250): print("What is your guess (in hex)?") guess = str(input()).lower() if guess == key: print("You found the key!") found = True break else: print("That is not the key!")
ifnot found: print("You did not find the key!") exit(0)
flag = open('/src/flag.txt', 'r').read() print("Here is the flag:", flag)
sh = remote("betta.utctf.live",2435) msg = b"a"*16 sh.recvuntil(b"You will need to guess the key (you get 250 guesses for one key). You will do this 3 times!\n")
for i inrange(3): sh.recvuntil(b"What would you like to do (1 - guess the key, 2 - encrypt a message)?\n") sh.sendline(b"2") sh.sendlineafter(b"What is your message?",msg) sh.recvline() cipher = sh.recvline().strip().decode().split(":")[-1].strip()
print(f"cipher = {cipher}") for seed in trange(10**6): key = b"" for j inrange(8): key += (get_random_number() % (2 ** 16)).to_bytes(2, 'big') aes = AES.new(key, AES.MODE_ECB) c = aes.encrypt(pad(msg,AES.block_size)).hex() if c == cipher: print(f"key = {key}") sh.sendline(b"1") sh.recvuntil(b"What is your guess (in hex)?\n") sh.sendline(key.hex().encode()) sh.recvline() break sh.interactive() # utflag{ok_you_are_either_really_lucky_or_you_solved_it_as_intended_yay}
print("What's your guess?") guess = input().lower()
assertlen(guess) == 5 for letter in guess: assert letter in'abcdefghijklmnopqrstuvwxyz'
if guess == answer: break
response = 1 for x inrange(5): a = ord(guess[x]) - ord('a') b = ord(answer[x]) - ord('a') response = (response * (a-b)) % 31 print(response) if num_guesses > 6: print("Sorry, you took more than 6 tries. No flag for you :(") exit() else: print("Good job! Onward...")
if num_guesses <= 6: print('Nice! You got it :) Have a flag:') flag = open('/src/flag.txt', 'r').read() print(flag) else: print("Sorry, you took more than 6 tries. No flag for you :(")
猜单词,单词的长度为5,需要我们猜中3次,每次猜谜中有6次机会,如果猜错,靶机会返回我们这样的值:
1 2 3 4 5 6
response = 1 for x inrange(5): a = ord(guess[x]) - ord('a') b = ord(answer[x]) - ord('a') response = (response * (a-b)) % 31 print(response)
└─$ nc betta.utctf.live 4374 Welcome to the signature generator! This service generates signatures for nonnegative integer messages. Today's RSA parameters are: n = 22715415800845998993024248030912907934417610887661897677054217214410204092730320049883830649576833798235714524267550954257998402694512553806347540563817503765200000540567467194229934670132595181693756907560598419504853644981230926968934508408798411039604272013286354235309604897737849867286894191734498426882265991962178303977297297251166823420641597385760024527882951963763449900905583806374810182746133330897953973605976893360656996077027444918972375454537579314357093723161232116480999012805953845834378812517394470647495652867705481169517276997801093879183367121124675601652536608512214606801800156081683634353613 e = 65537 Enter a message as an integer (enter 0 to stop): 2 Your signature is: 19305047859578018954980116599753882711666480484142979465593383963718233040355590155869672573524217910051341399926166313215438016944909841325609661233708867343163708635690290325145359946697142164401814696198967248480534658338503630656123368239008794161223488100051552078603748861066699059542173080955664314245942352900854926237713096042527712292770988034717809771051464470887040552525974670894693177946816058097139433917736749106750964478978103361323385114107986313741317398412086531210680773102594971067051466113817094724683640177915480168931380713903297694652708554062155884806690502249638131714247467724175797421627 Enter a message as an integer (enter 0 to stop): 3 Your signature is: 12466668289899335464133090475657405950931821501533663001516736457824416177523171645577410125680582801199031807950155805989703649370706570876105560672722786621599217384752567820542034014172784328764628129021815078333759824898640044024669060187741947696361614188900150657553950899178216102406146022841319632133901664545580403590911676417478329981850274513600128209610835989969785039648356553422593375047160549502704081296610218123751535810888825205063182213809953668870294813497134950692299358898522409282459702028599784084273165843672444206386732642592570271106680551501845998454554339849461050571639928425405734311733 Enter a message as an integer (enter 0 to stop): 0 Now, come up with your own pair! Enter a message: 6 Enter a signature: 18982512873975173404933208419297386148920412591312317190999194687782049821680066612137323122655631365467978106391805163213875322096115052965353281855431718650033207890296554899233461063309157149813467505339311987308434971353194958650326478611180026442531262465134575047863754669782250309134800418243005941952440587177890885709176439351435995900545760925916705390507936161719544350561690754688037652781517684043996183726063988733579686454511426639010681269324482585239497278113727930739428354647428514162145491240213537530578274699904468976840913094523715136698577665810122637986259264550250518723399900126769899559214 Congrats! Here is the flag: utflag{a1m05t_t3xtb00k_3x3rc153}