Python Server for PoshC2
 
 
 
Go to file
m0rv4i ae3c5ed3cf Minor changes and fixes 2019-04-12 16:23:08 +01:00
Files Minor changes and fixes 2019-04-12 16:23:08 +01:00
Images Initial Commit 2018-07-23 09:55:15 +01:00
Modules Update Bloodhound (again!) 2019-03-13 08:52:00 +00:00
.gitignore Added ability to load and execute LinuxPrivChecker in memory on *nix implants. 2019-01-13 16:16:09 +00:00
Alias.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
AutoLoads.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
C2Server.py Minor refactoring 2019-04-05 11:37:52 +01:00
Cert.py Initial Commit 2018-07-23 09:55:15 +01:00
Colours.py Initial Commit 2018-07-23 09:55:15 +01:00
Config.py Update notifications config if it is changed in the Config.py 2019-04-05 11:13:46 +01:00
CookieDecrypter.py Fix indenting 2019-04-01 20:46:40 +01:00
Core.py Pull out payloads from Payloads.py; Add base64 encoded binary payload files; Fix whitespace issues that were triggering. 2019-03-12 20:33:45 +00:00
DB.py Pull out payloads from Payloads.py; Add base64 encoded binary payload files; Fix whitespace issues that were triggering. 2019-03-12 20:33:45 +00:00
HTML.py Pull out payloads from Payloads.py; Add base64 encoded binary payload files; Fix whitespace issues that were triggering. 2019-03-12 20:33:45 +00:00
Help.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
INSTALL.txt Updated install notes 2019-02-28 08:58:16 +00:00
INSTALL_Socks.txt Initial Commit 2018-07-23 09:55:15 +01:00
INSTALL_Windows.txt Initial Commit 2018-07-23 09:55:15 +01:00
Implant.py Update notifications config if it is changed in the Config.py 2019-04-05 11:13:46 +01:00
ImplantHandler.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
Install.sh Add fpc script for searching DB for commands or output 2019-04-08 17:19:19 +01:00
LICENSE Initial Commit 2018-07-23 09:55:15 +01:00
OfflineReportGenerator.py Pull out payloads from Payloads.py; Add base64 encoded binary payload files; Fix whitespace issues that were triggering. 2019-03-12 20:33:45 +00:00
Opsec.py Added netsh and invoke-shellcode to opsec 2019-02-12 19:40:58 +00:00
PSHandler.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
Payloads.py Refactor payload names for clarity; Add ability to specify the default migration process in the _migrate payloads 2019-03-13 14:50:33 +00:00
PyHandler.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
README.md Add known issues to README 2019-03-12 10:15:58 +00:00
SharpHandler.py Minor changes and fixes 2019-04-12 16:23:08 +01:00
TabComplete.py Rework imports to improve dependency management 2019-03-12 10:19:08 +00:00
Tasks.py Update changelog 2019-03-12 10:25:55 +00:00
Testing.md Updated to include opsec as test command 2019-02-12 19:48:56 +00:00
Update.sh Remove redirecting stash to /dev/null in Update.sh 2019-03-31 11:02:24 +01:00
UrlConfig.py Rework imports to improve dependency management 2019-03-12 10:19:08 +00:00
Utils.py Pull out payloads from Payloads.py; Add base64 encoded binary payload files; Fix whitespace issues that were triggering. 2019-03-12 20:33:45 +00:00
changelog.txt Add fpc script for searching DB for commands or output 2019-04-08 17:19:19 +01:00
oldurls.txt Adding files to enable custom URL generation. 2018-12-14 01:39:24 +00:00
poshc2.service Move service instructions to readme so that poshc2.service can just be copied to /lib/systemd/system 2019-02-13 16:38:06 +00:00
requirements.txt Initial Commit 2018-07-23 09:55:15 +01:00
wordlist.txt Adding files to enable custom URL generation. 2018-12-14 01:39:24 +00:00

README.md

PoshC2

PoshC2 is a proxy aware C2 framework that utilises Powershell and/or equivalent (System.Management.Automation.dll) to aid penetration testers with red teaming, post-exploitation and lateral movement. Powershell was chosen as the base implant language as it provides all of the functionality and rich features without needing to introduce multiple third party libraries to the framework.

In addition to the Powershell implant, PoshC2 also has a basic dropper written purely in Python that can be used for command and control over Unix based systems such as Mac OS or Ubuntu.

The server-side component is written in Python for cross-platform portability and speed, a Powershell server component still exists and can be installed using the 'Windows Install' as shown below but will not be maintained with future updates and releases.

Linux Install of PoshC2_Python

Install using curl & bash

curl -sSL https://raw.githubusercontent.com/nettitude/PoshC2_Python/master/Install.sh | bash

Manual install

wget https://raw.githubusercontent.com/nettitude/PoshC2_Python/master/Install.sh
chmod +x ./Install.sh
./Install.sh

Windows Install of PoshC2

powershell -exec bypass -c "IEX (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/nettitude/PoshC2/master/C2-Installer.ps1')"

Viewing the logs

If you want others to be able to to just view the C2 output you can pipe the C2Server.py to a file and stdout with:

python -u C2Server.py | tee -a /var/log/poshc2_server.log

Note the -u option is required to prevent buffering.

Then you can view it with

tail -f -n 50 /var/log/poshc2_server.log

Installing as a service

Installing as a service provides multiple benefits such as being able to log to service logs, viewing with journalctl and automatically starting on reboot.

  1. Add the file in systemd
cp poshc2.service /lib/systemd/system/poshc2.service
systemctl enable poshc2.service
systemctl start poshc2.service
  1. Stop the service
systemctl stop poshc2.service
  1. Restart the service
systemctl restart poshc2.service
  1. View the output
tail -f -n 50 /var/log/poshc2_server.log
  1. Or alternatively us journalctl (but note this can be rate limited)
journalctl -n 20000 -u poshc2.service -f --output cat

Issues / FAQs

If you are experiencing any issues during the installation or use of PoshC2 please check the known issues below and the open issues tracking page within GitHub. If this page doesn't have what you're looking for please open a new issue and we will try to resolve the issue asap.

If you are looking for tips and tricks on PoshC2 usage and optimisation, you are welcome to join the slack channel below.

License / Terms of Use

This software should only be used for authorised testing activity and not for malicious use.

By downloading this software you are accepting the terms of use and the licensing agreement.

Documentation

We maintain PoshC2 documentation over at https://poshc2.readthedocs.io/en/latest/

Find us on #Slack - poshc2.slack.com (to request an invite send an email to labs@nettitude.com)

Known issues

Python < 2.7.9 SSL Error

Remove this line for all python versions less that 2.7.9 when running a python implant only:

ssl._create_default_https_context=ssl._create_unverified_context

Error encrypting value: object type

If you get this error after installing PoshC2 it is due to dependency clashes in the pip packages on the system.

Try creating a virtualenv in python and re-install the requirements so that the exact versions specified are in use for PoshC2. Make sure you deactivate when you've finished in this virtualenv.

For example:

pip install virtualenv
virtualenv /opt/PoshC2_Python/
source /opt/PoshC2_Python/bin/activate
pip install -r requirements.txt
python C2Server.py

Note anytime you run PoshC2 you have to reactivate the virtual environment and run it in that.