Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <openssl/sha.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- void calc_sha256(char *src,char *buffer) {
- SHA256_CTX c;
- SHA256_Init(&c);
- SHA256_Update(&c,src,11);
- SHA256_Final(buffer,&c);
- }
- int cmp(char *a,char *b);
- int main(void) {
- unsigned char phone_num[11];
- int top,bottom,i,j,tmp_bottom;
- unsigned char ***phone_sha;
- unsigned char input[70],input_hex[32];
- unsigned char tmp_sha;
- phone_sha = (unsigned char ***)malloc(3 * sizeof(unsigned char**));
- for(i = 0;i < 3;i++) {
- phone_sha[i] = (unsigned char **)malloc(100000000 * sizeof(unsigned char *));
- for(j = 0;j < 100000000;j++) {
- phone_sha[i][j] = (unsigned char *)malloc(32 * sizeof(unsigned char));
- }
- }
- puts("memory allocate done.");
- phone_num[0] = '0';
- phone_num[2] = '0';
- for(top = 7;top <= 9;top++) {
- phone_num[1] = '0' + top;
- for(bottom = 0; bottom < 100000000; bottom++) {
- tmp_bottom = bottom;
- for(i = 10;i >= 3;i--) {
- phone_num[i] = tmp_bottom % 10 + '0';
- tmp_bottom /= 10;
- }
- calc_sha256(phone_num,phone_sha[top - 7][bottom]);
- }
- }
- puts("hash calculate done.");
- while(1) {
- scanf("%s",input);
- for(i = 0;i < 32;i++) {
- input_hex[i] = (input[i * 2] < 'A' ? input[i * 2] - '0' : input[i * 2] - 'A' + 10) * 16 + (input[i * 2 + 1] < 'A' ? input[i * 2 + 1] - '0' : input[i * 2 + 1] - 'A' + 10);
- }
- printf("input: %s\n",input);
- for(i = 0;i < 3;i++) {
- for(j = 0;j < 100000000;j++) {
- if(!memcmp(phone_sha[i][j],input_hex,32 * sizeof(unsigned char))) {
- printf("result: 0%d0%8d\n",i + 7,j);
- }
- }
- }
- puts("search done.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement