Cleanup techniques

← maldev README · docs/index

On-host artifact removal and anti-forensics primitives applied at the end of an operation. Each package targets one specific class of artifact (file on disk, memory region, NTFS timestamp, service registration, in-memory state). Compose them as the implant tears itself down.

TL;DR

flowchart LR
    A[wipe sensitive memory] --> B[reset timestamps]
    B --> C[remove files]
    C --> D[hide service / clear logs]
    D --> E[self-delete or BSOD]

A typical end-of-mission chain: memory.WipeAndFree keys → timestomp any artefacts you can't delete → wipe.File what you can → service.HideService or unregister → selfdelete.Run (or bsod.Trigger if egress is critical).

Packages

PackageTech pageDetectionOne-liner
cleanup/adsads.mdquietNTFS Alternate Data Streams CRUD
cleanup/bsodbsod.mdvery-noisyTrigger BSOD via NtRaiseHardError — last-resort kill switch
cleanup/memorymemory-wipe.mdvery-quietSecureZero / WipeAndFree / DoSecret for in-process secrets
cleanup/selfdeleteself-delete.mdmoderateDelete the running EXE via NTFS ADS rename + delete-on-close
cleanup/serviceservice.mdnoisyHide a Windows service via DACL manipulation
cleanup/timestomptimestomp.mdquietReset $STANDARD_INFORMATION MAC timestamps
cleanup/wipewipe.mdquietMulti-pass random overwrite then os.Remove

Quick decision tree

You want to…Use
…forget keys/credentials still in process memorymemory.SecureZero or memory.WipeAndFree
…make a dropped artefact's mtime match notepad.exetimestomp.CopyFrom
…shred a file before removing itwipe.File (low-volume forensics) or pair it with timestomp
…delete the running EXE and exit cleanlyselfdelete.Run
…terminate the host immediately to stop log shippingbsod.Trigger (last resort)
…hide a Windows service from services.mscservice.HideService
…stash a payload on disk where Explorer can't see itads.Write

MITRE ATT&CK

T-IDNamePackagesD3FEND counter
T1070Indicator Removalcleanup/memory, cleanup/timestomp, cleanup/wipe, cleanup/selfdeleteD3-RAPA, D3-PFV
T1070.004File Deletioncleanup/wipe, cleanup/selfdeleteD3-PFV
T1070.006Timestompcleanup/timestompD3-FH (File Hashing)
T1529System Shutdown/Rebootcleanup/bsodD3-PSEP
T1543.003Create or Modify System Process: Windows Servicecleanup/serviceD3-RAPA
T1564Hide Artifactscleanup/service, cleanup/adsD3-RAPA
T1564.004NTFS File Attributescleanup/adsD3-FCR (File Content Rules)

See also