etc.git


etc

~ scripts and random things
git clone https://github.com/djnnvx/etc.git
log | files | refs | archive

xor20charkey.py (1253B)

      1 '''
      2 
      3     Author: vari.sh
      4 
      5     Description: This program XOR the shellcode
      6     
      7 '''
      8 
      9 
     10 #!/usr/bin/env python3
     11 def xor_bytes(shellcode, key_bytes):
     12     """
     13     Applies the XOR operation to each byte of the shellcode using the key.
     14     The key is repeated if the shellcode is longer.
     15     """
     16     result = []
     17     key_length = len(key_bytes)
     18     for i, b in enumerate(shellcode):
     19         result.append(b ^ key_bytes[i % key_length])
     20     return result
     21 
     22 def main():
     23     # Shellcode in the form of a list of bytes (decimal or hexadecimal)
     24     shellcode = [0xe8, 0xc0, 0x4d]
     25 
     26     # Define the key as a 20-character string.
     27     # For example: "0123456789abcdefghij"
     28     key_str = "0123456789abcdefghij"
     29     if len(key_str) != 20:
     30         print("The key must be 20 characters long!")
     31         return
     32 
     33     # Convert the key into a list of numerical values (bytes)
     34     key_bytes = [ord(c) for c in key_str]
     35 
     36     # Apply XOR to the shellcode
     37     xor_result = xor_bytes(shellcode, key_bytes)
     38 
     39     # Format the result in the same format: 0xXX, 0xXX, ...
     40     formatted_result = ", ".join("0x{:02X}".format(b) for b in xor_result)
     41     print("XORed Shellcode:")
     42     print(formatted_result)
     43 
     44 if __name__ == "__main__":
     45     main()