[*] Session decodes to: {'username': 'qwsa'} [*] No wordlist selected, falling back to default wordlist.. [*] Starting brute-forcer with 8 threads.. [*] Attempted (2176): -----BEGIN PRIVATE KEY-----ECR [+] Found secret key after 21760 attemptsARmLVrlFlXaB 'supersecretkey'
a = 'GK4L7{Xg_EVfQ_4Th9vJkkkkk}' key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' b = ''.join([key[(8+key.index(i)) % len(key)] if i in key else i for i in a]) print(b) key = 'abcdefghijklmnopqrstuvwxyz0123456789' c = ''.join([key[(8+key.index(i)) % len(key)] if i in key[:26] else i for i in b]) print(c)
The Secret Message
from Cryptodome.Util.number import getPrime, bytes_to_long
flag = bytes_to_long(b"REDACTED") p = getPrime(512) q = getPrime(512) n = p*q e = 3
from Crypto.Util.number import * import gmpy2 e = c = print(long_to_bytes(gmpy2.iroot(c, e)[0]))
Couple Primes
from Crypto.Util.number import * from sympy import nextprime flag = b'REDACTED' p = getPrime(1024) q = nextprime(p) e = 65537 n = p * q c = pow(bytes_to_long(flag), e, n) print(f"n = {n}") print(f"c = {c}")
n = 20159884168863899177128175715030429666461733285660170664255048579116265087763268748333820860913271674586980839088092697230336179818435879126554509868570255414201418619851045615744211750178240471758695923469393333600480843090831767416937814471973060610730578620506577745372347777922355677932755542699210313287595362584505135967456855068550375989801913361017083952090117041405458626488736811460716474071561590513778196334141517893224697977911862004615690183334216587398645213023148750443295007000911541566340284156527080509545145423451091853688188705902833261507474200445477515893168405730493924172626222872760780966427 c = 18440162368010249375653348677429595229051180035668845001125855048750591059785630865891877031796050869136099359028540172514890273415892550857190509410541828375948243175466417949548148007390803680005616875833010137407850955608659023797782656930905693262770473679394796595557898347900786445803645539553815614140428316398058138450937721961593146082399553119578102712100359284788650328835784603011091312735813903241087475279011862693938914825685547337081335030237385061397899718079346063519325222861490101383929790275635381333028091769118083102339908694751574572782030287570280071809896532329742115422479473386147281509394
pq相近,开平方爆破
from Crypto.Util.number import * import gmpy2 n = c = e = 65537 deffactor(n): a, f = gmpy2.iroot(n, 2) while (True): a += 1 try: b, f = gmpy2.iroot(a*a - n, 2) except: pass if f: return a-b, a+b p = factor(n)[0] q = factor(n)[1] print(p*q == n) d = inverse(e, (p-1)*(q-1)) print(long_to_bytes(pow(c, d, n)))
Efficient RSA
from Cryptodome.Util.number import getPrime, bytes_to_long Flag = bytes_to_long(b"REDACTED") p = getPrime(112) q = getPrime(112) n = p*q e = 65537 ciphertext = pow(Flag, e, n) print([n, e, ciphertext])
from Crypto.Util.number import * import gmpy2 n = 13118792276839518668140934709605545144220967849048660605948916761813 c = 8124539402402728939748410245171419973083725701687225219471449051618 e = 65537 p = 3058290486427196148217508840815579 q = 4289583456856434512648292419762447 d = inverse(e, (p-1)*(q-1)) print(long_to_bytes(pow(c, d, n)))
QR
from Crypto.Util.number import * from random import * flag = b'REDACTED' p = 96517490730367252566551196176049957092195411726055764912412605750547823858339 a = 1337 flag = bin(bytes_to_long(flag))[2:] encrypt = [] for bit in flag: encrypt.append(pow(a, (randint(2, p) * randrange(2, p, 2)) + int(bit), p)) print(encrypt)
from Crypto.Util.number import * c = [] p = 96517490730367252566551196176049957092195411726055764912412605750547823858339 a = 1337 print(GCD(a,p)) flag='' for i in range(len(c)): b=legendre_symbol(c[i],p) if b==1: flag+='0' else: flag+='1' print(long_to_bytes(int(flag,2))) # b'OSCTF{d0_y0U_L0v3_m47H_?_<3}'
a = 'KJOL_T_ZCTS_ZV_CQKLX_NDFKZTUC' b = '' for i inrange(len(a)): if a[i] == '_': b += a[i] else: for j inrange(65, 123): if (j-65+i) % 26 + 65 == ord(a[i]): b += chr(j) break print('OSCTF{'+b+'}')
from Crypto.Util.number import * from openpyxl import load_workbook workbook = load_workbook(filename="output.xlsx") sheet = workbook['Sheet'] row_values = [cell.value for cell in sheet['B']] for i in row_values: print(i, end='') print("\n") flag = 0b010011110101001101000011010101000100011001111011001100010110111001100110001100000101111101100100001100010111001101110000011011000011010001100011001100110110010001111101 print(long_to_bytes(flag))