pupy
Pupy is an opensource, cross-platform (Windows, Linux, OSX, Android) C2 and post-exploitation framework written in python and C
Top Related Projects
A swiss army knife for pentesting networks
Empire is a PowerShell and Python post-exploitation agent.
Merlin is a cross-platform post-exploitation HTTP/2 Command & Control server and agent written in golang.
Metasploit Framework
PowerSploit - A PowerShell Post-Exploitation Framework
Quick Overview
Pupy is an open-source, cross-platform (Windows, Linux, OSX, Android) remote administration and post-exploitation tool written in Python. It provides a comprehensive set of features for remote system control, surveillance, and data exfiltration, making it a powerful tool for penetration testing and security research.
Pros
- Cross-platform compatibility, supporting multiple operating systems
- Extensive feature set for remote administration and post-exploitation tasks
- Modular architecture allowing easy extension and customization
- Active development and community support
Cons
- Potential for misuse by malicious actors
- Complexity may require a steep learning curve for new users
- Some antivirus software may flag it as malicious due to its nature
- Requires careful handling to avoid legal and ethical issues
Getting Started
To get started with Pupy, follow these steps:
-
Clone the repository:
git clone https://github.com/n1nj4sec/pupy.git cd pupy
-
Install dependencies:
pip install -r requirements.txt
-
Generate SSL certificates:
./create-workspace.py -DG
-
Start the Pupy server:
python pupysh.py
-
Generate a payload for your target system using the
gen
command in the Pupy console. -
Deploy the payload on the target system and wait for the connection.
Note: Always ensure you have proper authorization before using Pupy on any system. Unauthorized use may be illegal and unethical.
Competitor Comparisons
A swiss army knife for pentesting networks
Pros of CrackMapExec
- Specialized for Windows/Active Directory environments
- Extensive built-in modules for various post-exploitation tasks
- Lightweight and easy to deploy
Cons of CrackMapExec
- Limited cross-platform support (primarily Windows-focused)
- Less flexible for custom payload development
- Narrower scope of functionality compared to Pupy's versatility
Code Comparison
CrackMapExec example:
from crackmapexec import CME
cme = CME()
cme.target = "192.168.1.0/24"
cme.module = "mimikatz"
cme.execute()
Pupy example:
import pupylib.PupyModule
class MyModule(pupylib.PupyModule.PupyModule):
def init_argparse(self):
self.arg_parser.add_argument('target', help='Target IP')
def run(self, args):
self.client.conn.modules.os.system('whoami')
CrackMapExec is more focused on Windows/AD environments with built-in modules, while Pupy offers greater flexibility for cross-platform operations and custom payload development. CrackMapExec excels in rapid AD enumeration and exploitation, whereas Pupy provides a more comprehensive framework for diverse post-exploitation scenarios. The code examples illustrate CrackMapExec's simplicity for predefined tasks, while Pupy demonstrates its extensibility for creating custom modules.
Empire is a PowerShell and Python post-exploitation agent.
Pros of Empire
- More extensive post-exploitation capabilities and modules
- Better suited for Windows environments with PowerShell-based payloads
- Larger community and more frequent updates
Cons of Empire
- Primarily focused on Windows, less versatile for cross-platform operations
- Heavier footprint and potentially easier to detect
- Steeper learning curve for beginners
Code Comparison
Empire (PowerShell-based payload):
$s=New-Object IO.MemoryStream(,[Convert]::FromBase64String("H4sIAAAAAAAAAL1Xe2..."));
IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($s,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd();
Pupy (Python-based payload):
import pupyimporter
pupyimporter.install()
import pupy
pupy.main()
Key Differences
- Pupy is more versatile, supporting multiple platforms (Windows, Linux, macOS, Android)
- Empire focuses on PowerShell-based attacks, while Pupy uses Python for cross-platform compatibility
- Pupy offers a wider range of communication protocols and transport layers
- Empire has a more extensive module library for Windows post-exploitation
- Pupy provides a more flexible and customizable framework for payload generation
Both tools are powerful post-exploitation frameworks, but they cater to different needs and environments. Empire excels in Windows-centric operations, while Pupy offers greater flexibility across various platforms.
Merlin is a cross-platform post-exploitation HTTP/2 Command & Control server and agent written in golang.
Pros of Merlin
- Written in Go, offering better cross-platform compatibility and easier deployment
- Supports multiple communication protocols (HTTP/1.1, HTTP/2, HTTPS)
- Implements advanced evasion techniques like domain fronting
Cons of Merlin
- Fewer built-in modules compared to Pupy
- Less extensive documentation and community support
- Lacks some of the more advanced features found in Pupy (e.g., audio recording, webcam capture)
Code Comparison
Merlin (Go):
func (a *Agent) executeCommand(cmd string) (string, error) {
execution, err := a.executeShellcode(cmd)
if err != nil {
return "", err
}
return string(execution), nil
}
Pupy (Python):
def execute(self, command):
try:
output = subprocess.check_output(command, shell=True)
return output.decode('utf-8')
except subprocess.CalledProcessError as e:
return str(e)
Both repositories provide post-exploitation frameworks, but they differ in implementation and features. Merlin focuses on stealth and evasion, while Pupy offers a wider range of built-in modules and capabilities. The code comparison shows how each project handles command execution, with Merlin using Go's concurrency features and Pupy relying on Python's subprocess module.
Metasploit Framework
Pros of Metasploit-framework
- Larger community and more extensive exploit database
- Better documentation and support
- More mature project with regular updates and maintenance
Cons of Metasploit-framework
- Larger footprint and more complex setup
- Less stealthy, more likely to be detected by antivirus software
- Primarily focused on exploitation rather than post-exploitation
Code Comparison
Metasploit-framework (Ruby):
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HTTP::Wordpress
def exploit
# Exploit code here
end
end
Pupy (Python):
class PupyModule(PupyModule):
""" Description of the module """
dependencies = ['pupyutils.basic_cmds']
def init_argparse(self):
# Argument parsing
def run(self, args):
# Module execution code
Both frameworks use object-oriented programming, but Metasploit uses Ruby while Pupy uses Python. Metasploit's modules are more focused on specific exploits, while Pupy's modules are designed for post-exploitation tasks and command execution.
PowerSploit - A PowerShell Post-Exploitation Framework
Pros of PowerSploit
- Specifically designed for PowerShell, making it highly effective on Windows systems
- Extensive collection of PowerShell modules for various post-exploitation tasks
- Well-documented and actively maintained by the security community
Cons of PowerSploit
- Limited to Windows environments and PowerShell
- May be more easily detected by modern antivirus solutions due to its popularity
- Requires PowerShell execution policy to be bypassed in some cases
Code Comparison
PowerSploit (PowerView module):
Get-NetDomain
Get-NetUser
Get-NetComputer
Invoke-UserHunter
Find-LocalAdminAccess
Pupy (Python-based commands):
from pupylib.PupyModule import *
run(["net", "user"])
run(["net", "localgroup", "administrators"])
run(["systeminfo"])
run(["tasklist"])
PowerSploit focuses on PowerShell-specific commands for Windows environments, while Pupy offers a more versatile approach with Python-based commands that can work across different operating systems. PowerSploit's commands are more tailored for Windows domain enumeration and exploitation, whereas Pupy's commands are more general-purpose and can be adapted for various scenarios.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Pupy
Installation
Installation instructions are on the wiki, in addition to all other documentation. For maximum compatibility, it is recommended to use Docker Compose.
Description
Pupy is a cross-platform, multi function RAT and post-exploitation tool mainly written in python. It features an all-in-memory execution guideline and leaves a very low footprint. Pupy can communicate using multiple transports, migrate into processes using reflective injection, and load remote python code, python packages and python C-extensions from memory.
Features
-
Windows payload can load the entire Python interpreter from memory using a reflective DLL.
- Pupy does not touch the disk.
-
Can be packed into a single .py file and run without any dependencies other than the python standard library on all OSes.
- PyCrypto gets replaced by pure Python AES & RSA implementations when unavailable.
-
Reflectively migrate into other processes.
-
Remotely import pure python packages (.py, .pyc) and compiled python C extensions (.pyd, .so) from memory.
- Imported python modules do not touch the disk.
-
Easily extensible, modules are simple to write and are sorted by os and category.
-
Modules can directly access python objects on the remote client using rpyc.
-
Access remote objects interactively from the pupy shell and get auto-completion of remote attributes.
-
Communication transports are modular and stackable. Exfiltrate data using HTTP over HTTP over AES over XOR, or any combination of the available transports.
-
Communicate using obfsproxy pluggable transports.
-
Execute noninteractive commands on multiple hosts at once.
-
Commands and scripts running on remote hosts are interruptible.
-
Auto-completion for commands and arguments.
-
Custom config can be defined: command aliases, modules. automatically run at connection, etc.
-
Open interactive python shells with auto-completion on the all-in-memory remote python interpreter.
-
Interactive shells (cmd.exe, /bin/bash, etc) can be opened remotely.
- Remote shells on Unix & Windows clients have a real tty with all keyboard signals working just like an SSH shell.
-
Execute PE executable remotely and from memory.
-
Generate payloads in various formats:
Format | Architecture | Short Name |
---|---|---|
Android Package | x86 & ARMv7 | apk |
Linux Binary | x86 | lin_x86 |
Linux Binary | x64 | lin_x64 |
Linux Shared Object | x86 | so_x86 |
Linux Shared Object | x64 | so_x64 |
Windows PE Executable | x86 | exe_x86 |
Windows PE Executable | x64 | exe_x64 |
Windows DLL | x86 | dll_x86 |
Windows DLL | x64 | dll_x64 |
Python Script | x86 & x64 | py |
PyInstaller | x86 & x64 | pyinst |
Python Oneliner | x86 & x64 | py_oneliner |
Powershell | x86 & x64 | ps1 |
Powershell Oneliner | x86 & x64 | ps1_oneliner |
Ducky Script | N/A | rubber_ducky |
-
Deploy in memory from a single command line using python or powershell one-liners.
-
Embed "scriptlets" in generated payloads to perform some tasks "offline" without needing network connectivity (ex: start keylogger, add persistence, execute custom python script, check_vm, etc.)
-
Multiple Target Platforms:
Platform | Support Status |
---|---|
Windows XP | Supported |
Windows 7 | Supported |
Windows 8 | Supported |
Windows 10 | Supported |
Linux | Supported |
Mac OSX | Limited Support |
Android | Limited Support |
Documentation
All documentation can be found on the wiki.
FAQ
Does the server work on windows?
Pupy has not been tested on Windows. Theoretically, it should work on any platform that supports Docker and Docker Compose. However, you will need to adapt the Docker Compose installation instructions for the Windows platform.
I can't install Pupy. The installation fails.
- Please refer to the wiki. It is possible that your answer is there.
- Search the Github issues and see if your issue was already solved.
- If you issue was not solved, open a new issue following the issue guidelines.
If you do not follow these steps, you issue will be closed.
Android and/or Mac OSX payloads and modules don't work.
Pupy has limited support for Android and OSX. These platforms may not be well maintained and may break intermittently. Some modules (i.e. keylogger) may be missing for these platforms.
Development
If some of you want to participate to pupy development, don't hesitate! All help is greatly appreciated and all pull requests will be reviewed.
Also there is small note about development. Please run flake8 before doing any commits. File with config is here.
Contact
Platform | Contact Info |
---|---|
contact@n1nj4.eu | |
https://twitter.com/n1nj4sec |
This project is a personal development, please respect its philosophy and don't use it for evil purposes!
Special thanks
Special thanks to all contributors that help improve pupy and make it a better tool! :)
Top Related Projects
A swiss army knife for pentesting networks
Empire is a PowerShell and Python post-exploitation agent.
Merlin is a cross-platform post-exploitation HTTP/2 Command & Control server and agent written in golang.
Metasploit Framework
PowerSploit - A PowerShell Post-Exploitation Framework
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot