summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/lib3.c32
-rw-r--r--lib/lib3.h5
-rw-r--r--set3/task22.c9
3 files changed, 45 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
diff --git a/set3/task22.c b/set3/task22.c
new file mode 100644
index 0000000..4daaf0f
--- /dev/null
+++ b/set3/task22.c
@@ -0,0 +1,9 @@
+#include "../lib/lib.h"
+#include "../lib/lib2.h"
+#include "../lib/lib3.h"
+#include <time.h>
+
+int main()
+{
+ mt_19937_brute_force_timestamp();
+}