removed signing, doesn't work.
This commit is contained in:
9
gui.py
9
gui.py
@@ -15,12 +15,12 @@ TODO :
|
|||||||
- Add resources
|
- Add resources
|
||||||
- Change PE metadata (company, description, etc...)
|
- Change PE metadata (company, description, etc...)
|
||||||
- Random Windows API calls (help)
|
- Random Windows API calls (help)
|
||||||
|
- Code signing (optional)
|
||||||
|
|
||||||
Done :
|
Done :
|
||||||
- RunPE
|
- RunPE
|
||||||
- Junk code
|
- Junk code
|
||||||
- Control flow
|
- Control flow
|
||||||
- Code signing
|
|
||||||
- IAT obfuscation (adding "normal" imports in addition to the others)
|
- IAT obfuscation (adding "normal" imports in addition to the others)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtCore import QCoreApplication
|
from PyQt5.QtCore import QCoreApplication
|
||||||
from obfuscation import obfuscate
|
from obfuscation import obfuscate
|
||||||
from sign import sign
|
|
||||||
import os, shutil
|
import os, shutil
|
||||||
|
|
||||||
class Ui_mainWindow(object):
|
class Ui_mainWindow(object):
|
||||||
@@ -180,11 +179,7 @@ class Ui_mainWindow(object):
|
|||||||
if return_code :
|
if return_code :
|
||||||
self.label_2.setText("build failed.")
|
self.label_2.setText("build failed.")
|
||||||
QCoreApplication.processEvents()
|
QCoreApplication.processEvents()
|
||||||
else :
|
|
||||||
self.label_2.setText("Signing the file...")
|
|
||||||
QCoreApplication.processEvents()
|
|
||||||
sign(out_filename)
|
|
||||||
|
|
||||||
# Cleaning up..
|
# Cleaning up..
|
||||||
os.remove("main.cpp")
|
os.remove("main.cpp")
|
||||||
os.rename("DO_NOT_TOUCH.cpp", "main.cpp")
|
os.rename("DO_NOT_TOUCH.cpp", "main.cpp")
|
||||||
|
|||||||
83
sign.py
83
sign.py
@@ -1,83 +0,0 @@
|
|||||||
from OpenSSL import crypto, SSL
|
|
||||||
from Crypto.Signature import pkcs1_15
|
|
||||||
from Crypto.Hash import SHA256
|
|
||||||
from Crypto.PublicKey import RSA
|
|
||||||
from randomness import *
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def cert_gen(
|
|
||||||
emailAddress=GetRandomString(10)+"@gmail.com",
|
|
||||||
commonName=GetRandomString(10),
|
|
||||||
countryName="NT",
|
|
||||||
localityName=GetRandomString(10),
|
|
||||||
stateOrProvinceName=GetRandomString(10),
|
|
||||||
organizationName=GetRandomString(10),
|
|
||||||
organizationUnitName=GetRandomString(10),
|
|
||||||
serialNumber=0,
|
|
||||||
validityStartInSeconds=0,
|
|
||||||
validityEndInSeconds=10*365*24*60*60,
|
|
||||||
KEY_FILE = "private.key",
|
|
||||||
CERT_FILE="selfsigned.crt"):
|
|
||||||
#can look at generated file using openssl:
|
|
||||||
#openssl x509 -inform pem -in selfsigned.crt -noout -text
|
|
||||||
# create a key pair
|
|
||||||
k = crypto.PKey()
|
|
||||||
k.generate_key(crypto.TYPE_RSA, 4096)
|
|
||||||
# create a self-signed cert
|
|
||||||
cert = crypto.X509()
|
|
||||||
cert.get_subject().C = countryName
|
|
||||||
cert.get_subject().ST = stateOrProvinceName
|
|
||||||
cert.get_subject().L = localityName
|
|
||||||
cert.get_subject().O = organizationName
|
|
||||||
cert.get_subject().OU = organizationUnitName
|
|
||||||
cert.get_subject().CN = commonName
|
|
||||||
cert.get_subject().emailAddress = emailAddress
|
|
||||||
cert.set_serial_number(serialNumber)
|
|
||||||
cert.gmtime_adj_notBefore(0)
|
|
||||||
cert.gmtime_adj_notAfter(validityEndInSeconds)
|
|
||||||
cert.set_issuer(cert.get_subject())
|
|
||||||
cert.set_pubkey(k)
|
|
||||||
cert.sign(k, 'sha512')
|
|
||||||
with open(CERT_FILE, "wt") as f:
|
|
||||||
f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode("utf-8"))
|
|
||||||
with open(KEY_FILE, "wt") as f:
|
|
||||||
f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, k).decode("utf-8"))
|
|
||||||
|
|
||||||
def sign(filename) :
|
|
||||||
cert_gen()
|
|
||||||
# Load the private key
|
|
||||||
with open('private.key', 'rb') as private_key_file:
|
|
||||||
private_key_data = private_key_file.read()
|
|
||||||
private_key = RSA.import_key(private_key_data)
|
|
||||||
|
|
||||||
# Load the .cert file (assuming it contains the certificate in PEM format)
|
|
||||||
with open('selfsigned.crt', 'rb') as cert_file:
|
|
||||||
certificate_data = cert_file.read()
|
|
||||||
|
|
||||||
# Load the .exe file to be signed
|
|
||||||
with open(filename, 'rb') as exe_file:
|
|
||||||
exe_data = exe_file.read()
|
|
||||||
|
|
||||||
# Compute the SHA-256 hash of the .exe file
|
|
||||||
hash_obj = SHA256.new(exe_data)
|
|
||||||
|
|
||||||
# Sign the hash using the private key
|
|
||||||
signature = pkcs1_15.new(private_key).sign(hash_obj)
|
|
||||||
|
|
||||||
# Save the signature to a file
|
|
||||||
with open('signature.sig', 'wb') as signature_file:
|
|
||||||
signature_file.write(signature)
|
|
||||||
|
|
||||||
# Combine the .exe file and the signature
|
|
||||||
signed_exe = exe_data + signature
|
|
||||||
|
|
||||||
# Save the signed .exe file
|
|
||||||
with open(filename, 'wb') as signed_exe_file:
|
|
||||||
signed_exe_file.write(signed_exe)
|
|
||||||
|
|
||||||
print(f"Successfully signed {filename}.")
|
|
||||||
|
|
||||||
os.remove("selfsigned.crt")
|
|
||||||
os.remove("private.key")
|
|
||||||
os.remove("signature.sig")
|
|
||||||
Reference in New Issue
Block a user