Skip to content

Commit 31e8d3e

Browse files
committed
Better system
1 parent c00e4ca commit 31e8d3e

File tree

2 files changed

+120
-30
lines changed

2 files changed

+120
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ passing only a folder will decrypt all .lua files in the directory.
2121
python birdout.py <directory> <directory> ...
2222

2323
Understandable, if you don't trust the .exe or the .jar file: openssl.exe. here is a virustotal scan: [virustotal](https://www.virustotal.com/gui/file/be0f086b9303fd52b6f5ec094c753c2b68f02559eb462f23929e72a6996eb1f8/detection/f-be0f086b9303fd52b6f5ec094c753c2b68f02559eb462f23929e72a6996eb1f8-1703249224)
24-
and here scan for the unluac.jar: [virustotal](https://www.virustotal.com/gui/file/50f23c0b1cb85cc2bd07055ce782a918fdcb5d36d18d268b9606298d801bbb6e/detection/f-50f23c0b1cb85cc2bd07055ce782a918fdcb5d36d18d268b9606298d801bbb6e-1689512688). You can also just you own version of openssl if you already have on you PATH, just change the one line of code in the [.py](https://github.com/jooapa/Angry_Birds_Decompilation/blob/master/birdout.py#L119) from `combined_path = os.path.join(org_path, "bin/openssl")` to `combined_path = "openssl"`
24+
and here scan for the unluac.jar: [virustotal](https://www.virustotal.com/gui/file/50f23c0b1cb85cc2bd07055ce782a918fdcb5d36d18d268b9606298d801bbb6e/detection/f-50f23c0b1cb85cc2bd07055ce782a918fdcb5d36d18d268b9606298d801bbb6e-1689512688). You can also just you own version of openssl, the program will ask you, if you want to use the one in the folder.
2525

2626
## Manual Usage
2727

birdout.py

Lines changed: 119 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, sys, subprocess
22

3-
class col:
3+
class C:
44
HEADER = '\033[95m'
55
OKBLUE = '\033[94m'
66
OKCYAN = '\033[96m'
@@ -22,22 +22,105 @@ class col:
2222
path_to_current_lua_file = []
2323

2424
if len(arg_files) == 0:
25-
print(col.FAIL + "Usage: birdout.py <file.lua> <file.lua> ..." + col.ENDC)
25+
print(C.FAIL + "Usage: birdout.py <file.lua> <file.lua> ..." + C.ENDC)
2626
print("You can also pass a directory as an argument to decrypt all .lua files in it.")
2727
sys.exit(1)
28+
29+
bin_folder_exists = False
30+
# check if bin folder exists
31+
if not os.path.exists(os.path.join(org_path, "bin")):
32+
print(f"{C.FAIL}bin folder not found! nöf nöf!{C.ENDC}")
33+
bin_folder_exists = False
34+
else:
35+
bin_folder_exists = True
2836

37+
# check if openssl is installed
38+
have_openSSL = False
39+
if os.name == 'nt':
40+
try:
41+
subprocess.run(["openssl", "version"], capture_output=True)
42+
have_openSSL = True
43+
print(f"{C.OKGREEN}OpenSSL found!{C.ENDC}")
44+
except FileNotFoundError:
45+
have_openSSL = False
46+
print(f"{C.FAIL}OpenSSL not found! {C.WARNING}Using the bundled version of OpenSSL in the bin folder.{C.ENDC}")
47+
elif os.name == 'posix':
48+
try:
49+
subprocess.run(["which", "openssl"], capture_output=True)
50+
have_openSSL = True
51+
print(f"{C.OKGREEN}OpenSSL found!{C.ENDC}")
52+
except FileNotFoundError:
53+
have_openSSL = False
54+
print(f"{C.FAIL}OpenSSL not found!\n{C.WARNING}Using the bundled version of OpenSSL in the bin folder.{C.ENDC}")
55+
56+
if not bin_folder_exists and not have_openSSL:
57+
print(f"{C.FAIL}No bin folder so can't use bundled OpenSSL! nöf nöf!{C.ENDC}\n{C.WARNING}Please install OpenSSL and add it to PATH or download the bin folder from the repository.{C.ENDC}")
58+
sys.exit(1)
59+
60+
# check if java is installed
61+
have_java = False
62+
if os.name == 'nt':
63+
try:
64+
subprocess.run(["java", "-version"], capture_output=True)
65+
have_java = True
66+
print(f"{C.OKGREEN}Java found!{C.ENDC}")
67+
except FileNotFoundError:
68+
have_java = False
69+
print(f"{C.FAIL}Java not found!{C.ENDC}")
70+
elif os.name == 'posix':
71+
try:
72+
subprocess.run(["which", "java"], capture_output=True)
73+
have_java = True
74+
print(f"{C.OKGREEN}Java found!{C.ENDC}")
75+
except FileNotFoundError:
76+
have_java = False
77+
print(f"{C.FAIL}Java not found!{C.ENDC}")
78+
79+
if not have_java:
80+
print(f"{C.FAIL}Java is required for decrypting .lua files! \nTry using this guide https://www.freecodecamp.org/news/how-to-set-up-java-development-environment-a-comprehensive-guide/{C.ENDC}")
81+
sys.exit(1)
82+
83+
# check if unluac.jar exists
84+
if not os.path.exists(os.path.join(org_path, "bin", "unluac.jar")):
85+
print(f"{C.FAIL}unluac.jar not found! nöf nöf!{C.WARNING}\n Add unluac.jar to the bin folder.{C.ENDC}")
86+
sys.exit(1)
87+
88+
# check if 7z is installed
89+
have_7z = False
90+
if os.name == 'nt':
91+
try:
92+
subprocess.run(["7z", "version"], capture_output=True)
93+
have_7z = True
94+
print(f"{C.OKGREEN}7z found!{C.ENDC}")
95+
except FileNotFoundError:
96+
have_7z = False
97+
print(f"{C.FAIL}7z not found!{C.ENDC}")
98+
elif os.name == 'posix':
99+
try:
100+
subprocess.run(["which", "7z"], capture_output=True)
101+
have_7z = True
102+
print(f"{C.OKGREEN}7z found!{C.ENDC}")
103+
except FileNotFoundError:
104+
have_7z = False
105+
print(f"{C.FAIL}7z not found!{C.ENDC}")
106+
107+
if not have_7z:
108+
print(f"{C.FAIL}7z is required for extracting .7z files!{C.ENDC}")
109+
sys.exit(1)
110+
111+
# ask user if they want to decrypt only .lua files
29112
onlyLuaFiles = True
30113

31114
while True:
32-
onlyLuaFiles = input("\nDo you want to decrypt only .lua files? " + col.GREY + "(y/n): " + col.ENDC)
115+
onlyLuaFiles = input("\nDo you want to decrypt only .lua files? " + C.GREY + "(y/n): " + C.ENDC)
33116
if onlyLuaFiles == "y" or onlyLuaFiles == "n":
34117
if onlyLuaFiles == "y":
35118
onlyLuaFiles = True
36119
else:
37120
onlyLuaFiles = False
38121
break
39122
else:
40-
print(f"{col.FAIL}Invalid input! nöf nöf!{col.ENDC}")
123+
print(f"{C.FAIL}Invalid input! nöf nöf!\nyes or no{C.ENDC}")
41124

42125

43126
for file in arg_files:
@@ -48,17 +131,17 @@ class col:
48131
for file_in_dir in files_in_dir:
49132
if file_in_dir.endswith(".lua") or not onlyLuaFiles:
50133
file_path = os.path.join(root, file_in_dir)
51-
print(col.OKGREEN + "Found file: " + file_path + col.ENDC)
134+
print(C.OKGREEN + "Found file: " + file_path + C.ENDC)
52135
files.append(file_path)
53136

54137
elif os.path.isfile(file):
55-
print(col.OKGREEN + "Found file: " + file + col.ENDC)
138+
print(C.OKGREEN + "Found file: " + file + C.ENDC)
56139
files.append(file)
57140
else:
58-
print(col.FAIL + "File not found: " + file + col.ENDC)
141+
print(C.FAIL + "File not found: " + file + C.ENDC)
59142

60143
if len(files) == 0:
61-
print(col.FAIL + "No valid Files!" + col.ENDC)
144+
print(C.FAIL + "No .lua files found! nöf nöf!" + C.ENDC)
62145
sys.exit(1)
63146

64147
# get directory of each file
@@ -68,18 +151,18 @@ class col:
68151
# remove the path from files
69152
# files = [os.path.basename(file) for file in files]
70153

71-
print(col.HEADER)
72-
print("\nAngry Birds Lua Decryptor"+ col.ENDC +", works on for decrypting Angry Birds game files.")
73-
print("For " + col.UNDERLINE + "Encrypting" + col.ENDC + " files back to og, " + col.BOLD + "Check README.md" + col.ENDC)
154+
print(C.HEADER)
155+
print("\nAngry Birds Lua Decryptor"+ C.ENDC +", works on for decrypting Angry Birds game files.")
156+
print("For " + C.UNDERLINE + "Encrypting" + C.ENDC + " files back to og, " + C.BOLD + "Check README.md" + C.ENDC)
74157

75158
inp = input(f'''
76-
{col.HEADER}CHOOSE Angry Birds Game: {col.ENDC}
77-
{col.BOLD}1.{col.ENDC} Angry Birds
78-
{col.BOLD}2.{col.ENDC} Angry Birds Rio
79-
{col.BOLD}3.{col.ENDC} Angry Birds Seasons
80-
{col.BOLD}4.{col.ENDC} Angry Birds Space
81-
{col.BOLD}5.{col.ENDC} Angry Birds Star Wars
82-
6{col.BOLD}.{col.ENDC} Angry Birds Star Wars II
159+
{C.HEADER}CHOOSE Angry Birds Game: {C.ENDC}
160+
{C.BOLD}1.{C.ENDC} Angry Birds
161+
{C.BOLD}2.{C.ENDC} Angry Birds Rio
162+
{C.BOLD}3.{C.ENDC} Angry Birds Seasons
163+
{C.BOLD}4.{C.ENDC} Angry Birds Space
164+
{C.BOLD}5.{C.ENDC} Angry Birds Star Wars
165+
6{C.BOLD}.{C.ENDC} Angry Birds Star Wars II
83166
''')
84167

85168
if inp == '1': # Angry Birds
@@ -95,11 +178,11 @@ class col:
95178
elif inp == '6': # Angry Birds Star Wars II
96179
hex = "4230706D3354416C7A6B4E3967687A6F65324E697A456C6C50644E3068516E69"
97180
else:
98-
print(f"{col.FAIL}Invalid input! nöf nöf!{col.ENDC}")
181+
print(f"{C.FAIL}Invalid input! nöf nöf!{C.ENDC}")
99182
sys.exit(1)
100183

101184
def extract_7z(archive_path, extract_path):
102-
print(f"Extracting {col.OKBLUE}" + archive_path + f"{col.ENDC}...")
185+
print(f"Extracting {C.OKBLUE}" + archive_path + f"{C.ENDC}...")
103186
try:
104187
if '7Z' in os.environ:
105188
seven_zip_path = os.environ['7Z']
@@ -108,34 +191,41 @@ def extract_7z(archive_path, extract_path):
108191

109192
subprocess.run([seven_zip_path, "x", archive_path, f"-o{extract_path}"])
110193
except subprocess.CalledProcessError:
111-
print(f"{col.FAIL}Error: Not a 7z archive! File might be corrupted somehow or it already has been decrypted.{col.ENDC}")
194+
print(f"{C.FAIL}Error: Not a 7z archive! File might be corrupted somehow or it already has been decrypted.{C.ENDC}")
112195
os.remove(archive_path)
113196
sys.exit(1)
114197

115198
def decrypt_file(hex, file):
116-
print(f"Decrypting {col.OKBLUE}" + file + f"{col.ENDC}...")
199+
print(f"Decrypting {C.OKBLUE}" + file + f"{C.ENDC}...")
117200
output_file = file + ".7z"
118201

119-
combined_path = os.path.join(org_path, "bin/openssl")
202+
if have_openSSL:
203+
combined_path = "openssl"
204+
else:
205+
combined_path = os.path.join(org_path, "bin/openssl")
206+
120207
if os.name == 'nt':
121208
decryption_result = subprocess.run([combined_path, "enc", "-aes-256-cbc", "-d", "-K", hex, "-iv", "0", "-in", file, "-out", output_file], capture_output=True)
122209
elif os.name == 'posix':
123-
decryption_result = subprocess.run(["wine", combined_path, "enc", "-aes-256-cbc", "-d", "-K", hex, "-iv", "0", "-in", file, "-out", output_file], capture_output=True)
210+
if have_openSSL:
211+
decryption_result = subprocess.run(["openssl", "enc", "-aes-256-cbc", "-d", "-K", hex, "-iv", "0", "-in", file, "-out", output_file], capture_output=True)
212+
else:
213+
decryption_result = subprocess.run(["wine", combined_path, "enc", "-aes-256-cbc", "-d", "-K", hex, "-iv", "0", "-in", file, "-out", output_file], capture_output=True)
124214

125215
if decryption_result.returncode != 0:
126-
print(f"{col.FAIL}You might have entered the wrong game file or the file is corrupted. Decrypting failed! nöf nöf! \nor the file has been already decrypted{col.ENDC}")
216+
print(f"{C.FAIL}You might have entered the wrong game file or the file is corrupted. Decrypting failed! nöf nöf! \nor the file has been already decrypted{C.ENDC}")
127217
os.remove(file + ".7z")
128218

129219
while True:
130-
continue_still = input(f"\nDo you want to continue with the next file? " + col.GREY + "(y/n): " + col.ENDC)
220+
continue_still = input(f"\nDo you want to continue with the next file? " + C.GREY + "(y/n): " + C.ENDC)
131221
if continue_still == "y" or continue_still == "n":
132222
if continue_still == "y":
133223
pass
134224
else:
135225
sys.exit(1)
136226
break
137227
else:
138-
print(f"{col.FAIL}Invalid input! nöf nöf!{col.ENDC}")
228+
print(f"{C.FAIL}Invalid input! nöf nöf!{C.ENDC}")
139229
return
140230

141231
extract_7z(output_file, extract_path)
@@ -157,7 +247,7 @@ def decrypt_file(hex, file):
157247
# remove out folder
158248
os.rmdir("out")
159249

160-
print(f"{col.OKCYAN}Done! {file} decrypted!{col.ENDC}")
250+
print(f"{C.OKCYAN}Done! {file} decrypted!{C.ENDC}")
161251

162252
extract_path = "out"
163253

@@ -169,4 +259,4 @@ def decrypt_file(hex, file):
169259
file = os.path.basename(file)
170260
decrypt_file(hex, file)
171261

172-
print(col.OKGREEN + "nöf nöf! Done!" + col.ENDC)
262+
print(C.OKGREEN + "nöf nöf! Done!" + C.ENDC)

0 commit comments

Comments
 (0)