mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 01:40:47 +00:00
Added Apply unpacker menu on binary data
Added Harman unpacker for binary data Added Multilevel binary data unpacking is possible
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2023 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.packers;
|
||||
|
||||
import com.jpexs.decompiler.flash.harman.HarmanBinaryDataEncrypt;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class HarmanAirPacker implements Packer {
|
||||
|
||||
@Override
|
||||
public Boolean suitableForBinaryData(DefineBinaryDataTag dataTag) {
|
||||
if (dataTag.binaryData.getLength() < 32) {
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean suitableForData(byte[] data) {
|
||||
if (data.length < 32) {
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean decrypt(InputStream is, OutputStream os) throws IOException {
|
||||
byte[] encryptedData = Helper.readStream(is);
|
||||
byte[] decryptedData = HarmanBinaryDataEncrypt.decrypt(encryptedData);
|
||||
if (decryptedData == null) {
|
||||
return false;
|
||||
}
|
||||
os.write(decryptedData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean encrypt(InputStream is, OutputStream os) throws IOException {
|
||||
byte[] data = Helper.readStream(is);
|
||||
byte[] encryptedData = HarmanBinaryDataEncrypt.encrypt(data);
|
||||
if (encryptedData == null) {
|
||||
return false;
|
||||
}
|
||||
os.write(encryptedData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Harman AIR SDK";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "harmanair";
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,12 @@ public class MochiCryptPacker implements Packer {
|
||||
if (!handleXor(payload)) {
|
||||
return false;
|
||||
}
|
||||
Helper.copyStream(new InflaterInputStream(new ByteArrayInputStream(payload)), os);
|
||||
try {
|
||||
Helper.copyStreamEx(new InflaterInputStream(new ByteArrayInputStream(payload)), os);
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,7 +105,7 @@ public class MochiCryptPacker implements Packer {
|
||||
public boolean encrypt(InputStream is, OutputStream os) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DeflaterOutputStream def = new DeflaterOutputStream(baos);
|
||||
Helper.copyStream(is, def);
|
||||
Helper.copyStreamEx(is, def);
|
||||
def.finish();
|
||||
byte[] payload = baos.toByteArray();
|
||||
|
||||
@@ -117,4 +122,14 @@ public class MochiCryptPacker implements Packer {
|
||||
public String getName() {
|
||||
return "MochiCrypt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean suitableForData(byte[] data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "mochicrypt";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,16 @@ public interface Packer {
|
||||
* work
|
||||
*/
|
||||
public Boolean suitableForBinaryData(DefineBinaryDataTag dataTag);
|
||||
|
||||
/**
|
||||
* Is this data packed with this packer?
|
||||
*
|
||||
* @param data
|
||||
* @return true = it definitely is encrypted with this, false = it
|
||||
* definitely is not encrypted with this, null = it is unknown that it will
|
||||
* work
|
||||
*/
|
||||
public Boolean suitableForData(byte[] data);
|
||||
|
||||
/**
|
||||
* Unpack the data
|
||||
@@ -65,4 +75,6 @@ public interface Packer {
|
||||
* @return
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
public String getIdentifier();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user