Changed: AS1/2: Export names are deobfuscated only when start with __Packages.,

if not, then classical escaping is performed (with quotes)
This commit is contained in:
Jindra Petřík
2025-07-21 20:56:01 +02:00
parent a9763c7151
commit 41118564b3
21 changed files with 163 additions and 37 deletions
@@ -245,17 +245,15 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
@Override
public Map<String, String> getNameProperties() {
String expName = swf == null ? "" : swf.getExportName(spriteId);
String exportName = swf == null ? "" : swf.getExportName(spriteId);
Map<String, String> ret = super.getNameProperties();
ret.put("sid", "" + spriteId);
if (expName == null || expName.isEmpty()) {
if (exportName == null || exportName.isEmpty()) {
return ret;
}
//String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName};
//ret.put("exp", pathParts[pathParts.length - 1]);
ret.put("exp", expName);
ret.put("exp", Helper.escapeExportname(exportName, true));
return ret;
}
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -58,7 +59,7 @@ public class ExportAssetsTag extends SymbolClassTypeTag {
@SWFArray(value = "name", countField = "count")
@Table(value = "assets", itemName = "asset")
@DottedIdentifier
@DottedIdentifier(exportName = true)
public List<String> names;
/**
@@ -164,7 +165,8 @@ public class ExportAssetsTag extends SymbolClassTypeTag {
Map<String, String> ret = super.getNameProperties();
if (names.size() == 1) {
ret.put("chid", "" + tags.get(0));
ret.put("ex", "" + DottedChain.parseNoSuffix(names.get(0)).toPrintableString(false));
String exportName = names.get(0);
ret.put("exp", Helper.escapeExportname(exportName, true));
}
return ret;
}
@@ -162,7 +162,12 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
Map<String, String> ret = super.getNameProperties();
if (names.size() == 1) {
ret.put("chid", "" + tags.get(0));
ret.put("im", "" + DottedChain.parseNoSuffix(names.get(0)).toPrintableString(false));
String importName = names.get(0);
if (importName.startsWith("__Packages.")) {
ret.put("imp", DottedChain.parseNoSuffix(importName).toPrintableString(false));
} else {
ret.put("imp", "\"" + Helper.escapePCodeString(importName) + "\"");
}
}
return ret;
}
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.decompiler.flash.types.annotations.Table;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -138,7 +139,13 @@ public class ImportAssetsTag extends Tag implements ImportTag {
Map<String, String> ret = super.getNameProperties();
if (names.size() == 1) {
ret.put("chid", "" + tags.get(0));
ret.put("im", "" + DottedChain.parseNoSuffix(names.get(0)).toPrintableString(false));
String importName = names.get(0);
if (importName.startsWith("__Packages.")) {
ret.put("imp", DottedChain.parseNoSuffix(importName).toPrintableString(false));
} else {
ret.put("imp", "\"" + Helper.escapePCodeString(importName) + "\"");
}
}
return ret;
}
@@ -131,7 +131,7 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
* If PlaceFlagHasName, Name of character
*/
@Conditional("placeFlagHasName")
@DottedIdentifier
@DottedIdentifier
public String name;
/**
@@ -99,7 +99,7 @@ public abstract class CharacterTag extends Tag implements CharacterIdTag {
ret.put("chid", "" + chid);
}
if (exportName != null) {
ret.put("exp", DottedChain.parseNoSuffix(exportName).toPrintableString(false));
ret.put("exp", Helper.escapeExportname(exportName, true));
}
if (!classNames.isEmpty()) {
List<String> escapedList = new ArrayList<>();
@@ -25,7 +25,9 @@ import com.jpexs.decompiler.flash.types.ColorTransform;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RGBA;
import com.jpexs.decompiler.flash.types.filters.FILTER;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
@@ -336,7 +338,7 @@ public abstract class PlaceObjectTypeTag extends Tag implements CharacterIdTag,
ret.put("chid", "" + charId);
}
if (exportName != null) {
ret.put("exp", exportName);
ret.put("exp", Helper.escapeExportname(exportName, true));
}
}
@@ -18,7 +18,9 @@ package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import java.util.Map;
/**
@@ -48,7 +50,7 @@ public abstract class RemoveTag extends Tag implements DepthTag {
ret.put("chid", "" + getCharacterId());
}
if (exportName != null) {
ret.put("exp", exportName);
ret.put("exp", Helper.escapeExportname(exportName, true));
}
ret.put("dpt", "" + getDepth());
@@ -30,4 +30,5 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface DottedIdentifier {
boolean as3() default false;
boolean exportName() default false;
}