Try it using Invoke-Atomic

Proxy: Internal Proxy

Description from ATT&CK

Adversaries may use an internal proxy to direct command and control traffic between two or more systems in a compromised environment. Many tools exist that enable traffic redirection through proxies or port redirection, including HTRAN, ZXProxy, and ZXPortMap. (Citation: Trend Micro APT Attack Tools) Adversaries use internal proxies to manage command and control communications inside a compromised environment, to reduce the number of simultaneous outbound network connections, to provide resiliency in the face of connection loss, or to ride over existing trusted communications paths between infected systems to avoid suspicion. Internal proxy connections may use common peer-to-peer (p2p) networking protocols, such as SMB, to better blend in with the environment.

By using a compromised internal system as a proxy, adversaries may conceal the true destination of C2 traffic while reducing the need for numerous connections to external systems.

Atomic Tests

Atomic Test #1 - Connection Proxy

Enable traffic redirection.

Note that this test may conflict with pre-existing system configuration.

Supported Platforms: macos,linux

auto_generated_guid: 0ac21132-4485-4212-a681-349e8a6637cd

Inputs:

Name Description Type Default Value
proxy_server Proxy server URL (host:port) Url 127.0.0.1:8080
proxy_scheme Protocol to proxy (http or https) String http

Attack Commands: Run with sh!

1
2
export #{proxy_scheme}_proxy=#{proxy_server}

Cleanup Commands:

1
2
3
unset http_proxy
unset https_proxy

Atomic Test #2 - Connection Proxy for macOS UI

Enable traffic redirection on macOS UI (not terminal). The test will modify and enable the "Web Proxy" and "Secure Web Proxy" settings in System Preferences => Network => Advanced => Proxies for the specified network interface.

Note that this test may conflict with pre-existing system configuration.

Supported Platforms: macos

auto_generated_guid: 648d68c1-8bcd-4486-9abe-71c6655b6a2c

Inputs:

Name Description Type Default Value
proxy_server Proxy server URL (host) Url 127.0.0.1
proxy_port Proxy server port Integer 8080
interface Protocol to proxy (http or https) String Wi-Fi

Attack Commands: Run with sh!

1
2
3
networksetup -setwebproxy #{interface} #{proxy_server} #{proxy_port}
networksetup -setsecurewebproxy #{interface} #{proxy_server} #{proxy_port}

Cleanup Commands:

1
2
3
networksetup -setwebproxystate #{interface} off
networksetup -setsecurewebproxystate #{interface} off  

Atomic Test #3 - portproxy reg key

Adds a registry key to set up a proxy on the endpoint at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PortProxy\v4tov4 Upon execution there will be a new proxy entry in netsh netsh interface portproxy show all

Supported Platforms: windows

auto_generated_guid: b8223ea9-4be2-44a6-b50a-9657a3d4e72a

Inputs:

Name Description Type Default Value
connectaddress Specifies the IPv4 address to which to connect. Acceptable values are IP address, computer NetBIOS name, or computer DNS name. If an address is not specified, the default is the local computer. String 127.0.0.1
connectport Specifies the IPv4 port, by port number or service name, to which to connect. If connectport is not specified, the default is the value of listenport on the local computer. String 1337
listenport Specifies the IPv4 port, by port number or service name, on which to listen. String 1337

Attack Commands: Run with powershell! Elevation Required (e.g. root or admin)

1
netsh interface portproxy add v4tov4 listenport=#{listenport} connectport=#{connectport} connectaddress=#{connectaddress}

Cleanup Commands:

1
netsh interface portproxy delete v4tov4 listenport=#{listenport} -ErrorAction Ignore | Out-Null

source