Personal
Successfully got flag from Reverse challenge
The Satellite challenge
import javax.management.*;
import javax.management.remote.*;
import java.util.*;
import [java.io](<http://java.io/>).*;
import [java.net](<http://java.net/>).*;
public class JMXConnect {
public static void main(String[] args) throws Exception {
String mbean = "gov.sfb.schriever:type=Galileo";
String hostname = "10.0.2.135";
int port = 1958;
JMXServiceURL jmxUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + hostname + ":" + port + "/jmxrmi");
JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, null);
try {
MBeanServerConnection mbs = jmxConnector.getMBeanServerConnection();
ObjectName mbeanName = new ObjectName(mbean);
MBeanInfo mbeanInfo = mbs.getMBeanInfo(mbeanName);
// Print attributes
System.out.println("Attributes:");
for (MBeanAttributeInfo attr : mbeanInfo.getAttributes()) {
String attrName = attr.getName();
if (attrName.startsWith("channels")) {
Object attrValue = mbs.getAttribute(mbeanName, attrName);
System.out.println("\\\\tName: " + attrName + ", Value: " + attrValue);
}
}
// Print the available operations
System.out.println("Available Operations:");
for (MBeanOperationInfo op : mbeanInfo.getOperations()) {
System.out.println("\\\\tOperation Name: " + op.getName());
}
// Invoke the loadPayload operation
//System.out.println("Loading payload...");
//Object[] loadPayloadParams = {0}; // Assuming payload ID is 0
//String[] loadPayloadSignature = {"int"};
//mbs.invoke(mbeanName, "loadPayload", loadPayloadParams, loadPayloadSignature);
//System.out.println("Payload loaded successfully.");
// Invoke the getChannelValues operation
//System.out.println("Getting channel values...");
//Object result = mbs.invoke(mbeanName, "getChannelValues", null, null);
//System.out.println("Channel values: " + result);
// Declare totalChannels and totalSubchannels variables
int totalChannels = 350;
int totalSubchannels = 260;
//Iterate over channels and subchannels
System.out.println("Channel Values:");
for (int channel = 1; channel <= totalChannels; channel++) {
for (int subchannel = 1; subchannel <= totalSubchannels; subchannel++) {
try {
Object[] params = {channel, subchannel};
String[] signature = {"int", "int"};
Object result = mbs.invoke(mbeanName, "getChannelValues", params, signature);
System.out.println("Channel " + channel + ", Subchannel " + subchannel + ": " + result);
} catch (Exception e) {
System.err.println("Error invoking getChannelValues for Channel " + channel + ", Subchannel " + subchannel + ": " + e.getMessage());
e.printStackTrace();
}
}
}
//System.out.println("Getting identifiers...");
//Object result = mbs.invoke(mbeanName, "getIdentifier", new Object[1], new String[string]);
//System.out.println("Identifies: " + result);
// Find and print parameters of "getIdentifier" operation
//System.out.println("Parameters of getIdentifier operation:");
//for (MBeanOperationInfo operation : mbeanInfo.getOperations()) {
//if (operation.getName().equals("getIdentifier")) {
//MBeanParameterInfo[] signature = operation.getSignature();
//for (MBeanParameterInfo param : signature) {
//System.out.println("\\\\tParameter: " + param.getName() + ", Type: " + param.getType());
//}
//break;
//}
//}
// Enumerate and print identifier channels
//System.out.println("Identifier Channels:");
//int totalChannels = 350;
//for (int i = 1; i <= totalChannels; i++) {
//try {
//Object[] params = {i};
//String[] signature = {"int"};
//Object result = mbs.invoke(mbeanName, "getIdentifier", params, signature);
//System.out.println("\\\\tChannel " + i + ": " + result);
//} catch (Exception e) {
//System.err.println("Error invoking getIdentifier for Channel " + i + ": " + e.getMessage());
//}
//}
// Invoke the getIdentifier operation
//System.out.println("Identifier Channels:");
//Object result = mbs.invoke(mbeanName, "getChannelValues", null, null);
//System.out.println(result);
// Invoke the getIdentifier operation
//System.out.println("Identifier Channels:");
//Object[] params = new Object[0];
//String[] signature = new String[0];
//Object result = mbs.invoke(mbeanName, "getIdentifier", params, signature);
//System.out.println(result);
} finally {
jmxConnector.close();
}
}
}