Skip to content

Commit

Permalink
Merge pull request #479 from mechtifs/master
Browse files Browse the repository at this point in the history
Fix some issues when longs are provided
  • Loading branch information
daedalus committed May 5, 2024
2 parents b23fc01 + 2dedcc5 commit 05b0a73
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions RsaCtfTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ def decrypt_file(args, logger):
if args.publickey:
return True

# Check if n and e are provided
if args.n and args.e:
return True

# No private key or public key provided
logger.error("Private key or public key and decrypted data are required.")
return False
Expand Down Expand Up @@ -441,6 +445,9 @@ def main():
if args.d is not None:
args.d = get_numeric_value(args.d)

if args.n is not None:
args.n = get_numeric_value(args.n)

if args.e is not None:
e_array = []
for e in args.e.split(","):
Expand All @@ -450,17 +457,15 @@ def main():
elif args.n is not None:
args.e = 65537

# get n if we can
if args.n is not None:
args.n = get_numeric_value(args.n)
elif args.p is not None and args.q is not None:
args.n = args.p * args.q

if args.n is not None and (args.p is not None or args.q is not None):
logger.warning(
"[!] It seems you already provided one of the prime factors, nothing to do here..."
)

# get n from p and q
if args.n is None and args.p is not None and args.q is not None:
args.n = args.p * args.q

# get p and q from n, e and d
if args.n is not None and args.e is not None and args.d is not None and args.p is None and args.q is None:
pq = factor_ned(args.n, args.e, args.d)
Expand Down

0 comments on commit 05b0a73

Please sign in to comment.