1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-20 14:39:22 +01:00

refine string handlings

This commit is contained in:
XenoAmess 2021-02-11 23:09:41 +08:00
parent badaaa4df2
commit 384b5fb795
4 changed files with 11 additions and 12 deletions

View File

@ -29,7 +29,7 @@ public class MeterpreterTest extends TestCase {
Assert.assertEquals(4096, uc.getContentLength());
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamForwarder.forward(uc.getInputStream(), out);
Assert.assertEquals(new String(randomData, "ISO-8859-1"), new String(out.toByteArray(), "ISO-8859-1"));
Assert.assertEquals(new String(randomData, "ISO-8859-1"), out.toString("ISO-8859-1"));
}
public void testMeterpreterStage() throws Exception {
@ -37,7 +37,7 @@ public class MeterpreterTest extends TestCase {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
StreamForwarder.forward(MeterpDummy.class.getResourceAsStream(MeterpDummy.class.getSimpleName() + ".class"), baos);
String meterpDummy = new String(baos.toByteArray(), "ISO-8859-1").replace("MeterpDummy", "Meterpreter");
String meterpDummy = baos.toString("ISO-8859-1").replace("MeterpDummy", "Meterpreter");
baos.reset();
JarOutputStream jos = new JarOutputStream(baos);
jos.putNextEntry(new ZipEntry("com/metasploit/meterpreter/Meterpreter.class"));

View File

@ -20,7 +20,7 @@ public class ShellTest extends TestCase {
Thread.sleep(100);
timeout -= 100;
}
String shellOutput = new String(out.toByteArray(), "ISO-8859-1");
String shellOutput = out.toString("ISO-8859-1");
// Assert.assertTrue("MagicToken missing in shell output: " + shellOutput, shellOutput.contains("MagicToken"));
// Assert.assertEquals(-1, in.read());
}

View File

@ -17,11 +17,10 @@ public class core_machine_id implements Command {
private static String machine_id;
private String getSerial() throws IOException {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(Utils.runCommand("getprop ro.serialno").trim());
stringBuffer.append(Utils.runCommand("getprop ro.product.brand").trim());
stringBuffer.append(Utils.runCommand("getprop ro.product.model").trim());
return stringBuffer.toString();
String stringBuffer = Utils.runCommand("getprop ro.serialno").trim() +
Utils.runCommand("getprop ro.product.brand").trim() +
Utils.runCommand("getprop ro.product.model").trim();
return stringBuffer;
}
private String getHDLabel() {

View File

@ -21,10 +21,10 @@ public class core_transport_add implements Command {
HttpTransport h = new HttpTransport(meterpreter, transportUrl);
// do the HTTP specific stuff here, since we know what we are
h.setUserAgent(request.getStringValue(TLVType.TLV_TYPE_TRANS_UA, new String()));
h.setProxy(request.getStringValue(TLVType.TLV_TYPE_TRANS_PROXY_HOST, new String()));
h.setProxyUser(request.getStringValue(TLVType.TLV_TYPE_TRANS_PROXY_USER, new String()));
h.setProxyPass(request.getStringValue(TLVType.TLV_TYPE_TRANS_PROXY_PASS, new String()));
h.setUserAgent(request.getStringValue(TLVType.TLV_TYPE_TRANS_UA, ""));
h.setProxy(request.getStringValue(TLVType.TLV_TYPE_TRANS_PROXY_HOST, ""));
h.setProxyUser(request.getStringValue(TLVType.TLV_TYPE_TRANS_PROXY_USER, ""));
h.setProxyPass(request.getStringValue(TLVType.TLV_TYPE_TRANS_PROXY_PASS, ""));
h.setCertHash(request.getRawValue(TLVType.TLV_TYPE_TRANS_CERT_HASH, null));
t = h;