Penelope Shell Handler

Overview

penelope

Penelope is an advanced shell handler. Its main aim is to replace netcat as shell catcher during exploiting RCE vulnerabilities. It works on Linux and macOS and the only requirement is Python3. It is one script without 3rd party dependencies and hopefully it will stay that way.

Among the main features are:

  • Auto-upgrade shells to PTY (auto-resize included)
  • Logging interaction with the targets
  • Download files from targets
  • Upload files to targets
  • Upload preset scripts to targets
  • Spawn backup shells
  • Multiple sessions
  • Multiple listeners
  • Can be imported by exploits and get shell on the same terminal.

Sample basic usage

penelope.py                   # Listening for reverse shells on 0.0.0.0:4444
penelope.py 5555              # Listening for reverse shells on 0.0.0.0:5555
penelope.py 5555 -i eth0      # Listening for reverse shells on eth0:5555

penelope.py -c target 3333    # Connect to a bind shell on target:3333

Demonstrating random usage (1)

  1. Executing penelope without parameters and getting a reverse shell
  2. Pressing F12 to detach the session and go to the main menu
  3. Run 'recon' command to upload preset privesc scripts to the target
  4. Interacting again with the session, confirming that scripts are uploaded
  5. Detaching again with F12 and downloading /etc directory from the target
  6. Kill the session and exiting with Ctrl-D

sample_usage

Demonstrating random usage (2)

  1. Adding an extra listener and show all listeners
  2. Interacting with session 1
  3. Spawning 2 extra backup sessions
  4. Showing all sessions

sample_usage2

Command line options

positional arguments:
  PORT                  Port to listen/connect to depending on -i/-c options. Default: 4444

Reverse or Bind shell?:
  -i , --address        IP Address or Interface to listen on. Default: 0.0.0.0
  -c , --connect        Bind shell Host

Hints:
  -a, --hints           Show sample payloads for reverse shell based on the registered listeners
  -l, --interfaces      Show the available network interfaces
  -h, --help            show this help message and exit

Verbosity:
  -Q, --silent          Show only errors and warnings
  -X, --extra-silent    Suppress all logging messages

Logging:
  -L, --no-log          Do not create session log files
  -T, --no-timestamps   Do not include timestamps on logs

Misc:
  -H, --no-history      Disable shell history on target
  -P, --plain           Just land to the menu
  -S, --single-session  Accommodate only the first created session
  -C, --no-attach       Disable auto attaching sessions upon creation
  -U, --no-upgrade      Do not upgrade shells

Debug:
  -d, --debug           Show debug messages
  -NP, --no-python      Simulate python absense on target
  -NB, --no-bash        Simulate bash absense on target

Menu options

use [sessionID|none]
  Select a session

sessions [sessionID]
  Show active sessions. When followed by <sessionID>, interact with that
  session

interact [sessionID]
  Interact with a session

kill [sessionID|all]
  Kill a session

download <glob>...
  Download files and folders from the target

open <glob>...
  Download files and folders from the target and open them locally

upload <glob|URL>...
  Upload files and folders to the target. If URL is specified then it is
  downloaded locally and then uploaded to the target

recon [sessionID]
  Upload preset reconnaissance scripts to the target

spawn [sessionID]
  Spawn a new session. Whether it will be reverse or bind, depends on
  the current session.

upgrade [sessionID]
  Upgrade the session's shell to "PTY". If it fails attempts to upgrade
  it to "Advanced". If this fail too, then falls back to "Basic" shell.

dir|. [sessionID]
  Open the session's local folder. If no session is selected, opens the
  base folder.

listeners [<add|stop> <Interface|IP> <Port>]
  Add or stop a Listener. When invoked without parameters, it shows the
  active Listeners.

connect <Host> <Port>
  Connect to a bind shell

hints
  Show sample commands to run on the targets to get reverse shell, based
  on the registered listeners

reset
  Reset the local terminal

history
  Show menu history

help [command]
  Show menu help or help about specific command

DEBUG
  Open debug console

SET [<param> <value>]
  Set options. When invoked without paramaters it shows current options

exit|quit|q|Ctrl+D
  Exit penelope

Bonus

There are also included two sample exploit simulation scripts to demonstrate how penelope can be imported and get shell on the same terminal. Furthermore, one bash script is included that automatically upgrades Unix shells to PTY using xdotool.

TODO

Features

  • currenly download/upload/spawn/upgrade commands are supported only on Unix shells.
  • port forwarding
  • persistence
  • edit command: open the remote file locally, make changes and upon saving, upload it to target
  • ability to specify a list of commands to run automatically on target and/or the main menu
  • execute a local script on target and get the output on a local file
  • main menu autocompletion for short commands
  • download/upload progress bar
  • download/upload autocompletion
  • IPv6
  • encryption
  • UDP

Bugs

  • Ctrl-C on main menu has not the expected behaviour yet. However can still stop commands like 'download'.
  • Session logging: when executing commands with alternate buffers like nano on target, then when cat the log it seems corrupted. However the data are still there.

Misc

  • apply some PEP8
  • consider autorunning bash -l on new shells
  • better way to handle duplicate downloads

Limitations

  • emojis don't appear on mate-terminal (parrot OS)
  • download command: path links are not clickable on qterminal (Kali Linux)
  • penelope menu commands and PTY autoresize operate on the same socket. This could be an advantage but it has a side effect that for example if nano is open on target, then detaching the session and attempt a download, penelope copes with that by sending Ctrl-Z -> Ctrl-E -> Ctrl-U. Then must run fg to get the process back. Maybe consider to spawn extra socket for controling the session in the future. However, if before executing a menu command, the target's terminal if left on a clear state, then there is no problem.
Comments
  • Upload not working

    Upload not working

    Hello, just found this tool last night and it looks amazing. Just starting to play around with it this evening and I have a great reverse shell (multiple shells with the maintain function) and I have tried to upload files unsuccessfully multiple times.

    Here's what one session looks like when trying to use the run upload_privesc_scripts command

    image

    The session gets disconnected and then says the upload was successful and then tells you there there are no sessions.

    Here's another time when I tried to upload the linpeas.sh script from my system to the remote machine and the session was disconnected again but I had enabled the maintain function and a new shell was spawned. None of the file are visible on the remote system. I have validated that I can write files to the location that I am trying to upload to

    image

    I was able to do a download. I downloaded the entire /etc/ directory without any issue.

    The system is running CentOS release 5.6 (Final) Linux version 2.6.18-238.12.1.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Tue May 31 13:23:01 EDT 2011

    Great tool even without the upload, but I will definitely have an even bigger ear to ear grin if I can get the upload working.

    Thanks for an excellent tool!

    opened by robertstrom 4
  • multiple session break console output

    multiple session break console output

    Hi,

    First of all, this tool is amazing. Right now i facing weird issue is that the console just simply messed up after receiving more than 2 connection.

    I attached screenshot to visually describe the issue Capture

    thank you!

    bug 
    opened by RamadhanAmizudin 4
  • Use

    Use "script /dev/null" instead of relying on Python for PTY upgrade

    The shell command "script /dev/null" (and some variations) work without spawning a Python process to launch a PTY shell.

    I'd recommend doing this before trying to do the better known Python method, as it is more reliable.

    enhancement 
    opened by darrenmartyn 4
  • Invalid shell from *

    Invalid shell from *

    Hi When I am trying to connect to the shell through Linux ubuntu 5.11.0-34-generic (using fish shell), it is writing to me: "Invalid shell from"

    opened by NirLevy98 3
  • More privesc scripts

    More privesc scripts

    It would be awesome if you added deepce (Docker enumeration ) , PrivescCheck (Fancy script)

    options.recon_scripts = {
    'Unix':[
    	'https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh',
    	'https://raw.githubusercontent.com/diego-treitos/linux-smart-enumeration/master/lse.sh',
    	'https://raw.githubusercontent.com/stealthcopter/deepce/main/deepce.sh'
    ],
    'Windows':[
    	'https://raw.githubusercontent.com/PowerShellEmpire/PowerTools/master/PowerUp/PowerUp.ps1',
    	'https://raw.githubusercontent.com/itm4n/PrivescCheck/master/PrivescCheck.ps1'
    ]}
    
    enhancement 
    opened by zAbuQasem 2
  • new feature: Interact console

    new feature: Interact console

    I'm glad to see the creation of this tool,During my use, I came up with a new idea: Can I connect to the current penelope console at another terminal by running the same command again? This makes it easy for me to connect and manage multiple sessions at the same time

    enhancement 
    opened by WAY29 2
  • TERM=xterm-256color for all connection is a slight issue with old Linux versions

    TERM=xterm-256color for all connection is a slight issue with old Linux versions

    Hello,

    I'm working on a very old version of Red Hat (Linux tophat.acme.com 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 athlon i386 GNU/Linux) and I noticed this when using penelope and trying to clear the screen it would not work and you would get an error about unknown terminal xterm-256color

    image

    Trying to clear the terminal

    image

    Environment

    image

    Setting the TERM variable to TERM=xterm image

    The clear command works now

    image

    Not a huge deal by any means, not sure if you were aware or had experienced this or not and not sure if you can check for something like this and set the TERM variable to a standard xterm if xterm-256color is not possible.

    Thanks for the great tool! I'm loving using it and cannot wait to, hopefully, see some updates in the not too distant future (Windows multiple sessions , etc. ;-) )

    opened by robertstrom 1
  • Appreciation

    Appreciation

    I loved your script I have a question can you do some type of stuff like if its windows shell instead of aborting the shell it starts the shell with non tty mode

    bug good first issue 
    opened by root-tanishq 1
  • Questions about v0.9.2

    Questions about v0.9.2

    Hello, I'm about to pull down v0.9.2 and was wondering if you could elaborate on what these two statements translate to.

    • Removed Unix 'advanced' shell support
    • Removed PTY Windows shell support temporarily

    I'm particularly interested in the Windows shell support. Does this mean that using v0.9.2 of penelope no longer supports any Windows reverse shells, or no longer supports some subset of Windows reverse shells?

    What does the removal of Unix 'advanced' shell support mean as far as reduced functionality?

    Thanks again for an excellent tool!! Very glad to see some development updates.

    opened by robertstrom 1
  • Download files /folders

    Download files /folders

    Hi, great work with penelope! My target machine is windows client, so it is not possible to upgrade shell to PTY. When I try do download a file / folder it does not show up "download sucsseful" and the file is not stored on the penelope location it should be. So, is it because the shell is not PTY? Isn t it possible to download files with the simple shell? And, if it isn t, Is there any command to see contents of files on targest system, instead of downloading them? Thanks

    opened by darkness2020 2
Releases(v0.9.2)
  • v0.9.2(Dec 18, 2022)

    Features added:

    • Added PEASS-ng module
    • Introduced tasks (execute remote command from file/memory in background and get the output in a local file)
    • Introduced 'exec' menu command
    • Introduced progress bar for download/upload

    Improvements

    • Enriched Unix shell PTY upgrade process
    • Changed terminal resize functionality from auto to realtime
    • Improved download and upload functionalities
    • Fixed several bugs

    Changes

    • Introduce 'agent' mode (needs python on target) for smoother interaction with the targets
    • Introduce 'control session' concept when python is not available
    • Removed PTY Windows shell support temporarily
    • Removed Unix 'advanced' shell support
    Source code(tar.gz)
    Source code(zip)
  • v0.8.5(May 11, 2022)

    Features added:

    • Configuration file
    • Interfaces command
    • Multiple listeners at once via command line

    Changes

    • Removed 'recon' command and implemented 'run' command
    Source code(tar.gz)
    Source code(zip)
  • v0.8.4(Jan 24, 2022)

    Features added:

    • Maintain X active sessions
    • Spawn to another port and/or host
    • Compatibility with Python >= 3.6
    • Upload exploitdb exploit from URL

    Changes

    • No detaching or PTY resize while on alternate buffer
    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Jan 24, 2022)

    Initial release

    Features

    • Auto-upgrade shells to PTY (auto-resize included)
    • Logging interaction with the targets
    • Download files from targets
    • Upload files to targets
    • Upload preset scripts to targets
    • Spawn backup shells
    • Multiple sessions
    • Multiple listeners
    • Can be imported by exploits and get shell on the same terminal
    Source code(tar.gz)
    Source code(zip)
Owner
null
An easy FASTA object handler, reader, writer and translator for small to medium size projects without dependencies.

miniFASTA An easy FASTA object handler, reader, writer and translator for small to medium size projects without dependencies. Installation Using pip /

Jules Kreuer 3 Jun 30, 2022
An optional component handler for hikari, inspired by discord.py's views.

hikari-miru An optional component handler for hikari, inspired by discord.py's views.

null 43 Dec 26, 2022
A beautiful and useful prompt for your shell

A Powerline style prompt for your shell A beautiful and useful prompt generator for Bash, ZSH, Fish, and tcsh: Shows some important details about the

Buck Ryan 6k Jan 8, 2023
Information about a signed UEFI Shell that can be used when Secure Boot is enabled.

SignedUEFIShell During our research of the BootHole vulnerability last year, we tried to find as many signed bootloaders as we could. We searched all

Mickey 61 Jan 3, 2023
Shell scripts made simple 🐚

zxpy Shell scripts made simple ?? Inspired by Google's zx, but made much simpler and more accessible using Python. Rationale Bash is cool, and it's ex

Tushar Sadhwani 492 Dec 27, 2022
A server shell for you to play with Powered by Django + Nginx + Postgres + Bootstrap + Celery.

A server shell for you to play with Powered by Django + Nginx + Postgres + Bootstrap + Celery.

Mengting Song 1 Jan 10, 2022
Shell Trality API for local development.

Trality Simulator Intro This package is a work in progress. It allows local development of Trality bots in an IDE such as VS Code. The package provide

CrypTrality 1 Nov 17, 2021
Utility/Raiding selfbot made by Shell and Roover.

Utility/Raiding selfbot made by Shell and Roover. We are open to suggestions and ideas.

Shell 2 Dec 8, 2021
Improve current data preprocessing for FTM's WOB data to analyze Shell and Dutch Governmental contacts.

We're the hackathon leftovers, but we are Too Good To Go ;-). A repo by Lukas Schubotz and Raymon van Dinter. We aim to improve current data preprocessing for FTM's WOB data to analyze Shell and Dutch Governmental contacts.

ASReview hackathon for Follow the Money 5 Dec 9, 2021
Kubernetes shell: An integrated shell for working with the Kubernetes

kube-shell Kube-shell: An integrated shell for working with the Kubernetes CLI Under the hood kube-shell still calls kubectl. Kube-shell aims to provi

CloudNative Labs 2.2k Jan 8, 2023
(BionicLambda Universal SHell) A simple shell made in Python. Docs and possible C port incoming.

blush ?? (BionicLambda Universal SHell) A simple shell made in Python. Docs and possible C port incoming. Note: The Linux executables were made on Ubu

null 3 Jun 30, 2021
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
ICMP Reverse Shell written in Python 3 and with Scapy (backdoor/rev shell)

icmpdoor - ICMP Reverse Shell icmpdoor is an ICMP rev shell written in Python3 and scapy. Tested on Ubuntu 20.04, Debian 10 (Kali Linux), and Windows

Jeroen van Kessel 206 Dec 29, 2022
iTerm2 Shell integration for Xonsh shell.

iTerm2 Shell Integration iTerm2 Shell integration for Xonsh shell. Installation To install use pip: xpip install xontrib-iterm2 # or: xpip install -U

Noorhteen Raja NJ 6 Dec 29, 2022
Discord-shell - Reverse shell accessible via discord.py bot

Discord-shell reverse shell on discord bot. (STILL IN DEVELOPMENT) Installation

Skultz 6 Oct 21, 2022
A simple discord slash command handler for for discord.py.

A simple discord slash command handler for discord.py About ⦿ Installation ⦿ Disclaimer ⦿ Examples ⦿ Documentation ⦿ Discussions Note that master bran

null 641 Jan 3, 2023
A meme error handler for python

Pwython OwO what's this? Pwython is project aiming to fill in one of the biggest problems with python, which is that it is slow lacks owoified text. N

SystematicError 23 Jan 15, 2022
Simple to use image handler for python sqlite3.

SQLite Image Handler Simple to use image handler for python sqlite3. Functions Function Name Parameters Returns init databasePath : str tableName : st

Mustafa Ozan Çetin 7 Sep 16, 2022