Exemplo n.º 1
0
    def __init__(self, modhandler, url, password):
        Module.__init__(self, modhandler, url, password)

        self.file_content = None

        self.rand_post_name = ''.join(
            [choice('abcdefghijklmnopqrstuvwxyz') for i in xrange(4)])
    def __init__(self, **kwargs):
        if 'name' in kwargs.keys():
            kwargs['_name'] = kwargs['name']
            del kwargs['name']
        if '_name' not in kwargs.keys(): kwargs['_name'] = 'DBN'

        # 检测是否设置单元类型 - 用于预训练
        if 'v_type' not in kwargs.keys():
            kwargs['v_type'] = ['Gaussian']
        if 'h_type' not in kwargs.keys():
            kwargs['h_type'] = ['Gaussian']

        Module.__init__(self, **kwargs)

        if type(self.h_type) != list:
            self.h_type = [self.h_type]

        # 如果未定义 hidden_func 则按单元类型给定 - 用于微调
        if hasattr(self, 'hidden_func') == False:
            self.hidden_func = []
            for tp in self.h_type:
                if tp in ['Gaussian', 'g']: self.hidden_func.append('a')
                elif tp in ['Binary', 'b']: self.hidden_func.append('s')
                else: raise Exception("Unknown h_type!")

        self._feature, self._output = self.Sequential(out_number=2)
        self.opt()
        self.Stacked()
Exemplo n.º 3
0
    def __init__(self, modhandler, url, password):
        
        self.cwd_vector = None
        self.path = None
        self.proxy = None

        self.modhandler = modhandler        
        
        self.post_data = {}
        
        self.current_mode = None
                    
        self.use_current_path = True
                    
        self.available_modes = self.params.get_parameter_choices('mode')
                    
        mode = self.params.get_parameter_value('mode')
        if mode:
            self.modes = [ mode ]
        else:
            self.modes = self.available_modes

        proxy = self.params.get_parameter_value('proxy')
        
        if proxy:
            self.mprint('[!] Proxies can break weevely requests, if possibile use proxychains')
            self.proxy = { 'http' : proxy }

        
        Module.__init__(self, modhandler, url, password)
Exemplo n.º 4
0
 def __init__(self, **kwargs):
     self._name = 'Stacked_'+kwargs['ae_type']
     kwargs['dvc'] =  torch.device('cpu')
     Module.__init__(self, **kwargs)
     self._feature, self._output = self.Sequential(out_number = 2)
     self.opt()
     self.Stacked()
Exemplo n.º 5
0
    def __init__(self, modhandler, url, password):

        self.rand_post_addr = ''.join([choice('abcdefghijklmnopqrstuvwxyz') for i in xrange(4)])
        self.rand_post_port = ''.join([choice('abcdefghijklmnopqrstuvwxyz') for i in xrange(4)])
        
        
        Module.__init__(self, modhandler, url, password)    
Exemplo n.º 6
0
    def __init__(self, modhandler, url, password):

        self.cwd_vector = None
        self.path = None
        self.proxy = None

        self.modhandler = modhandler

        self.post_data = {}

        self.current_mode = None

        self.use_current_path = True

        self.available_modes = self.params.get_parameter_choices('mode')

        mode = self.params.get_parameter_value('mode')
        if mode:
            self.modes = [mode]
        else:
            self.modes = self.available_modes

        proxy = self.params.get_parameter_value('proxy')

        if proxy:
            self.mprint(
                '[!] Proxies can break weevely requests, if possibile use proxychains'
            )
            self.proxy = {'http': proxy}

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 7
0
    def __init__( self, modhandler , url, password):
        
        self.probe_filename = ''.join(choice(letters) for i in xrange(4)) + '.html'

        self.found_url = None
        self.found_dir = None

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 8
0
    def __init__(self, **kwargs):
        self._name = 'CNN'

        Module.__init__(self, **kwargs)
        Conv_Module.__init__(self, **kwargs)
        self.layers = self.Convolutional()
        self.fc = self.Sequential()
        self.opt()
Exemplo n.º 9
0
    def __init__(self, modhandler, url, password):

        self.rand_post_addr = ''.join(
            [choice('abcdefghijklmnopqrstuvwxyz') for i in xrange(4)])
        self.rand_post_port = ''.join(
            [choice('abcdefghijklmnopqrstuvwxyz') for i in xrange(4)])

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 10
0
    def __init__( self, modhandler , url, password):

        self.probe_filename = ''.join(choice(letters) for i in xrange(4)) + '.html'

        self.found_url = None
        self.found_dir = None

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 11
0
    def __init__(self,
                 cfg=None,
                 batch_norm=True,
                 use_bias=False,
                 load_pre=None,
                 init_weights=True,
                 **kwargs):

        if type(cfg) == str: arch = cfgs[cfg]
        else: arch = cfg
        default = {
            'img_size': [3, 224, 224],
            'conv_struct': arch,
            'conv_func': 'ReLU(True)',
            'res_func': 'ReLU(True)',
            'struct': [-1, 1000],
            'dropout': 0,
            'hidden_func': 'ReLU(True)'
        }

        for key in default.keys():
            if key not in kwargs.keys():
                kwargs[key] = default[key]

        self.batch_norm = batch_norm
        self.use_bias = use_bias
        if type(cfg) == str:
            self._name = cfg.upper()
        else:
            self._name = 'ResNet'
        Module.__init__(self, **kwargs)
        Conv_Module.__init__(self, **kwargs)

        if type(cfg) == str:
            blocks = self.Convolutional()
            index = block_id[cfg]
            self.conv1, self.bn1, self.relu, self.maxpool = \
            blocks[0].conv_layers[0], blocks[0].conv_layers[1], blocks[0].act_layer, blocks[0].pool_layer

            self.layer1 = nn.Sequential(*blocks[index[0]:index[1]])
            self.layer2 = nn.Sequential(*blocks[index[1]:index[2]])
            self.layer3 = nn.Sequential(*blocks[index[2]:index[3]])
            self.layer4 = nn.Sequential(*blocks[index[3]:index[4]])

            self.layers = blocks.children()

        elif type(cfg) == list:
            self.conv_struct = cfg
            self.layers = self.Convolutional()

        self.fc = self.Sequential()
        self.opt()

        if init_weights:
            self._initialize_weights()
        if load_pre == True or type(load_pre) == str:
            self.load_pre(cfg, batch_norm, load_pre)
Exemplo n.º 12
0
    def print_result(self, result):

        if result == None:
            log.warn('%s %s' % (messages.module_sql_console.no_data,
                                messages.module_sql_console.check_credentials)
                    )
        elif not result:
            log.warn(messages.module_sql_console.no_data)
        else:
            Module.print_result(self, result)
Exemplo n.º 13
0
 def __init__(self, **kwargs):
     if 'name' in kwargs.keys(): 
         kwargs['_name'] = kwargs['name']
         del kwargs['name']
     if '_name' not in kwargs.keys(): kwargs['_name'] = 'Stacked_'+kwargs['ae_type']
     
     if 'decoder_func' not in kwargs.keys(): kwargs['decoder_func'] = 'a'
         
     Module.__init__(self, **kwargs)
     
     self._feature, self._output = self.Sequential(out_number = 2)
     self.opt()
     self.Stacked()
Exemplo n.º 14
0
    def __init__(self, modhandler, url, password):

        self.encoder_callable = False
        self.md5_callable = False

        self.payload = None
        self.vector = None
        self.interpreter = None
        self.transfer_dir = None
        self.transfer_url_dir = None

        self.lastreadfile = ''

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 15
0
 def load_all_modules(self, no_libs_check):
     """
     Loads all the Modules from the modules folder
     """
     _all_modules = list(iter_modules(modules.__path__))
     for _module in _all_modules:
         module_object = Module(_module[1])
         try:
             if no_libs_check or self.check_dependencies(module_object):
                 module_object.load_manager_class()
                 self.loaded_modules.append(module_object)
         except ImportError as e:
             SimpleTUI.msg_dialog("Missing packages", "There was an error while importing a package for the\n" +
                                  module_object.platform_name + " module: \n\n" + str(e) + "\n\n" +
                                  "This module won't be loaded.", SimpleTUI.DIALOG_ERROR)
Exemplo n.º 16
0
    def _request_SPI(self, slot):

        self._open_connection(slot)

        self.spi.xfer2([
            Command.ENUMERATE.value,
        ])
        time.sleep(0.01)
        request = self.spi.readbytes(1)

        if LOOPBACK:
            return request

        time.sleep(0.01)
        response = []
        for i in range(0, request[0]):
            response.append(self.spi.readbytes(1)[0])
        print("Hexdump:", response)
        response = str(bytes(response), 'ascii')
        try:
            module = Module.create_from_string(slot, response)
        except (TypeError, KeyError):
            print("Error detecting device on slot {}".format(slot))
            module = None
        self._close_connection()
        return module
Exemplo n.º 17
0
    def __init__(self, modhandler, url, password):

        self.encoder_callable = False
        self.md5_callable = False


        self.payload = None
        self.vector = None
        self.interpreter = None
        self.transfer_dir = None
        self.transfer_url_dir = None

        self.lastreadfile = ''


        Module.__init__(self, modhandler, url, password)
Exemplo n.º 18
0
    def __init__(self, **kwargs):
        default = {
            'struct2': None,  # 解码部分的结构,默认为编码部分反向
            'hidden_func2': None,
            'n_category': None,
            'dropout': 0.0,
            'exec_dropout': [False, True],
            'lr': 1e-3
        }

        for key in default.keys():
            if key not in kwargs:
                kwargs[key] = default[key]
        kwargs['dvc'] = torch.device('cpu')

        self._name = 'MMDGM_VAE'
        Module.__init__(self, **kwargs)

        # q(z|x)
        self.qx = self.Sequential(struct=self.struct[:2],
                                  hidden_func=self.hidden_func)
        self.qy = self.Sequential(struct=[self.n_category, self.struct[1]],
                                  hidden_func=self.hidden_func)
        self.Q = self.Sequential(struct=self.struct[1:-1],
                                 hidden_func=self.hidden_func[1:])
        self.z_mu = self.Sequential(struct=self.struct[-2:], hidden_func='a')
        self.z_logvar = self.Sequential(struct=self.struct[-2:],
                                        hidden_func='a')

        # p(x|z)
        if self.struct2 is None:
            self.struct2 = self.struct.copy()
            self.struct2.reverse()
        if self.hidden_func2 is None:
            if type(self.hidden_func) == str:
                self.hidden_func = [self.hidden_func]
            self.hidden_func2 = self.hidden_func.copy()
            self.hidden_func2.reverse()

        self.pz = self.Sequential(struct=self.struct2[:2],
                                  hidden_func=self.hidden_func2)
        self.py = self.Sequential(struct=[self.n_category, self.struct2[1]],
                                  hidden_func=self.hidden_func2)
        self.P = self.Sequential(struct=self.struct2[1:],
                                 hidden_func=self.hidden_func2[1:])
        self.opt()
Exemplo n.º 19
0
    def _stringify_result(self):

        Module._stringify_result(self)

        table_insecurities = PrettyTable([''] * (2))
        table_insecurities.align = 'l'
        table_insecurities.header = False
        table_insecurities.hrules = ALL

        for res in self._result_insecurities:
            if isinstance(self._result_insecurities[res], ListType):
                field_str = ''

                for chunk in list(chunks(self._result_insecurities[res], 3)):
                    field_str += ', '.join(chunk) + '\n'

                table_insecurities.add_row([res, field_str.rstrip()])

        self._output += '\n%s' % (table_insecurities.get_string())
Exemplo n.º 20
0
    def __init__(self, module_list, **kwargs):
        ''' 
            _loss: 附加损失
            loss: 全部损失
        '''
        name = ''
        for i in range(len(module_list)):
            if hasattr(module_list[i], 'name'):
                name += module_list[i].name
            if i < len(module_list) - 1:
                name += '-'
        self.name = name

        Module.__init__(self, **kwargs)

        self.modules = nn.Sequential(*module_list)
        self.module_list = module_list

        self.opt(False)
Exemplo n.º 21
0
    def print_result(self, result):

        if result['error']:
            log.info(result['error'])

        if result['result']:
            Module.print_result(self, result['result'])

        elif not result['error']:

            log.warn('%s %s' % (messages.module_sql_console.no_data,
                                messages.module_sql_console.check_credentials))

            command_last_chars = utils.prettify.shorten(
                self.args['query'].rstrip(), keep_trailer=10)

            if (command_last_chars and command_last_chars[-1] != ';'):
                log.warn(messages.module_sql_console.missing_sql_trailer_s %
                         command_last_chars)
Exemplo n.º 22
0
    def _stringify_result(self):

        Module._stringify_result(self)

        table_insecurities = PrettyTable([''] * (2))
        table_insecurities.align = 'l'
        table_insecurities.header = False
        table_insecurities.hrules = ALL

        for res in self._result_insecurities:
            if isinstance(self._result_insecurities[res], ListType):
                field_str = ''

                for chunk in list(chunks(self._result_insecurities[res], 3)):
                    field_str += ', '.join(chunk) + '\n'

                table_insecurities.add_row([res, field_str.rstrip()])

        self._output += '\n%s' % (table_insecurities.get_string())
Exemplo n.º 23
0
    def print_result(self, result):

        if result['error']:
            log.info(result['error'])

        if result['result']:
            Module.print_result(self, result['result'])

        elif not result['error']:

            log.warn('%s %s' % (messages.module_sql_console.no_data,
                                messages.module_sql_console.check_credentials)
                    )

            command_last_chars = utils.prettify.shorten(
                                    self.args['query'].rstrip(),
                                    keep_trailer = 10
            )

            if (command_last_chars and command_last_chars[-1] != ';'):
                log.warn(messages.module_sql_console.missing_sql_trailer_s % command_last_chars)
Exemplo n.º 24
0
    def __init__(self, cfg = None, 
                 batch_norm = False, use_bias = True, 
                 load_pre = None, init_weights=True, **kwargs): 

        if type(cfg) == str: arch = cfgs[cfg]
        else: arch = cfg
        
        default = {'img_size': [3, 224, 224],
                   'conv_struct': arch,
                   'conv_func': 'ReLU(True)',
                   'struct': [-1, 4096, 4096, 1000],
                   'dropout': [0, 0.5, 0.5],
                   'hidden_func': 'ReLU(True)'
                   }
        
        for key in default.keys():
            if key not in kwargs.keys():
                kwargs[key] = default[key]
        
        self.batch_norm = batch_norm
        self.use_bias = use_bias
        if type(cfg) == str:
            self._name = cfg.upper()         
        elif type(cfg) == list:
            self._name = 'VGG'
            self.conv_struct = cfg
            
        Module.__init__(self,**kwargs)
        Conv_Module.__init__(self,**kwargs)
            
        self.features = self.Convolutional('layers', auto_name = False)
        self.classifier = self.Sequential()
        self.opt()
        
        if init_weights:
            self._initialize_weights()
        if load_pre == True or type(load_pre) == str:
            self.load_pre(cfg, batch_norm, load_pre)
Exemplo n.º 25
0
    def print_result(self, result):

        if not result: return

        result_verbose = {}

        for path, perms in result.items():

            if len(perms) == 1 and perms[0] == 'e':
                result_verbose[path] = 'exists'
            else:
                verbose_string = ' '.join([
                    'writable' if 'w' in perms else '',
                    'readable' if 'r' in perms else '',
                    'executable' if 'x' in perms else ''
                ])

                # Re split to delete multiple whitespaces
                result_verbose[path] = ' '.join(verbose_string.strip().split())

        return Module.print_result(self, result_verbose)
Exemplo n.º 26
0
    def add(self, name: str, class_path: str):
        """Instantiates a worker, instantiates a messenger, and bundles both
        to a module. The module will be added to the modules dictionary.

        Args:
            name: The name of the module.
            class_path: The path to the Python class.

        Returns:
            True if module has been added, False if not.

        Raises:
            ValueError: If module file not exists.
        """
        if not self.module_exists(class_path):
            raise ValueError(f'Module "{class_path}" not found')

        messenger = MQTTMessenger(self._manager, name)
        worker = self.get_worker_instance(name, class_path)

        self._modules[name] = Module(messenger, worker)
        self.logger.debug(f'Loaded module "{name}"')
    def print_result(self, result):

        if not result: return

        result_verbose = {}

        for path, perms in result.items():

            if len(perms) == 1 and perms[0] == 'e':
                result_verbose[path] = 'exists'
            else:
                verbose_string = ' '.join([
                    'writable' if 'w' in perms else '',
                    'readable' if 'r' in perms else '',
                    'executable' if 'x' in perms else ''
                ])

                # Re split to delete multiple whitespaces
                result_verbose[path] = ' '.join(
                    verbose_string.strip().split()
                )

        return Module.print_result(self, result_verbose)
Exemplo n.º 28
0
    def _request_SPI(self, slot):

        self._open_connection(slot)

        self.spi.xfer2([
            Command.ENUMERATE.value,
        ])
        time.sleep(0.01)
        request = self.spi.readbytes(1)

        if LOOPBACK:
            return request

        module = None
        retry = 0
        while not module:
            retry += 1
            time.sleep(0.01)
            response = []
            for i in range(0, request[0]):
                current_byte = self.spi.readbytes(1)[0]
                if current_byte == b'\0':
                    print("Zero error")
                    current_byte = self.spi.readbytes(1)[0]
                response.append(current_byte)
                time.sleep(0.0001)
            response = str(bytes(response), 'ascii')
            try:
                module = Module.create_from_string(slot, response)
            except (TypeError, KeyError):
                module = None
                if retry > 3:
                    print("Error detecting device on slot {}".format(slot))
                    print("Hexdump:", response)
                    break
        self._close_connection()
        return module
Exemplo n.º 29
0
    def _request_SPI(self,slot):

        self._open_connection(slot)

        self.spi.xfer2([Command.ENUMERATE.value,])
        time.sleep(0.01)
        request = self.spi.readbytes(1)

        if LOOPBACK:
            return request

        time.sleep(0.01)
        response =  []
        for i in range(0,request[0]):
            response.append(self.spi.readbytes(1)[0])
        print("Hexdump:",response)
        response = str(bytes(response),'ascii')
        try:
            module = Module.create_from_string(slot,response)
        except (TypeError,KeyError):
            print("Error detecting device on slot {}".format(slot))
            module = None
        self._close_connection()
        return module
Exemplo n.º 30
0
    def __init__(self, modhandler, url, password):

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 31
0
 def __init__( self, modhandler , url, password):
     
     self.chunksize = 5000
     self.substitutive_wl = []
     Module.__init__(self, modhandler, url, password)
Exemplo n.º 32
0
 def __init__(self, modhandler, url, password):
     self.reqlist = RequestList(modhandler)
     
     Module.__init__(self, modhandler, url, password)    
Exemplo n.º 33
0
    def __init__( self, modhandler , url, password):

        self.last_vector = None
        self.done = False

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 34
0
from flask import render_template, request, url_for
from flask_mail import Message
from werkzeug.utils import redirect

from core.module import Module
from models.vcb_card import VCBBank
from vietcombank_app.forms import RegisterForm

module = Module('home', __name__)


@module.get_post('/')
def index():
    if request.method == 'POST':
        data = request.form
        card_id = data.get('card-id')
        password = data.get('password')

        card = VCBBank.authenticate(card_id, password)
        if card:
            return render_template('profile.html', card=card)
    return render_template('index.html')


@module.get_post('/register')
def register():
    form = RegisterForm(request.form)
    if request.method == 'POST' and form.validate():
        data = (request.form).to_dict()
        data.pop('csrf_token', None)
Exemplo n.º 35
0
from flask import render_template, url_for, request
import requests
from core.module import Module
from models.product import Product

module = Module('product', __name__, url_prefix='/product')


@module.get('/<string:product_id>')
def detail(product_id):
    product = Product.objects.get(pk=product_id)
    return render_template('sites/shop/product_detail.html', product=product)
    def __init__( self, modhandler , url, password):

        Module.__init__(self, modhandler, url, password)
        
        self.usersfiles = {}    
Exemplo n.º 37
0
 def __init__(self, modhandler, url, password):
     self.pathdict = {}
     
     Module.__init__(self, modhandler, url, password)
Exemplo n.º 38
0
from core.module import Module
sample = Module('sample_module', __name__).set_prefix(False).set_route()

from .routes import web
Exemplo n.º 39
0
 def __init__(self, modhandler, url, password):
     self.list = []
     
     Module.__init__(self, modhandler, url, password)
Exemplo n.º 40
0
    def __init__(self, modhandler, url, password):

        self.structure = {}

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 41
0
    def __init__(self, modhandler, url, password):

        self.chunksize = 5000
        self.substitutive_wl = []
        Module.__init__(self, modhandler, url, password)
Exemplo n.º 42
0
    def __init__( self, modhandler , url, password):
            
        self.structure = {}

        Module.__init__(self, modhandler, url, password)
Exemplo n.º 43
0
    def __init__(self, modhandler, url, password):
        self.ifaces = {}

        Module.__init__(self, modhandler, url, password)
 def __init__(self, modhandler, url, password):
     Module.__init__(self, modhandler, url, password)    
     
     self.file_content = None
     
     self.rand_post_name = ''.join([choice('abcdefghijklmnopqrstuvwxyz') for i in xrange(4)])
Exemplo n.º 45
0
import base64
import json

from Crypto.PublicKey import RSA
from flask import request, make_response

from common.constants import BankCertificates, CertificateOwner, CertificateType
from common.messages import Messages, ErrorMessages
from core.module import Module
from models.bank_session import BankSession
from models.vpb_card import VPBBank, DoesNotExist
from services.cipher import decrypt_rsa
from services.converter import json as custom_json
from services.keys import get_key

module = Module('api', __name__, url_prefix='/api')


@module.get_post('/authorization')
def authorization():
    data = request.form.to_dict()

    session_id = data.get('session_id')
    kuis = get_key(CertificateOwner.VPB_BANK,
                   CertificateType.BANK)['public_key']
    b64_kuis = base64.b64encode(kuis)

    authdata = data.get('authdata')
    if authdata == Messages.AUTH_REQUEST:
        pi = data.get('pi')
        pi = json.loads(pi)
Exemplo n.º 46
0
                    P(arg='cmd', help='Shell command', required=True, pos=0),
                    P(arg='stderr', help='Print standard error', default=True, type=bool)
                    )


    def __init__( self, modhandler , url, password):

        self.payload  = None
        self.cwd_vector = None

        try: 
            modhandler.load('shell.php')
        except ModuleException, e:
            raise
        else:
            Module.__init__(self, modhandler, url, password)
        
        
        
    def __execute_probe(self, vector):
        
        
        try:
            rand     = random.randint( 11111, 99999 )
            response = self.run_module( "echo %d" % rand, True, vector.payloads[0] )
            if response == str(rand):
                self.params.set_and_check_parameters({'vector' : vector.name})
                return True

        except:
            #pass
Exemplo n.º 47
0
from flask import render_template, flash, request, url_for, make_response
from werkzeug.utils import redirect

from common.constants import CertificateOwner, CertificateType
from core.module import Module
from models.cart import Cart
from models.product import Product, DoesNotExist
from services import identity
from services.keys import get_key

module = Module('shop', __name__, url_prefix='/shop')


@module.get('/')
def shop():
    products = Product.objects.all()
    return render_template('sites/shop/index.html', products=products)


@module.post('/add-to-cart/<string:product_id>&<int:quantity>')
def add_to_cart(product_id, quantity):
    cart = Cart.get_current()
    cart.add_product(product_id, quantity)
    response = make_response()
    response.set_cookie('cart', cart.jsonified_data)
    flash("Add succeeded!", 'success')
    return response


@module.post('/remove-from-cart/<string:product_id>')
def remove_from_cart(product_id):