Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


PHP zip remote code doesn't work


I wrote a simple script to zip whole folder on ftp. I connect to this through ftp protocol, and I found it difficult to zip and unzip anything this way, so decided to use php as shell turned out to be too difficult for me. I run script bellow by bat file, it looks like that:

open ftp…….

cd domains/
echo '<?php system("zip -r folder1") ?>' | php -q

Connection and patch is ok because I was using this to remove files (rm) and it works then. Also when I try to run this php script in a php file through browser, then it works so system() function is available at my hosting. Bellow is log, and there is nothing so I have no idea why it doesn’t work.

. 2019-04-28 19:37:12.074 Using FTP protocol.

. 2019-04-28 19:37:12.074 Doing startup conversation with host.
> 2019-04-28 19:37:12.074 PWD
< 2019-04-28 19:37:12.095 257 "/" is the current directory
. 2019-04-28 19:37:12.095 Getting current directory name.
. 2019-04-28 19:37:12.095 Startup conversation with host finished.
< 2019-04-28 19:37:12.095 Script: Aktywna sesja: [1] xxxxxxx@xxxxxxxxxx
> 2019-04-28 19:37:12.099 Script: cd domains/
. 2019-04-28 19:37:12.099 Cached directory change via "domains/" to "/domains/".
. 2019-04-28 19:37:12.099 Getting current directory name.
< 2019-04-28 19:37:12.099 Script: /domains/
> 2019-04-28 19:37:12.103 Script: echo '<?php system("zip -r folder1") ?>' | php -q
< 2019-04-28 19:37:12.103 Script: '<?php system("zip -r folder1") ?>' | php -q
> 2019-04-28 19:37:12.106 Script: exit
. 2019-04-28 19:37:12.106 Script: Exit code: 0
. 2019-04-28 19:37:12.109 Rozłączono z serwerem