Commit baac51e6 authored by Jeff Williams's avatar Jeff Williams
Browse files
parents 996c9c53 6500ff68
Showing with 10 additions and 8 deletions
+10 -8
package com.contrastsecurity;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import net.bytebuddy.agent.ByteBuddyAgent;
import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
import net.bytebuddy.agent.ByteBuddyAgent;
public class App {
public static void main(String[] args){
System.out.println("SafeLog4j by Contrast Security");
System.out.println( "https://contrastsecurity.com" );
......@@ -21,8 +18,13 @@ public class App {
try{
String pid = args[0];
String options = args.length>=2 ? args[1] : null;
String agentFilePath = "safelog4j-1.0.2.jar";
File agentFile = new File(agentFilePath);
String filename = App.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.toURI()
.getPath();
File agentFile = new File(filename);
ByteBuddyAgent.attach(agentFile.getAbsoluteFile(), pid, options);
System.out.println("Attached to target jvm and loaded agent successfully");
}catch(Exception e){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment