Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.62 KB | None | 0 0
  1. /----------------- ENCRYPTION ROUTINES -------------------------------------------------------------------------
  2.  
  3. void encrypt_chars(int length, char EKey)
  4. {
  5. 00CB5C00  push        ebp  
  6. 00CB5C01  mov         ebp,esp  
  7. 00CB5C03  sub         esp,0DCh  
  8. 00CB5C09  push        ebx  
  9. 00CB5C0A  push        esi  
  10. 00CB5C0B  push        edi  
  11. 00CB5C0C  lea         edi,[ebp-0DCh]  
  12. 00CB5C12  mov         ecx,37h  
  13. 00CB5C17  mov         eax,0CCCCCCCCh  
  14. 00CB5C1C  rep stos    dword ptr es:[edi]  
  15. 00CB5C1E  mov         eax,dword ptr ds:[00CC0008h]  
  16. 00CB5C23  xor         eax,ebp  
  17. 00CB5C25  mov         dword ptr [ebp-4],eax  
  18.     char temp_char;                         // char temporary store
  19.  
  20.     for (int i = 0; i < length; i++)        // encrypt characters one at a time
  21. 00CB5C28  mov         dword ptr [ebp-18h],0  
  22. 00CB5C2F  jmp         encrypt_chars+3Ah (0CB5C3Ah)  
  23. 00CB5C31  mov         eax,dword ptr [ebp-18h]  
  24. 00CB5C34  add         eax,1  
  25. 00CB5C37  mov         dword ptr [ebp-18h],eax  
  26. 00CB5C3A  mov         eax,dword ptr [ebp-18h]  
  27. 00CB5C3D  cmp         eax,dword ptr [length]  
  28. 00CB5C40  jge         encrypt_chars+74h (0CB5C74h)  
  29.     {
  30.         temp_char = OChars[i];              // temp_char now contains the address values of the individual character
  31. 00CB5C42  mov         eax,dword ptr [ebp-18h]  
  32. 00CB5C45  mov         cl,byte ptr [eax+0CC0320h]  
  33. 00CB5C4B  mov         byte ptr [temp_char],cl  
  34.         __asm
  35.         {
  36.                 push    eax                 // Save values contained within register to stack
  37. 00CB5C4E  push        eax  
  38.                 push    ecx
  39. 00CB5C4F  push        ecx  
  40.  
  41.                 movzx   ecx, temp_char
  42. 00CB5C50  movzx       ecx,byte ptr [temp_char]  
  43.                 push    ecx                 // Push argument #2
  44. 00CB5C54  push        ecx  
  45.                 lea     eax, EKey
  46. 00CB5C55  lea         eax,[EKey]  
  47.                 push    eax                 // Push argument #1
  48. 00CB5C58  push        eax  
  49.                 call    encrypt4
  50. 00CB5C59  call        encrypt4 (0CB5C76h)  
  51.                 add     esp, 8              // Clean parameters of stack
  52. 00CB5C5E  add         esp,8  
  53.                 mov     temp_char, al       // Move the temp character into a register    
  54. 00CB5C61  mov         byte ptr [temp_char],al  
  55.  
  56.                 pop     ecx
  57. 00CB5C64  pop         ecx  
  58.                 pop     eax
  59. 00CB5C65  pop         eax  
  60.         }
  61.         EChars[i] = temp_char;              // Store encrypted char in the encrypted chars array
  62. 00CB5C66  mov         eax,dword ptr [ebp-18h]  
  63. 00CB5C69  mov         cl,byte ptr [temp_char]  
  64. 00CB5C6C  mov         byte ptr [eax+0CC0328h],cl  
  65.     }
  66. 00CB5C72  jmp         encrypt_chars+31h (0CB5C31h)  
  67.     return;
  68. 00CB5C74  jmp         encrypt4+21h (0CB5C97h)  
  69.  
  70.     // Inputs: register EAX = 32-bit address of Ekey,
  71.     // ECX = the character to be encrypted (in the low 8-bit field, CL).
  72.     // Output: register EAX = the encrypted value of the source character (in the low 8-bit field, AL).
  73.  
  74.     __asm
  75.     {
  76.     encrypt4:
  77.             push    ebp                 // Set stack
  78. 00CB5C76  push        ebp  
  79.             mov     ebp, esp            // Set up the base pointer
  80. 00CB5C77  mov         ebp,esp  
  81.  
  82.             mov     eax, [ebp + 8]      // Move value of parameter 1 into EAX
  83. 00CB5C79  mov         eax,dword ptr [length]  
  84.             mov     ecx, [ebp + 12]     // Move value of parameter 2 into ECX
  85. 00CB5C7C  mov         ecx,dword ptr [EKey]  
  86.             push    edi                 // Used for string and memory array copying
  87. 00CB5C7F  push        edi  
  88.             push    ecx                 // Loop counter for pushing character onto stack
  89. 00CB5C80  push        ecx  
  90.  
  91.             not     byte ptr[eax]       // Negation
  92. 00CB5C81  not         byte ptr [eax]  
  93.             add     byte ptr[eax], 0x04 // Adds hex 4 to EKey
  94. 00CB5C83  add         byte ptr [eax],4  
  95.             movzx   edi, byte ptr[eax]  // Moves value of EKey into EDI using zeroes
  96. 00CB5C86  movzx       edi,byte ptr [eax]  
  97.             pop     eax                 // Pop the character value from stack
  98. 00CB5C89  pop         eax  
  99.             xor     eax, edi            // XOR character to give encrypted value of source
  100. 00CB5C8A  xor         eax,edi  
  101.             pop     edi                 // Pop original address of EDI from the stack
  102. 00CB5C8C  pop         edi  
  103.  
  104.             rol     al, 1               // Rotates the encrypted value of source by 1 bit (left)
  105. 00CB5C8D  rol         al,1  
  106.             rol     al, 1               // Rotates the encrypted value of source by 1 bit (left) again
  107. 00CB5C8F  rol         al,1  
  108.             add     al, 0x04            // Adds hex 4 to encrypted value of source
  109. 00CB5C91  add         al,4  
  110.  
  111.             mov     esp, ebp            // Deallocate values
  112. 00CB5C93  mov         esp,ebp  
  113.             pop     ebp                 // Restore the base pointer
  114. 00CB5C95  pop         ebp  
  115.             ret
  116. 00CB5C96  ret  
  117.     }
  118.  
  119.     //--- End of Assembly code
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement