JHook - A tool that can dynamically modify Java classes at runtime.

Related tags

Spring Boot JHook
Overview

JHook

A tool that can dynamically modify Java classes at runtime.

Demo

Tested on Java 1.8 - Java 17, just support JDK

package com.binklac.jhook.test;

import com.binklac.jhook.JHook;
import com.binklac.jhook.Utils;
import javassist.*;

import java.io.IOException;

class JHookTestPrinter {
    public static Boolean PrintAndGetResult(){
        System.out.println("[X] The function has not been modified. ");
        return false;
    }
}

public class JHookTest {
    public static void main(String[] args) throws NotFoundException, CannotCompileException, IOException {
        System.out.println("[#] JHook operating environment check.");

        ClassPool defaultClassPool = ClassPool.getDefault();

        defaultClassPool.appendClassPath(Utils.GetJHookJarPath());

        CtClass jndiLookupClass = defaultClassPool.get("com.binklac.jhook.test.JHookTestPrinter");
        CtMethod lookup = jndiLookupClass.getDeclaredMethod("PrintAndGetResult");
        lookup.setBody("{System.out.println(\"[#] The function was successfully modified.\"); return Boolean.TRUE;}");

        if (!JHook.Instance().ModifyClass("com.binklac.jhook.test.JHookTestPrinter", jndiLookupClass.toBytecode())) {
            System.out.println("[X] The class cannot be modified, you need to install jdk or upgrade to a version after Java SE 9 to use the program normally.!");
        }

        if (JHookTestPrinter.PrintAndGetResult()) {
            System.out.println("[#] JHook is running normally and your environment supports JHook.");
        } else {
            System.out.println("[X] JHook cannot run normally and the test fails.");
        }
    }
}
You might also like...

Código Fonte das classes em Java.

ExerciciosClasses ▶️ PLAYLIST COM OS EXERCÍCIOS RESOLVIDOS POO CLASSES - JAVA ▶️ ⚠️ Alguns dos exercícios foram adaptados do site Python Brasil! ⚠️ 🛑

Sep 5, 2022

🎒 💻 Material for Computer Club Classes

🎒 💻 Material for Computer Club Classes

MNNIT Computer Coding Club This repository contains the codes, support links and other relevant materials for every class under Computer Coding Club,

Dec 18, 2022

Piranha - a modern cloud runtime

Piranha Project The Piranha Project delivers you with Cloud ready containers and useful add-on / integration modules. Getting Started To get started w

Dec 24, 2022

The ByteSkript development kit, including resources for third-party libraries that are not contained within the standard runtime.

ByteSkript Development Kit Todo. The development kit is a set of advanced resources available for library creators. These are not available within the

Jan 8, 2022

Allows acquiring of vanilla/mod assets at runtime instead of including them in builds potentially violating licenses

AssetMover Allows acquiring of vanilla/mod assets at runtime instead of including them in builds potentially violating licenses. Features: Downloading

Nov 26, 2022

Cloud native multi-runtime microservice framework

Cloud native multi-runtime microservice framework

Femas: Cloud native multi-runtime microservice framework The repository address has been transferred to PolarisMesh English | 简体中文 Introduction abilit

Sep 5, 2022

The Distributed Application Runtime (Dapr) provides APIs that simplify microservice connectivity

The Distributed Application Runtime (Dapr) provides APIs that simplify microservice connectivity

Quarkus - Dapr Introduction What is Quarkus? Traditional Java stacks were engineered for monolithic applications with long startup times and large mem

Jan 5, 2023

A library that automatically generates and manages configuration files based on classes.

sc-cfg SC-CFG is a simple, yet powerful library that automatically generate configuration files based on your classes. Compatible with Java 8+ and Kot

Nov 28, 2022

This is a Maven plugin designed to help developers automatizing the creation of code classes from YML files based on AsyncApi and OpenAPI.

SCS MultiApi Maven Plugin This is a Maven plugin designed to help developers automatizing the creation of code classes from YML files based on AsyncAp

Dec 20, 2022
Releases(v1.0.0)
Owner
VeroFess
Ease it off.
VeroFess
Dynamically filters JPA entities with a simple query syntax. Provides JPA/Hibernate predicates and Spring Data specifications.

Spring Filter You need a way to dynamically filter entities without any effort? Just add me to your pom.xml. Your API will gain a full featured search

Turkraft 142 Dec 13, 2022
Discourse-java is a platform where users can freely discuss on topics they want to, and like-minded people can join in and contribute

Discourse is the 100% open source discussion platform built for the next decade of the Internet. Use it as a: mailing list discussion forum long-form

Infosys Ltd 16 Oct 19, 2022
By this package we can get sim info, call logs and sms logs.Also we can find for specific sim info and call logs as well.

sim_sms_call_info A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package

 Hasib Akon 3 Sep 17, 2022
Free and 100% open source Progressive Java Runtime for modern Java™ deployments supported by a leading OpenJDK contributor

BellSoft Liberica JDK is a build of OpenJDK that is tested and verified to be compliant with the Java SE specification using OpenJDK Technology Compat

null 195 Dec 22, 2022
ijrd - internal java runtime debugger (loads through java agents LOL)

ijrd ijrd - internal java runtime debugger (loads through java agents LOL) this actually requires brain to build and then setup little guide to setup

null 6 Jan 28, 2022
Resconstruct is a java library to infer missing information vectors of java classes.

Reconstruct Resconstruct is a java library to infer missing information vectors of java classes. Features Phantom classes Inheritance solving Dummy fi

Nowilltolife 14 Nov 17, 2022
A manager tool to categorize game assets such as images and sounds/music. The tool enables you to tag these files, so that finding them by tags allows fast searches.

BtAssetManager This application allows you to easily categorize large amounts of image and sound files. You can apply tags to each individual file to

null 21 Sep 15, 2022
Runtime code generation for the Java virtual machine.

Byte Buddy runtime code generation for the Java virtual machine Byte Buddy is a code generation and manipulation library for creating and modifying Ja

Rafael Winterhalter 5.3k Dec 27, 2022
A Java library for performing runtime interception of methods

Interceptify This library is designed to provide a convenient and simple means of performing runtime interception of Java methods/constructors. Usage

Oliver 4 Aug 17, 2022
A list of direct references to classes and interfaces in the Java Language Specification (3d Ed.)

A list of direct references to classes and interfaces in the Java Language Specification (3d Ed.) and a program to compute the indirectly required classes and interfaces

Joshua Bloch 12 Jun 3, 2022