Weevely is a web shell designed for post-exploitation purposes that can be extended over the network at run time.
Upload weevely PHP agent to a target web server to get remote shell access to it via a small footprint PHP agent. It has more than 30 modules to assist administrative tasks, maintain access, provide situational awareness, elevate privileges, and spread into the target network.
Weevely is a stealth PHP web shell that simulate telnet-like connection. It is an essential tool for web application post exploitation, and can be used as stealth backdoor or as a web shell to manage legit web accounts, even free hosted ones. It is a command line web shell dynamically extended over the network at runtime, designed for remote server administration and penetration testing.
- Shell access to the target
- SQL console pivoting on the target
- HTTP/HTTPS proxy to browse through the target
- Upload and download files
- Spawn reverse and direct TCP shells
- Audit remote target security
- Run Meterpreter payloads
- Port scan pivoting on target
- Mount the remote filesystem
- Bruteforce SQL accounts pivoting on the target
In this guide, we’ll be taking it for a spin on our localhost. You can follow along, or you can get it running on another server where you can do a lot more with it.
Download the Git file:
Download via your browser:
Download via wget (in your terminal):
- wget https://github.com/epinna/weevely3/archive/master.zip
Create the PHP Snippet
No matter how you’ve grabbed the Weevely download above, make sure you have a terminal or shell window open in the directory containing that master.zip file. Assuming you’ve downloaded it to your Downloads folder, let’s go there, unzip the file, change into that unzipped folder location, and do a quick listing to check out the files.
- cd Downloads
- unzip master.zip
- cd weevely3-master/
You should run the weevely.py set-up file alone to get an idea what’s going on here, because the script requires specific syntax, and you can learn about it here.
Generate backdoor agent” option. Let’s make our password HOC, and call our PHP file path config.php . We should end up with a file called config.php in the same directory where we’re working.
- ./weevely.py generate mypassword myfilename.php
So the result that is generated is
Source code of congif.php file
Find a vulnerable website with upload abilities—the kind that lets you share a file or image upload file and get the link to your file.
Any way you do it, you want to get your config.php file—or the contents of your PHP file—into some other PHP file, on some local or remote server. Once you’ve done that, it’s time to call on it.
Access your backdoor
The first thing about Weevely that you may notice is that your config.php file running in the web directory, or on the tail end of some other PHP file, doesn’t do or show anything in your web browser.
What we want to do is open weevely.py on our system again, only this time we’re not going to create a file with it—we’re going to use it to target the place we put the script that we already created. On my localhost server, with my file, this means:
- ./weevely.py http://localhost/config.php HOC
If you’re not testing this out with localhost, it’d be something more like:
- ./weevely.py http://some.websitename.com/myfilename.phpmypassword
Simply typing :help at this point will show you all the things you’re able to try right out of the box.
You can also generate weevely in other format.
Weevely is a webshell management tool written in python.
As this tool is being used in penetration testing we can learn more things. This tutorial is a very basic introduction for beginners on Weevely so the readers can move from basic to advance level according to their comfort level.
Audit the file system for weak permissions.
Find files with SUID or SGID flags.
Bypass disable_function restrictions with mod_cgi and .htaccess
Read /etc/passwd with different techniques.
Audit PHP configuration.
Execute shell commands.
Execute commands with su.
Execute PHP commands.
Collect PHP and webserver extension list.
Collect system information.
List running processes.
Execute a reverse TCP shell.
Spawn a shell on a TCP port.
Start a meterpreter session.
Bruteforce SQL database.
Compress or expand gzip files.
Remove string from a file.
Get attributes and permissions of a file.
Upload file to remote filesystem.
Download an URL.
Compress or expand tar archives.
Download file from remote filesystem.
Compress or expand bzip2 files.
Edit remote file on a local editor.
Print lines matching a pattern in multiple files.
List directory content.
Copy single file.
Remove remote file.
Upload file automatically to a web folder and get corresponding URL.
Compress or expand zip files.
Change file timestamp.
Find files with given names and attributes.
Mount remote filesystem using HTTPfs.
Check existence and permissions of a list of paths.
Read remote file from the remote filesystem.
Change current working directory.
Execute SQL query or run console.
Multi dbms mysqldump replacement.
Install PHP proxy on the target.
Perform a curl-like HTTP request.
Run local proxy to pivot HTTP/HTTPS browsing through the target.
TCP Port scan.
Get network interfaces addresses.
Disclaimer- This article is only for knowledge purpose don’t use it doing unacceptable things.