Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added command to setup proxy via objection #439

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -470,6 +471,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