SlideShare a Scribd company logo
Subject: How to crack Netrek RSA binary verification system
Date: September 19, 2004
From: J Corrales
-----------------------------------------------------
The RSA Algorithm
Select two primes p and q
Calculate n = p q
Calculate f(n) = (p-1)(q-1)
Select e such that 1 < e < f(n) and gcd(f(n),e) = 1
Calculate d = e^-1 mod f(n)
Public key KU = {e,n}
Private key KR = {d,n}
Example
Select two primes p=7 and q=17
Calculate n = p q = 119
Calculate f(n) = (p-1)(q-1) = 96
Select e such that 1 < e < f(n) and gcd(f(n),e) = 1, e.g., e = 5
Calculate d = e^-1 mod f(n), e.g., d = 77
Public key KU = {e,n} = {5,119}
Private key KR = {d,n} = {77,119}
Cracking RSA
Factor n, which is public, yielding p and q
Calculate f(n) = (p-1)(q-1)
Calculate d = e^-1 mod f(n) (e is public)
Private key KR = {d,n}
Note: you can check your calculation of d because d e = 1 mod f(n)
Cracking RSA (Example)
Factor 119, which is public, yielding 7 and 17
Calculate f(119) = (7-1)(17-1) = 96
Calculate 5^-1 = 77 mod 96
Private key KR = {77,119}
Plaintext M = 19
Ciphertext C = Me mod n = 195 mod 119 = 66
Plaintext M = Cd mod n = 6677 mod 119 = 19
-------------------------------------------
Netrek RSA Specifics:
Go to http://65.193.17.240:3530/ and select a key. Try:
key.brmh2.sun4:ct=BRM-Hadley:cr=hadley@uci.edu:
:cd=September 1994:ar=Sun4 / SunOS 4.1.2:cl=inl,standard2:
:cm=At cad.ics.uci.edu-/pub/netrek:
:gk=636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901:
:pk=0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800:
Convert gk and pk to integers. Note gk and pk are little endian, so
they must be reversed and converted. I used java:
//be2i.java : converts gk and pk to plain integers
//
import java.math.BigInteger;
public class be2i {
static BigInteger GLOBAL_KEY = new
BigInteger(swapEndian("636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901"),
16);
static BigInteger PUBLIC_KEY = new
BigInteger(swapEndian("0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800"),
16);
static String swapEndian(String s)
{
char c[] = s.toCharArray();
StringBuffer buffer = new StringBuffer(c.length);
for(int i = c.length; (i -= 2) >= 0;)
{
buffer.append(c[i]);
buffer.append(c[i + 1]);
}
return buffer.toString();
}
public static void main(String args[]) {
System.out.println(GLOBAL_KEY.toString(10));
System.out.println(PUBLIC_KEY.toString(10));
}
}
E:be2i>javac -d . be2i.java
E:be2i>java be2i
892321428802586219001502719778378451271677716961403333724586529659410803299
326802201186638185587649392739171025726846542356328056267675213531974007821
Note:
gk=892321428802586219001502719778378451271677716961403333724586529659410803299
pk=326802201186638185587649392739171025726846542356328056267675213531974007821
Factor gk. Download PARI/GP http://pari.math.u-bordeaux.fr/ Install
it, then run it:
Reading GPRC: /cygdrive/c/Program Files/PARI/.gprc ...Done.
GP/PARI CALCULATOR Version 2.2.8 (development CHANGES-1.887)
i686 running cygwin (ix86 kernel) 32-bit version
compiled: Jan 13 2004, gcc-3.3.1 (cygming special)
(readline v4.3 enabled, extended help available)
Copyright (C) 2003 The PARI Group
PARI/GP is free software, covered by the GNU General Public License,
and
comes WITHOUT ANY WARRANTY WHATSOEVER.
Type ? for help, q to quit.
Type ?12 for how to get moral (and possibly technical) support.
realprecision = 28 significant digits
seriesprecision = 16 significant terms
format = g0.28
parisize = 4000000, primelimit = 500000
(19:29) gp > factorint(892321428802586219001502719778378451271677716961403333724586529659410803299)
*** Warning: MPQS: the factorization of this number will take
several hours.
%1 =
[6158427920916659824908651606478252183 1]
[144894352951973396937037531927458847253 1]
(21:29) gp >
Calculate d = e^-1 mod f(n) (e is public)
Download res-rsa-2.9.2
ftp://ftp.netrek.org/pub/netrek/rsa/res-rsa-2.9.2.tar.gz
Modify mkkey.c as follows:
/* mpz_set_ui(x, 0); */
/* mpz_set_ui(y, 0); */
/* mpz_set_ui(global, 0); */
mpz_set_str(x,"6158427920916659824908651606478252183", 0);
mpz_set_str(y, "144894352951973396937037531927458847253", 0);
mpz_set_str
(global, "892321428802586219001502719778378451271677716961403333724586529659410803299",
0);
mpz_set_str
(private, "326802201186638185587649392739171025726846542356328056267675213531974007821",
0);
/* mpz_set_ui(public, 0); */
mpz_set_ui(public, 0);
mpz_set_ui(xyminus1, 0);
/* here we find x and y, two large primes */
rand_raw(temp, HALF);
temp[0] |= 1; /* force odd */
/* raw_to_num(x, temp); */
while (!is_prime(x))
mpz_add(x, x, two);
check_positive(x);
assert(is_prime(x));
rand_raw(temp, HALF);
temp[0] |= 1; /* force odd */
/* raw_to_num(y, temp); */
while (!is_prime(y))
mpz_add(y, y, two);
check_positive(y);
assert(is_prime(y));
/* the private key is a large prime (it should be the larger than
* x & y) */
rand_raw(temp, HALF + 1);
temp[0] |= 1; /* force odd */
//raw_to_num(private, temp);
// while (!is_prime(private))
// mpz_add(private, private, two);
check_positive(private);
//assert(is_prime(private));
Note rest of mkkeys.c is unchanged.
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ diff mkkey.c mkkey-mine.c
1103,1106c1119,1129
< mpz_set_ui(x, 0);
< mpz_set_ui(y, 0);
< mpz_set_ui(global, 0);
< mpz_set_ui(private, 0);
---
> /* mpz_set_ui(x, 0); */
> /* mpz_set_ui(y, 0); */
> /* mpz_set_ui(global, 0); */
>
> mpz_set_str(x,"6158427920916659824908651606478252183", 0);
> mpz_set_str(y, "144894352951973396937037531927458847253", 0);
> mpz_set_str
> (global, "892321428802586219001502719778378451271677716961403333724586529659410803299", 0);
> mpz_set_str
> (private, "326802201186638185587649392739171025726846542356328056267675213531974007821", 0);
> /* mpz_set_ui(public, 0); */
1114c1137
< raw_to_num(x, temp);
---
> /* raw_to_num(x, temp); */
1124c1147
< raw_to_num(y, temp);
---
> /* raw_to_num(y, temp); */
1137c1160
< raw_to_num(private, temp);
---
> //raw_to_num(private, temp);
1139,1140c1162,1163
< while (!is_prime(private))
< mpz_add(private, private, two);
---
> // while (!is_prime(private))
> // mpz_add(private, private, two);
1143c1166
< assert(is_prime(private));
---
> //assert(is_prime(private));
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ make
gcc -O2 -c mkkey.c
gcc -O2 -o mkkey mkkey.o -lgmp
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ ./mkkey foo foo foo foo
foo
mkkey version [RES-RSA 2.9.2: Mar. 13, 2000][GMP]
Source basename: "rsa_box"
Number of shells: 3
Number of steps between swaps: 2
Number of files: 5
Ratio of computation in files to main file: 0.8
Making new key, hold on....
Testing key .................................................. key
seems OK
Writing...
240 bits left, 5 files left, 37 bits in rsa_box_0.c
202 bits left, 4 files left, 7 bits in main file
194 bits left, 4 files left, 42 bits in rsa_box_1.c
151 bits left, 3 files left, 11 bits in main file
139 bits left, 3 files left, 29 bits in rsa_box_2.c
109 bits left, 2 files left, 10 bits in main file
98 bits left, 2 files left, 32 bits in rsa_box_3.c
65 bits left, 1 files left, 13 bits in main file
51 bits left, 1 files left, 39 bits in rsa_box_4.c
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ cat foo.secret
foo:ct=foo:cr=foo:
:cd=September 2004:ar=foo:
:cm=foo:
:gk=636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901:
:pk=057505d6c5b0b5ccd0f7819a7670da469e000000000000000000000000000000:
:sk=0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800:
Note pk and sk are reversed. Edit foo.secret to correct the order to:
foo:ct=foo:cr=foo:
:cd=September 2004:ar=foo:
:cm=foo:
:gk=636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901:
:pk=0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800:
:sk=057505d6c5b0b5ccd0f7819a7670da469e000000000000000000000000000000:
Rerun mkkey with the edited secret key file:
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ ./mkkey -k foo.secret
mkkey version [RES-RSA 2.9.2: Mar. 13, 2000][GMP]
Source basename: "rsa_box"
Number of shells: 3
Number of steps between swaps: 2
Number of files: 5
Ratio of computation in files to main file: 0.8
Reading key from keycap file "foo.secret"...
Testing key .................................................. key
seems OK
Writing...
128 bits left, 5 files left, 19 bits in rsa_box_0.c
108 bits left, 4 files left, 6 bits in main file
101 bits left, 4 files left, 20 bits in rsa_box_1.c
80 bits left, 3 files left, 5 bits in main file
74 bits left, 3 files left, 15 bits in rsa_box_2.c
58 bits left, 2 files left, 6 bits in main file
51 bits left, 2 files left, 21 bits in rsa_box_3.c
29 bits left, 1 files left, 5 bits in main file
23 bits left, 1 files left, 14 bits in rsa_box_4.c
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ ls -aFl rsa_box_?.c
-rw-r--r-- 1 bd bd 3856 Sep 19 20:02 rsa_box_0.c
-rw-r--r-- 1 bd bd 4093 Sep 19 20:02 rsa_box_1.c
-rw-r--r-- 1 bd bd 3222 Sep 19 20:02 rsa_box_2.c
-rw-r--r-- 1 bd bd 4368 Sep 19 20:02 rsa_box_3.c
-rw-r--r-- 1 bd bd 3130 Sep 19 20:02 rsa_box_4.c
cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$
Copy rsa_box_?.c files into your own custom client source directory,
compile, and login to any public netrek server, including INL server
of your choice.

More Related Content

What's hot

Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловАсинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Yandex
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory Management
Alan Uthoff
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their Applications
Alex Pruden
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
alexgolec
 
Data structure programs in c++
Data structure programs in c++Data structure programs in c++
Data structure programs in c++mmirfan
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
Chih-Hsuan Kuo
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt III
Ajit Nayak
 
Dun ddd
Dun dddDun ddd
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Codemotion
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
Ajit Nayak
 
Tracing and awk in ns2
Tracing and awk in ns2Tracing and awk in ns2
Tracing and awk in ns2
Pradeep Kumar TS
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
Ajit Nayak
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
Chih-Hsuan Kuo
 
Gilat_ch05.pdf
Gilat_ch05.pdfGilat_ch05.pdf
Gilat_ch05.pdf
ArhamQadeer
 
Kubernetes Tutorial
Kubernetes TutorialKubernetes Tutorial
Kubernetes Tutorial
Ci Jie Li
 
EKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningEKON22 Introduction to Machinelearning
EKON22 Introduction to Machinelearning
Max Kleiner
 
AST: threats and opportunities
AST: threats and opportunitiesAST: threats and opportunities
AST: threats and opportunities
Alexander Lifanov
 
Explain this!
Explain this!Explain this!
Explain this!
Fabio Telles Rodriguez
 
Scoped dynamic rewrite rules
Scoped dynamic rewrite rulesScoped dynamic rewrite rules
Scoped dynamic rewrite rules
Eelco Visser
 

What's hot (20)

Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловАсинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory Management
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their Applications
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
 
Data structure programs in c++
Data structure programs in c++Data structure programs in c++
Data structure programs in c++
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt III
 
Dun ddd
Dun dddDun ddd
Dun ddd
 
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
Tracing and awk in ns2
Tracing and awk in ns2Tracing and awk in ns2
Tracing and awk in ns2
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
 
Gilat_ch05.pdf
Gilat_ch05.pdfGilat_ch05.pdf
Gilat_ch05.pdf
 
Kubernetes Tutorial
Kubernetes TutorialKubernetes Tutorial
Kubernetes Tutorial
 
EKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningEKON22 Introduction to Machinelearning
EKON22 Introduction to Machinelearning
 
AST: threats and opportunities
AST: threats and opportunitiesAST: threats and opportunities
AST: threats and opportunities
 
Explain this!
Explain this!Explain this!
Explain this!
 
Scoped dynamic rewrite rules
Scoped dynamic rewrite rulesScoped dynamic rewrite rules
Scoped dynamic rewrite rules
 

Viewers also liked

دانش فنی پایه
دانش فنی پایه دانش فنی پایه
دانش فنی پایه
elham jahanpoor
 
Introduction to science and technology
Introduction to science and technologyIntroduction to science and technology
Introduction to science and technology
Izzah Aqilah
 
инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...
инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...
инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...
pelka123
 
Successful business while adhering to the norms
Successful business while adhering to the normsSuccessful business while adhering to the norms
Successful business while adhering to the norms
Syed Hamza Nadeem
 
первые годы правления александра I (для фпо мгу)
первые годы правления александра I (для фпо мгу)первые годы правления александра I (для фпо мгу)
первые годы правления александра I (для фпо мгу)
pelka123
 
International history 1945 1990
International history 1945 1990International history 1945 1990
International history 1945 1990
tahere qurani
 
Web 2.0
Web 2.0Web 2.0
Vaught m week 14_storyboard
Vaught m week 14_storyboardVaught m week 14_storyboard
Vaught m week 14_storyboard
TTT Help
 
первые годы правления Александра фпо
первые годы правления Александра фпопервые годы правления Александра фпо
первые годы правления Александра фпо
pelka123
 

Viewers also liked (10)

دانش فنی پایه
دانش فنی پایه دانش فنی پایه
دانش فنی پایه
 
Muhammad Zahir Aslam CV-2.docttt
Muhammad Zahir Aslam CV-2.doctttMuhammad Zahir Aslam CV-2.docttt
Muhammad Zahir Aslam CV-2.docttt
 
Introduction to science and technology
Introduction to science and technologyIntroduction to science and technology
Introduction to science and technology
 
инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...
инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...
инф порядок оформ ления европро токола дисцип лина страховое дело информитиза...
 
Successful business while adhering to the norms
Successful business while adhering to the normsSuccessful business while adhering to the norms
Successful business while adhering to the norms
 
первые годы правления александра I (для фпо мгу)
первые годы правления александра I (для фпо мгу)первые годы правления александра I (для фпо мгу)
первые годы правления александра I (для фпо мгу)
 
International history 1945 1990
International history 1945 1990International history 1945 1990
International history 1945 1990
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Vaught m week 14_storyboard
Vaught m week 14_storyboardVaught m week 14_storyboard
Vaught m week 14_storyboard
 
первые годы правления Александра фпо
первые годы правления Александра фпопервые годы правления Александра фпо
первые годы правления Александра фпо
 

Similar to How To Crack RSA Netrek Binary Verification System

HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docxHW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
wellesleyterresa
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
Samsung Open Source Group
 
LLVM Backend の紹介
LLVM Backend の紹介LLVM Backend の紹介
LLVM Backend の紹介
Akira Maruoka
 
2.1 ### uVision Project, (C) Keil Software .docx
2.1   ### uVision Project, (C) Keil Software    .docx2.1   ### uVision Project, (C) Keil Software    .docx
2.1 ### uVision Project, (C) Keil Software .docx
tarifarmarie
 
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
Maho Nakata
 
Tracing Parallel Execution (UKOUG 2006)
Tracing Parallel Execution (UKOUG 2006)Tracing Parallel Execution (UKOUG 2006)
Tracing Parallel Execution (UKOUG 2006)
Doug Burns
 
GCC
GCCGCC
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
FreddyGuzman19
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
David de Boer
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
Engine Yard
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
Emanuel Calvo
 
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
corehard_by
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
Aman Gupta
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
Dharmalingam Ganesan
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPMiller Lee
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
Jarek Ratajski
 

Similar to How To Crack RSA Netrek Binary Verification System (20)

HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docxHW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
LLVM Backend の紹介
LLVM Backend の紹介LLVM Backend の紹介
LLVM Backend の紹介
 
2.1 ### uVision Project, (C) Keil Software .docx
2.1   ### uVision Project, (C) Keil Software    .docx2.1   ### uVision Project, (C) Keil Software    .docx
2.1 ### uVision Project, (C) Keil Software .docx
 
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
 
Tracing Parallel Execution (UKOUG 2006)
Tracing Parallel Execution (UKOUG 2006)Tracing Parallel Execution (UKOUG 2006)
Tracing Parallel Execution (UKOUG 2006)
 
GCC
GCCGCC
GCC
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Vcs16
Vcs16Vcs16
Vcs16
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
Real to protected_mode
Real to protected_modeReal to protected_mode
Real to protected_mode
 
Stop Monkeys Fall
Stop Monkeys FallStop Monkeys Fall
Stop Monkeys Fall
 

How To Crack RSA Netrek Binary Verification System

  • 1. Subject: How to crack Netrek RSA binary verification system Date: September 19, 2004 From: J Corrales ----------------------------------------------------- The RSA Algorithm Select two primes p and q Calculate n = p q Calculate f(n) = (p-1)(q-1) Select e such that 1 < e < f(n) and gcd(f(n),e) = 1 Calculate d = e^-1 mod f(n) Public key KU = {e,n} Private key KR = {d,n} Example Select two primes p=7 and q=17 Calculate n = p q = 119 Calculate f(n) = (p-1)(q-1) = 96 Select e such that 1 < e < f(n) and gcd(f(n),e) = 1, e.g., e = 5 Calculate d = e^-1 mod f(n), e.g., d = 77 Public key KU = {e,n} = {5,119} Private key KR = {d,n} = {77,119} Cracking RSA Factor n, which is public, yielding p and q Calculate f(n) = (p-1)(q-1) Calculate d = e^-1 mod f(n) (e is public) Private key KR = {d,n} Note: you can check your calculation of d because d e = 1 mod f(n) Cracking RSA (Example) Factor 119, which is public, yielding 7 and 17 Calculate f(119) = (7-1)(17-1) = 96 Calculate 5^-1 = 77 mod 96 Private key KR = {77,119} Plaintext M = 19 Ciphertext C = Me mod n = 195 mod 119 = 66 Plaintext M = Cd mod n = 6677 mod 119 = 19 ------------------------------------------- Netrek RSA Specifics: Go to http://65.193.17.240:3530/ and select a key. Try: key.brmh2.sun4:ct=BRM-Hadley:cr=hadley@uci.edu: :cd=September 1994:ar=Sun4 / SunOS 4.1.2:cl=inl,standard2: :cm=At cad.ics.uci.edu-/pub/netrek: :gk=636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901: :pk=0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800: Convert gk and pk to integers. Note gk and pk are little endian, so they must be reversed and converted. I used java: //be2i.java : converts gk and pk to plain integers // import java.math.BigInteger; public class be2i { static BigInteger GLOBAL_KEY = new BigInteger(swapEndian("636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901"), 16); static BigInteger PUBLIC_KEY = new BigInteger(swapEndian("0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800"), 16); static String swapEndian(String s) { char c[] = s.toCharArray(); StringBuffer buffer = new StringBuffer(c.length); for(int i = c.length; (i -= 2) >= 0;) { buffer.append(c[i]); buffer.append(c[i + 1]); } return buffer.toString(); } public static void main(String args[]) { System.out.println(GLOBAL_KEY.toString(10)); System.out.println(PUBLIC_KEY.toString(10)); } } E:be2i>javac -d . be2i.java E:be2i>java be2i 892321428802586219001502719778378451271677716961403333724586529659410803299 326802201186638185587649392739171025726846542356328056267675213531974007821 Note: gk=892321428802586219001502719778378451271677716961403333724586529659410803299 pk=326802201186638185587649392739171025726846542356328056267675213531974007821 Factor gk. Download PARI/GP http://pari.math.u-bordeaux.fr/ Install it, then run it: Reading GPRC: /cygdrive/c/Program Files/PARI/.gprc ...Done. GP/PARI CALCULATOR Version 2.2.8 (development CHANGES-1.887) i686 running cygwin (ix86 kernel) 32-bit version compiled: Jan 13 2004, gcc-3.3.1 (cygming special) (readline v4.3 enabled, extended help available) Copyright (C) 2003 The PARI Group PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER.
  • 2. Type ? for help, q to quit. Type ?12 for how to get moral (and possibly technical) support. realprecision = 28 significant digits seriesprecision = 16 significant terms format = g0.28 parisize = 4000000, primelimit = 500000 (19:29) gp > factorint(892321428802586219001502719778378451271677716961403333724586529659410803299) *** Warning: MPQS: the factorization of this number will take several hours. %1 = [6158427920916659824908651606478252183 1] [144894352951973396937037531927458847253 1] (21:29) gp > Calculate d = e^-1 mod f(n) (e is public) Download res-rsa-2.9.2 ftp://ftp.netrek.org/pub/netrek/rsa/res-rsa-2.9.2.tar.gz Modify mkkey.c as follows: /* mpz_set_ui(x, 0); */ /* mpz_set_ui(y, 0); */ /* mpz_set_ui(global, 0); */ mpz_set_str(x,"6158427920916659824908651606478252183", 0); mpz_set_str(y, "144894352951973396937037531927458847253", 0); mpz_set_str (global, "892321428802586219001502719778378451271677716961403333724586529659410803299", 0); mpz_set_str (private, "326802201186638185587649392739171025726846542356328056267675213531974007821", 0); /* mpz_set_ui(public, 0); */ mpz_set_ui(public, 0); mpz_set_ui(xyminus1, 0); /* here we find x and y, two large primes */ rand_raw(temp, HALF); temp[0] |= 1; /* force odd */ /* raw_to_num(x, temp); */ while (!is_prime(x)) mpz_add(x, x, two); check_positive(x); assert(is_prime(x)); rand_raw(temp, HALF); temp[0] |= 1; /* force odd */ /* raw_to_num(y, temp); */ while (!is_prime(y)) mpz_add(y, y, two); check_positive(y); assert(is_prime(y)); /* the private key is a large prime (it should be the larger than * x & y) */ rand_raw(temp, HALF + 1); temp[0] |= 1; /* force odd */ //raw_to_num(private, temp); // while (!is_prime(private)) // mpz_add(private, private, two); check_positive(private); //assert(is_prime(private)); Note rest of mkkeys.c is unchanged. cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ diff mkkey.c mkkey-mine.c 1103,1106c1119,1129 < mpz_set_ui(x, 0); < mpz_set_ui(y, 0); < mpz_set_ui(global, 0); < mpz_set_ui(private, 0); --- > /* mpz_set_ui(x, 0); */ > /* mpz_set_ui(y, 0); */ > /* mpz_set_ui(global, 0); */ > > mpz_set_str(x,"6158427920916659824908651606478252183", 0); > mpz_set_str(y, "144894352951973396937037531927458847253", 0); > mpz_set_str > (global, "892321428802586219001502719778378451271677716961403333724586529659410803299", 0); > mpz_set_str > (private, "326802201186638185587649392739171025726846542356328056267675213531974007821", 0); > /* mpz_set_ui(public, 0); */ 1114c1137 < raw_to_num(x, temp); --- > /* raw_to_num(x, temp); */ 1124c1147 < raw_to_num(y, temp); --- > /* raw_to_num(y, temp); */ 1137c1160 < raw_to_num(private, temp); --- > //raw_to_num(private, temp); 1139,1140c1162,1163 < while (!is_prime(private)) < mpz_add(private, private, two); --- > // while (!is_prime(private)) > // mpz_add(private, private, two);
  • 3. 1143c1166 < assert(is_prime(private)); --- > //assert(is_prime(private)); cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ make gcc -O2 -c mkkey.c gcc -O2 -o mkkey mkkey.o -lgmp cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ ./mkkey foo foo foo foo foo mkkey version [RES-RSA 2.9.2: Mar. 13, 2000][GMP] Source basename: "rsa_box" Number of shells: 3 Number of steps between swaps: 2 Number of files: 5 Ratio of computation in files to main file: 0.8 Making new key, hold on.... Testing key .................................................. key seems OK Writing... 240 bits left, 5 files left, 37 bits in rsa_box_0.c 202 bits left, 4 files left, 7 bits in main file 194 bits left, 4 files left, 42 bits in rsa_box_1.c 151 bits left, 3 files left, 11 bits in main file 139 bits left, 3 files left, 29 bits in rsa_box_2.c 109 bits left, 2 files left, 10 bits in main file 98 bits left, 2 files left, 32 bits in rsa_box_3.c 65 bits left, 1 files left, 13 bits in main file 51 bits left, 1 files left, 39 bits in rsa_box_4.c cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ cat foo.secret foo:ct=foo:cr=foo: :cd=September 2004:ar=foo: :cm=foo: :gk=636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901: :pk=057505d6c5b0b5ccd0f7819a7670da469e000000000000000000000000000000: :sk=0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800: Note pk and sk are reversed. Edit foo.secret to correct the order to: foo:ct=foo:cr=foo: :cd=September 2004:ar=foo: :cm=foo: :gk=636a5977da5ce59948885d1003e983deabf405ed0cb952a5b42930523909f901: :pk=0dfc24f1d19398586dafa37e985163290eb01f139c03f90affc5d458a7f6b800: :sk=057505d6c5b0b5ccd0f7819a7670da469e000000000000000000000000000000: Rerun mkkey with the edited secret key file: cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ ./mkkey -k foo.secret mkkey version [RES-RSA 2.9.2: Mar. 13, 2000][GMP] Source basename: "rsa_box" Number of shells: 3 Number of steps between swaps: 2 Number of files: 5 Ratio of computation in files to main file: 0.8 Reading key from keycap file "foo.secret"... Testing key .................................................. key seems OK Writing... 128 bits left, 5 files left, 19 bits in rsa_box_0.c 108 bits left, 4 files left, 6 bits in main file 101 bits left, 4 files left, 20 bits in rsa_box_1.c 80 bits left, 3 files left, 5 bits in main file 74 bits left, 3 files left, 15 bits in rsa_box_2.c 58 bits left, 2 files left, 6 bits in main file 51 bits left, 2 files left, 21 bits in rsa_box_3.c 29 bits left, 1 files left, 5 bits in main file 23 bits left, 1 files left, 14 bits in rsa_box_4.c cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ ls -aFl rsa_box_?.c -rw-r--r-- 1 bd bd 3856 Sep 19 20:02 rsa_box_0.c -rw-r--r-- 1 bd bd 4093 Sep 19 20:02 rsa_box_1.c -rw-r--r-- 1 bd bd 3222 Sep 19 20:02 rsa_box_2.c -rw-r--r-- 1 bd bd 4368 Sep 19 20:02 rsa_box_3.c -rw-r--r-- 1 bd bd 3130 Sep 19 20:02 rsa_box_4.c cherry:/home/bd/netrek/mkkey/res-rsa-2.9.2$ Copy rsa_box_?.c files into your own custom client source directory, compile, and login to any public netrek server, including INL server of your choice.