88 KB include stdio include string include openssl aes int main unsign

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
1.88 KB
#include <stdio.h>
#include <string.h>
#include <openssl/aes.h>
int main()
{
    unsigned char req_num[12] = "514685077602";
    unsigned long longInt = 190550043697;
    unsigned char local_84[12];
    unsigned char aes_user_key [16];
    unsigned char aes_iv [16];
    unsigned long long req_num_encrypted;
    //undefined4 uStack80;
    unsigned char formatted_req_num_encrypted [12];
    int operation_amount = 5000;
    AES_KEY aes_key;
 
    void print_hex_memory(void *mem) {
      int i;
      unsigned char *p = (unsigned char *)mem;
      for (i=0;i<8;i++) {
        printf("%02X ", p[i]);
        if ((i%16==0) && i)
          printf("\n");
      }
      printf("\n");
    }
 
    unsigned char byteArray[8];
    memset(byteArray, 0, 8);
    byteArray[0] = (char)(longInt & 0xFF );
    byteArray[1] = (char)(longInt >> 8 & 0xFF );
    byteArray[2] = (char)(longInt >> 16 & 0xFF );
    byteArray[3] = (char)(longInt >> 24 & 0xFF );
    byteArray[4] = (char)(longInt >> 32 & 0xFF );
    byteArray[5] = (char)(longInt >> 40 & 0xFF );
    byteArray[6] = (char)(longInt >> 48 & 0xFF );
    byteArray[7] = (char)(longInt >> 56 & 0xFF );
 
    memset(aes_user_key,0,0x10);
    memset(aes_iv,0,0x10);
    strcpy((char *)aes_user_key,"cityManageoffer");
    sprintf((char *)aes_iv,"initvector_%d",operation_amount);
    AES_set_encrypt_key(aes_user_key,0x80,&aes_key);
    memset(&req_num_encrypted,0,0x10);
    AES_cbc_encrypt(byteArray,(unsigned char *)&req_num_encrypted,8,&aes_key,aes_iv,1);
    print_hex_memory(&byteArray);
    printf("up: byteArray\n");
    print_hex_memory((unsigned char *)&req_num_encrypted);
    printf("%llu\n", req_num_encrypted);
    sprintf((char *)&formatted_req_num_encrypted,"%llu",req_num_encrypted); //uStack80);
    memset(&local_84,0,0xd);
    strcpy(local_84, formatted_req_num_encrypted);
    printf("%s\n", (char *)&local_84);
}