CTF toolkit: lib (net, crypto_utils), templates per category, scaffold, cheatsheet, ps_and_qs example
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
CRYPTO skeleton — copy & fill. (p4-team style: read source, do the math)
|
||||
|
||||
For RSA challenges, start by importing lib.crypto_utils and try the recipes:
|
||||
recover_n_from_keys, common_modulus_attack, wiener, hastad_broadcast
|
||||
"""
|
||||
import lib.crypto_utils as cu
|
||||
from Crypto.Util.number import long_to_bytes, bytes_to_long, getPrime, inverse
|
||||
|
||||
|
||||
def main():
|
||||
# 1) Read the challenge output / source. Example: RSA with weird params.
|
||||
e = 0x10001
|
||||
# ... load n, c, etc from the provided data ...
|
||||
|
||||
# 2) Try the right recipe. Example (from 'lost_modulus'):
|
||||
# p, q = cu.recover_n_from_keys(e, d, ipmq, iqmp)
|
||||
# n = p * q
|
||||
# m = pow(c, d, n)
|
||||
# print(long_to_bytes(m))
|
||||
|
||||
raise NotImplementedError("fill in the crypto math")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user