November 2019
Intermediate to advanced
346 pages
9h 36m
English
In this recipe, you will use UPX to pack a directory of files.
import osfiles_path = "Benign PE Samples UPX/"files = os.listdir(files_path)file_paths = [files_path+x for x in files]
from subprocess import Popen, PIPEcmd = "upx.exe"for path in file_paths: cmd2 = cmd+" \""+path+"\"" res = Popen(cmd2, stdout=PIPE).communicate() print(res)
if "error" in str(res[0]): print(path) os.remove(path)