summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenedict <benedict@0xb8000.de>2016-08-11 18:56:21 +0200
committerBenedict <benedict@0xb8000.de>2017-02-21 13:00:25 +0100
commitb2aa636bfee0c4a7f607eaad06803cd7c42d8214 (patch)
treeb567626a8f22d46044f8b1aaf81d6fdbd7dc57ba /lib
parent62fa141050aa054183fb781fed8e782f99e6072f (diff)
set3, challenge 22 completed
Diffstat (limited to 'lib')
-rw-r--r--lib/lib3.c32
-rw-r--r--lib/lib3.h5
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/lib3.c b/lib/lib3.c
index 43f3ec6..adea72e 100644
--- a/lib/lib3.c
+++ b/lib/lib3.c
@@ -129,3 +129,35 @@ int mt_19937()
return (y & 0xFFFFFFFF);
}
+
+int mt_19937_timestamp_orcale()
+{
+ sleep(random_number_between(40,1000));
+
+ unsigned int seed = time(NULL);
+ printf("timestamp orcale seed: %u\n", seed);
+ mt_19937_seed(seed);
+
+ sleep(random_number_between(40,1000));
+
+ return mt_19937();
+}
+/***
+ * is there a more clever way to do this than brute force?
+ *
+ **/
+void mt_19937_brute_force_timestamp()
+{
+ unsigned int start = time(NULL);
+ int rnd = mt_19937_timestamp_orcale();
+ unsigned int stop = time(NULL);
+ unsigned int i;
+ // try every seed between start and stop
+ for(i=start;start<=stop;i++) {
+ mt_19937_seed(i);
+ if (rnd == mt_19937()) {
+ printf("found seed: %u\n", i);
+ break;
+ }
+ }
+}
diff --git a/lib/lib3.h b/lib/lib3.h
index 8adbbb9..ee11a15 100644
--- a/lib/lib3.h
+++ b/lib/lib3.h
@@ -5,6 +5,8 @@
#include <string.h>
#include <stdlib.h>
#include <openssl/aes.h>
+#include <unistd.h>
+#include <time.h>
#define BLOCKSIZE 16
@@ -29,5 +31,6 @@ int aes_ctr(char *in, int length_in, char *out, char *string_key, char *nonce);
void mt_19937_seed(unsigned int seed);
int mt_19937();
-
+int mt_19937_timestamp_orcale();
+void mt_19937_brute_force_timestamp();
#endif