Advertisement
Guest User

wangrange.c

a guest
Sep 29th, 2014
497
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. char *strtab[32] = {"CBI PHJ MJH MIJ XBBH MBAE XFC MBBI XBAA XIH XGA XGG ",
  6.     "GJ MBCF XED MDI PEI PFC XHB MEJ PDG XFC PGE ",
  7.     "JE XGH XBAI MBCC XII PFB MHH XBCC PDI PFC XHE MFG XGF ",
  8.     "MGD PBCH MHE XBAE PFH XHF PBCD MFE XIG PDE PHJ XBBA PDE XJH XGG PIJ XFG XJA PEG PGE ",
  9.     "MDF MED PJA MHJ XBCH MHF XHG XBAG XEB PFE XHG PEB MFJ PDG PFA XBAD PFJ ",
  10.     "BGI MBAG XBBJ XFJ MEE PBBE MBAA XBAF MJI XJG PBAB MBBF PFG PFD ",
  11.     "CJH XDI XEI XEF XDC MBCC MBBA PJD MHI PGH MBBA PDG MBCD PIF XHI XJH ",
  12.     "ED MFE PHC XBAG MEH MFD XBBE PFD MBCD MGF PGE XGA MJC MFC PGD MGE XBCE XFI XFA MHC ",
  13.     "CHC MBBG PDH MEF XJC XHB XJI XGH PBAG MBBI MBCF MFE PGF XBAA MDJ PBAC ",
  14.     "BGD XBAA MBCA PEG PHG XBAD MBBJ PEI MBAE XBCB XHH MGA XHF XEI XJI XED XIH XFI XBBD ",
  15.     "EGC PFE PGE MFG XBBH MIC MBBE PFC PDF XFF MHD XBAF XDI PEI MBBH MBAE MED ",
  16.     "MCI XIF XIA MEC XBAA MFB XGB PEI PBCF PEA PBAA XIF XIB MJG MBBJ MGF PFA MIE PGG XID XDJ ",
  17.     "MBE PFD MBAE XFB PBBD PBBH XFA PGF XDH XJI MJJ MDF PEA XBBE XEJ PHG XEI MBAG ",
  18.     "MIB PEE PHF MFI XDG PDD MII XEF PEB XBBH XHB PIJ XID XDI PEA PFE MJG PIF MIH PFA ",
  19.     "MEJ XGF XEE PDG XBCB PDG XJF XBAB XBBD MBAD PIB PBAJ MBAI MGG PDH XBBB MEF XFG MFC PJJ ",
  20.     "CA XBAC XFB PGB XBBD XGH PJH PDD MDD XEB MID PFH PHI MIF MFJ PFG ",
  21.     "BDB XGC XBAE PFG MBBJ XHG PIE XIC MEH PDG PFF XIC PII PBCH MBBH ",
  22.     "H PEH XEB MEB MJF PHC XBAD PBBA XFC PBBB XBCH XFC XBBI MGA ",
  23.     "CAB MHB XEH PHA PBAB MBAE PEA MEF PGD XHD PDI XJJ MBCG MBAH XGG XED XGC XBCE ",
  24.     "MHF XFG MDE PBBD XBBH PJI MBBJ XGE PFC MJF MJD PDJ PDI ",
  25.     "BHB MBCF MGC XBAC XDF PGD PGC MDJ MED XBBJ XBAG ",
  26.     "E PHG MBBG XHE XIF XHI MJE PBCG MBBD XHI XDG ",
  27.     "CGA PJF MFH MEC MFI MBAJ PGJ XBCG PJG MEF MBAE XIG PIB ",
  28.     "BHC XBCD PDC MBAD XFI MJF XBBE PBCB PBCH MBBB XGI MIH MBCG ",
  29.     "BFI XGG XGI MFJ MBBD PFC PBCH XIH MEC XIJ MJC MDD XJF PED PDH MFE XID PHI MBAC ",
  30.     "MGC XBAD PJB XFJ PBAG MHH MBAB XGB MFI XGE MDH PGI MHB PHE PJF MBCH XEI XEI XEG XBBI ",
  31.     "B XFJ XBBD XFJ XHF XBCC XDE XII PHB XDI PBAE MFD MHD PGG XJD MFJ ",
  32.     "EBH XGG PBAG PGG MIE MBBC MHI XBAI MGE MDJ MBAF PGC MBBB ",
  33.     "BEF XBBI MGH XBBG XHF PBAH PHA PDF XGB XHJ MFA MJI MHC MHI XBBA ",
  34.     "MDC XFC XFA MDJ PDC PFH XBAF XBCD XIA PDJ XGE XBAH MJE PGF ",
  35.     "FEH MDJ MBBD XDI MIE XHC PBBH XFB XHF MGJ PIE XEE MJG XBAD MEI XEE XDF MDD MHD MEH XIH ",
  36.     "CCI XGH MFJ MFE XJD XHF MDJ MJJ XHI PBBG MBBF MHH "};
  37.  
  38. int output[4];
  39. int sub_401250(char a1, int a2)
  40. {
  41.     return (a1 >> (2 * a2)) & 3;
  42. }
  43. char trans(int ser,int len)
  44. {
  45.     int v1; // eax@2
  46.     char v6; // [sp+17h] [bp-5h]@3
  47.     int i; // [sp+18h] [bp-4h]@3
  48.     unsigned int j; // [sp+18h] [bp-4h]@6
  49.  
  50.     v6 = ser;
  51.     for ( j = 0; j < 4; ++j )
  52.     {
  53.     v1 = sub_401250(v6, j) + 4 * len;
  54.     output[j] = v1;
  55.     }
  56.     return v1;
  57. }
  58. void shift17(char *a1)
  59. {
  60.     int len;
  61.     int i; // [sp+14h] [bp-4h]@3
  62.  
  63.     len = strlen(a1);
  64.     for ( i = 0; i < len; ++i )
  65.     {
  66.     if ( a1[i] == ' ' ){
  67.         break;
  68.     }
  69.     a1[i] += 17;
  70.     }
  71. }
  72.  
  73. int tonum(char a1)
  74. {
  75.     return a1 >= 'A' && a1 < 'K';
  76. }
  77. int oper(signed int a1, signed int a2, char a3)
  78. {
  79.     int v4; // [sp+4h] [bp-4h]@0
  80.  
  81.     switch ( a3 )
  82.     {
  83.     case 'P':
  84.         v4 = a2 + a1;
  85.         break;
  86.     case 'M':
  87.         v4 = a1 - a2;
  88.         break;
  89.     case 'U':
  90.         v4 = a2 * a1;
  91.         break;
  92.     case 'V':
  93.         if ( !a2 )
  94.         a2 = 1;
  95.         v4 = a1 / a2;
  96.         break;
  97.     case 'X':
  98.         v4 = a2 ^ a1;
  99.         break;
  100.     default:
  101.         return v4;
  102.     }
  103.     return v4;
  104. }
  105. signed int sub_4010D0(const char *str)
  106. {
  107.     char c; // [sp+13h] [bp-1Dh]@3
  108.     int v3[3]; // [sp+14h] [bp-1Ch]@1
  109.     unsigned int len; // [sp+20h] [bp-10h]@1
  110.     int v5; // [sp+24h] [bp-Ch]@1
  111.     unsigned int idx; // [sp+28h] [bp-8h]@1
  112.     char v7; // [sp+2Fh] [bp-1h]@9
  113.  
  114.     idx = 0;
  115.     len = strlen(str);
  116.     v5 = 0;
  117.     v3[0] = 0;
  118.     v3[1] = 0;
  119.     v3[2] = 2;
  120.     while ( (signed int)idx <= (signed int)len )
  121.     {
  122.     c = str[idx];
  123.     if ( v5 >= 2 )
  124.         return -1;
  125.     if ( tonum(c) )
  126.     {
  127.         v3[v5] *= 10;
  128.         v3[v5] = c + v3[v5] - 'A';
  129.     }
  130.     else if ( c )
  131.     {
  132.         if ( c != 'P' && c != 'V' && c != 'M' && c != 'U' && c != 'X' )
  133.         {
  134.         if ( c == ' ' )
  135.             ++v5;
  136.         }
  137.         else
  138.         {
  139.         v7 = c;
  140.         }
  141.     }
  142.     else if ( v5 > 1 )
  143.     {
  144.         v3[0] = oper(v3[0], v3[1], v7);
  145.         v3[1] = 0;
  146.         --v5;
  147.     }
  148.     if ( v5 > 1 )
  149.     {
  150.         v3[0] = oper(v3[0], v3[1], v7);
  151.         v3[1] = 0;
  152.         --v5;
  153.     }
  154.     ++idx;
  155.     }
  156.     return v3[0];
  157. }
  158.  
  159. int calc(int ser,int len){
  160.     int i;
  161.     char dest[1024];
  162.     char v3;
  163.     char text[1024];
  164.  
  165.     trans(ser,len);
  166.  
  167.     for ( i = 0; i < 32; ++i )
  168.     {
  169.     sprintf(dest, "P%d ", output[i % 4]);
  170.     shift17(&dest[1]);
  171.     strcat(dest,strtab[i]);
  172.     v3 = (sub_4010D0(dest) & 0xFF);
  173.     text[i] = v3;
  174.     //Text[i] = v3;
  175.     }
  176.     text[32] = '\0';
  177.     printf("%s\n",text);
  178.  
  179.     return 0;
  180. }
  181.  
  182. int main(){
  183.     int i,j;
  184.     for(i = 0;i < 256;i++){
  185.     for(j = 1;j < 32;j++){
  186.         calc(i,j);
  187.     }
  188.     }
  189.     return 0;
  190. }
Advertisement
RAW Paste Data Copied
Advertisement