//
// sub_E23168 from 0xe23168 to 0xe235fc (1172 bytes)
//
// 1 xrefs:
// > sub_E238EC @ 0xe23948
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:09:47 +0000
//
__int64 __fastcall sub_E23168(__int64 a1, char *a2)
{
const char *v2; // x20
__int64 v4; // x0
char *v5; // x22
char *v6; // x24
signed __int64 v7; // x22
int *v8; // x0
__int64 v9; // x20
const char *v10; // x0
char *v11; // x0
char *v12; // x0
char *pw_name; // x22
__uid_t v14; // w0
int *v15; // x0
__int64 v16; // x20
const char *v17; // x0
__pid_t v18; // w0
int v19; // w26
int v20; // w19
__int64 v21; // x20
const char *v22; // x0
__uid_t v23; // w0
int v24; // w20
__int64 v25; // x22
const char *v26; // x0
int *v27; // x0
__int64 v28; // x19
const char *v29; // x0
int *v30; // x0
__int64 v31; // x19
const char *v32; // x0
int v33; // [xsp+68h] [xbp+58h]
int v34; // [xsp+68h] [xbp+58h]
int v35; // [xsp+68h] [xbp+58h]
int v36; // [xsp+68h] [xbp+58h]
int v37; // [xsp+78h] [xbp+68h] BYREF
int v38; // [xsp+7Ch] [xbp+6Ch]
struct passwd *result; // [xsp+80h] [xbp+70h] BYREF
struct passwd resultbuf; // [xsp+88h] [xbp+78h] BYREF
char buffer[1024]; // [xsp+B8h] [xbp+A8h] BYREF
v2 = a2;
v4 = 0;
if ( *(_QWORD *)(a1 + 1264) != 0xFFFFFFFFLL )
return v4;
if ( !a2 || !*a2 )
{
v11 = getenv("NTLMUSER");
if ( v11 && *v11 || (v11 = getenv("LOGNAME")) != nullptr && *v11 )
{
v2 = v11;
goto LABEL_4;
}
v12 = getenv("USER");
pw_name = v12;
if ( v12 )
{
if ( *v12 )
{
v2 = v12;
goto LABEL_4;
}
v14 = geteuid();
if ( getpwuid_r(v14, &resultbuf, buffer, 0x400u, &result) || !result )
goto LABEL_19;
}
else
{
v23 = geteuid();
if ( getpwuid_r(v23, &resultbuf, buffer, 0x400u, &result) || !result )
goto LABEL_4;
}
pw_name = resultbuf.pw_name;
if ( !resultbuf.pw_name )
goto LABEL_4;
LABEL_19:
if ( *pw_name )
v2 = pw_name;
}
LABEL_4:
v5 = strpbrk(v2, "\\/");
if ( v5 )
{
v6 = off_154A3D8(v2);
if ( !v6 )
return 27;
v7 = v5 - v2;
v2 += v7 + 1;
v6[v7] = 0;
}
else
{
v6 = nullptr;
}
if ( access("/usr/bin/ntlm_auth", 1) )
{
v8 = (int *)__errno();
v9 = *(_QWORD *)a1;
v33 = *v8;
v10 = (const char *)sub_E15618(a1, *v8);
sub_DF1848(v9, "Could not access ntlm_auth: %s errno %d: %s", "/usr/bin/ntlm_auth", v33, v10);
LABEL_9:
off_154A3C8(v6);
off_154A3C8(nullptr);
return 9;
}
if ( socketpair(1, 1, 0, &v37) )
{
v15 = (int *)__errno();
v16 = *(_QWORD *)a1;
v34 = *v15;
v17 = (const char *)sub_E15618(a1, *v15);
sub_DF1848(v16, "Could not open socket pair. errno %d: %s", v34, v17);
goto LABEL_9;
}
v18 = fork();
v19 = v18;
if ( v18 == -1 )
{
v24 = *(_DWORD *)__errno();
close(v37);
close(v38);
v25 = *(_QWORD *)a1;
v26 = (const char *)sub_E15618(a1, v24);
sub_DF1848(v25, "Could not fork. errno %d: %s", v24, v26);
goto LABEL_9;
}
if ( !v18 )
{
close(v37);
if ( dup2(v38, v19) != -1 )
{
if ( dup2(v38, 1) != -1 )
{
if ( v6 )
execl(
"/usr/bin/ntlm_auth",
"/usr/bin/ntlm_auth",
"--helper-protocol",
"ntlmssp-client-1",
"--use-cached-creds",
"--username",
v2,
"--domain",
v6,
0);
else
execl(
"/usr/bin/ntlm_auth",
"/usr/bin/ntlm_auth",
"--helper-protocol",
"ntlmssp-client-1",
"--use-cached-creds",
"--username",
v2,
0);
v20 = *(_DWORD *)__errno();
close(v38);
v21 = *(_QWORD *)a1;
v22 = (const char *)sub_E15618(a1, v20);
sub_DF1848(v21, "Could not execl(). errno %d: %s", v20, v22);
exit(1);
}
v27 = (int *)__errno();
v28 = *(_QWORD *)a1;
v35 = *v27;
v29 = (const char *)sub_E15618(a1, *v27);
sub_DF1848(v28, "Could not redirect child stdout. errno %d: %s", v35, v29);
exit(1);
}
v30 = (int *)__errno();
v31 = *(_QWORD *)a1;
v36 = *v30;
v32 = (const char *)sub_E15618(a1, *v30);
sub_DF1848(v31, "Could not redirect child stdin. errno %d: %s", v36, v32);
exit(1);
}
close(v38);
*(_DWORD *)(a1 + 1268) = v19;
*(_DWORD *)(a1 + 1264) = v37;
off_154A3C8(v6);
off_154A3C8(nullptr);
return 0;
}