|
|
@ -1,10 +1,12 @@ |
|
|
|
#!/usr/bin/ruby |
|
|
|
#!/usr/bin/ruby |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require_relative "rsa.rb" |
|
|
|
|
|
|
|
|
|
|
|
Primes = File.read("primes.txt").split(",") |
|
|
|
Primes = File.read("primes.txt").split(",") |
|
|
|
# BigPrimes = File.readlines("bigprimes.txt") |
|
|
|
# BigPrimes = File.readlines("bigprimes.txt") |
|
|
|
|
|
|
|
|
|
|
|
print "Modbase target: " |
|
|
|
#print "Modbase target: " |
|
|
|
target = gets.chomp.to_i |
|
|
|
#target = gets.chomp.to_i |
|
|
|
|
|
|
|
|
|
|
|
def bruteforce(target) |
|
|
|
def bruteforce(target) |
|
|
|
Primes.each do |p| |
|
|
|
Primes.each do |p| |
|
|
@ -19,6 +21,14 @@ def bruteforce(target) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
p1, p2 = bruteforce(target) |
|
|
|
def gen_key(p1, p2, e) |
|
|
|
puts "Found primes:" |
|
|
|
puts "Generating key pair..." |
|
|
|
puts p1, p2 |
|
|
|
n = p1 * p2 |
|
|
|
|
|
|
|
phi = (p1-1)*(p2-1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d = RSA.modinv(e, phi) |
|
|
|
|
|
|
|
return e, n, d |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
#p1, p2 = bruteforce(target) |
|
|
|
|
|
|
|
#puts "Found primes:" |
|
|
|
|
|
|
|
#puts p1, p2 |
|
|
|