Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 |
# you can find the original source here - https://github.com/shapedbyregret/actionscript-3-obfuscator # special thanks goes to Erik Johnson for making a great script and commenting the code EXTREMELY WELL so that a python noob can use it |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# Actionscript 3.0 Obfuscator # # Copyright (c) 2008 Erik Johnson (shapedbyregret@gmail.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #======================================== # Import modules # #======================================== import os.path import re import random import string import sys #======================================== # Options # #======================================== removeComments = True changeVarName = True encodeStrings = True # Following options should not be changed. # They are either incomplete or incorrectly implemented. removeWhitespace = False changeFileName = True #======================================== # Declare Variables # #======================================== blockCommentFound = False varDeclareFound = False varsFound = varsNew = varLength = 5 varCharSet = string.ascii_uppercase + string.ascii_lowercase + string.digits #======================================== # Function declarations # #======================================== #======================================== # strip_white_space(String) # First replaces each newline with an empty string, then splits at each # tab, and then joins it all back together before returning. tmpLine = tmpList = tmpLine = ". return tmpLine #======================================== # string_to_hex(String) # Iterates over each character in oldString and converts it first to an # int, and then to a hex string. All "0" chars are replaced with "\" # and added to newString. newString = " for char in oldString: tmpString = tmpString = newString += tmpString return newString #======================================== # Handle arguments # #======================================== # Check if arguments given if >1: filePath = fullFileName = fileName = if >2: newFilePath = newFullFileName = newFileName = else: # Create new file path tmpList = if >1: # Check if there is a file extension newFilePath = + "_Obfs." + else: newFilePath = fileName + "_Obfs" # Create new file name tmpList = if >1: newFullFileName = + "_Obfs." + else: newFullFileName = fileName + "_Obfs" newFileName = fileName + "_Obfs" else: print "Filename not provided." #======================================== # Open File # #======================================== fileToChange = listLines = # Store fileToChange to memory in a list # Close file #======================================== # Iterate over file, one line at a time # #======================================== for line in listLines: newLine = line #======================================== # Remove comments if removeComments: #======================================== # Remove and delete all inline block comments # Replaces everything between "/*" and "*/" with an empty string. tmpLine = if tmpLine != ": newLine = tmpLine #======================================== # Remove all other block comments. # Attempts to find beginning of block comment statement. if != -1: blockCommentFound = True # If we find the end of the block comment, then we will store # everything past it, otherwise simply replace entire line with # a newline ("\n"), which helps to preserve code structure. if blockCommentFound: if != -1: tmpLine = newLine = blockCommentFound = False else: newLine = "\n" #======================================== # Remove single line comments i.e. all text following "//" # Find last instance of "//" and determine if it is after semicolon. # If so then it is safe to delete. Which we do by splitting at the # last instance of found "//", appending a "\n" and storing it. # Note: The following relies on the assumption that the code being # read uses semicolons to end statements. tmpLine = if tmpLine != ": newLine = tmpLine #======================================== # Collect variable names if changeVarName: tmpList = # Store indices of AS3 reserved words "var", "function", or "const" varIndex = functionIndex = constIndex = if varIndex != -1 or functionIndex != -1 or constIndex != -1: varDeclareFound = True |
1 2 3 |
# NOTE - using this to only obfuscate private and function-scoped members if != -1 or != -1 or != -1 or != -1: varDeclareFound = False |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# If "function" was found, then we make a list of all words preceding # a ":" or "(". Otherwise only store words preceding ":". # After we've found our words we add them to varsFound and create a # jumbled replacement name for each one. if varDeclareFound: tmpList = for tmpLine in tmpList: # Skip over constructor name if == -1: # Create new variable name. # Keep searching until find a unique name consisting of an # underscore preceding a random number from 1-5000. newVarName = " foundNewName = False while not foundNewName: #newVarName = "_" + str(random.randrange(1,5000)) newVarName = "_" newVarName += ". if newVarName not in varsNew: foundNewName = True # Reached a semicolon or open bracket and presumably end of # var/function/const declaration. if != -1 or != -1: varDeclareFound = False #======================================== # Encode strings # Iterates over each character in string until a single or double # quote is found. If quote has not been escaped, then convert # following chars to their hex string equivalent until another quote # is found. if encodeStrings: tmpLine = " inSingleQuote = False inDoubleQuote = False for x in : if =="\" and not inSingleQuote: if x>0 and !="\\": if inDoubleQuote: inDoubleQuote = False else: inDoubleQuote = True tmpLine += else: tmpLine += elif =="\'" and not inDoubleQuote: if x>0 and !="\\": if inSingleQuote: inSingleQuote = False else: inSingleQuote = True tmpLine += else: tmpLine += else: if inDoubleQuote or inSingleQuote: tmpLine += else: tmpLine += newLine = tmpLine #======================================== # Remove newlines and tabs if removeWhitespace: newLine = #======================================== # Change constructor to match new file name if changeFileName: tmpLine = if tmpLine != ": newLine = tmpLine #======================================== # Replace line lineIndex = #======================================== # Change Variable names # Iterates over file again and attempts to replace all instances of # variables previously found. # TODO: Find less expensive way to implement. if changeVarName: for line in listLines: newLine = line # Attempt to find import at beginning of line tmpLine = tmpIndex = if( tmpIndex!=0 ): for j in : newLine = lineIndex = #======================================== # Write to file # #======================================== if changeFileName: fileToWrite = else: fileToWrite = for line in listLines: # Close file after writing |