So I have to get password which "hides" somewhere here
void __regparm3 entry(undefined4 param_1,void *param_2,size_t param_3,void *param_4,size_t param_5)
{
char cVar1;
int iVar2;
size_t __n;
void *__buf;
int unaff_retaddr;
_write((int)prompt,param_2,param_3);
_read(unaff_retaddr,param_4,param_5);
iVar2 = 0;
do {
cVar1 = (**(code **)(&vfunc + (uint)(byte)(&vmp)[iVar2] * 4))(); //cant understand this
if (cVar1 != (&vmr)[__n]) {
_write((int)fail,__buf,__n);
/* WARNING: Subroutine does not return */
_exit(unaff_retaddr);
}
iVar2 = __n + 1;
} while (iVar2 != 0x17);
_write((int)success,__buf,0x17);
/* WARNING: Subroutine does not return */
_exit(unaff_retaddr);
}
I found that vmr contains 0x17 values and vmp only one: 03.
Question:
How cVar1 is created and especially what does mean this (**(code **)(&vfunc + (uint)(byte)(&vmp)[iVar2] * 4))()
? Is this line converting vmp value to some number or what else?
It's a call to a function referenced by an indexed function pointer returning something that is then stored into a char
variable but:
But anyway, the expression here says that:
vfunc
is probably an array of 32-bits integers acting like pointers towards different callback functions, without being explicitly declared as pointers (probably because of some length & format purposes) ;vmp
is probably an array contains the number of the function to be called for each particular case ;&vmp
returns the address of this array (which is useless if this is really an array, can be necessary if it's an union
or something) ;&vmp[iVar]
gets the value of entry indexed by iVar
;(uint)(byte)
then casts this value to a byte first (probably for trimming unnecessary bits) then to an integer. Remark that cast operator precedence (…)
comes after the indexing one […]
;* 4
because of 32-bits pointers, which tends to say that vfunc
does not point at natively declared pointers, otherwise the pointer arithmetic would have applied ;(code **)
, which is a "pointer to a pointer to some code". code
here is probably an alias to a function pointer declared somewhere with typedef
;(** …)
…()
;cVar1 = …