Is it possible to conceal the existence of a malicious alias in Bash on a Linux system and have it executed by the user without their knowledge?
Is it possible to conceal the existence of a malicious alias in Bash on a Linux system and have it executed by the user without their knowledge?
It is possible to do that by appending the existing alias onto the malicious one and using cursor movement to hide it if the
alias
command is used to display alias definitions. It's not a perfectly foolproof method, but it might go undetected for a while. Pipingalias
throughhd
will show you whether there are any escape sequences (cursor movement) in your aliases. Here is a proof of concept for how a malicious command could be inserted into an alias:sed
command modifies a file called "aliases" in place - a real script of this type would go for the throat and modify a real script file so the malicious alias would be activated the next time it's executed.hide
as an argument so it's conceivable that you could get an error similar to the one reported in the this question. It might be possible to reverse the original and malicious portions to affect this, although this would interfere with arguments being provided to the alias. An attempt is made in the script above to mark the end of arguments with--
.&&
, you could pipe one to the next and make the malicious script (represented above by the simpleecho
command) function as astdin
tostdout
pass-through either to modify the data as it's going across or to hide its existence further by not interfering with other redirectionhide
string could be modified to include different cursor movement and the text of the original alias so thealias
command would appear to show the unmodified alias instead of hiding it along with the malicious part.. aliases
. Then you can try to use the affected alias and see what it looks like when you doalias|hd
.