Skip to content

Commit

Permalink
Added command to setup proxy via objection (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
GOAT-FARM3R authored Feb 17, 2021
1 parent 03b4194 commit 91d1311
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
26 changes: 26 additions & 0 deletions agent/src/android/proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { wrapJavaPerform } from "./lib/libjava";
import { colors as c } from "../lib/color";
import { qsend } from "../lib/helpers";

export namespace proxy {

export const set = (host: string, port: string): Promise<void> => {
return wrapJavaPerform(() => {
var proxyHost = host;
var proxyPort = port;

var System = Java.use("java.lang.System");

if(System != undefined) {
send(c.green(`Setting properties for a proxy`));
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);

System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", proxyPort);

send(`${c.green(`Proxy configured to ` + proxyHost + ` ` + proxyPort)}`);
}
});
};
}
4 changes: 4 additions & 0 deletions agent/src/rpc/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { sslpinning } from "../android/pinning";
import { root } from "../android/root";
import { androidshell } from "../android/shell";
import { userinterface } from "../android/userinterface";
import { proxy } from "../android/proxy";

export const android = {
// android clipboard
Expand Down Expand Up @@ -64,6 +65,9 @@ export const android = {
// android ssl pinning
androidSslPinningDisable: (quiet: boolean) => sslpinning.disable(quiet),

// android proxy set/unset
androidProxySet: (host: string, port: string): Promise<void> => proxy.set(host, port),

// android root detection
androidRootDetectionDisable: () => root.disable(),
androidRootDetectionEnable: () => root.enable(),
Expand Down
18 changes: 18 additions & 0 deletions objection/commands/android/proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import click
from objection.state.connection import state_connection


def android_proxy_set(args: list = None) -> None:
"""
Sets a proxy specifically within the application.
:param args:
:return:
"""

if len(args) != 2:
click.secho('Usage: android proxy set <ip address> <port>', bold=True)
return

api = state_connection.get_api()
api.android_proxy_set(args[0], args[1])
10 changes: 10 additions & 0 deletions objection/console/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ..commands.android import intents
from ..commands.android import keystore
from ..commands.android import pinning as android_pinning
from ..commands.android import proxy as android_proxy
from ..commands.android import root
from ..commands.ios import binary
from ..commands.ios import bundles
Expand Down Expand Up @@ -471,6 +472,15 @@
}
}
},
'proxy': {
'meta': 'Commands to work with a proxy for the application',
'commands': {
'set': {
'meta': 'Set a proxy for the application',
'exec': android_proxy.android_proxy_set
}
}
},
'ui': {
'meta': 'Android user interface commands',
'commands': {
Expand Down

0 comments on commit 91d1311

Please sign in to comment.