Merge origin/master

This commit is contained in:
Jindra Petřík
2014-08-23 21:59:07 +02:00
10 changed files with 237 additions and 235 deletions
@@ -195,7 +195,7 @@ public class MethodBody implements Cloneable, Serializable {
MethodBody b = Helper.deepCopy(this);
AVM2Code deobfuscated = b.code;
deobfuscated.markMappedOffsets();
if (Configuration.deobfuscationMode.get() != 0) {
if (Configuration.autoDeobfuscate.get()) {
try {
deobfuscated.removeTraps(constants, trait, method_info.get(this.method_info), b, abc, scriptIndex, classIndex, isStatic, path);
} catch (StackOverflowError ex) {
@@ -93,11 +93,12 @@ public class ActionListReader {
*/
public static ActionList readActionListTimeout(final List<DisassemblyListener> listeners, final SWFInputStream sis, final int version, final int ip, final int endIp, final String path) throws IOException, InterruptedException, TimeoutException {
try {
final int deobfuscationMode = Configuration.autoDeobfuscate.get() ? Configuration.deobfuscationMode.get() : -1;
ActionList actions = CancellableWorker.call(new Callable<ActionList>() {
@Override
public ActionList call() throws IOException, InterruptedException {
return readActionList(listeners, sis, version, ip, endIp, path, Configuration.deobfuscationMode.get());
return readActionList(listeners, sis, version, ip, endIp, path, deobfuscationMode);
}
}, Configuration.decompilationTimeoutSingleMethod.get(), TimeUnit.SECONDS);
@@ -125,7 +126,7 @@ public class ActionListReader {
* @param ip
* @param endIp
* @param path
* @param deobfuscate
* @param deobfuscationMode
* @return List of actions
* @throws IOException
* @throws java.lang.InterruptedException
@@ -178,7 +179,7 @@ public class ActionListReader {
}
}
if (deobfuscationMode == 1) {
if (deobfuscationMode == 0) {
try {
actions = deobfuscateActionList(listeners, actions, version, 0, path);
updateActionLengths(actions, version);
@@ -186,7 +187,7 @@ public class ActionListReader {
// keep orignal (not deobfuscated) actions
Logger.getLogger(ActionListReader.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
} else if (deobfuscationMode == 1) {
try {
new ActionDeobfuscatorSimple().actionListParsed(actions, sis.getSwf());
new ActionDeobfuscator().actionListParsed(actions, sis.getSwf());
@@ -109,7 +109,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener {
byte[] actionBytes = Action.actionsToBytes(actions, true, SWF.DEFAULT_VERSION);
try {
SWFInputStream rri = new SWFInputStream(swf, actionBytes);
ActionList newActions = ActionListReader.readActionList(new ArrayList<DisassemblyListener>(), rri, SWF.DEFAULT_VERSION, 0, actionBytes.length, "", 0);
ActionList newActions = ActionListReader.readActionList(new ArrayList<DisassemblyListener>(), rri, SWF.DEFAULT_VERSION, 0, actionBytes.length, "", -1);
actions.setActions(newActions);
} catch (IOException | InterruptedException ex) {
Logger.getLogger(ActionDeobfuscator.class.getName()).log(Level.SEVERE, null, ex);
@@ -80,7 +80,11 @@ public class Configuration {
@ConfigurationCategory("decompilation")
public static final ConfigurationItem<Integer> parallelThreadCount = null;
@ConfigurationDefaultInt(0)
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("script")
public static final ConfigurationItem<Boolean> autoDeobfuscate = null;
@ConfigurationDefaultInt(1)
@ConfigurationCategory("script")
public static final ConfigurationItem<Integer> deobfuscationMode = null;
@@ -87,7 +87,7 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener {
private final MainFrameClassic mainFrame;
//private JCheckBoxMenuItem miAutoDeobfuscation;
private JCheckBoxMenuItem miAutoDeobfuscation;
private JCheckBoxMenuItem miInternalViewer;
private JCheckBoxMenuItem miParallelSpeedUp;
private JCheckBoxMenuItem miAssociate;
@@ -199,10 +199,11 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener {
miDeobfuscation.setActionCommand(ACTION_DEOBFUSCATE);
miDeobfuscation.addActionListener(this);
//miAutoDeobfuscation = new JCheckBoxMenuItem(translate("menu.settings.autodeobfuscation"));
//miAutoDeobfuscation.setSelected(Configuration.autoDeobfuscate.get());
//miAutoDeobfuscation.addActionListener(this);
//miAutoDeobfuscation.setActionCommand(ACTION_AUTO_DEOBFUSCATE);
miAutoDeobfuscation = new JCheckBoxMenuItem(translate("menu.settings.autodeobfuscation"));
miAutoDeobfuscation.setSelected(Configuration.autoDeobfuscate.get());
miAutoDeobfuscation.addActionListener(this);
miAutoDeobfuscation.setActionCommand(ACTION_AUTO_DEOBFUSCATE);
JMenuItem miRenameOneIdentifier = new JMenuItem(translate("menu.tools.deobfuscation.globalrename"));
miRenameOneIdentifier.setActionCommand(ACTION_RENAME_ONE_IDENTIFIER);
miRenameOneIdentifier.addActionListener(this);
@@ -270,7 +271,7 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener {
miAutoRenameIdentifiers.addActionListener(this);
JMenu menuSettings = new JMenu(translate("menu.settings"));
//menuSettings.add(miAutoDeobfuscation);
menuSettings.add(miAutoDeobfuscation);
menuSettings.add(miInternalViewer);
menuSettings.add(miParallelSpeedUp);
menuSettings.add(miDecompile);
@@ -441,14 +442,14 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener {
case ACTION_SEARCH_AS:
mainFrame.panel.searchAs();
break;
/*case ACTION_AUTO_DEOBFUSCATE:
if (View.showConfirmDialog(mainFrame.panel, translate("message.confirm.autodeobfuscate") + "\r\n" + (miAutoDeobfuscation.isSelected() ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Configuration.autoDeobfuscate.set(miAutoDeobfuscation.isSelected());
mainFrame.panel.autoDeobfuscateChanged();
} else {
miAutoDeobfuscation.setSelected(!miAutoDeobfuscation.isSelected());
}
break;*/
case ACTION_AUTO_DEOBFUSCATE:
if (View.showConfirmDialog(mainFrame.panel, translate("message.confirm.autodeobfuscate") + "\r\n" + (miAutoDeobfuscation.isSelected() ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Configuration.autoDeobfuscate.set(miAutoDeobfuscation.isSelected());
mainFrame.panel.autoDeobfuscateChanged();
} else {
miAutoDeobfuscation.setSelected(!miAutoDeobfuscation.isSelected());
}
break;
case ACTION_EXIT:
mainFrame.panel.setVisible(false);
if (Main.proxyFrame != null) {
@@ -123,13 +123,12 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
static final String ACTION_CHECK_RESOURCES = "CHECKRESOURCES";
static final String ACTION_VIEWMODE_RESOURCES = "VIEWMODERESOURCES";
static final String ACTION_VIEWMODE_HEX = "VIEWMODEHEX";
static final String ACTION_DEOBFUSCATION_MODE_DISABLED = "DEOBFUSCATIONMODEDISABLED";
static final String ACTION_DEOBFUSCATION_MODE_OLD = "DEOBFUSCATIONMODEOLD";
static final String ACTION_DEOBFUSCATION_MODE_NEW = "DEOBFUSCATIONMODENEW";
private final MainFrameRibbon mainFrame;
//private JCheckBox miAutoDeobfuscation;
private JCheckBox miAutoDeobfuscation;
private JCheckBox miInternalViewer;
private JCheckBox miDumpView;
private JCheckBox miParallelSpeedUp;
@@ -147,7 +146,6 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
private JCommandButton importTextCommandButton;
private JCommandToggleButton viewModeResourcesToggleButton;
private JCommandToggleButton viewModeHexToggleButton;
private JCommandToggleButton deobfuscationModeDisabledToggleButton;
private JCommandToggleButton deobfuscationModeOldToggleButton;
private JCommandToggleButton deobfuscationModeNewToggleButton;
@@ -283,7 +281,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
resizePolicies.add(new CoreRibbonResizePolicies.Mirror(ribbonBand.getControlPanel()));
return resizePolicies;
}
private List<RibbonBandResizePolicy> getResizePolicies(JRibbonBand ribbonBand) {
List<RibbonBandResizePolicy> resizePolicies = new ArrayList<>();
resizePolicies.add(new CoreRibbonResizePolicies.Mirror(ribbonBand.getControlPanel()));
@@ -432,10 +430,11 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
JRibbonBand settingsBand = new JRibbonBand(translate("menu.settings"), null);
settingsBand.setResizePolicies(getResizePolicies(settingsBand));
//miAutoDeobfuscation = new JCheckBox(translate("menu.settings.autodeobfuscation"));
//miAutoDeobfuscation.setSelected(Configuration.autoDeobfuscate.get());
//miAutoDeobfuscation.addActionListener(this);
//miAutoDeobfuscation.setActionCommand(ACTION_AUTO_DEOBFUSCATE);
miAutoDeobfuscation = new JCheckBox(translate("menu.settings.autodeobfuscation"));
miAutoDeobfuscation.setSelected(Configuration.autoDeobfuscate.get());
miAutoDeobfuscation.addActionListener(this);
miAutoDeobfuscation.setActionCommand(ACTION_AUTO_DEOBFUSCATE);
miInternalViewer = new JCheckBox(translate("menu.settings.internalflashviewer"));
miInternalViewer.setSelected(Configuration.internalFlashViewer.get() || externalFlashPlayerUnavailable);
if (externalFlashPlayerUnavailable) {
@@ -478,7 +477,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
miDumpView.setSelected(Configuration.dumpView.get());
miDumpView.setActionCommand(ACTION_DUMP_VIEW_SWITCH);
miDumpView.addActionListener(this);*/
//settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation));
settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation));
settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer));
settingsBand.addRibbonComponent(new JRibbonComponent(miParallelSpeedUp));
settingsBand.addRibbonComponent(new JRibbonComponent(miDecompile));
@@ -507,38 +506,30 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
assignListener(clearRecentFilesCommandButton, ACTION_CLEAR_RECENT_FILES);
advancedSettingsBand.addCommandButton(clearRecentFilesCommandButton, RibbonElementPriority.MEDIUM);
JRibbonBand deobfuscationBand = new JRibbonBand(translate("menu.deobfuscation"), null);
JRibbonBand deobfuscationBand = new JRibbonBand(translate("menu.deobfuscation"), null);
deobfuscationBand.setResizePolicies(getEmptyResizePolicies(deobfuscationBand)); //TODO: add icons and change this to getResizePolicies
CommandToggleButtonGroup grpDeobfuscation = new CommandToggleButtonGroup();
deobfuscationModeDisabledToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.deobfuscation.disabled")), null);
assignListener(deobfuscationModeDisabledToggleButton, ACTION_DEOBFUSCATION_MODE_DISABLED);
deobfuscationModeOldToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.deobfuscation.old")), null);
assignListener(deobfuscationModeOldToggleButton, ACTION_DEOBFUSCATION_MODE_OLD);
deobfuscationModeNewToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.deobfuscation.new")), null);
assignListener(deobfuscationModeNewToggleButton, ACTION_DEOBFUSCATION_MODE_NEW);
grpDeobfuscation.add(deobfuscationModeDisabledToggleButton);
grpDeobfuscation.add(deobfuscationModeOldToggleButton);
grpDeobfuscation.add(deobfuscationModeNewToggleButton);
int deobfuscationMode = Configuration.deobfuscationMode.get();
switch (deobfuscationMode) {
case 0:
grpDeobfuscation.setSelected(deobfuscationModeDisabledToggleButton, true);
break;
case 1:
grpDeobfuscation.setSelected(deobfuscationModeOldToggleButton, true);
break;
case 2:
case 1:
grpDeobfuscation.setSelected(deobfuscationModeNewToggleButton, true);
break;
}
deobfuscationBand.addCommandButton(deobfuscationModeDisabledToggleButton, RibbonElementPriority.MEDIUM);
deobfuscationBand.addCommandButton(deobfuscationModeOldToggleButton, RibbonElementPriority.MEDIUM);
deobfuscationBand.addCommandButton(deobfuscationModeNewToggleButton, RibbonElementPriority.MEDIUM);
@@ -712,6 +703,14 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
Configuration.dumpView.set(true);
mainFrame.panel.showDumpView(true);
break;
case ACTION_DEOBFUSCATION_MODE_OLD:
Configuration.deobfuscationMode.set(0);
mainFrame.panel.autoDeobfuscateChanged();
break;
case ACTION_DEOBFUSCATION_MODE_NEW:
Configuration.deobfuscationMode.set(1);
mainFrame.panel.autoDeobfuscateChanged();
break;
case ACTION_DUMP_VIEW_SWITCH:
Configuration.dumpView.set(miDumpView.isSelected());
mainFrame.panel.showDumpView(miDumpView.isSelected());
@@ -722,14 +721,14 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
case ACTION_TIMELINE:
mainFrame.panel.timeline();
break;
/*case ACTION_AUTO_DEOBFUSCATE:
if (View.showConfirmDialog(mainFrame.panel, translate("message.confirm.autodeobfuscate") + "\r\n" + (miAutoDeobfuscation.isSelected() ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Configuration.autoDeobfuscate.set(miAutoDeobfuscation.isSelected());
mainFrame.panel.autoDeobfuscateChanged();
} else {
miAutoDeobfuscation.setSelected(!miAutoDeobfuscation.isSelected());
}
break;*/
case ACTION_AUTO_DEOBFUSCATE:
if (View.showConfirmDialog(mainFrame.panel, translate("message.confirm.autodeobfuscate") + "\r\n" + (miAutoDeobfuscation.isSelected() ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Configuration.autoDeobfuscate.set(miAutoDeobfuscation.isSelected());
mainFrame.panel.autoDeobfuscateChanged();
} else {
miAutoDeobfuscation.setSelected(!miAutoDeobfuscation.isSelected());
}
break;
case ACTION_CLEAR_RECENT_FILES:
Configuration.recentFiles.set(null);
break;
@@ -515,6 +515,5 @@ contextmenu.parseABC = Parse ABC
contextmenu.parseInstructions = Parse AVM2 Instrctions
menu.deobfuscation = Deobfuscation
menu.file.deobfuscation.disabled = Disabled
menu.file.deobfuscation.old = Old
menu.file.deobfuscation.new = New
@@ -515,6 +515,5 @@ contextmenu.parseABC = ABC elemz\u00e9se
contextmenu.parseInstructions = AVM2 utas\u00edt\u00e1sok elemz\u00e9se
menu.deobfuscation = Deobfuszk\u00e1l\u00e1s
menu.file.deobfuscation.disabled = Letiltva
menu.file.deobfuscation.old = R\u00e9gi
menu.file.deobfuscation.new = \u00daj