vsol

mail@pastecode.io avatar
unknown
c_cpp
a year ago
9.4 kB
61
Indexable
Never

void FUN_80439b40(int param_1,byte *param_2,undefined *param_3,uint param_4)

{
  uint *puVar1;
  int iVar2;
  uint *puVar3;
  uint *puVar4;
  uint uVar5;
  int iVar6;
  uint uVar7;
  int iVar8;
  uint uVar9;
  uint uVar10;
  uint uVar11;
  uint uVar12;
  uint uVar13;
  
  iVar2 = *(int *)(param_1 + 0x34);
  puVar3 = (uint *)(param_1 + 0x2c);
  iVar6 = *(int *)(param_1 + 0xc0);
  for (uVar5 = 0; uVar5 < param_4 >> 3; uVar5 = uVar5 + 1) {
    uVar11 = (uint)*param_2 << 0x18 | (uint)param_2[1] << 0x10 | (uint)param_2[3] |
             (uint)param_2[2] << 8;
    uVar9 = (uint)param_2[4] << 0x18 | (uint)param_2[5] << 0x10 | (uint)param_2[7] |
            (uint)param_2[6] << 8;
    if ((iVar2 == 1) && (iVar6 != 0)) {
      uVar11 = uVar11 ^ *puVar3;
      uVar9 = uVar9 ^ *(uint *)(param_1 + 0x30);
    }
    uVar7 = (uVar11 >> 4 ^ uVar9) & DAT_80439ea8;
    uVar12 = uVar7 ^ uVar9;
    uVar13 = uVar7 << 4 ^ uVar11;
    uVar7 = (uVar13 >> 0x10 ^ uVar12) & 0xffff;
    uVar12 = uVar7 ^ uVar12;
    uVar13 = uVar7 << 0x10 ^ uVar13;
    uVar7 = (uVar13 ^ uVar12 >> 2) & DAT_80439eac;
    uVar13 = uVar7 ^ uVar13;
    uVar12 = uVar7 << 2 ^ uVar12;
    uVar7 = (uVar12 >> 8 ^ uVar13) & DAT_80439eb0;
    uVar13 = uVar7 ^ uVar13;
    uVar12 = uVar12 ^ uVar7 << 8;
    uVar7 = uVar12 << 1 | uVar12 >> 0x1f;
    uVar12 = (uVar13 ^ uVar7) & DAT_80439eb4;
    uVar13 = uVar12 ^ uVar13;
    uVar12 = uVar12 ^ uVar7;
    uVar7 = uVar13 << 1 | uVar13 >> 0x1f;
    iVar8 = 0;
    puVar4 = (uint *)(param_1 + 0x38);
    do {
      uVar13 = *puVar4 ^ (uVar12 << 0x1c | uVar12 >> 4);
      uVar10 = uVar12 ^ puVar4[1];
      uVar7 = uVar7 ^ (*(uint *)(PTR_DAT_80439eb8 + (uVar13 & 0x3f) * 4) |
                       *(uint *)(PTR_DAT_80439ebc + (uVar10 >> 8 & 0x3f) * 4) |
                       *(uint *)(PTR_DAT_80439ec0 + (uVar10 & 0x3f) * 4) |
                       *(uint *)(PTR_DAT_80439ec4 + (uVar10 >> 0x10 & 0x3f) * 4) |
                       *(uint *)(PTR_PTR_DAT_80439ec8 + (uVar10 >> 0x18 & 0x3f) * 4) |
                       *(uint *)(PTR_DAT_80439ecc + (uVar13 >> 8 & 0x3f) * 4) |
                       *(uint *)(PTR_DAT_80439ed0 + (uVar13 >> 0x10 & 0x3f) * 4) |
                      *(uint *)(PTR_DAT_80439ed4 + (uVar13 >> 0x18 & 0x3f) * 4));
      uVar13 = (uVar7 << 0x1c | uVar7 >> 4) ^ puVar4[2];
      puVar1 = puVar4 + 3;
      puVar4 = puVar4 + 4;
      uVar10 = *puVar1 ^ uVar7;
      iVar8 = iVar8 + 1;
      uVar12 = uVar12 ^ (*(uint *)(PTR_DAT_80439eb8 + (uVar13 & 0x3f) * 4) |
                         *(uint *)(PTR_DAT_80439ebc + (uVar10 >> 8 & 0x3f) * 4) |
                         *(uint *)(PTR_DAT_80439ec0 + (uVar10 & 0x3f) * 4) |
                         *(uint *)(PTR_DAT_80439ec4 + (uVar10 >> 0x10 & 0x3f) * 4) |
                         *(uint *)(PTR_PTR_DAT_80439ec8 + (uVar10 >> 0x18 & 0x3f) * 4) |
                         *(uint *)(PTR_DAT_80439ecc + (uVar13 >> 8 & 0x3f) * 4) |
                         *(uint *)(PTR_DAT_80439ed0 + (uVar13 >> 0x10 & 0x3f) * 4) |
                        *(uint *)(PTR_DAT_80439ed4 + (uVar13 >> 0x18 & 0x3f) * 4));
    } while (iVar8 != 8);
    uVar12 = uVar12 << 0x1f | uVar12 >> 1;
    uVar13 = (uVar7 ^ uVar12) & DAT_80439eb4;
    uVar7 = uVar13 ^ uVar7;
    uVar13 = uVar13 ^ uVar12;
    uVar12 = uVar7 << 0x1f | uVar7 >> 1;
    uVar7 = (uVar12 >> 8 ^ uVar13) & DAT_80439eb0;
    uVar13 = uVar7 ^ uVar13;
    uVar12 = uVar7 << 8 ^ uVar12;
    uVar7 = (uVar12 >> 2 ^ uVar13) & DAT_80439eac;
    uVar13 = uVar7 ^ uVar13;
    uVar12 = uVar7 << 2 ^ uVar12;
    uVar7 = (uVar12 ^ uVar13 >> 0x10) & 0xffff;
    uVar12 = uVar12 ^ uVar7;
    uVar13 = uVar7 << 0x10 ^ uVar13;
    uVar7 = (uVar12 ^ uVar13 >> 4) & DAT_80439ea8;
    uVar12 = uVar12 ^ uVar7;
    uVar13 = uVar7 << 4 ^ uVar13;
    if (iVar2 == 1) {
      if (iVar6 == 0) {
        uVar7 = *puVar3;
        *puVar3 = uVar11;
        uVar13 = uVar13 ^ uVar7;
        uVar12 = uVar12 ^ *(uint *)(param_1 + 0x30);
      }
      else {
        *puVar3 = uVar13;
        uVar9 = uVar12;
      }
      *(uint *)(param_1 + 0x30) = uVar9;
    }
    param_2 = param_2 + 8;
    param_3[3] = (char)uVar13;
    *param_3 = (char)(uVar13 >> 0x18);
    param_3[2] = (char)(uVar13 >> 8);
    param_3[1] = (char)(uVar13 >> 0x10);
    param_3[4] = (char)(uVar12 >> 0x18);
    param_3[6] = (char)(uVar12 >> 8);
    param_3[5] = (char)(uVar12 >> 0x10);
    param_3[7] = (char)uVar12;
    param_3 = param_3 + 8;
  }
  return;
}




void FUN_8043a1c8(undefined4 vs_key_hex,undefined4 exit_mac)

{
    undefined *puVar1;
    int *piVar2;
    undefined *puVar3;
    int iVar4;
    undefined *puVar5;
    code *UNRECOVERED_JUMPTABLE;
    char local_180 [8];
    char local_178 [8];
    char local_170 [8];
    char local_168 [8];
    undefined4 local_160;
    undefined auStack_15c [32];
    undefined auStack_13c [96];
    undefined auStack_dc [36];
    undefined4 local_b8;
    undefined4 local_b4;
    undefined4 local_b0;
    undefined4 local_ac;
    undefined4 local_a8;
    uint local_1c;
    char *local_18;

    puVar5 = memcpy;
    memcpy(auStack_13c,vs_key_hex,0x60);
    local_160 = 0x38;
    (*(code *)puVar5)(auStack_15c,0x23,7);
    (*DAT_8043a320)(auStack_dc);
    local_a8 = 0;
    local_1c = 0;
    (*DAT_8043a324)(auStack_dc,&local_160);
    puVar1 = 0x26;
    puVar5 = 0x00;
    local_b0 = local_b8;
    piVar2 = 0x40;
    puVar3 = 0x00;
    do {
        iVar4 = *piVar2;
        local_18 = local_180;
        piVar2 = piVar2 + 1;
        *puVar3 = auStack_13c[iVar4];
        puVar3 = puVar3 + 1;
    } while (((uint)piVar2 ^ (uint)puVar1) != 0);
    local_ac = local_b4;
    FUN_80439b40(auStack_dc,0x00,PTR_DAT_8043a338,24);
    (*DAT_8043a33c)(local_18,local_170,PTR_DAT_8043a338);
    local_a8 = 1;
    local_1c = (uint)piVar2 ^ (uint)puVar1;
    (*DAT_8043a324)(auStack_dc,&local_160);
    (*DAT_8043a340)(auStack_dc,PTR_DAT_8043a344);
    puVar1 = 0x00;
    local_b0 = local_b8;
    piVar2 = 0x26;
    do {
        iVar4 = *piVar2;
        piVar2 = piVar2 + 1;
        *puVar5 = auStack_13c[iVar4];
        puVar5 = puVar5 + 1;
    } while (piVar2 != (int *)puVar1);
    local_ac = local_b4;
    FUN_80439b40(auStack_dc,0x00,PTR_DAT_8043a338,24);
    (*DAT_8043a33c)(local_178,local_168,PTR_DAT_8043a338);
    puVar5 = memcpy;
    iVar4 = 0;
    do {
        if (local_178[iVar4] != local_180[iVar4]) break;
        iVar4 = iVar4 + 1;
    } while (iVar4 != 6);
    iVar4 = 0;
    do {
        if (PTR_DAT_8043a34c[iVar4] != local_170[iVar4]) goto LAB_8043a2f4;
        iVar4 = iVar4 + 1;
    } while (iVar4 != 8);
    iVar4 = 0;
    do {
        if (PTR_DAT_8043a34c[iVar4] != local_168[iVar4]) break;
        iVar4 = iVar4 + 1;
    } while (iVar4 != 8);
LAB_8043a2f4:
    memcpy(exit_mac,local_180,6);
    (*(code *)puVar5)(PTR_DAT_8043a350,local_170,8);
    /* WARNING: Could not recover jumptable at 0x8043a314. Too many branches */
    /* WARNING: Treating indirect jump as call */
    (*UNRECOVERED_JUMPTABLE)();
    return;
}


void FUN_80439868(void)

{
    char cVar1;
    undefined *puVar2;
    int iVar3;
    char *pcVar4;
    code *UNRECOVERED_JUMPTABLE;
    undefined elan_mac_address [8];
    undefined key_mac_address [8];
    undefined auStack_218 [12];
    undefined auStack_20c [96];
    char local_1ac [192];
    char acStack_ec [4];
    undefined auStack_e8 [220];

    puVar2 = PTR_thunk_FUN_80122588_80439964;
    pcVar4 = local_1ac;
    (*(code *)PTR_thunk_FUN_80122588_80439964)(pcVar4,0, 193);
    (*(code *)puVar2)(auStack_e8,0,0xd2);
    (*DAT_80439968)(0xc01d,auStack_e8);
    (*DAT_80439970)(pcVar4,PTR_DAT_8043996c,auStack_e8);
    iVar3 = (*DAT_80439974)(pcVar4);
    if (iVar3 == 192) { //lenght check
        //check if all bytes are hex (I guess)
        do {
            cVar1 = *pcVar4;
            if (((9 < (byte)(cVar1 - 0x30U)) && (0x19 < (byte)(cVar1 + 0x9fU))) &&
                (0x19 < (byte)(cVar1 + 0xbfU))) goto LAB_804398d6;
            pcVar4 = pcVar4 + 1;
        } while (pcVar4 != acStack_ec);
        
        (*DAT_8043998c)(local_1ac,auStack_20c); // convert ascii to hex
        puVar2 = PTR_thunk_FUN_80122588_80439964;
        FUN_8043a1c8(auStack_20c,key_mac_address); //convert VS_KEY to mac address
        (*(code *)puVar2)(auStack_e8,0,0x20);
        (*(code *)puVar2)(auStack_218,0,0xc);
        (*DAT_80439968)(0xc001,elan_mac_address); //Get ELAN MAC ADDRESS???
        // iVar3 = (*DAT_80439994)(elan_mac_address); //check MAC
        // if (iVar3 == 0) { //mac check
            iVar3 = FUN_80439f14(elan_mac_address,key_mac_address,6); //Compare 
            if (iVar3 == 0) {
                // (*DAT_8043997c)(PTR_s_Software_encryption_check_is_fai_80439988);
                printf("Software encryption check is fail!");
            } else {
                // (*DAT_8043997c)(PTR_s_Software_encryption_check_is_suc_80439980);
                printf("Software encryption check is succeed!");
            }
        // } else {
            // //(*DAT_8043997c)(PTR_s_Software_encryption_check_is_suc_80439980);
            // printf("Software encryption check is succeed!");
        // }
    } else {
LAB_804398d6:
        printf("Software_encryption_key_is_not_set");
        // (*DAT_8043997c)(PTR_s_Software_encryption_key_is_not_s_80439978);
    }
    /* WARNING: Could not recover jumptable at 0x80439916. Too many branches */
    /* WARNING: Treating indirect jump as call */
    (*UNRECOVERED_JUMPTABLE)();
    return;
}