1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-14 17:37:27 +01:00

add java architecture to sysinfo

This commit is contained in:
Tim W 2022-02-08 13:05:47 +00:00
parent d3a60ff656
commit a0b297f073
3 changed files with 34 additions and 11 deletions

View File

@ -12,13 +12,8 @@ import android.os.Build;
public class stdapi_sys_config_sysinfo_android extends
stdapi_sys_config_sysinfo implements Command {
public int execute(Meterpreter meterpreter, TLVPacket request,
TLVPacket response) throws Exception {
protected String getOsName() throws Exception {
String androidOS = Utils.runCommand("getprop ro.build.version.release").replace("\n", "");
response.add(TLVType.TLV_TYPE_COMPUTER_NAME, Utils.getHostname());
response.add(TLVType.TLV_TYPE_OS_NAME, "Android " + androidOS
+ " - " + System.getProperty("os.name")
+ " " + System.getProperty("os.version") + " (" + System.getProperty("os.arch") + ")");
return ERROR_SUCCESS;
return "Android " + androidOS + " - " + System.getProperty("os.name");
}
}

View File

@ -137,6 +137,7 @@ public interface TLVType {
public static final int TLV_TYPE_OS_NAME = TLVPacket.TLV_META_TYPE_STRING | 1041;
public static final int TLV_TYPE_USER_NAME = TLVPacket.TLV_META_TYPE_STRING | 1042;
public static final int TLV_TYPE_ARCHITECTURE = TLVPacket.TLV_META_TYPE_STRING | 1043;
public static final int TLV_TYPE_LANG_SYSTEM = TLVPacket.TLV_META_TYPE_STRING | 1044;
public static final int TLV_TYPE_LOCAL_DATETIME = TLVPacket.TLV_META_TYPE_STRING | 1048;
public static final int TLV_TYPE_ENV_VARIABLE = TLVPacket.TLV_META_TYPE_STRING | 1100;

View File

@ -1,16 +1,43 @@
package com.metasploit.meterpreter.stdapi;
import java.net.InetAddress;
import com.metasploit.meterpreter.Meterpreter;
import com.metasploit.meterpreter.TLVPacket;
import com.metasploit.meterpreter.TLVType;
import com.metasploit.meterpreter.Utils;
import com.metasploit.meterpreter.command.Command;
import java.util.Locale;
public class stdapi_sys_config_sysinfo implements Command {
private static String normalizeArch(String arch) {
if (arch.equals("i386") || arch.equals("i486") || arch.equals("i586") || arch.equals("i686")) {
return "x86";
}
if (arch.equals("amd64") || arch.equals("x86_64")) {
return "x64";
}
if (arch.equals("arm") || arch.equals("arm32")) {
return "armle";
}
if (arch.equals("arm64")) {
return "aarch64";
}
return arch;
}
protected String getOsName() throws Exception {
return System.getProperty("os.name");
}
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
response.add(TLVType.TLV_TYPE_COMPUTER_NAME, InetAddress.getLocalHost().getHostName());
response.add(TLVType.TLV_TYPE_OS_NAME, System.getProperty("os.name") + " " + System.getProperty("os.version") + " (" + System.getProperty("os.arch") + ")");
String arch = System.getProperty("os.arch");
response.add(TLVType.TLV_TYPE_COMPUTER_NAME, Utils.getHostname());
response.add(TLVType.TLV_TYPE_OS_NAME, getOsName() + " " + System.getProperty("os.version") + " (" + arch + ")");
if (arch != null) {
response.add(TLVType.TLV_TYPE_ARCHITECTURE, normalizeArch(arch));
}
response.add(TLVType.TLV_TYPE_LANG_SYSTEM, Locale.getDefault().toString());
return ERROR_SUCCESS;
}
}