Added #2090 Support for Mochicrypt packed binarydata tags - loading SWF as subtree

This commit is contained in:
Jindra Petřík
2023-10-16 09:36:06 +02:00
parent 0725f13f5d
commit 8a92a273a5
9 changed files with 250 additions and 11 deletions
@@ -17,6 +17,8 @@
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.gui.hexview.HexView;
import com.jpexs.decompiler.flash.packers.MochiCryptPacker;
import com.jpexs.decompiler.flash.packers.Packer;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -44,6 +46,8 @@ public final class BinaryPanel extends JPanel {
private DefineBinaryDataTag binaryDataTag = null;
private final MainPanel mainPanel;
private final JLabel swfInsideLabel;
public BinaryPanel(final MainPanel mainPanel) {
super(new BorderLayout());
@@ -64,10 +68,13 @@ public final class BinaryPanel extends JPanel {
setBinaryData(binaryDataTag);
}
});*/
swfInsideLabel = new JLabel(AppStrings.translate("binarydata.swfInside"));
swfInsidePanel = new JPanel();
swfInsidePanel.setBackground(new Color(253, 205, 137));
swfInsidePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
swfInsidePanel.add(new JLabel(AppStrings.translate("binarydata.swfInside")));
swfInsidePanel.add(swfInsideLabel);
swfInsidePanel.setFocusable(true);
swfInsidePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
swfInsidePanel.addMouseListener(new MouseAdapter() {
@@ -88,7 +95,15 @@ public final class BinaryPanel extends JPanel {
data = binaryDataTag == null ? null : binaryDataTag.binaryData.getRangeData();
if (data != null) {
hexEditor.setData(data, null, null);
swfInsidePanel.setVisible(binaryDataTag.innerSwf == null && binaryDataTag.isSwfData());
boolean isSwfData = binaryDataTag.isSwfData();
if (isSwfData) {
if (binaryDataTag.usedPacker != null) {
swfInsideLabel.setText(AppStrings.translate("binarydata.swfInside.packer").replace("%packer%", binaryDataTag.usedPacker.getName()));
} else {
swfInsideLabel.setText(AppStrings.translate("binarydata.swfInside"));
}
}
swfInsidePanel.setVisible(binaryDataTag.innerSwf == null && isSwfData);
} else {
hexEditor.setData(new byte[0], null, null);
swfInsidePanel.setVisible(false);
@@ -162,7 +162,13 @@ public abstract class MainFrameMenu implements MenuBuilder {
try {
openable.saveTo(baos);
SWF swf = (SWF) openable;
swf.binaryData.binaryData = new ByteArrayRange(baos.toByteArray());
byte data[] = baos.toByteArray();
if (swf.binaryData.usedPacker != null) {
ByteArrayOutputStream encBaos = new ByteArrayOutputStream();
swf.binaryData.usedPacker.encrypt(new ByteArrayInputStream(data), encBaos);
data = encBaos.toByteArray();
}
swf.binaryData.binaryData = new ByteArrayRange(data);
swf.binaryData.setModified(true);
saved = saveOpenable(swf.binaryData.getSwf()); //save parent swf
} catch (IOException ex) {
@@ -4978,8 +4978,16 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
try {
SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(path);
String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name());
InputStream is = new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData());
SWF bswf = new SWF(is, null, "(SWF Data)", new ProgressListener() {
byte data[] = binaryDataTag.binaryData.getRangeData();
String packerAdd = "";
if (binaryDataTag.usedPacker != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
binaryDataTag.usedPacker.decrypt(new ByteArrayInputStream(data), baos);
data = baos.toByteArray();
packerAdd = " - " + binaryDataTag.usedPacker.getName();
}
InputStream is = new ByteArrayInputStream(data);
SWF bswf = new SWF(is, null, "(SWF Data" + packerAdd +")", new ProgressListener() {
@Override
public void progress(int p) {
Main.loadingDialog.setPercent(p);
@@ -1157,4 +1157,7 @@ menu.tools.abcexplorer = ABC Explorer
contextmenu.abcexplorer = Explore ABC
button.abcexploretrait = Show trait in ABC Explorer
button.abcexploretrait = Show trait in ABC Explorer
#after 19.0.0
binarydata.swfInside.packer = It looks like there is SWF inside this binary data tag packed with %packer%. Click here to unpack the SWF and load it as subtree.
@@ -1142,4 +1142,7 @@ menu.tools.abcexplorer = Pr\u016fzkumn\u00edk ABC
contextmenu.abcexplorer = Prozkoumat ABC
button.abcexploretrait = Zobrazit vlastnost v pr\u016fzkumn\u00edku ABC
button.abcexploretrait = Zobrazit vlastnost v pr\u016fzkumn\u00edku ABC
#after 19.0.0
binarydata.swfInside.packer = Vypad\u00e1 to, \u017ee uvnit\u0159 v tomto BinaryData tagu se nach\u00e1z\u00ed SWF soubor zabalen\u00fd pomoc\u00ed %packer%. Klikn\u011bte zde pro jeho rozbalen\u00ed a na\u010dten\u00ed jako podstrom.