Advertisement
Aslai

Untitled

Oct 8th, 2011
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stack>
  3.  
  4. int main(){
  5.     std::stack<int> s;
  6.     int pos;
  7.     char in[100000];
  8.     printf( "BF: "); gets( in );
  9.     FILE* a = fopen( "out.bin", "w" );
  10.     int p = 0x9D93;
  11.  
  12.  
  13.  
  14.     fprintf( a, "%c%c", 0xBB, 0x6D ); p+=2;
  15.     char getAnstoDE[] = {   0x21, 0x78, 0x84,
  16.                             0x36, 0x04,
  17.                             0x23,
  18.                             0x36, 0x72,
  19.                             0x23,
  20.                             0x36, 0x00,
  21.                             0x23,
  22.                             0x36, 0x00,
  23.                             0xEF, 0xF4, 0x42,
  24.                             0x1A, 0x6f, 0x13,
  25.                             0x1A, 0x67, 0x13,
  26.                             0x19, 0x36, 0x00
  27.                             };
  28.     fwrite( getAnstoDE, 26, 1, a ); p += 26;
  29.     fprintf( a, "%c%c%c", 0x21, 0xEC, 0x86 ); p+=3;
  30.  
  31.     fprintf( a, "%c%c", 0x3E, 0xFF ); p+=2;
  32.     fprintf( a, "%c%c%c%c%c%c%c%c%c", 0x36, 0, 0x23, 0x3D, 0xFE, 0, 0xC2, p&0xFF, (p>>8)&0xFF ); p+=9;
  33.     fprintf( a, "%c%c%c%c%c", 0x21, 0xEC, 0x86, 0x06, 0x00 ); p+=5;
  34.  
  35.     for( int i = 0; in[i] != 0; i ++ ){
  36.         switch( in[i] ){
  37.             case '+':
  38.                 fprintf( a, "%c", 0x34 ); p++;
  39.                 break;
  40.             case '-':
  41.                 fprintf( a, "%c", 0x35 ); p++;
  42.                 break;
  43.             case '>':
  44.                 fprintf( a, "%c%c%c%c%c%c%c%c%c", 0x23, 0x78, 0xC6, 0x01, 0x30, 0x01, 0x25, 0x47 ); p+=8;
  45.                 break;
  46.             case '<':
  47.                 fprintf( a, "%c%c%c%c%c%c%c%c%c", 0x2B, 0x78, 0xD6, 0x01, 0x30, 0x01, 0x24, 0x47 ); p+=8;
  48.                 break;
  49.             case '[':
  50.             {
  51.                 s.push( p+6 );
  52.                 int pp = p;
  53.                 for( int j = i+1, depth = 1; in[j] != 0; j++ ){
  54.                     if( in[j] == '[' ) depth ++;
  55.                     if( in[j] == ']' ) depth --;
  56.  
  57.                     if( in[j] == '+' || in[j] == '-' ){
  58.                         pp++;
  59.                     }
  60.                     if( in[j] == '<' || in[j] == '>' ){
  61.                         pp+=8;
  62.                     }
  63.  
  64.                     if( in[j] == '[' || in[j] == ']' ){
  65.                         pp+=6;
  66.                     }
  67.                     if( in[j] == '.'){
  68.                         pp+=4;
  69.                     }
  70.                     if( in[j] == ','){
  71.                         pp+=7;
  72.                     }
  73.  
  74.                     if( depth <= 0 ) break;
  75.                 }
  76.                 fprintf( a, "%c%c%c%c%c%c", 0x7E, 0xFE, 0x00, 0xCA, pp&0xFF, (pp>>8)&0xFF ); p+=6;
  77.             } break;
  78.             case ']':
  79.             {
  80.                 int pp = s.top( );
  81.                 s.pop();
  82.                 fprintf( a, "%c%c%c%c%c%c", 0x7E, 0xFE, 0x00, 0xC2, pp&0xFF, (pp>>8)&0xFF ); p+=6;
  83.             } break;
  84.             case '.':
  85.             {
  86.                 fprintf( a, "%c%c%c%c", 0x7E, 0xEF, 0x04, 0x45 ); p+=4;
  87.             } break;
  88.             case ',':
  89.             {
  90.                 fprintf( a, "%c%c%c%c%c%c%c", 0x1A, 0x77, 0xFE, 0x00, 0x28, 0x01, 0x13 ); p+=7;
  91.             } break;
  92.  
  93.         }
  94.     }
  95.     fprintf( a, "%c", 0xC9 ); p+=1;
  96. }
  97.  
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement