Advertisement
krot

hlenc

May 11th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.81 KB | None | 0 0
  1. void hldec(unsigned char *buff, unsigned int pcksz) {
  2.     #define HL_NTOHL(x)  \
  3.        ((((x) & 0xff000000) >> 24) | \
  4.         (((x) & 0x00ff0000) >>  8) | \
  5.         (((x) & 0x0000ff00) <<  8) | \
  6.         (((x) & 0x000000ff) << 24))
  7.  
  8.     const static unsigned char  hlhash[] =
  9.                     "\x05\x61\x7A\xED\x1B\xCA\x0D\x9B\x4A\xF1\x64\xC7\xB5\x8E\xDF\xA0";
  10.     unsigned char   *ptrebpc;
  11.     unsigned int   *lbuff = (unsigned int *)buff,
  12.                     pcknum,
  13.                     invnum,
  14.                     ebpc;
  15.     int             cont,
  16.                     i;
  17.  
  18.     if(pcksz < 9) return;
  19.     pcknum = *buff;
  20.     invnum = ~pcknum;
  21.     pcksz = (pcksz - 8) >> 2;
  22.     lbuff += 2;
  23.     cont = 0;
  24.  
  25.     while(pcksz--) {
  26.         ebpc = *lbuff ^ pcknum;
  27.  
  28.         ptrebpc = (unsigned char *)&ebpc;
  29.         for(i = 0; i < 4; i++) {
  30.             *ptrebpc ^= (((hlhash[(cont + i) & 0xf] | (i << i)) | i) | 0xA5);
  31.             ptrebpc++;
  32.         }
  33.  
  34.         *lbuff = HL_NTOHL(ebpc) ^ invnum;
  35.         lbuff++;
  36.         cont++;
  37.     }
  38. }
  39.  
  40. int main()
  41. {
  42.     unsigned char msg[] = "\x02\x00\x00\xc0\x01\x00\x00\x80Y\x18\x01\x03\x99\x00\x10Bg\x19@\x020/x!\x0fQ\x0b`2\r\x18Zp\x14CG+tePfkup(8=bq|%\x10n+5ph7n+7 ?6kv<q6-tl*6ie/2*- %q2~/sy6s5,~#%\"4.y,+wnw(gb,9(\'p\x11\x18Jwt\'3 <3e,>s5`f69,1?~wbwr,)0\'p5\n\x00";
  43.     printf("ds", strlen(msg)
  44.     hldec(msg, 148);
  45.     unsigned char* mmm = msg;
  46.     printf("hello");
  47.     printf("%s here",mmm);
  48.     return 0;
  49. }
  50.  
  51.  
  52.  
  53.  
  54.     <?php
  55.      
  56.         function HL_NTOHL($x)
  57.         {
  58.             return ((($x) & 0xff000000) >> 24) | ((($x) & 0x00ff0000) >>  8) | ((($x) & 0x0000ff00) <<  8) | ((($x) & 0x000000ff) << 24);
  59.         }
  60.      
  61.         function pre_hldec($str)
  62.         {
  63.             hldec(str_split($str), strlen($str), $str);
  64.         }
  65.      
  66.         function int_to_byte_array($int)
  67.         {
  68.             return unpack("c*", pack("l", $int));
  69.         }
  70.      
  71.       function hldec($buff, $pcksz, $bin_str)
  72.       {
  73.               $hlhash =
  74.                         "\x05\x61\x7A\xED\x1B\xCA\x0D\x9B\x4A\xF1\x64\xC7\xB5\x8E\xDF\xA0";
  75.         $lbuff = unpack("l*", $bin_str);
  76.      
  77.         if($pcksz < 9) return;
  78.         $pcknum = $buff[1];
  79.         $invnum = ~$pcknum;
  80.         $pcksz = ($pcksz - 8) >> 2;
  81.         $ilbuff = 3;
  82.         $cont = 0;
  83.      
  84.         while($pcksz--) {
  85.             $ebpc = $lbuff[$ilbuff] ^ $pcknum;
  86.      
  87.             $ptrebpc = int_to_byte_array($ebpc);
  88.             for($i = 1; $i <= 4; $i++) {
  89.                 $ptrebpc[$i] ^= ((($hlhash[($cont + $i) & 0xf] | ($i << $i)) | $i) | 0xA5);
  90.             }
  91.      
  92.             $lbuff[$ilbuff] = HL_NTOHL($ebpc) ^ $invnum;
  93.             $ilbuff++;
  94.             $cont++;
  95.         }
  96.      
  97.         return pack("l*", $lbuff);
  98.       }
  99.      
  100.       echo hldec("DeadBeafDeadBeaf");
  101.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement