Skip to content

Commit

Permalink
Merge pull request #630 from bytedance/feat-attachinfo
Browse files Browse the repository at this point in the history
Feat attachinfo
  • Loading branch information
yoloyyh committed Jun 5, 2024
2 parents be13a83 + 8f6d3ac commit ac9036b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ public static void agentmain(String agentArgs, Instrumentation inst) {
SmithAgentLogger.logger.info("parse parseParameter success");

if(cmd.equals("attach")) {
AttachInfo.info();
checksumStr = checksumStr_sb.toString();
proberPath = proberPath_sb.toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.security.smith.client.message.*;
import com.security.smith.common.Reflection;
import com.security.smith.common.SmithHandler;
import com.security.smith.log.AttachInfo;
import com.security.smith.log.SmithLogger;
import com.security.smith.module.Patcher;
import com.security.smith.type.*;
Expand Down Expand Up @@ -179,6 +180,7 @@ public void setProbePath(String proberPath) {
}

public void init() {
AttachInfo.info();
SmithLogger.loggerProberInit();
SmithLogger.logger.info("probe init enter");
smithClasses = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.security.smith.log;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import com.security.smith.common.ProcessHelper;

public class AttachInfo {
public static void info() {

try {
Path path = Paths.get("/proc/" + ProcessHelper.getCurrentPID() + "/cwd");
String cwd = Files.readSymbolicLink(path).toString();

File file = new File(cwd);

if (file.exists()) {

file = new File(cwd + "/0_your_service_has_been_protected_by_elkeid_rasp.log");
if (!file.exists()) {
if (file.createNewFile()) {

FileWriter writer = new FileWriter(file);
writer.write("Your Java Service Will Be Protected By RASP");
writer.close();
}
}
}
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}

0 comments on commit ac9036b

Please sign in to comment.