Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.41 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5. #include <windows.h>
  6.  
  7. #include <cutil.h>
  8.  
  9. #define verh 2
  10.  
  11. #define verl 1
  12.  
  13. #define DWORD unsigned int
  14.  
  15.  
  16.  
  17. #define MAXpasswords 199
  18.  
  19. #define THREADS 128
  20.  
  21. unsigned long BLOKS = 20 ;
  22.  
  23. #define lrot32(X,Y) (((X)<<Y)|((X)>>(32-Y)))
  24.  
  25. #define rrot32(X,Y) (((X)>>Y)|((X)<<(32-Y)))
  26.  
  27. #define H_new  1
  28.  
  29. #define H_bad  0
  30.  
  31. #define H_find 5
  32.  
  33. #define Ldata (32768*8)
  34.  
  35. #define Cdata MAXpasswords*4+1
  36.  
  37. #define Thdata 6 //length data returned from Nvidia
  38.  
  39. #define hesh_md5 0
  40.  
  41. #define hesh_md5sp 1
  42.  
  43.  
  44.  
  45. struct PassBrutStruct{
  46.  
  47.        char name[27];
  48.  
  49.        char finded;
  50.  
  51.        char hash[32];
  52.  
  53.        unsigned int HASH[4];
  54.  
  55.        unsigned int salt[8];
  56.  
  57.        unsigned char csalt[33];
  58.  
  59.        char password[32];
  60.  
  61.        char coment[128];
  62.  
  63.    };
  64.  
  65.  
  66.  
  67. union PD {
  68.  
  69.     DWORD  d[Ldata];
  70.  
  71.     unsigned char b[Ldata*4];
  72.  
  73.          };
  74.  
  75. union PDword {
  76.  
  77.     DWORD  d;
  78.  
  79.     unsigned char b[4];
  80.  
  81.          };
  82.  
  83. // -----------
  84.  
  85.  
  86.  
  87. char password[32];
  88.  
  89. char * pb;
  90.  
  91. PassBrutStruct Pass[MAXpasswords];
  92.  
  93. int  PassCount;
  94.  
  95.     PD values;
  96.  
  97.     DWORD comp[Cdata];
  98.  
  99.     DWORD salt[Cdata];
  100.  
  101.     DWORD data[Thdata];
  102.  
  103.     DWORD * dvalues;
  104.  
  105.     DWORD * dcom;
  106.  
  107.     DWORD * ddata;
  108.  
  109.     DWORD * dsalt;
  110.  
  111.     int hesh_type;
  112.  
  113.     PDword gdata[16];
  114.  
  115. //------------
  116.  
  117. unsigned char bufr[20000000];
  118.  
  119. int nDataLen ;
  120.  
  121. unsigned char String[10000];
  122.  
  123. unsigned long StringPos;
  124.  
  125. char CharsetName[256];
  126.  
  127. char CharSet[256];
  128.  
  129. unsigned long CharSetLen;
  130.  
  131.  
  132.  
  133. //---------------------------------------------
  134.  
  135. bool HexStrToInt_(char * s,unsigned long * d)
  136.  
  137. {
  138.  
  139.     for (int i=0;i<8;i++){
  140.  
  141.         *d=*d<<4;
  142.  
  143.         if ((s[i]>='0')&(s[i]<='9')) *d|=0x0+(s[i]-'0');else
  144.  
  145.         if ((s[i]>='a')&(s[i]<='f')) *d|=0xa+(s[i]-'a');else
  146.  
  147.         if ((s[i]>='A')&(s[i]<='F')) *d|=0xa+(s[i]-'A');else return false;
  148.  
  149.     }
  150.  
  151. return true;
  152.  
  153. }
  154.  
  155. //---------------------------------------------
  156.  
  157. // namber of PassBrutStruct
  158.  
  159. bool HashToDword(DWORD N)
  160.  
  161. {
  162.  
  163.     int nb=0;
  164.  
  165.     unsigned long tmp;
  166.  
  167.     char s[8];
  168.  
  169.     for (int H=0;H<2;H++){
  170.  
  171.     for (int i=0;i<8;i++) {s[i]=Pass[N].hash[nb++];}
  172.  
  173.     if (HexStrToInt_((char *)&s,&tmp)!=false) Pass[N].HASH[H]=tmp;  else return false;
  174.  
  175.     }
  176.  
  177. return true;
  178.  
  179. }
  180.  
  181.  
  182.  
  183. void hash_print(DWORD b8)
  184.  
  185. {
  186.  
  187.     DWORD D=b8;
  188.  
  189.     for (int H=0;H<4;H++)
  190.  
  191.     {
  192.  
  193.     char b1 = D & 0xf; D>>=4;
  194.  
  195.     char b2 = D & 0xf; D>>=4;
  196.  
  197.     b1<10 ? b1+='0' : b1+='a'-10;
  198.  
  199.     b2<10 ? b2+='0' : b2+='a'-10;
  200.  
  201.     printf("%c%c",b2,b1);
  202.  
  203.     }
  204.  
  205. }
  206.  
  207. void hash_to_string(DWORD b8,char * p)
  208.  
  209. {
  210.  
  211.     DWORD D=b8;
  212.  
  213.     char i=0;
  214.  
  215.     for (int H=0;H<4;H++)
  216.  
  217.     {
  218.  
  219.     char b1 = D & 0xf; D>>=4;
  220.  
  221.     char b2 = D & 0xf; D>>=4;
  222.  
  223.     b1<10 ? b1+='0' : b1+='a'-10;
  224.  
  225.     b2<10 ? b2+='0' : b2+='a'-10;
  226.  
  227.     p[i]=b2;i++;p[i]=b1;i++;
  228.  
  229.     }
  230.  
  231. }
  232.  
  233. char GetNumIn(char c)
  234.  
  235. {
  236.  
  237.  int i=0;
  238.  
  239.  int f=0;
  240.  
  241.  while (i<CharSetLen)
  242.  
  243.   {
  244.  
  245.     if (CharSet[i]==c) { f=i; break;}
  246.  
  247.     i++;
  248.  
  249.   }
  250.  
  251.  return f;
  252.  
  253. }
  254.  
  255. int StringrCopy0(LPTSTR s1, LPTSTR s2)
  256.  
  257. {
  258.  
  259.  int i=0;
  260.  
  261.  while (s2[i]!=0) {s1[i] = s2[i]; i++; }
  262.  
  263.  s1[i]=0;  
  264.  
  265.  return i;
  266.  
  267. }
  268.  
  269. int StringrCopyI0(LPTSTR s1, LPTSTR s2, int Pos)
  270.  
  271. {
  272.  
  273.  int i=0;
  274.  
  275.  while (s2[i+Pos]!=0) {s1[i] = s2[i+Pos]; i++; }
  276.  
  277.  s1[i]=0;  
  278.  
  279.  return i;
  280.  
  281. }
  282.  
  283. int GetPosition(char s1, LPTSTR s2 , int Pos)
  284.  
  285. {
  286.  
  287.  int i=0;
  288.  
  289.  int Count = 0;
  290.  
  291.  int Last = 0;
  292.  
  293.  while (s2[i]!=0)
  294.  
  295.   {
  296.  
  297.      if (s2[i] == s1)
  298.  
  299.      {
  300.  
  301.       Pos--;
  302.  
  303.       Count++;
  304.  
  305.       Last=i;
  306.  
  307.       if (Pos == 0) { return Last; }   
  308.  
  309.      };
  310.  
  311.      i++;
  312.  
  313.   }
  314.  
  315. if (Count==0) return -1; else return Last;
  316.  
  317. }
  318.  
  319. int StringrCopy (LPTSTR s1, LPTSTR s2 ,int From, int Count)
  320.  
  321. {
  322.  
  323.  int i=0;
  324.  
  325.  while (Count>0) {s1[i] = s2[i+From]; i++; Count--; }
  326.  
  327.  s1[i+1]=0;
  328.  
  329.  return i;
  330.  
  331. }
  332.  
  333. bool CmpString (LPTSTR s1, LPTSTR s2)
  334.  
  335. {
  336.  
  337.  int i=0;
  338.  
  339.  while (s1[i]!=0) { if (s1[i]!=s2[i]) return false; i++; }
  340.  
  341.  if ((s2[i]==' ')|(s2[i]=='=')|(s2[i]==9)) {return true;} else {return false;}
  342.  
  343. }
  344.  
  345.  
  346.  
  347. int GetString(LPTSTR s1, LPTSTR s2)
  348.  
  349. {
  350.  
  351.  int i=StringPos;
  352.  
  353.  while ( i < nDataLen)    
  354.  
  355.   {
  356.  
  357.       if ((s1[i+1] == (char)0x0A)&&(s1[i] == (char)0x0D)) {
  358.  
  359.           int retl = i - StringPos ;           
  360.  
  361.           StringrCopy( s2 , (char *)&s1[StringPos] ,0,retl);
  362.  
  363.           StringPos = StringPos + (retl + 2);
  364.  
  365.           s2[retl] = 0;
  366.  
  367.           return retl;
  368.  
  369.                       }
  370.  
  371.       if (s1[i] == 0) {
  372.  
  373.           int retl = i - StringPos ;           
  374.  
  375.           StringrCopy( s2 , (char *)&s1[StringPos] ,0,retl);
  376.  
  377.           StringPos = StringPos + (retl + 2);
  378.  
  379.           s2[retl] = 0;
  380.  
  381.           return retl;
  382.  
  383.                       }
  384.  
  385.       if (s1[i] == (char)0x0A) {
  386.  
  387.           int retl = i - StringPos ;           
  388.  
  389.           StringrCopy( s2 , (char *)&s1[StringPos] ,0,retl);
  390.  
  391.           StringPos = StringPos + (retl + 1);
  392.  
  393.           s2[retl] = 0;
  394.  
  395.           return retl;
  396.  
  397.                       }
  398.  
  399.     i++;
  400.  
  401.   }
  402.  
  403.  return -1;
  404.  
  405. }
  406.  
  407.  
  408.  
  409. //GetCmdLineInteger(argc, (const char**) argv, 's', &size_Start);
  410.  
  411. void GetCmdLineInteger(int count,const char** s1,char s2, int * ret )
  412.  
  413. {
  414.  
  415.     char str[256];
  416.  
  417.     if (count > 1) for (int i = 1; i < count; i++)
  418.  
  419.      if ((s1[i][0]==s2)&&(s1[i][1]=='='))
  420.  
  421.      {
  422.  
  423.         StringrCopy0(str,(LPTSTR)&s1[i][2]);
  424.  
  425.         sscanf_s(str, "%d", ret);
  426.  
  427.      }
  428.  
  429. }
  430.  
  431.  
  432.  
  433. // md5.h ---------------------------------------------
  434.  
  435. //  0..9,a..z - 3 low
  436.  
  437. //  
  438.  
  439. // const for GPU
  440.  
  441. __constant__ unsigned long nVCharSetLen;
  442.  
  443. __constant__ unsigned char nVCharSet[255];
  444.  
  445.  
  446.  
  447. __constant__ DWORD compd[MAXpasswords*4+1];
  448.  
  449.  
  450.  
  451. __global__ static void My_Sql(DWORD * values, DWORD * retd , DWORD dcount)//,DWORD * compd
  452.  
  453. {
  454.  
  455. //__shared__
  456.  
  457. DWORD data[6];
  458.  
  459. DWORD tid =(threadIdx.x << 2) + (blockIdx.x << 2)*THREADS;
  460.  
  461. data[0]=values[tid+0];
  462.  
  463. data[1]=(data[0] >> 8 ) & 0xff;
  464.  
  465. data[2]=(data[0] >> 16) & 0xff;
  466.  
  467. data[3]=(data[0] >> 24) & 0xff;
  468.  
  469. data[0]&=0xff;
  470.  
  471. data[4]=values[tid+1];
  472.  
  473. data[5]=(data[4] >> 8 ) & 0xff;;
  474.  
  475. DWORD lens =(data[4] >> 24 ) & 0xff;;
  476.  
  477. data[4]&=0xff;
  478.  
  479. if (lens==0) {retd[0]=1;return;}
  480.  
  481.  
  482.  
  483. DWORD pcount=dcount; // PASSWORD count
  484.  
  485.  
  486.  
  487. DWORD col=(95*95*lens*lens);
  488.  
  489.  
  490.  
  491.  DWORD f1 = 0x50305735;
  492.  
  493.  DWORD f2 = 0x12345671;
  494.  
  495.  DWORD fadd = 7;
  496.  
  497.  
  498.  
  499.  if (data[5]!=0){
  500.  
  501.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * data[5] ) + (f1 << 8));
  502.  
  503.     f2 = f2 + ((f2 << 8) ^ f1 );
  504.  
  505.     fadd = fadd + data[5];}
  506.  
  507.  if (data[4]!=0){
  508.  
  509.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * data[4] ) + (f1 << 8));
  510.  
  511.     f2 = f2 + ((f2 << 8) ^ f1 );
  512.  
  513.     fadd = fadd + data[4];}
  514.  
  515.  if (data[3]!=0){
  516.  
  517.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * data[3] ) + (f1 << 8));
  518.  
  519.     f2 = f2 + ((f2 << 8) ^ f1 );
  520.  
  521.     fadd = fadd + data[3];}
  522.  
  523.  if (data[2]!=0){
  524.  
  525.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * data[2] ) + (f1 << 8));
  526.  
  527.     f2 = f2 + ((f2 << 8) ^ f1 );
  528.  
  529.     fadd = fadd + data[2];}
  530.  
  531.  if (data[1]!=0){
  532.  
  533.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * data[1] ) + (f1 << 8));
  534.  
  535.     f2 = f2 + ((f2 << 8) ^ f1 );
  536.  
  537.     fadd = fadd + data[1];}
  538.  
  539.  if (data[0]!=0){
  540.  
  541.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * data[0] ) + (f1 << 8));
  542.  
  543.     f2 = f2 + ((f2 << 8) ^ f1 );
  544.  
  545.     fadd = fadd + data[0];}
  546.  
  547.  
  548.  
  549. for (DWORD dd4 = 0; dd4<lens; dd4++){
  550.  
  551.   DWORD ddd4 = nVCharSet[dd4];
  552.  
  553.   DWORD   f41 = f1 ^ ((( (f1 & 0x3f) + fadd ) * ddd4 ) + (f1 << 8));
  554.  
  555.   DWORD   f42 = f2 + ((f2 << 8) ^ f41 );
  556.  
  557.   DWORD   fadd4 = fadd + ddd4;
  558.  
  559.  
  560.  
  561. for ( DWORD i=0;i<pcount;i++){
  562.  
  563. DWORD step = (f41 & 0x3f) + fadd4;
  564.  
  565. DWORD stepa = (f41 << 8);
  566.  
  567. DWORD xor2 = (f42 << 8) ^ f41;
  568.  
  569.  
  570.  
  571. for (DWORD dd3 = 0; dd3 < lens; dd3++) {//, xor1 += step
  572.  
  573. DWORD ddd3 = nVCharSet[dd3];
  574.  
  575. DWORD xor1 = step*ddd3 + stepa;
  576.  
  577. DWORD tmp2 = f42 + (xor1 ^ xor2);
  578.  
  579. DWORD tmp1 = f41 ^ xor1;
  580.  
  581.  
  582.  
  583.  
  584.  
  585. DWORD tmp3 = (compd[(i*4)+2] - tmp2) ^ (tmp2 << 8);
  586.  
  587. DWORD div = (tmp1 & 0x3f) + fadd4 + ddd3;
  588.  
  589. DWORD diff = ((tmp3 ^ tmp1) - (tmp1 << 8)) & 0x7fffffff;
  590.  
  591. if (diff > (div << 7)) continue;
  592.  
  593. if (diff % div != 0) continue;
  594.  
  595. DWORD ddd2 = diff / div;
  596.  
  597. if (ddd2 < '!' || ddd2 > '~') continue;
  598.  
  599.  
  600.  
  601. div = (tmp3 & 0x3f) + fadd4 + ddd3 + ddd2;
  602.  
  603. diff = ((compd[(i*4)+0] ^ tmp3) - (tmp3 << 8)) & 0x7fffffff;
  604.  
  605. if (diff > (div << 7)) continue;
  606.  
  607. if (diff % div != 0) continue;
  608.  
  609. DWORD dd1 = diff / div;
  610.  
  611. if (dd1 < '!' || dd1 > '~') continue;
  612.  
  613.  
  614.  
  615. retd[1]=dd1 | (ddd2 <<8) | (ddd3 <<16) | (ddd4 <<24) ;
  616.  
  617. retd[2]=(data[1]<<8 ) | (data[2] <<16) | (data[3] <<24) | (data[0]);
  618.  
  619. retd[3]= data[4] | (data[5]<<8 );
  620.  
  621. retd[4]=5;
  622.  
  623. retd[5]=i;
  624.  
  625. return;
  626.  
  627. }}}
  628.  
  629.  
  630.  
  631. retd[0]=col;return;
  632.  
  633.  
  634.  
  635. }
  636.  
  637.  
  638.  
  639. DWORD hash[4];
  640.  
  641. unsigned char shash[256];
  642.  
  643.  
  644.  
  645. void pen_mysql(unsigned char * data)
  646.  
  647. {
  648.  
  649.  DWORD f1 = 0x50305735;
  650.  
  651.  DWORD f2 = 0x12345671;
  652.  
  653.  DWORD fadd = 7;
  654.  
  655.   for (;*data;data++)
  656.  
  657.   {
  658.  
  659.     f1 = f1 ^ ((( (f1 & 0x3f) + fadd ) * *data ) + (f1 << 8));
  660.  
  661.     f2 = f2 + ((f2 << 8) ^ f1 );
  662.  
  663.     fadd = fadd + *data;
  664.  
  665.   }
  666.  
  667. hash[0]= f1 & 0x7fffffff;
  668.  
  669. hash[1]= f2 & 0x7fffffff;
  670.  
  671. }
  672.  
  673.  
  674.  
  675.     char size;
  676.  
  677.     char sizeold;
  678.  
  679. // ---------------------------------------------------
  680.  
  681. // ----------------- main ----------------------------
  682.  
  683. // ---------------------------------------------------
  684.  
  685. int main(int argc, char** argv)
  686.  
  687. {
  688.  
  689.  
  690.  
  691. LONG dwVersion = GetVersion();
  692.  
  693. int dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
  694.  
  695. int dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
  696.  
  697. printf("MySql(64) V%d.%.2d Win:v%d.%.2d\n",verh,verl,dwWindowsMajorVersion,dwWindowsMinorVersion);
  698.  
  699.     int deviceCount;
  700.  
  701.     cudaGetDeviceCount(&deviceCount);
  702.  
  703.     if (deviceCount == 0)
  704.  
  705.     {
  706.  
  707.         printf("There is no device supporting CUDA\n");
  708.  
  709.                 return(0);
  710.  
  711.     }
  712.  
  713.  
  714.  
  715.         cudaDeviceProp deviceProp;
  716.  
  717.         cudaGetDeviceProperties(&deviceProp, 0);
  718.  
  719.         printf("CudaV%d.%.2d  %s, Processors: %d  Clock rate: %.3f Mg.\n",
  720.  
  721.         deviceProp.major,
  722.  
  723.         deviceProp.minor,
  724.  
  725.             deviceProp.name,
  726.  
  727.             deviceProp.multiProcessorCount*8,
  728.  
  729.             (float)deviceProp.clockRate/1000000.0);
  730.  
  731.  
  732.  
  733.     BLOKS=20;
  734.  
  735.     GetCmdLineInteger(argc, (const char**) argv, 'b',(int *)&BLOKS);
  736.  
  737.     BLOKS=(BLOKS >> 3)*8;
  738.  
  739.     if (BLOKS < 10) BLOKS=10;
  740.  
  741.     if (BLOKS > 512) BLOKS=512;
  742.  
  743.  
  744.  
  745.     __int64  pTIME,pasTIME;
  746.  
  747.     GetSystemTimeAsFileTime((FILETIME *)&pTIME);
  748.  
  749.  
  750.  
  751.     int size_Start=4;
  752.  
  753.     int size_End=10;
  754.  
  755.     GetCmdLineInteger(argc, (const char**) argv, 's', &size_Start);
  756.  
  757.     GetCmdLineInteger(argc, (const char**) argv, 'e', &size_End);
  758.  
  759.     size_End++;
  760.  
  761.     if (size_Start<4) size_Start=4;
  762.  
  763.     if (size_Start>size_End-1) size_Start=size_End-1;
  764.  
  765.     if (size_End>11) { printf("Sorry short version.\n");    return(0);}
  766.  
  767.  
  768.  
  769. //---- Get Char Set -----------------------
  770.  
  771.     for (int i=0;i<sizeof(bufr);i++) bufr[i]=0;
  772.  
  773.     CharSetLen = 0;
  774.  
  775.     CharsetName[0] = 0;
  776.  
  777.     if (argc > 1) for (int i = 1; i < argc; i++)
  778.  
  779.      if ((argv[i][0]=='c')&(argv[i][1]=='='))   StringrCopyI0(CharsetName, argv[i],2 );
  780.  
  781.       if (CharsetName[0] == 0) StringrCopy0(CharsetName,"loweralpha-numeric");
  782.  
  783.     HANDLE file = NULL;//   fopen_s(&file,"charset.txt", "r");
  784.  
  785.     file = CreateFileA("charset.txt",GENERIC_READ,0,0,OPEN_EXISTING,0,0);
  786.  
  787.     if (file != NULL)
  788.  
  789.       {
  790.  
  791.     ReadFile(file,bufr,sizeof(bufr),(LPDWORD)&nDataLen,0); 
  792.  
  793.     CloseHandle(file);
  794.  
  795.  
  796.  
  797.         StringPos = 0;
  798.  
  799.         while ( GetString((char *)&bufr[0],(char *)&String)>=0 )
  800.  
  801.         {
  802.  
  803.             if (String[0]!='#')
  804.  
  805.             {
  806.  
  807.                 if (CmpString(CharsetName,(char *)&String))
  808.  
  809.                 {
  810.  
  811.                 int FirstPos = GetPosition('[',(char *)&String,1);
  812.  
  813.                 int LastPos  = GetPosition(']',(char *)&String,0xff);
  814.  
  815.                 if ((FirstPos<LastPos)&(FirstPos!=-1)&(LastPos!=-1))
  816.  
  817.                  {
  818.  
  819.                  CharSetLen = StringrCopy(CharSet,(char *)&String,FirstPos+1,LastPos-FirstPos-1);
  820.  
  821.                  }
  822.  
  823.                 }
  824.  
  825.             }
  826.  
  827.         }
  828.  
  829.  
  830.  
  831.       }
  832.  
  833.     if (CharSetLen==0) CharSetLen = StringrCopy0(CharSet,"asdfghjklqwertyuiopzxcvbnm1234567890");
  834.  
  835. printf("CharSet %s = %s \n",CharsetName,CharSet);
  836.  
  837. //---- Get Char Set ------------------- end --
  838.  
  839.    
  840.  
  841.    
  842.  
  843.     DWORD Nthread = (BLOKS*THREADS);
  844.  
  845.  
  846.  
  847.     char Filename[512]="mysqlpas.txt";
  848.  
  849.     if (argc!=0)
  850.  
  851.     for (int i=1;i<argc;i++)
  852.  
  853.     {
  854.  
  855.     pb=argv[i];
  856.  
  857.     if ((pb[0]=='f')&(pb[1]=='='))
  858.  
  859.      { int i1=0;while ((pb[i1]!=0)&(pb[i1]!='"')) { Filename[i1]=pb[i1+2];i1++;} Filename[i1]=0; }
  860.  
  861.     }
  862.  
  863.  
  864.  
  865.     for (int i=0;i<sizeof(bufr);i++) bufr[i]=0;
  866.  
  867.     int FileLength;
  868.  
  869.     HANDLE FilePas=CreateFileA(Filename,GENERIC_READ,0,0,OPEN_EXISTING,0,0);   
  870.  
  871.     if (FilePas==INVALID_HANDLE_VALUE) {
  872.  
  873.                 printf("There is no %s file.\n",Filename);
  874.  
  875.                 return(0);
  876.  
  877.                                         }  
  878.  
  879.     ReadFile(FilePas,bufr,sizeof(bufr),(LPDWORD)&FileLength,0);
  880.  
  881.     for (int i=0;i<sizeof(bufr);i++) if (bufr[i]==0xa) bufr[i]=0;
  882.  
  883.     for (int i=0;i<sizeof(bufr);i++) if (bufr[i]==0xd) bufr[i]=0;
  884.  
  885.     DWORD PassCount=0;
  886.  
  887.     int pos=0;
  888.  
  889.     while (pos<FileLength) {
  890.  
  891.         int posl=0;
  892.  
  893.         int next=0;
  894.  
  895.         while (bufr[pos+posl]!=0) {
  896.  
  897.             if ((bufr[pos+posl]==':')&(posl<16)&(next!=5)) {
  898.  
  899.                 for(int i=0;i<posl;i++) Pass[PassCount].name[i]=bufr[pos+i]; Pass[PassCount].name[posl]=0;
  900.  
  901.             posl++;
  902.  
  903.                 for(int i=0;i<16;i++) Pass[PassCount].hash[i]=bufr[pos+posl+i];
  904.  
  905.             next=5;PassCount++;
  906.  
  907.             }
  908.  
  909.             if ((posl==15)&(next!=5)) {
  910.  
  911.                 for(int i=0;i<16;i++) Pass[PassCount].hash[i]=bufr[pos+i];
  912.  
  913.  
  914.  
  915.             next=5;if (MAXpasswords>PassCount) PassCount++; else break;
  916.  
  917.             }
  918.  
  919.                 posl++;
  920.  
  921.         }  
  922.  
  923.         if (next!=0)
  924.  
  925.             if (HashToDword(PassCount-1)!=false)
  926.  
  927.                 {
  928.  
  929.                 if (((Pass[PassCount-1].HASH[0]&0x80000000)==0 ) && ((Pass[PassCount-1].HASH[1]&0x80000000)==0 ))
  930.  
  931.                 Pass[PassCount-1].finded=H_new;
  932.  
  933.                  else
  934.  
  935.                     PassCount--;
  936.  
  937.                 }else
  938.  
  939.                     PassCount--;
  940.  
  941.                
  942.  
  943.         pos+=(posl+1);
  944.  
  945.     }
  946.  
  947.     CloseHandle(FilePas);
  948.  
  949.  
  950.  
  951.  
  952.  
  953. //printf("Weit \n");
  954.  
  955. DWORD PassCountr=0;
  956.  
  957. for (int i=0;i<PassCount;i++)
  958.  
  959. {
  960.  
  961. comp[i*4+0]=Pass[i].HASH[0];
  962.  
  963. comp[i*4+1]=Pass[i].HASH[1];
  964.  
  965. DWORD mlb = (comp[i*4+1] - comp[i*4+0]);
  966.  
  967. mlb = comp[i*4+1] - ((mlb << 8) ^ comp[i*4+0]);
  968.  
  969. mlb = comp[i*4+1] - ((mlb << 8) ^ comp[i*4+0]);
  970.  
  971. mlb = comp[i*4+1] - ((mlb << 8) ^ comp[i*4+0]);
  972.  
  973. comp[i*4+2] = mlb & 0x7fffffff;
  974.  
  975. comp[i*4+0]&=0x7fffffff;
  976.  
  977. comp[i*4+1]&=0x7fffffff;
  978.  
  979.  PassCountr++; 
  980.  
  981. }
  982.  
  983.  
  984.  
  985. DWORD TIME=GetTickCount();
  986.  
  987.  
  988.  
  989. if (PassCountr==0) {
  990.  
  991.                 printf("There is no MySql hash \n");
  992.  
  993.                 return(0);
  994.  
  995.                     }
  996.  
  997.  
  998.  
  999.  DWORD f1 = 0x50305735;
  1000.  
  1001.  DWORD f2 = 0x12345671;
  1002.  
  1003.  DWORD fadd = 7;
  1004.  
  1005.   for (DWORD cc1='!';cc1<='~';cc1++)
  1006.  
  1007.   {
  1008.  
  1009.    DWORD f21 = f1 ^ ((( (f1 & 0x3f) + fadd ) * cc1 ) + (f1 << 8));
  1010.  
  1011.    DWORD f22 = f2 + ((f2 << 8) ^ f21 );
  1012.  
  1013.     for (int i=0;i<PassCountr;i++)
  1014.  
  1015.     {
  1016.  
  1017.      if ((comp[i*4+0]==f21)&(comp[i*4+1]==f22))
  1018.  
  1019.      {
  1020.  
  1021.         printf( "password %c  \n", cc1);
  1022.  
  1023.         for (int i=data[5];i<PassCountr;i++)
  1024.  
  1025.         {
  1026.  
  1027.         comp[i*4+0]=comp[(i+1)*4+0];
  1028.  
  1029.         comp[i*4+1]=comp[(i+1)*4+1];
  1030.  
  1031.         comp[i*4+2]=comp[(i+1)*4+2];
  1032.  
  1033.         }
  1034.  
  1035.         PassCountr--;
  1036.  
  1037.      }
  1038.  
  1039.     }
  1040.  
  1041.   }
  1042.  
  1043.   for (DWORD cc1='!';cc1<='~';cc1++)
  1044.  
  1045.   {
  1046.  
  1047.    DWORD f21 = f1 ^ ((( (f1 & 0x3f) + fadd ) * cc1 ) + (f1 << 8));
  1048.  
  1049.    DWORD f22 = f2 + ((f2 << 8) ^ f21 );
  1050.  
  1051.    DWORD fadd2 = fadd + cc1;
  1052.  
  1053.   for (DWORD cc2='!';cc2<='~';cc2++)
  1054.  
  1055.   {
  1056.  
  1057.    DWORD f31 = f21 ^ ((( (f21 & 0x3f) + fadd2 ) * cc2 ) + (f21 << 8));
  1058.  
  1059.    DWORD f32 = f22 + ((f22 << 8) ^ f31 );
  1060.  
  1061.     for (DWORD i=0;i<PassCountr;i++)
  1062.  
  1063.     {
  1064.  
  1065.      if ((comp[i*4+0]==(f31&0x7fffffff))&(comp[i*4+1]==(f32&0x7fffffff)))
  1066.  
  1067.       {
  1068.  
  1069.         printf( "password %c%c \n", cc1,cc2);
  1070.  
  1071.         if (i<(PassCountr-1))
  1072.  
  1073.         for (int ii=i;ii<PassCountr;ii++)
  1074.  
  1075.         {
  1076.  
  1077.         comp[ii*4+0]=comp[(ii+1)*4+0];
  1078.  
  1079.         comp[ii*4+1]=comp[(ii+1)*4+1];
  1080.  
  1081.         comp[ii*4+2]=comp[(ii+1)*4+2];
  1082.  
  1083.         }
  1084.  
  1085.         PassCountr--;
  1086.  
  1087.      }
  1088.  
  1089.      if (i>=PassCountr) break;
  1090.  
  1091.     }
  1092.  
  1093.   }}
  1094.  
  1095.   for (DWORD cc1='!';cc1<='~';cc1++)
  1096.  
  1097.   {
  1098.  
  1099.    DWORD f21 = f1 ^ ((( (f1 & 0x3f) + fadd ) * cc1 ) + (f1 << 8));
  1100.  
  1101.    DWORD f22 = f2 + ((f2 << 8) ^ f21 );
  1102.  
  1103.    DWORD fadd2 = fadd + cc1;
  1104.  
  1105.   for (DWORD cc2='!';cc2<='~';cc2++)
  1106.  
  1107.   {
  1108.  
  1109.    DWORD f31 = f21 ^ ((( (f21 & 0x3f) + fadd2 ) * cc2 ) + (f21 << 8));
  1110.  
  1111.    DWORD f32 = f22 + ((f22 << 8) ^ f31 );
  1112.  
  1113.    DWORD fadd3 = fadd2 + cc2;
  1114.  
  1115.   for (DWORD cc3='!';cc3<='~';cc3++)
  1116.  
  1117.   {
  1118.  
  1119.    DWORD f41 = f31 ^ ((( (f31 & 0x3f) + fadd3 ) * cc3 ) + (f31 << 8));
  1120.  
  1121.    DWORD f42 = f32 + ((f32 << 8) ^ f41 );
  1122.  
  1123.     for (DWORD i=0;i<PassCountr;i++)
  1124.  
  1125.     {
  1126.  
  1127.      if ((comp[i*4+0]==(f41&0x7fffffff))&(comp[i*4+1]==(f42&0x7fffffff)))
  1128.  
  1129.      {
  1130.  
  1131.         printf( "password %c%c%c \n", cc1,cc2,cc3);
  1132.  
  1133.         for (int i=data[5];i<PassCountr;i++)
  1134.  
  1135.         {
  1136.  
  1137.         comp[i*4+0]=comp[(i+1)*4+0];
  1138.  
  1139.         comp[i*4+1]=comp[(i+1)*4+1];
  1140.  
  1141.         comp[i*4+2]=comp[(i+1)*4+2];
  1142.  
  1143.         }
  1144.  
  1145.         PassCountr--;
  1146.  
  1147.      }
  1148.  
  1149.     }
  1150.  
  1151.   }}}
  1152.  
  1153.  
  1154.  
  1155.     HANDLE OutPas=INVALID_HANDLE_VALUE;
  1156.  
  1157.     for (int i=1;i<argc;i++)
  1158.  
  1159.     {
  1160.  
  1161.     pb=argv[i];
  1162.  
  1163.     if ((pb[0]=='o')&(pb[1]=='='))
  1164.  
  1165.      {
  1166.  
  1167.       int i1=0;while ((pb[i1]!=0)&(pb[i1]!='"')) { Filename[i1]=pb[i1+2];i1++;} Filename[i1]=0;
  1168.  
  1169.       OutPas=CreateFileA(Filename,GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_ALWAYS,0,0);
  1170.  
  1171.       int I=0; SetFilePointer(OutPas,I,(PLONG)&I,FILE_END);
  1172.  
  1173.      }
  1174.  
  1175.     }
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181. printf( "Start with %d passwords \n", PassCountr);
  1182.  
  1183.     CUDA_SAFE_CALL(cudaMalloc((void**)&dvalues, sizeof(DWORD) * Ldata));
  1184.  
  1185.     CUDA_SAFE_CALL(cudaMalloc((void**)&dcom, sizeof(DWORD) * Cdata));
  1186.  
  1187.     CUDA_SAFE_CALL(cudaMalloc((void**)&ddata, sizeof(DWORD) * Thdata));
  1188.  
  1189.     CUDA_SAFE_CALL(cudaMemcpyToSymbol(compd, comp, sizeof(DWORD) * Cdata ));
  1190.  
  1191.     CUDA_SAFE_CALL(cudaMemcpyToSymbol(nVCharSetLen, &CharSetLen, 4  ));
  1192.  
  1193.     CUDA_SAFE_CALL(cudaMemcpyToSymbol(nVCharSet, CharSet, CharSetLen  ));
  1194.  
  1195.  
  1196.  
  1197. //--------------------------
  1198.  
  1199.  
  1200.  
  1201.     DWORD f; // time
  1202.  
  1203.     bool founded=false;
  1204.  
  1205.     size=size_Start;
  1206.  
  1207.     sizeold=size;
  1208.  
  1209.     char c3,c4,c5,c6,c7,c8;
  1210.  
  1211.     c3=c4=c5=c6=c7=c8=0;
  1212.  
  1213. //---- SET Plan -----------------------
  1214.  
  1215.     int Rest = 0;
  1216.  
  1217.     if (argc > 1) for (int i = 1; i < argc; i++)
  1218.  
  1219.      if ((argv[i][0]=='r')&(argv[i][1]=='='))   Rest = StringrCopyI0((char *)&String, argv[i], 2 );
  1220.  
  1221.     if ((Rest!=0)&&(Rest<size_End))
  1222.  
  1223.     {
  1224.  
  1225.      printf( "Restart from ????%s \n", (char *)&String[4]);
  1226.  
  1227.      if (Rest>4) c3=GetNumIn(String[4]);
  1228.  
  1229.      if (Rest>5) c4=GetNumIn(String[5]);
  1230.  
  1231.      if (Rest>6) c5=GetNumIn(String[6]);
  1232.  
  1233.      if (Rest>7) c6=GetNumIn(String[7]);
  1234.  
  1235.      if (Rest>8) c7=GetNumIn(String[8]);
  1236.  
  1237.      if (Rest>9) c8=GetNumIn(String[9]);
  1238.  
  1239.     size = Rest;
  1240.  
  1241.     sizeold=size;
  1242.  
  1243.     }
  1244.  
  1245. //---- SET Plan ------------------- end --
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251. for(int i = 0; i < Ldata; i++) values.d[i] = 0;
  1252.  
  1253. __int64 fsr=0;
  1254.  
  1255. char fsrc=0;
  1256.  
  1257. int fv=0;
  1258.  
  1259.    
  1260.  
  1261. while (true) {
  1262.  
  1263.  
  1264.  
  1265. if (!founded)
  1266.  
  1267. {
  1268.  
  1269.     for(int i = 0; i < Nthread; i++)
  1270.  
  1271.     {
  1272.  
  1273.             values.b[(i*16)+7]=CharSetLen;
  1274.  
  1275. if (size>4) values.b[(i*16)+0]=CharSet[c3];
  1276.  
  1277. if (size>5) values.b[(i*16)+1]=CharSet[c4];
  1278.  
  1279. if (size>6) values.b[(i*16)+2]=CharSet[c5];
  1280.  
  1281. if (size>7) values.b[(i*16)+3]=CharSet[c6];
  1282.  
  1283. if (size>8) values.b[(i*16)+4]=CharSet[c7];
  1284.  
  1285. if (size>9) values.b[(i*16)+5]=CharSet[c8];
  1286.  
  1287.        c3++; if (c3>=CharSetLen) { if (size< 6) {size++;break;}
  1288.  
  1289. c3=0;c4++; if (c4>=CharSetLen) { if (size< 7) {size++;break;}
  1290.  
  1291. c4=0;c5++; if (c5>=CharSetLen) { if (size< 8) {size++;break;}
  1292.  
  1293. c5=0;c6++; if (c6>=CharSetLen) { if (size< 9) {size++;break;}
  1294.  
  1295. c6=0;c7++; if (c7>=CharSetLen) { if (size<10) {size++;break;}
  1296.  
  1297. c7=0;c8++; if (c8>=CharSetLen) { size++;break;
  1298.  
  1299. }}}}}}
  1300.  
  1301.     }  
  1302.  
  1303. }  
  1304.  
  1305.  
  1306.  
  1307.     CUDA_SAFE_CALL(cudaMemcpy(dvalues, values.d, sizeof(DWORD) * Ldata, cudaMemcpyHostToDevice));
  1308.  
  1309.     data[4]=0;data[0]=0;
  1310.  
  1311.     CUDA_SAFE_CALL(cudaMemcpy(ddata, data, sizeof(DWORD) * Thdata , cudaMemcpyHostToDevice));
  1312.  
  1313.  
  1314.  
  1315.     My_Sql<<<BLOKS,THREADS>>>(dvalues,ddata,PassCountr);
  1316.  
  1317.     cudaMemcpy(data, ddata, sizeof(DWORD) * Thdata , cudaMemcpyDeviceToHost);
  1318.  
  1319.  
  1320.  
  1321.     if ((data[4]==0)&(data[0]==0)){
  1322.  
  1323.     printf("X.Z. nVidia driver fall down \n");
  1324.  
  1325.     CUDA_SAFE_CALL(cudaFree(dvalues));
  1326.  
  1327.     CUDA_SAFE_CALL(cudaFree(dcom));
  1328.  
  1329.     CUDA_SAFE_CALL(cudaFree(ddata));
  1330.  
  1331.     return(0);
  1332.  
  1333.                     }
  1334.  
  1335.            
  1336.  
  1337.     DWORD tTIME=GetTickCount();
  1338.  
  1339.     TIME= tTIME-TIME;
  1340.  
  1341.     if (TIME!=0) f =((((__int64)Nthread*(__int64)(data[0]))/ TIME)) /1000;
  1342.  
  1343.     TIME= tTIME;
  1344.  
  1345.     if (fsrc==16)
  1346.  
  1347.     {
  1348.  
  1349.         fv=fsr / fsrc;
  1350.  
  1351.         fsr=0;fsrc=0;
  1352.  
  1353.     }
  1354.  
  1355.     fsrc++;
  1356.  
  1357.     fsr+=f;
  1358.  
  1359.  
  1360.  
  1361.     switch (sizeold)
  1362.  
  1363.     {
  1364.  
  1365.     case 4 :printf( "???? ");break;
  1366.  
  1367.     case 5 :printf( "????%c ",values.b[0]);break;
  1368.  
  1369.     case 6 :printf( "????%c%c ",values.b[0],values.b[1]);break;
  1370.  
  1371.     case 7 :printf( "????%c%c%c ",values.b[0],values.b[1],values.b[2]);break;
  1372.  
  1373.     case 8 :printf( "????%c%c%c%c ",values.b[0],values.b[1],values.b[2],values.b[3]);break;
  1374.  
  1375.     case 9 :printf( "????%c%c%c%c%c ",values.b[0],values.b[1],values.b[2],values.b[3],values.b[4]);break;
  1376.  
  1377.     case 10:printf( "????%c%c%c%c%c%c ",values.b[0],values.b[1],values.b[2],values.b[3],values.b[4],values.b[5]);break;
  1378.  
  1379.     }
  1380.  
  1381.  
  1382.  
  1383.     GetSystemTimeAsFileTime((FILETIME *)&pasTIME);
  1384.  
  1385.     DWORD s = (pasTIME - pTIME)/10000000;
  1386.  
  1387.     DWORD m = s / 60; s%=60;
  1388.  
  1389.     DWORD a = m / 60; m%=60;
  1390.  
  1391.     printf( "Speed = %d mln.pas/sec Time: %d.%.2d.%.2d  \r", fv ,a,m,s );
  1392.  
  1393.  
  1394.  
  1395. if (data[4]==5)
  1396.  
  1397.     {
  1398.  
  1399.     printf( "\a : ");
  1400.  
  1401.     pb=(char *)&data[1]+(sizeold-1);
  1402.  
  1403.     for (int i=0;i<sizeold;i++){password[i]=*pb;pb--; }
  1404.  
  1405.     password[sizeold]=0;
  1406.  
  1407.     printf( "%.8x%.8x : %s                      \n",comp[data[5]*4+0],comp[data[5]*4+1], password);
  1408.  
  1409.         if (OutPas!=INVALID_HANDLE_VALUE)
  1410.  
  1411.     {
  1412.  
  1413.         char OutPasS[32];
  1414.  
  1415.         int IB=StringrCopy0(OutPasS,(LPTSTR)&password);
  1416.  
  1417.         OutPasS[IB]=0xd;OutPasS[IB+1]=0xa;IB+=2;
  1418.  
  1419.         WriteFile(OutPas,OutPasS,IB,(LPDWORD)&IB,0);
  1420.  
  1421.     }
  1422.  
  1423.     if (PassCountr!=data[5]) {
  1424.  
  1425. for (int i=data[5];i<PassCountr;i++)
  1426.  
  1427. {
  1428.  
  1429. comp[i*4+0]=comp[(i+1)*4+0];
  1430.  
  1431. comp[i*4+1]=comp[(i+1)*4+1];
  1432.  
  1433. comp[i*4+2]=comp[(i+1)*4+2];
  1434.  
  1435. }
  1436.  
  1437.     }
  1438.  
  1439. PassCountr--;
  1440.  
  1441.     CUDA_SAFE_CALL(cudaMemcpyToSymbol(compd, comp, sizeof(DWORD) * Cdata ));
  1442.  
  1443.  
  1444.  
  1445.     founded=true;
  1446.  
  1447.     } else
  1448.  
  1449. {
  1450.  
  1451. founded=false;
  1452.  
  1453. if (sizeold!=size)
  1454.  
  1455. {
  1456.  
  1457. sizeold=size;
  1458.  
  1459. c3=c4=c5=c6=c7=c8=0;
  1460.  
  1461.  
  1462.  
  1463. }
  1464.  
  1465. }
  1466.  
  1467.  
  1468.  
  1469. if ((size==size_End)|(PassCountr==0)) break;
  1470.  
  1471. } //while true
  1472.  
  1473. // 2..5 full char ---------------------------------- end
  1474.  
  1475.  
  1476.  
  1477.     printf( "\n\a all checked :{", &data[1]);
  1478.  
  1479.     CUDA_SAFE_CALL(cudaFree(dvalues));
  1480.  
  1481.     CUDA_SAFE_CALL(cudaFree(dcom));
  1482.  
  1483.     CUDA_SAFE_CALL(cudaFree(ddata));
  1484.  
  1485.     CUDA_SAFE_CALL(cudaFree(dsalt));
  1486.  
  1487.     return(0);
  1488.  
  1489. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement