Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
in
out
.vscode
.windows-serial
.lh

Binary file modified Obfuscator.jar
100755 → 100644
Binary file not shown.
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Arguments:
5. -namelength <length> | the length of each unique name, you need to also use -uniquenames
6. -help | display available commands

Settings files: Not required, MUST be stored in the working dir
* ignoreclass.txt: List of class won't be renamed
* ignorepackage.txt: List of package won't be renamed, all sub package and class inside this package still be renamed.
* ignorerenamememberinclass.txt: List of class which all public and protected function, public variable won't be renamed. Private function, private and protected properties still be ranmed.
* ignorevarname.txt: List of variable name, function name which won't be renamed. This affact for all public, protected and private functions/porperties.

**Tips n Tricks:**

Expand Down Expand Up @@ -90,25 +95,39 @@ Keep in mind that when local variables have the same name as global variables, i
----------
Updates

- 27 October 2022:
+ Support Namespaces, support file without having any class
+ Support regular expression
+ Support load ignore list from:
ignoreclass.txt: All class in this file will be keep it's name
ignorepackage.txt: All packages in this file will be keep as is
ignorerenamememberinclass.txt: All member (methods, properties, local variable) will be keep as is
ignorevarname.txt: All methods, properties, local variable name in this file will be keep as is
+ Fix many other errors
- 12 October 2012: Make the Obfuscator ignore Anonymous functions instead of terminate.
- 14 October 2012: Added Vector Type safety support.

------------
Unsupported:
------------

1. Namespaces, will generate errors
They're not too usefull.
2. The 'with' statement, will generate errors
1. The 'with' statement, will generate errors
Its slow and unhandy to read because of the extra { it creates
3. mxml, will not get parsed; only .as files
2. mxml, will not get parsed; only .as files
This is an actionscript obfuscator, not a UI obfuscator.
4. Local functions and anymous functions, may generate errors
3. Local functions and anymous functions, may generate errors
there is a chance where there can be collisions with names.
5. Dynamically typed members, may generate errors
4. Dynamically typed members, may generate errors
Without a type the variable or function cannot be referenced correctly, look out for warnings when you compile your original code for this.
7. Global function or field in separate .as file (global to the package)
8. Reflection, variable names will get changed.

5. Global function or field in separate .as file (global to the package)
6. Reflection, variable names will get changed.
7. Public/protected get magic method, such as public function get Width()
8. Multi level methods/properties calling in some case
Such as:
ret = SLogicsCore.Character.Appliances.GetAll()
You should convert it to:
var ch: CCharacter = SLogicsCore.Character;
var app: CAppliances = ch.Appliances();
ret = app.getAll();


1 change: 1 addition & 0 deletions ignoreclass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TApplication
Empty file added ignorepackage.txt
Empty file.
Empty file added ignorerenamememberinclass.txt
Empty file.
Empty file added ignorevarname.txt
Empty file.
1 change: 1 addition & 0 deletions src/asformat/CodeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CodeParser {

public CodeParser(File file) throws FileNotFoundException {
_fileName = file.getPath();
System.out.println("Processing file " + _fileName);
FileInputStream inputStream = new FileInputStream(file);
DataInputStream dataInput = new DataInputStream(inputStream);
try {
Expand Down
44 changes: 39 additions & 5 deletions src/classes/ActionScriptClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import data.IRenameLockable;
import data.RenameObjectCounter;
import data.Variable;
import java.util.Random;
import java.io.File;

/**
* Stores all the data that is to be stored on an Actionscript class. Also calls
Expand Down Expand Up @@ -125,6 +127,8 @@ public ActionScriptClass(File file, IGetClass model) {
_translationMap = new HashMap<String, Variable>();
_importMap = new HashMap<String, String>();
_asteriskImports = new ArrayList<String>();
//_renamed = true;
//_classNameRenamed = true;
}

/**
Expand Down Expand Up @@ -167,9 +171,16 @@ public int renameClassName(int i) {
return i;
}
if (ObfuscationSettings.uniqueNames())
_newName = UniqueStringCreator.getUniqueName(RenameType.CLASSNAME);
_newName = UniqueStringCreator.getUniqueName(RenameType.CLASSNAME, this.getClassName());
else
_newName = "C" + i++;
{
Random rand = new Random();
i += rand.nextInt(10);
_newName = "C" + i;
}

lockRename();

return i;
}

Expand Down Expand Up @@ -209,7 +220,18 @@ public void renameVariables() {
public int renameVariables(int index) {
if (_renamed)
return index;
int i = MemberRenamer.renameAllMembers(index, _members, this, _classManager);

int i = index;

MemberRenamer.setTypeAllMembers(index, _members, this, _classManager);

if (!ObfuscationSettings.isIgnoredMemberInClass(this._className))
{
i = MemberRenamer.renameAllMembers(index, _members, this, _classManager);
}

i = MemberRenamer.renameAllLocalVars(i, _members, this, _classManager);

_renamed = true;
return i;
}
Expand Down Expand Up @@ -321,9 +343,15 @@ public void renameReferences() {
*/
//TODO offload logic to helper class
public void outClass(File out) {
System.out.println("Write file " + this._file.toString());

File myOut = new File(out.getAbsolutePath() + "/" + getPackageStructure(out.getAbsolutePath()) + _newName + ".as");

if (_newName == null)
{
myOut = new File(out.getAbsolutePath() + "/" + getPackageStructure(out.getAbsolutePath()) + this._file.getName());
}

File myOut = new File(out.getAbsolutePath() + "/" + getPackageStructure(out.getAbsolutePath()) + _newName
+ ".as");
int tabCount = 0;
try {
myOut.createNewFile();
Expand Down Expand Up @@ -426,6 +454,12 @@ public void setPackageName(String packageName) {
public void setClassName(String className) {
this._className = className;
_newName = _className;

if (ObfuscationSettings.isIgnoredClass(className))
{
//_renamed = false;
_classNameRenamed = true;
}
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/classes/interpreters/ClassParseInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public static void parseClass(File file, ArrayList<String> _elements, ArrayList<
_translationMap.put(var.getOldName(), var);
}

if (asClass.getClassName() != null)
{
Variable variable = new Variable("super");
variable.SetType(asClass.getFullType(asClass.getClassName()));

_translationMap.put("super", variable);
}

asClass.setNewLines(parser.getNewLineList());
asClass.setSpaces(parser.getSpaceList());
}
Expand Down
16 changes: 14 additions & 2 deletions src/classes/interpreters/MemberInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ private static Variable parseProperty(String variableName, CodeParser parser, Ar

checkType(variableName, parser, elements, variable);

variable.setProtected(occursBefore(elements, "protected", 9));
variable.setPrivated(occursBefore(elements, "private", 9));
variable.setVar(occursBefore(elements, "var", 7));
variable.setStatic(occursBefore(elements, "static", 8));
variable.setFunction(false);

if (addVarsTo != null)
addVarsTo.addVariable(variable);

Expand Down Expand Up @@ -225,7 +231,7 @@ private static void checkType(String memberName, CodeParser parser, ArrayList<St
*/
private static void checkVector(CodeParser parser, ArrayList<String> elements, Variable member, String type) {
if (type.equals("Vector.<")) {
System.out.println("type is a vector!");
//System.out.println("type is a vector!");
String vectorType = getOrFail(parser, elements, "Vector.<");
member.setVectorType(vectorType);
}
Expand Down Expand Up @@ -273,8 +279,14 @@ private static Variable parseFunction(String functionName, CodeParser parser, Ar
} else
function = new Variable(functionName);

// store whether this function overrides
//Search for member type
function.setOverride(occursBefore(elements, "override", 5));
function.setProtected(occursBefore(elements, "protected", 4));
function.setPrivated(occursBefore(elements, "private", 4));
function.setVar(false);
function.setStatic(occursBefore(elements, "static", 3));
function.setFunction(true);
//function.setConst(occursBefore(elements, "privated", 5));

// function definition should be followed by a '('
String validAfterFunction = getOrFail(parser, elements, "function definition! " + functionName);
Expand Down
12 changes: 10 additions & 2 deletions src/classes/makechange/RenamingExecuter.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ public static int getReferences(ActionScriptClass baseType, ActionScriptClass ty
Variable var = null;
// TODO make check if superclass == null better!
if (varName.equals("super") && classManager.getClass(baseType.getFullType(superClassName)) != null) {
var = classManager.getClass(baseType.getFullType(superClassName)).askVariable(varName);
var = classManager.getClass(baseType.getFullType(superClassName)).askVariable("super");
var.lockRename();
//var = classManager.getClass(baseType.getFullType(superClassName));
}

if (type != null && var == null && isInChain) {
Expand Down Expand Up @@ -264,6 +266,12 @@ public static int getReferences(ActionScriptClass baseType, ActionScriptClass ty
}

i++;
if (i >= elements.size())
{
//System.out.println("Something wrong with the file");
i--;
return i;
}
string = elements.get(i);

if (string.equals("(") || string.equals("[")) {
Expand Down Expand Up @@ -296,7 +304,7 @@ public static int getReferences(ActionScriptClass baseType, ActionScriptClass ty
private static ActionScriptClass checkVector(Variable var, int i, ArrayList<String> elements, IGetClass classManager, ActionScriptClass baseType, Variable inFunction, String superClassName) {
i++;
String next = elements.get(i);
System.out.println("point: " + next);
//System.out.println("point: " + next);
if (next.equals("[")) {
while (true) {
i++;
Expand Down
Loading