casp3r0x0@home:~$

Polymorphic Signature Change Hash Of The Malware For Every Execution

[Polymorphic Signature] Change hash of the malware for every execution

About

in this blog we are going to talk about make the malware change its own hash by it self for every execution utilizing self deletion method .

advantages for red teamer

imagine that your malware detected in the environment for some reason for example post exploitation mistake , and you have multiple beacons runs on 5 devices if the SOC team block the malware hash and they investigated then they would find your malware very quickly which result of kick you out of the environment .

also using this method will bypass autoblock in that is implemented using SOAR.

How ?

Files in NTFS file systems can have multiple streams of data in addition to the default stream, :$DATA. :$DATA exists for every file, providing an alternative means of accessing them. as we know we can not delete a file that is currently used by a process , one way to get around this is by renaming the default data stream :$DATA to another random name that represents a new data stream.

steps to preform self deletion

  1. Retrieve File Handle
  2. Renaming The Data Stream
  3. Deleting The Data Stream
  4. Refreshing File Data Stream

implementation in C#

you can find the implementation here https://github.com/casp3r0x0/PolymorphicSignature/tree/main

steps

  1. read the current executable as byte array
  2. append random bytes to it
  3. do a self deletion
  4. write new bytes to disk (old bytes + appended byte array)
  5. done.

using this way every time the executable executed we will see a deferent hash see the following image :