-
Notifications
You must be signed in to change notification settings - Fork 14k
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 source meta command for shell session #10509
Conversation
|
||
if background | ||
print_status("Executing on remote machine background") | ||
print_line(shell_command("nohup sh -x #{remote_file} &")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of xtrace
to log executed commands!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I will try to test this command~ thank you for your suggestion~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're already doing it with -x
. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wvu-r7 Did you mean this tool? https://github.com/johnno1962/Xtrace
I found several tools named xtrace
, >_<, (strace
or ltrace
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the functionality of set -x
, which is called xtrace
:
wvu@kharak:~$ help set | grep -- -x | sed \$d
xtrace same as -x
-x Print commands and their arguments as they are executed.
wvu@kharak:~$
background = args[1].downcase == 'y' | ||
|
||
local_file = args[0] | ||
remote_file = "/tmp/." + ::Rex::Text.rand_text_alpha(32) + ".sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to protect the permissions of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't understand what you mean. The file created here is for temporary use and after use, it will be deleted. I don't understand why I need to protect the permissions of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WangYihang: TOCTOU concerns about whether you're executing what you intended, or what someone with access to your system (or the path where this file is created on a remotely mounted FS) while you're working is intending (at time of use, of course).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good start is 0600
for a script executed directly by the shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will update the code.
Jenkins test this please. |
Looks good, landing. |
Release NotesThis adds a |
Description
Implementation of source command
This command allows attack to execute a local script on the remote machine
Verification
Create a shell script file
/tmp/evil.rb
in the attacker's machine will be executed on the remote machine in foregroundsource /tmp/evil.sh n
, you can execute other commands immediately (eg:uname -a
), DO NOT have to wait for the end of the execution