Skip to content

Resources

Commands

  • File Signature
    • Windows
      • HxD Screenshot - Commands
    • Linux
      • xxd
        xxd -g 1 fadymoheb.exe | more 
      • File
        file fadymoheb.exe 
      • Python
        pip install python-magic --break-system-packages
         
        m = magic.open(magic.MAGIC_NONE)
        m.load()
        ftype = m.file(r'fadymoheb.exe')
        print(ftype)
  • Fingerprinting
    • Windows
      • HashMyFiles hashmy - Commands
    • LInux
      • md5sum
        md5sum fadymoheb.exe
        
      • sha256sum
        sha256sum fadymoheb.exe
        
      • sha1sum
        sha1sum fadymoheb.exe
      • Python
        import hashlib
         
        content = open(r"fadymoheb.exe", "rb").read()
         
        print (hashlib.md5(content).hexdigest())
        print (hashlib.sha256(content).hexdigest())
        print (hashlib.sha1(content).hexdigest())
  • Scanning
    • Pestudio pestudio - Commands
    • Puppy ppee - Commands
    • VirousTotal
      pip install vt-py
      python3 vt-cli.py -anf 066fc0ece66b263eb7dcd40c3f04e799
  • Strings
    • Strings
      strings -a fadymoheb.exe
      strings -el fadymoheb.exe # unicode 
    • Obfuscated
      • floss
        floss c460fc0d4fdaf5c68623e18de106f1c3601d7bd6ba80ddad86c10fd6ea123850 -j
  • Packers
    • Upx
      strings -a sample.exe | more # use W32.Nimda.E from thezoo 
      upx -o Sample_Packed.exe .\sample.exe # Packing 
      strings -a Sample_Packed | more # See again 
      upx -d -o Sample_Unpacked.exe Sample_Packed.exe # Unpacking 
    • TrID
      trid.exe .\Sample_Packed
    • Exeinfo Exeinfo - Commands
  • PE
    • Dll Imports
      • Pe Studio pestudio2 - Commands
      • Python
        import sys
        import pefile
         
        if len(sys.argv) < 2:
            print("Usage: python3 script.py <path_to_pe_file>")
            sys.exit(1)
         
        mal_file = sys.argv[1]
        pe = pefile.PE(mal_file)
         
        if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):
            for entry in pe.DIRECTORY_ENTRY_IMPORT:
                dll_name = entry.dll.decode('utf-8', 'ignore') if entry.dll else "Unknown DLL"
                print(dll_name)
         
                for imp in entry.imports:
                    if imp.name is not None:
                        func_name = imp.name.decode('utf-8', 'ignore')
                        print(f"\t{func_name}")
                    else:
                        print(f"\tord({imp.ordinal})")
         
                print() 
    • Dll Exports
      • Pestudio Screenshot - Commands
      • Python
        import sys
        import pefile
         
        # You can replace this with sys.argv[1] if you want to pass the file via command line
        file_path = "decrypted_inj_snake_x64.dll"
         
        try:
            pe = pefile.PE(file_path)
        except FileNotFoundError:
            print("Error: Could not find the file " + file_path)
            sys.exit(1)
         
        if hasattr(pe, 'DIRECTORY_ENTRY_EXPORT'):
            for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
                # Check if the export actually has a name, as some are exported by ordinal only
                if exp.name is not None:
                    # Decode the byte string returned by pefile in Python 3
                    export_name = exp.name.decode('utf-8', 'ignore')
                    print(export_name)
                else:
                    print("ord(" + str(exp.ordinal) + ")")
        else:
            print("No export directory found in " + file_path)
    • Section Table & Sections
      • PeStudio Screenshot - Commands Screenshot - Commands
      • Python
        import sys
        import pefile
         
        if len(sys.argv) < 2:
            print("Usage: python3 script.py <path_to_pe_file>")
            sys.exit(1)
         
        file_path = sys.argv[1]
         
        try:
            pe = pefile.PE(file_path)
        except FileNotFoundError:
            print("Error: Could not find the file " + file_path)
            sys.exit(1)
         
        for section in pe.sections:
            sec_name = section.Name.decode('utf-8', 'ignore').rstrip('\x00')
            print(f"{sec_name} {hex(section.VirtualAddress)} {hex(section.Misc_VirtualSize)} {section.SizeOfRawData}")
         
        print()
    • TimeStamp
      • Pestudio Screenshot - Commands
      • Python
        import sys
        import time
        import pefile
         
        if len(sys.argv) < 2:
            print("Usage: python3 script.py <path_to_pe_file>")
            sys.exit(1)
         
        file_path = sys.argv[1]
         
        try:
            pe = pefile.PE(file_path)
        except FileNotFoundError:
            print("Error: Could not find the file " + file_path)
            sys.exit(1)
         
        # Extract the raw Unix epoch timestamp from the PE header
        timestamp = pe.FILE_HEADER.TimeDateStamp
         
        # Convert the timestamp to a human-readable format.
        # time.gmtime() is used instead of time.localtime() to enforce UTC output.
        formatted_time = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(timestamp))
         
        print("Compile Time: " + formatted_time + " (UTC)")
    • Resources
      • Resourcehacker Screenshot - Commands
  • Comparing & Classifying
    • Hashing
      • Ssdeep
        ssdeep -pb * # Shows with the score 
        ssdeep -lrpa sampels/ # dirs with nested files 
         
        ssdeep * > all_hashes.txt # generate hashes 
        ssdeep -m all_hashes.txt Sample_Packed # Compare agains hashes file 
        • Python
          import sys
          import ssdeep
           
          if len(sys.argv) < 3:
              print("Usage: python3 script.py <file1> <file2>")
              sys.exit(1)
           
          file1 = sys.argv[1]
          file2 = sys.argv[2]
           
          try:
              hash1 = ssdeep.hash_from_file(file1)
              print("Hash 1: " + hash1)
           
              hash2 = ssdeep.hash_from_file(file2)
              print("Hash 2: " + hash2)
           
              similarity_score = ssdeep.compare(hash1, hash2)
              print("Similarity Score: " + str(similarity_score) + "%")
           
          except Exception as e:
              print("Error processing files: " + str(e))
    • Imphash
      • Tlsh
        tlsh -f sample.exe
        tlsh -c sample.exe -f Sample_Packed
      • Pestudio imphash - Commands
      • Python
        import sys
        import pefile
         
        if len(sys.argv) < 2:
            print("Usage: python3 script.py <path_to_pe_file>")
            sys.exit(1)
         
        file_path = sys.argv[1]
         
        try:
            pe = pefile.PE(file_path)
            imphash = pe.get_imphash()
            print(imphash)
        except pefile.PEFormatError:
            print("Error: The provided file is not a valid Windows PE file.")
            sys.exit(1)
        except FileNotFoundError:
            print("Error: Could not find the file " + file_path)
            sys.exit(1)
    • Section Hash
      • Pestudio Screenshot - Commands
    • Python
      import sys
      import pefile
       
      if len(sys.argv) < 2:
          print("Usage: python3 script.py <path_to_pe_file>")
          sys.exit(1)
       
      file_path = sys.argv[1]
       
      try:
          pe = pefile.PE(file_path)
      except pefile.PEFormatError:
          print("Error: The provided file is not a valid Windows PE file.")
          sys.exit(1)
      except FileNotFoundError:
          print("Error: Could not find the file " + file_path)
          sys.exit(1)
       
      print("Section\tMD5 Hash")
      print("-" * 40)
       
      for section in pe.sections:
          # Decode the byte string and strip trailing null bytes for clean output
          sec_name = section.Name.decode('utf-8', 'ignore').rstrip('\x00')
       
          # Extract the MD5 hash of the section
          sec_hash = section.get_hash_md5()
       
          print(f"{sec_name}\t{sec_hash}")
  • Yara
    • Yaragen-Go
      • Installation
        go install github.com/Neo23x0/yarGen-go/cmd/yargen@latest
        go install github.com/Neo23x0/yarGen-go/cmd/yargen-util@latest
        yargen-util update
      • Parctical
        yargen -m sample.exe  -o sample.yar -a 'fady' -no-llm
        yara W32.Nimda.E/sample.yar W32.Nimda.E/ [-r] [-c]

Tools

Notes