Skip to content

Commit

Permalink
- Add command to properly exit the entire application
Browse files Browse the repository at this point in the history
- Improving docs
- Code cleaning
- Creating Pypi package files
  • Loading branch information
r3nt0n committed Feb 22, 2023
1 parent bb27306 commit 5d5ecf9
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 20 deletions.
12 changes: 12 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include LICENSE
include *.in
include *.py
include multicat/*.cfg
global-exclude *.pyc *.pyo *~
global-exclude *test*
global-exclude *tmp*
prune __pycache__
prune */__pycache__
prune build
prune dist
prune multicat/tests
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,32 @@ Sometimes you have to spread the same payload to multiple targets and don't know
<p align="right">(<a href="#top">back to top</a>)</p>


<!-- INSTALLATION -->
## Installation
```commandline
pip install multicat
```

<!-- USAGE EXAMPLES -->
## Usage

To start listening on the port of your choice:
```commandline
mc -p 1234
```

### Arguments

Usage: mc.py [-h] [-p] [-m] [-t]
```commandline
Usage: mc [-h] [-p] [-m] [-t]
-h, --help show this help message and exit
-p , --port port to listen (default: 28000)
-m , --max-clients max number of new clients to queue before establish connection (default: 5)
-t , --timeout connections timeout (default: 10)
```

### Commands
Available commands in general menu context:
```commandline
COMMAND DESCRIPTION
Expand All @@ -42,6 +55,7 @@ HELP List available commands
SESSIONS List established sessions
START <id> Interact with a client
CLOSE <id> Close an specific connection
EXIT / QUIT Exit the entire application
```

Available commands in session context:
Expand Down
30 changes: 12 additions & 18 deletions mc.py → multicat/mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/r3nt0n/multicat
# multicat - multithread reverse shell listener

import socket, threading, time, sys, argparse
import socket, threading, time, argparse, os

name = 'multicat'
desc = 'Multithread reverse shell listener'
Expand Down Expand Up @@ -80,15 +80,13 @@ def listenToClient(self, client_object):
except UnicodeDecodeError:
print(output.decode('latin-1'), end='')

#command = input('') + '\n'
command = input('')
if command.upper() in ('HELP', '?'):
print(f'\n{color.BOLD}COMMAND\t\tDESCRIPTION{color.END}')
print(f'------------------------------------')
print('STOP\t\tStop interacting with the current session')
print('CLOSE \t\tClose the current connection')
command = ''
#if command.rstrip('\n').upper() == 'STOP':
if command.upper() == 'STOP':
if input(f'\n{color.ORANGE}[?]{color.END} Do you want to {color.ORANGE}stop{color.END} this session? [y/N] ').lower() == 'y':
print()
Expand Down Expand Up @@ -136,8 +134,11 @@ def menu(self):
print('SESSIONS\tList established sessions')
print('START <id>\tInteract with a client')
print('CLOSE <id>\tClose an specific connection')
print('EXIT / QUIT\tExit the entire application')
print()
#elif user_input.upper().startswith('HELP'):

elif user_input.upper() in ('EXIT', 'QUIT'):
os._exit(0)

elif user_input.upper().startswith('SESSIONS'):
print(f'\n{color.BOLD}ID\tRemote address\tRemote port{color.END}')
Expand Down Expand Up @@ -179,22 +180,15 @@ def run(self):
thread.start()
return

if __name__ == "__main__":

def main():
print(f'\n{name} by r3nt0n - https://github.com/r3nt0n/multicat\n')
#
# if len(sys.argv) == 2:
# port_num = sys.argv[1]
# try:
# port_num = int(port_num)
# if port_num < 0:
# raise ValueError
# except ValueError:
# print(f'{color.RED}[!]{color.END} ERROR: Invalid listening port')
# sys.exit(1)
#ThreadedServer('', port_num).run()
port, max_clients, timeout = process_args()
ThreadedServer('', port, max_clients, timeout).run()
# else:
# print(f'Usage: {sys.argv[0]} <listening-port>')


if __name__ == "__main__":
main()



3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[metadata]
description-file=README.md
license_files=LICENSE
38 changes: 38 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# https://github.com/r3nt0n/multicat

# packages with python3 setup.py -v sdist

from setuptools import setup, find_packages
from multicat.mc import __version__, desc

# Read project description
with open('README.md', 'r') as f:
long_desc = f.read()

setup(
name='multicat',
version=__version__,
author='r3nt0n',
author_email='[email protected]',
url='https://github.com/r3nt0n/multicat',
license='GNU General Public License v3.0',
description=desc,
long_description=long_desc,
long_description_content_type="text/markdown",
include_package_data=True,
package_data={
# If any package contains *.cfg files, include them
'': ['*.cfg'],
},
#packages=['modules',],
#packages=find_packages(),
packages=['multicat'],
#install_requires=[],
entry_points = {
'console_scripts':[
'mc = multicat.mc:main'
]
}
)

0 comments on commit 5d5ecf9

Please sign in to comment.