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

Land #467, StringBuffer to StringBuilder

This commit is contained in:
Tim W 2021-03-11 15:22:02 +00:00
commit 54de384b28
No known key found for this signature in database
GPG Key ID: 217FBA50ABBAABEF
4 changed files with 8 additions and 9 deletions

View File

@ -357,7 +357,7 @@ public class Payload extends ClassLoader {
s.push(thisToken);
}
}
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.size(); i++) {
if (i > 1) {
// not before the filesystem root and not after it, since root
@ -384,7 +384,7 @@ public class Payload extends ClassLoader {
//remove the initial separator; the root has it.
next = (ca[next] == sep) ? next + 1 : next;
StringBuffer sbPath = new StringBuffer();
StringBuilder sbPath = new StringBuilder();
// Eliminate consecutive slashes after the drive spec:
for (int i = next; i < ca.length; i++) {
if (ca[i] != sep || ca[i - 1] != sep) {

View File

@ -17,13 +17,13 @@ public class Utils {
public static String runCommand(String command) throws IOException {
Process process = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuffer stringBuffer = new StringBuffer();
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
stringBuffer.append(line);
stringBuffer.append('\n');
stringBuilder.append(line);
stringBuilder.append('\n');
}
return stringBuffer.toString();
return stringBuilder.toString();
}
public static String getHostname() {

View File

@ -15,10 +15,9 @@ public class core_machine_id implements Command {
private static String machine_id;
private String getSerial() throws IOException {
String stringBuffer = Utils.runCommand("getprop ro.serialno").trim() +
return 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

@ -15,7 +15,7 @@ public class stdapi_sys_process_execute implements Command {
private static int pid = 0;
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
StringBuffer cmdbuf = new StringBuffer();
StringBuilder cmdbuf = new StringBuilder();
String cmd = request.getStringValue(TLVType.TLV_TYPE_PROCESS_PATH);
String argsString = request.getStringValue(TLVType.TLV_TYPE_PROCESS_ARGUMENTS, "");
int flags = request.getIntValue(TLVType.TLV_TYPE_PROCESS_FLAGS);