GithubHelp home page GithubHelp logo

skidfuscator-ir's Introduction

skidfuscator-ir

Imagine if you could rename a class and its invokers by doing klass.setName(<name). Well now u can.

Usage

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        implementation 'com.github.skidfuscatordev:skidfuscator-ir:master-SNAPSHOT'
	}

Then, to begin using it, create a hierarchy as follows:

final Map<String, ClassNode> classes = new HashMap();
// Your class loading logic here

final SkidLibraryHierarchy hierarchy = new SkidLibraryHierarchy();
hierarchy.resolveClasses(classes);

Iterating wrapped classes


You can iterate all application classes by using

for (final KlassNode node : hierarchy.iterateKlasses()) {
    node.setName("Omg" + node.getName());
}

Finding a class


You can find a class of the name formatted as "my/searched/Class" by using

final KlassNode node = hierarchy.resolveClass("my/searched/Class");

If the class does not exist, if configured, an "UnresolvedKlassNode" will be generated. If you seek to not generate a phantom class, please instead use the deprecated hierarchy#findClass until I finish writing the config system.


Modifying the bytecode


You can access and modify the bytecode of a class by doing the following:

final KlassNode node = hierarchy.resolveClass("my/searched/Class");

for (final FunctionNode method : node.getMethods()) {
    final InstructionList bytecode = method.getInstructionList();
    bytecode.add(new SimpleInsn(hierarchy, new InsnNode(Opcodes.NOP)));
}

The following nodes are wrapped:

  • FieldInsnNode --> FieldInsn
  • FrameNode --> FrameInsn
  • IincInsnNode --> IincInsn
  • IntInsnNode --> IntInsn
  • InvokeDynamicInsnNode --> InvokeDynamicInsn
  • MethodInsnNode --> InvokeInsn
  • JumpInsnNode --> JumpInsn
  • LabelNode --> LabelInsn
  • LdcInsnNode --> LdcInsn
  • LineNumberNode --> LineNumberInsn
  • LookupSwitchInsnNode --> LookupSwitchInsn
  • TableSwitchInsnNode --> TableSwitchNode
  • MultiANewArrayInsnNode --> MultiANewArrayInsn
  • InsnNode --> SimpleInsn
  • TypeInsnNode --> TypeInsn
  • VarInsnNode --> VarInsn

Preventing further changes


With skidfuscator-ir, you can lock changes on a class. This will effectively prevent any further changes to the class if you wish to inspect a class and set it as a library post-resolving it. Practical for analysers wishing to debug what's changing what.

final KlassNode node = hierarchy.resolveClass("my/searched/Class");
node.lock(); // Locks a class

Todo

  • Finish all insn nodes
  • Create test suite
  • Add support for fields
  • Add support for annotation
  • signatures
  • mapper for types
  • mapper for annotations
  • mapper for annotation method linking

skidfuscator-ir's People

Contributors

terminalsin avatar narumii avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.