diff --git a/CHANGELOG.md b/CHANGELOG.md index 07362751..d90c3eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ - main: fix `KeyError: 0` when reporting results @williballehtin #703 - main: fix potential false negatives due to namespaces across scopes @williballenthin #721 +- linter: suppress some warnings about imports from ntdll/ntoskrnl @williballenthin #743 ### capa explorer IDA Pro plugin diff --git a/scripts/lint.py b/scripts/lint.py index 4e467e3f..ad2b9b11 100644 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -353,7 +353,7 @@ class FeatureNegativeNumber(Lint): class FeatureNtdllNtoskrnlApi(Lint): name = "feature api may overlap with ntdll and ntoskrnl" level = Lint.WARN - recommendation = ( + recommendation_template = ( "check if {:s} is exported by both ntdll and ntoskrnl; if true, consider removing {:s} " "module requirement to improve detection" ) @@ -362,8 +362,51 @@ class FeatureNtdllNtoskrnlApi(Lint): for feature in features: if isinstance(feature, capa.features.insn.API): modname, _, impname = feature.value.rpartition(".") + + if modname == "ntdll": + if impname in ( + "LdrGetProcedureAddress", + "LdrLoadDll", + "NtCreateThread", + "NtCreatUserProcess", + "NtLoadDriver", + "NtQueryDirectoryObject", + "NtResumeThread", + "NtSuspendThread", + "NtTerminateProcess", + "NtWriteVirtualMemory", + "RtlGetNativeSystemInformation", + "NtCreateThreadEx", + "NtCreateUserProcess", + "NtOpenDirectoryObject", + "NtQueueApcThread", + "ZwResumeThread", + "ZwSuspendThread", + "ZwWriteVirtualMemory", + "NtCreateProcess", + "ZwCreateThread", + "NtCreateProcessEx", + "ZwCreateThreadEx", + "ZwCreateProcess", + "ZwCreateUserProcess", + "RtlCreateUserProcess", + ): + # ntoskrnl.exe does not export these routines + continue + + if modname == "ntoskrnl": + if impname in ( + "PsGetVersion", + "PsLookupProcessByProcessId", + "KeStackAttachProcess", + "ObfDereferenceObject", + "KeUnstackDetachProcess", + ): + # ntdll.dll does not export these routines + continue + if modname in ("ntdll", "ntoskrnl"): - self.recommendation = self.recommendation.format(impname, modname) + self.recommendation = self.recommendation_template.format(impname, modname) return True return False