mirror of
https://github.com/maxDcb/C2LinuxImplant
synced 2026-06-08 15:48:43 +00:00
Update handleConfig.py
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import sys, getopt
|
||||
from Crypto.Cipher import AES
|
||||
import os
|
||||
from os import urandom
|
||||
import hashlib
|
||||
@@ -8,30 +7,12 @@ import string
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
characters = string.ascii_letters + string.digits
|
||||
password = ''.join(random.choice(characters) for i in range(16))
|
||||
|
||||
|
||||
KEY_XOR = password.replace('"','-').replace('\'','-')
|
||||
KEY_AES = urandom(16)
|
||||
|
||||
|
||||
def pad(s):
|
||||
return s + (AES.block_size - len(s) % AES.block_size) * chr(AES.block_size - len(s) % AES.block_size).encode('ISO-8859-1')
|
||||
|
||||
|
||||
def aesenc(plaintext, key):
|
||||
k = hashlib.sha256(key).digest()
|
||||
iv = 16 * b'\x00'
|
||||
plaintext = pad(plaintext)
|
||||
cipher = AES.new(k , AES.MODE_CBC, iv)
|
||||
output = cipher.encrypt(plaintext)
|
||||
return output
|
||||
|
||||
|
||||
def xor(data, key):
|
||||
|
||||
key = str(key)
|
||||
l = len(key)
|
||||
output_str = ""
|
||||
@@ -40,7 +21,7 @@ def xor(data, key):
|
||||
current = data[i]
|
||||
current_key = key[i % len(key)]
|
||||
output_str += chr(ord(current) ^ ord(current_key))
|
||||
|
||||
|
||||
return output_str
|
||||
|
||||
|
||||
@@ -49,7 +30,6 @@ def printCiphertext(ciphertext):
|
||||
|
||||
|
||||
def generateConfig(outputFilePath):
|
||||
|
||||
fileConfigJsonPath = os.path.join(Path(__file__).parent, 'BeaconConfig.json')
|
||||
fileConfig = open(fileConfigJsonPath, 'r')
|
||||
config = fileConfig.read()
|
||||
@@ -69,18 +49,13 @@ def generateConfig(outputFilePath):
|
||||
test = printCiphertext(KEY_XOR)
|
||||
fileClearContent = fileClearContent.replace("KEY_XOR", test)
|
||||
|
||||
|
||||
fileEncrypt.write(fileClearContent)
|
||||
|
||||
fileEncrypt.close()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def main(argv):
|
||||
|
||||
outputFilePath = "./cryptDef.hpp"
|
||||
|
||||
opts, args = getopt.getopt(argv,"hb:o:",["output="])
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
@@ -90,11 +65,8 @@ def main(argv):
|
||||
outputFilePath = arg
|
||||
|
||||
print('[+] Generate config:')
|
||||
|
||||
generateConfig(outputFilePath)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user