-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added string encryption and other transformers
- Loading branch information
Showing
17 changed files
with
453 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/scala/rip/hippo/mosey/transformer/impl/data/StringEncryptionTransformer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package rip.hippo.mosey.transformer.impl.data | ||
|
||
import org.objectweb.asm.tree.LdcInsnNode | ||
import rip.hippo.mosey.asm.wrapper.ClassWrapper | ||
import rip.hippo.mosey.configuration.Configuration | ||
import rip.hippo.mosey.dictionary.Dictionary | ||
import rip.hippo.mosey.transformer.Transformer | ||
import rip.hippo.mosey.transformer.impl.data.string.impl.LightStringEncryptionIntensity | ||
|
||
/** | ||
* @author Hippo | ||
* @version 1.0.0, 7/31/20 | ||
* @since 1.0.0 | ||
* | ||
* Well, encrypts strings, nothing more than that eh? | ||
*/ | ||
final class StringEncryptionTransformer(configuration: Configuration, val dictionary: Dictionary) extends Transformer { | ||
|
||
private val stringEncryptionIntensity = configuration.get("StringEncryption", "intensity").toString.toLowerCase match { | ||
case "light" => new LightStringEncryptionIntensity | ||
case x => throw new IllegalStateException("Could not resolve intensity mode %s".format(x)) | ||
} | ||
|
||
override def transform(classWrapper: ClassWrapper): Unit = { | ||
val hasStrings = classWrapper.methods.exists(_.getInstructions.toArray.exists(instruction => instruction.isInstanceOf[LdcInsnNode] && instruction.asInstanceOf[LdcInsnNode].cst.isInstanceOf[String])) | ||
|
||
if (hasStrings) { | ||
stringEncryptionIntensity.accept(classWrapper, this) | ||
|
||
classWrapper.methods.foreach(method => | ||
method.getInstructions.toArray.foreach { | ||
case ldcInsnNode: LdcInsnNode if ldcInsnNode.cst.isInstanceOf[String] => | ||
method.getInstructions.insert(ldcInsnNode, stringEncryptionIntensity.encrypt(ldcInsnNode, classWrapper)) | ||
method.getInstructions.remove(ldcInsnNode) | ||
case _ => | ||
} | ||
) | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/scala/rip/hippo/mosey/transformer/impl/data/string/StringEncryptionIntensity.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package rip.hippo.mosey.transformer.impl.data.string | ||
|
||
import org.objectweb.asm.tree.{InsnList, LdcInsnNode} | ||
import rip.hippo.mosey.asm.wrapper.ClassWrapper | ||
import rip.hippo.mosey.transformer.impl.data.StringEncryptionTransformer | ||
|
||
/** | ||
* @author Hippo | ||
* @version 1.0.0, 7/31/20 | ||
* @since 1.0.0 | ||
*/ | ||
trait StringEncryptionIntensity { | ||
def accept(classWrapper: ClassWrapper, parent: StringEncryptionTransformer): Unit | ||
def encrypt(ldcInsnNode: LdcInsnNode, classWrapper: ClassWrapper): InsnList | ||
} |
Oops, something went wrong.