diff --git a/pupy/modules/pyexec.py b/pupy/modules/pyexec.py index 02ba8533..7d864cd1 100644 --- a/pupy/modules/pyexec.py +++ b/pupy/modules/pyexec.py @@ -1,11 +1,9 @@ # -*- coding: UTF8 -*- # Copyright (c) 2015, Nicolas VERDIER (contact@n1nj4.eu) # Pupy is under the BSD 3-Clause license. see the LICENSE file at the root of the project for the detailed licence terms -from pupylib.PupyModule import * -from pupylib.PupyCompleter import * -from pupylib.PupyErrors import * + +from pupylib import * import StringIO -from pupylib.utils.rpyc_utils import redirected_stdo __class_name__="PythonExec" diff --git a/pupy/modules/scapy.py b/pupy/modules/scapy.py new file mode 100644 index 00000000..27513c51 --- /dev/null +++ b/pupy/modules/scapy.py @@ -0,0 +1,52 @@ +# -*- coding: UTF8 -*- +# Copyright (c) 2015, Nicolas VERDIER (contact@n1nj4.eu) +# Pupy is under the BSD 3-Clause license. see the LICENSE file at the root of the project for the detailed licence terms + +import sys +import subprocess +import threading +import Queue +import time +import readline +from pupylib import * + +__class_name__="InteractiveScapyShell" + + +def enqueue_output(out, queue): + for c in iter(lambda: out.read(1), b""): + queue.put(c) + +@config(cat="admin") +class InteractiveScapyShell(PupyModule): + """ open an interactive python shell on the remote client """ + max_clients=1 + dependencies=['pyshell', 'gzip', 'scapy'] + def init_argparse(self): + self.arg_parser = PupyArgumentParser(prog='scapy', description=self.__doc__) + def run(self, args): + try: + if not self.client.conn.modules["os.path"].exists("C:\\WIndows\\system32\\Packet.dll"): + raise PupyModuleError("WinPcap is not installed !. You should download/upload NPcap (https://github.com/nmap/npcap/releases) and install it silently (with the /S flag) ") + if not self.client.conn.modules['ctypes'].windll.Shell32.IsUserAnAdmin(): + self.warning("you are running this module without beeing admin") + with redirected_stdo(self.client.conn): + old_completer=readline.get_completer() + try: + psc=self.client.conn.modules['pyshell.controller'].PyShellController() + readline.set_completer(psc.get_completer()) + readline.parse_and_bind('tab: complete') + psc.write("from scapy.all import *") + while True: + cmd=raw_input(">>> ") + psc.write(cmd) + finally: + readline.set_completer(old_completer) + readline.parse_and_bind('tab: complete') + except KeyboardInterrupt: + pass + + + + + diff --git a/pupy/packages/all/gzip.pyc b/pupy/packages/all/gzip.pyc new file mode 100644 index 00000000..4e245ce0 Binary files /dev/null and b/pupy/packages/all/gzip.pyc differ diff --git a/pupy/packages/all/scapy b/pupy/packages/all/scapy index 43598670..7d39612f 120000 --- a/pupy/packages/all/scapy +++ b/pupy/packages/all/scapy @@ -1 +1 @@ -../src/scapy/scapy/ \ No newline at end of file +../src/scapy/scapy \ No newline at end of file diff --git a/pupy/packages/src/scapy b/pupy/packages/src/scapy index 7a546611..75d334fa 160000 --- a/pupy/packages/src/scapy +++ b/pupy/packages/src/scapy @@ -1 +1 @@ -Subproject commit 7a546611c39d4a37e34cafb27625ffa64ed89836 +Subproject commit 75d334fa7ec5b09af84fefe2093ceacd70a2ebe3 diff --git a/pupy/pupylib/__init__.py b/pupy/pupylib/__init__.py index e69de29b..97b86126 100644 --- a/pupy/pupylib/__init__.py +++ b/pupy/pupylib/__init__.py @@ -0,0 +1,4 @@ +from PupyErrors import * +from PupyModule import * +from PupyCompleter import * +from utils.rpyc_utils import *