Last active
May 2, 2021 14:42
-
-
Save 4rchib4ld/98ca1b860c301afbba63b9617d4a00d8 to your computer and use it in GitHub Desktop.
Extract IcedID C2 domain name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import binascii | |
import string | |
import pefile | |
import argparse | |
def extractPayload(file): | |
# Extracting the payload from the .data section | |
print("[+] Extracting the payload...") | |
pe = pefile.PE(file) | |
for section in pe.sections: | |
if ".data" in str(section.Name): | |
print("[+] Done !") | |
return section.get_data() | |
def decodePayload(payload): | |
decrypted = "" | |
for i in range(32): | |
decrypted += chr(payload[i+64] ^ payload[i]) | |
return decrypted.split("\x00")[0] | |
def main(): | |
parser = argparse.ArgumentParser(description='Decrypt the IcedID config') | |
parser.add_argument('-f', '--file', help='Path of the binary file', required=True) | |
args = parser.parse_args() | |
payload = extractPayload(args.file) | |
config = decodePayload(payload[4:]) #skipping the first 4 bytes | |
print(f"The C2 config is : {config}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment