Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <openssl/md5.h>
- // compile: gcc -o subhash subhash.c -lcrypto -O2 -Wall
- // by atom
- int main(int argc, char *argv[])
- {
- if (argc != 2)
- {
- fprintf (stderr, "Usage: %s hash\n", argv[0]);
- return -1;
- }
- uint32_t target;
- if (sscanf (argv[1], "%08x", &target) != 1)
- {
- fprintf (stderr, "Something is wrong with your hash: %s", argv[1]);
- return -1;
- }
- target = __builtin_bswap32 (target);
- char buf[BUFSIZ];
- while (fgets (buf, BUFSIZ, stdin))
- {
- uint32_t digest[4];
- MD5_CTX c;
- MD5_Init (&c);
- MD5_Update (&c, buf, strlen (buf) - 1);
- MD5_Final ((unsigned char *) digest, &c);
- if (target != digest[0]) continue;
- printf ("Password matches: %s", buf);
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement