Delete app.py
Browse files
app.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
from Crypto.Cipher import AES
|
2 |
-
from Crypto.Protocol.KDF import PBKDF2
|
3 |
-
import os
|
4 |
-
import tempfile
|
5 |
-
from dotenv import load_dotenv
|
6 |
-
|
7 |
-
load_dotenv() # Load all environment variables
|
8 |
-
|
9 |
-
def unpad(data):
|
10 |
-
return data[:-data[-1]]
|
11 |
-
|
12 |
-
def decrypt_and_run():
|
13 |
-
# Get password from Hugging Face Secrets environment variable
|
14 |
-
password = os.getenv("PASSWORD")
|
15 |
-
if not password:
|
16 |
-
raise ValueError("PASSWORD secret not found in environment variables")
|
17 |
-
|
18 |
-
password = password.encode()
|
19 |
-
|
20 |
-
with open("code.enc", "rb") as f:
|
21 |
-
encrypted = f.read()
|
22 |
-
|
23 |
-
salt = encrypted[:16]
|
24 |
-
iv = encrypted[16:32]
|
25 |
-
ciphertext = encrypted[32:]
|
26 |
-
|
27 |
-
key = PBKDF2(password, salt, dkLen=32, count=1000000)
|
28 |
-
cipher = AES.new(key, AES.MODE_CBC, iv)
|
29 |
-
|
30 |
-
plaintext = unpad(cipher.decrypt(ciphertext))
|
31 |
-
|
32 |
-
with tempfile.NamedTemporaryFile(suffix=".py", delete=False, mode='wb') as tmp:
|
33 |
-
tmp.write(plaintext)
|
34 |
-
tmp.flush()
|
35 |
-
print(f"[INFO] Running decrypted code from {tmp.name}")
|
36 |
-
os.system(f"python {tmp.name}")
|
37 |
-
|
38 |
-
if __name__ == "__main__":
|
39 |
-
decrypt_and_run()
|
40 |
-
|
41 |
-
# This script decrypts the encrypted code and runs it.
|
42 |
-
# Ensure you have the PASSWORD secret set in your Hugging Face Secrets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|