Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #16  
Old 06-05-2016, 18:43
mr.exodia mr.exodia is offline
Retired Moderator
 
Join Date: Nov 2011
Posts: 784
Rept. Given: 492
Rept. Rcvd 1,122 Times in 305 Posts
Thanks Given: 90
Thanks Rcvd at 711 Times in 333 Posts
mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299 mr.exodia Reputation: 1100-1299
My code for solving (see here on how to install z3py):

Code:
from z3 import *

key = BitVec('key', 64)
solve((key * key * key * key * key * key * key) == 0x90de757572b51cd3)
Output:
Code:
[key = 16721472531635646971]
0xE80E9AAC619831FB
Reply With Quote
The Following User Gave Reputation+1 to mr.exodia For This Useful Post:
niculaita (06-05-2016)
The Following 3 Users Say Thank You to mr.exodia For This Useful Post:
dila (06-05-2016), Git (06-05-2016), niculaita (06-05-2016)
  #17  
Old 06-05-2016, 20:59
dila dila is offline
Friend
 
Join Date: Jan 2010
Posts: 60
Rept. Given: 12
Rept. Rcvd 32 Times in 14 Posts
Thanks Given: 35
Thanks Rcvd at 74 Times in 20 Posts
dila Reputation: 32
Here is my solution based on solving it as an RSA problem:
  • key^7 = x (mod 2^64)
  • x^d = key (mod 2^64)

Where d is the private exponent, calculated by finding the multiplicative inverse of 7 modulo phi(2^64) = 2^63, which turns out to be 0x6db6db6db6db6db7.

Raising the magic constant to this private exponent, and taking modulo 2^64, produces the seret key 0xe80e9aac619831fb, as found by Kerlingen, UniSoft, and mr.exodia.

Code:
#include <iostream>
#include <stdint.h>
 
uint64_t modexp(uint64_t a, uint64_t b) {
  uint64_t y = 1;
  uint64_t tmp = a;
  for (int i = 0; i < 64; ++i) {
    uint64_t mask = uint64_t(1) << i;
    if (b & mask) {
      y *= tmp;
    }
    tmp *= tmp;
  }
  return y;
}
 
int main() {
  uint64_t in = 0x90de757572b51cd3;
  uint64_t tmp = modexp(in, 0x6db6db6db6db6db7);
  uint64_t out = modexp(tmp, 7);
  if (in == out) {
    std::cout << "Success: " << std::hex << tmp << std::endl;
  } else {
    std::cout << "Error" << std::endl;
  }
  return 0;
}
Reply With Quote
  #18  
Old 06-07-2016, 06:03
aliali aliali is offline
Friend
 
Join Date: Jan 2002
Posts: 59
Rept. Given: 4
Rept. Rcvd 8 Times in 4 Posts
Thanks Given: 1
Thanks Rcvd at 13 Times in 8 Posts
aliali Reputation: 8
Quote:
Originally Posted by dila View Post
Here is my solution based on solving it as an RSA problem:
  • key^7 = x (mod 2^64)
  • x^d = key (mod 2^64)

Where d is the private exponent, calculated by finding the multiplicative inverse of 7 modulo phi(2^64) = 2^63, which turns out to be 0x6db6db6db6db6db7.

Raising the magic constant to this private exponent, and taking modulo 2^64, produces the seret key 0xe80e9aac619831fb, as found by Kerlingen, UniSoft, and mr.exodia.

Code:
#include <iostream>
#include <stdint.h>
 
uint64_t modexp(uint64_t a, uint64_t b) {
  uint64_t y = 1;
  uint64_t tmp = a;
  for (int i = 0; i < 64; ++i) {
    uint64_t mask = uint64_t(1) << i;
    if (b & mask) {
      y *= tmp;
    }
    tmp *= tmp;
  }
  return y;
}
 
int main() {
  uint64_t in = 0x90de757572b51cd3;
  uint64_t tmp = modexp(in, 0x6db6db6db6db6db7);
  uint64_t out = modexp(tmp, 7);
  if (in == out) {
    std::cout << "Success: " << std::hex << tmp << std::endl;
  } else {
    std::cout << "Error" << std::endl;
  }
  return 0;
}
An enhanced version of modexp function

Code:
uint64_t modexp(uint64_t a, uint64_t b)
{
	uint64_t y = 1;
	uint64_t tmp = a;
	while( b )
	{
		if( b & 1 )
			y *= tmp;
		tmp *= tmp;
		b >>= 1;
	}
	return y;
}
Reply With Quote
The Following User Says Thank You to aliali For This Useful Post:
dila (06-14-2016)
  #19  
Old 06-21-2016, 21:28
Seth333
 
Posts: n/a
Quote:
Originally Posted by mr.exodia View Post
My code for solving (see here on how to install z3py):

Code:
from z3 import *

key = BitVec('key', 64)
solve((key * key * key * key * key * key * key) == 0x90de757572b51cd3)
Output:
Code:
[key = 16721472531635646971]
0xE80E9AAC619831FB
I still don't get it

Can anyone explain me the mathematical way to calculate this ?

I always come up to a different result.

Like:

0xE80E9AAC619831FB ^7 = 0x80BE33B7E7E4CB02B42B9C6FDF0D774CC0645D8992D29738EC470B848F80CFA482BA62D01E70C65E397E7EFE6F190D1990DE757572B51CD3

or something like that

Where is my "think failure" ?

- Seth
Reply With Quote
  #20  
Old 06-21-2016, 23:47
chessgod101's Avatar
chessgod101 chessgod101 is offline
Co-Administrator
 
Join Date: Jan 2011
Location: United States
Posts: 535
Rept. Given: 2,218
Rept. Rcvd 691 Times in 219 Posts
Thanks Given: 700
Thanks Rcvd at 939 Times in 186 Posts
chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699
We are calculating this with a 64 bit precision constraint. Since you overload the numerical capacity of 64 bits, the rest of the information is lost as a result. Since you are calculating this with full precision, you need to and your result by 0xFFFFFFFFFFFFFFFF.
0x80BE33B7E7E4CB02B42B9C6FDF0D774CC0645D8992D29738EC470B848F80CFA482BA62D01E70C65E397E7EFE6F190D1990DE757572B51CD3 <- 64 bit value
__________________
"As the island of our knowledge grows, so does the shore of our ignorance." John Wheeler
Reply With Quote
The Following 3 Users Say Thank You to chessgod101 For This Useful Post:
dila (07-01-2016), mr.exodia (06-24-2016), niculaita (06-22-2016)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GMP function Git General Discussion 4 06-16-2011 21:33
FUNCTION CHUNKs Git General Discussion 4 09-07-2005 19:35
C++ Help (Hooking a function) Peter[Pan] General Discussion 8 08-31-2004 20:37


All times are GMT +8. The time now is 16:51.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2024 )