LHOST    IP hosting the handler
            LPORT    Handler port
            PAYLOAD  Payload to inject: reverse_http or reverse_https (default: reverse_https)
            PROCID   Process ID to inject into (default: current powershell process)
335488
def options(self, context, module_options):
        '''
            
        '''

        self.met_payload = 'reverse_https'
        self.procid = None

        if not 'LHOST' in module_options or not 'LPORT' in module_options:
            context.log.error('LHOST and LPORT options are required!')
            exit(1)

        if 'PAYLOAD' in module_options:
            self.met_payload = module_options['PAYLOAD']

        if 'PROCID' in module_options:
            self.procid = module_options['PROCID']

        self.lhost = module_options['LHOST']
        self.lport = module_options['LPORT']

        self.ps_script = obfs_ps_script('powersploit/CodeExecution/Invoke-Shellcode.ps1')
749124
def _start_http(self):
        
        log.debug("Forward HTTP for %s to %d", self.name, self._console_http_port)
        command = ["docker", "exec", "-i", self._cid, "/gns3/bin/busybox", "nc", "127.0.0.1", str(self._console_http_port)]
        # We replace host and port in the server answer otherwise some link could be broken
        server = AsyncioRawCommandServer(command, replaces=[
            (
                '://127.0.0.1'.encode(),  # {{HOST}} mean client host
                '://{{HOST}}'.encode(),
            ),
            (
                ':{}'.format(self._console_http_port).encode(),
                ':{}'.format(self.console).encode(),
            )
        ])
        self._telnet_servers.append((yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console)))
867118
def _plumb_port(self, server, network_id, wrong_ips):
        

        for attached_interface in server.interface_list():
            if attached_interface.net_id == network_id:
                if any(map(lambda x: x['ip_address'] in wrong_ips, attached_interface.fixed_ips)):
                    continue
                return attached_interface

        return server.interface_attach(None, network_id, None)
51528
def get_handler(self, *args, **options):
        
        handler = super(Command, self).get_handler(*args, **options)
        insecure_serving = options.get('insecure_serving', False)
        if self.should_use_static_handler(options):
            return StaticFilesHandler(handler)
        return handler
631223
function() {

    // Return the correct config
    switch (process.platform) {
      case 'darwin':
        return Promise.resolve({
          host: '127.0.0.1',
          socketPath: '/var/run/docker.sock'
        });
      case 'linux':
        return Promise.resolve({
          host: '10.13.37.100',
          port: '2375'
        });
      case 'win32':
        return Promise.resolve({
          host: '127.0.0.1',
          port: '2375'
        });
    }

  }
374817
def post_fork(self, payload_handler, io_loop):
        '''
        
        '''
        self.payload_handler = payload_handler
        self.io_loop = io_loop
        self.serial = salt.payload.Serial(self.opts)
        with salt.utils.asynchronous.current_ioloop(self.io_loop):
            if USE_LOAD_BALANCER:
                self.req_server = LoadBalancerWorker(self.socket_queue,
                                                     self.handle_message,
                                                     ssl_options=self.opts.get('ssl'))
            else:
                if salt.utils.platform.is_windows():
                    self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                    _set_tcp_keepalive(self._socket, self.opts)
                    self._socket.setblocking(0)
                    self._socket.bind((self.opts['interface'], int(self.opts['ret_port'])))
                self.req_server = SaltMessageServer(self.handle_message,
                                                    ssl_options=self.opts.get('ssl'))
                self.req_server.add_socket(self._socket)
                self._socket.listen(self.backlog)
        salt.transport.mixins.auth.AESReqServerMixin.post_fork(self, payload_handler, io_loop)
1182116
function () {
		
		LOG.warn('starting [' + SR.Settings.SERVER_INFO.type + '] server at base port: ' + l_ip_port.port, l_name);
		
		// NOTE: name will determine which handler set to get/store
		// create a listener that'll listen to the default socket port for this server
		l_server = new SR.Listener({
			port:           l_ip_port.port + SR.Settings.PORT_INC_SOCKET,
			conn_module:    config.conn_handler
		});
		
		// always load system.js (NOTE: before other handlers)
		SR.Handler.addByFile({name: 'system',	file: 'system.js', owner: 'SR'}, config.path);
		
		// result may be true or false
		l_server.init(function (result) {
			if (result === false) {
				LOG.error('server init fail, listen port: ' + l_ip_port.port, l_name);
				
				// NOTE: this is redundant judgement with frontier's 
				//LOG.warn('treat this server as APP server, loading AppConnector...', l_name);
				//SR.Module.addStep(SR.Component.AppConnector());
				
				// TODO: try to close down more gracefully, right now this will trigger many 
				// unnecessary shutdown steps (& print too many error messages not useful)
				//l_dispose();
			}
			else {
				LOG.warn('server is ready & running...', l_name);
								
				// for entry server, we report the entry server HTTP base port
				// TODO: cleaner approach?
				if (SR.Settings.SERVER_INFO.type === 'entry')
					SR.Settings.SERVER_INFO.port = SR.Settings.PORT_ENTRY_ACTUAL;
				
				// NOTE: this is redundant judgement with frontier's 
				//else if (SR.Settings.SERVER_INFO.type === 'lobby') {
				//	LOG.warn('treat this server as LOBBY server, loading AppManager...', l_name);
				//	SR.Module.addStep(SR.Component.AppManager());
				//}
			}
			
			UTIL.safeCall(onDone, true);
		});
	}
1048890
function processPid(host,path,api_key,pid) {
	var query = nitro.newQuery();
	query.add(api.fProgrammesPageSize,pageSize,true)
		.add(api.mProgrammesContributions)
		.add(api.mProgrammesDuration)
		.add(api.mProgrammesAncestorTitles)
		.add(api.mProgrammesAvailableVersions)
		.add(api.mProgrammesGenreGroupings)

	if (upcoming || children) {
		query.add(api.fProgrammesDescendantsOf,pid)
		.add(api.fProgrammesAvailabilityPending);
	}
	else {
		query.add(api.fProgrammesPid,pid)
	}
	if (partner_pid != '') {
		query.add(api.fProgrammesPartnerPid,partner_pid);
	}
	else {
		if (pending) {
			query.add(api.fProgrammesAvailability,'P30D');
		}
		else {
			query.add(api.fProgrammesAvailabilityAvailable);
		}
		query.add(api.mProgrammesAvailability); // has a dependency on 'availability'
	}
	if (episode_type == 'clip') {
		query.add(api.fProgrammesAvailabilityEntityTypeClip);
	}
	else if ((episode_type == 'brand') || (episode_type == 'series')) {
		query.add(api.fProgrammesEntityType,episode_type);
	}
	else {
		query.add(api.fProgrammesAvailabilityEntityTypeEpisode);
	}
	if (embargoed) {
		query.add(api.xProgrammesEmbargoed,embargoed);
	}
	if (payment_type) {
		query.add(api.fProgrammesPaymentType,payment_type);
	}
	nitro.make_request(host,path,api_key,query,{},function(obj){
		return dispatch(obj);
	});
}
141847
def default_handler(url, method, timeout, headers, data):
    """"""

    def handle():
        request = Request(url, data=data)
        request.get_method = lambda: method
        for k, v in headers:
            request.add_header(k, v)
        resp = build_opener(HTTPHandler).open(request, timeout=timeout)
        if resp.code >= 400:
            raise IOError("error talking to pushgateway: {0} {1}".format(
                resp.code, resp.msg))

    return handle
714912
function probeServer(address, port, callback) {
    address = address || 'localhost';
    port    = port || 443;

    pingServer({
        address:  address,
        port:     port,
        attempts: 1,
        timeout:  5000
    }, function(err, data) {
        var available = data.min !== undefined;
        callback(err, available);
    });
}
175872
function(psRec,sProcId){
            if(!sProcId){throw new Error("No Proc Id found in data");}
            var iFind,sArgs
            iFind=psRec.CommandLine.indexOf(psRec.Name);
            sArgs = psRec.CommandLine.substring(iFind+psRec.Name.length+1);
            psRecs[sProcId]={
                pid: psRec.ProcessId
               ,ppid: psRec.ParentProcessId
               ,commandPath: psRec.ExecutablePath
               ,command: psRec.Name
               ,args: sArgs
            }
        }
90405
def spawn_process(self, port):
        
        return process.Process(name="ServerProcess.%i" % port,
                               kwargs={'namespace': self.namespace,
                                       'port': port})
1333040
def _port_postfix(self):
        
        port = self.real_connection.port
        default_port = {'https': 443, 'http': 80}[self._protocol]
        return ':{}'.format(port) if port != default_port else ''
1191925
function prox(req, res, options) {
    //  /prox/{type}/{vars}/{protocol}/{file}
    //  /prox/{type}/{module}/{vars}/{protocol}/{file}
    var xServ = URL.parse(req.url, true);
    var qm = ('' + xServ.path).match(/^\/prox\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(https?)\/(.+)/) || false;
    var qm = qm && {type: qm[1], module: qm[2], vars: qm[3], protocol: qm[4], file: qm[5]};

    // /prox/common-js/dddddz/-/,4/src/xfile-1.js

    if (!qm || !/^(?:common-js|json|js)$/.test(qm.type)) {
        endres(res, 400, '400 Bad Request')
        return;
    };

    var url = (qm.protocol === 'https' ? 'https://' : 'http://') + qm.file;
    qm.url = url;

    load(url
        , {
            authorization: req.headers['authorization'],
            X_Forwarded_For: req.X_Forwarded_For
        }

        , function(status, result) {
            wrap[qm.type](qm, result, function(status, result) {
                endres(res, 400, ''+result)
            });
        }
    )


}
610855
def connect_hostport(hostport, timeout=RPC_DEFAULT_TIMEOUT, my_hostport=None):
    
    host, port = url_to_host_port(hostport)

    assert host is not None and port is not None

    protocol = url_protocol(hostport)
    if protocol is None:
        log.warning("No scheme given in {}. Guessing by port number".format(hostport))
        if port == RPC_SERVER_PORT or port == RPC_SERVER_TEST_PORT:
            protocol = 'http'
        else:
            protocol = 'https'

    proxy = BlockstackRPCClient(host, port, timeout=timeout, src=my_hostport, protocol=protocol)
    return proxy
203324
function (host, port, onError) {
	
	var proxy = undefined;
	
	var options = {target: 'ws://' + host, ws: true};
	LOG.warn('create new ws proxy at port: ' + port + ' options: ', 'SR.Proxy');
	LOG.warn(options, 'SR.Proxy');
	
	proxy = httpProxy.createServer(options);
		
	// install error handler (NOTE: very imporant for stability)
	proxy.on('error', function (err, req, res) {
		UTIL.safeCall(onError, err);
	});
	
	// be notified when closed
	// ref: https://github.com/nodejitsu/node-http-proxy
	proxy.on('close', function (req, socket, head) {
  		// view disconnected websocket connections
  		console.log('Client disconnected');
	});	

	// store proxy for later uses
	// NOTE: not used directly
	l_proxies[host] = proxy;

	// record local port for future references
	// NOTE: this is an important step for future queries of the proxy
	// and may need to be performed before setting the on('xx') handler(s) 
	// BUG: seems like 'local_port' info will disappear under certain circumstances
	// (after entries are shutdown & restart many times)
	l_proxies[host].local_port = port;
		
	// start to listen for requests	
	// NOTE: listen may fail or cause errors that could trigger this proxy be removed from list
	proxy.listen(port);	

	return proxy;
	
	/* 2nd version
	proxy = httpProxy.createProxyServer(options);
	
	proxy.on('error', function (e) {
		UTIL.safeCall(onError, e);
	});
	
	// start a new HTTP server just for websocket connections
	var proxyServer = http.createServer(function (req, res) {
		LOG.warn('incoming request to standalone HTTP ws proxy', 'SR.Proxy');
		proxy.web(req, res);
	});

	//
	// Listen to the `upgrade` event and proxy the
	// WebSocket requests as well.
	//
	proxyServer.on('upgrade', function (req, socket, head) {
		try {
			proxy.ws(req, socket, head);
		}
	    catch (e) {
			LOG.error('websocket error:', 'SR.Proxy');
			LOG.error(e, 'SR.Proxy');
		}
			
	});

	// TODO: may need to provide a unique port for it
	// TODO: record this http server?
	LOG.warn('starting ws proxy at port: ' + port, 'SR.Proxy');
	proxyServer.listen(port);
	
	return proxy;
	*/
}
851471
public function handle(
        $msgType,
        \fpoirotte\Pssht\Wire\Decoder $decoder,
        \fpoirotte\Pssht\Transport $transport,
        array &$context
    ) {
        $hostAlgo   = null;
        foreach ($context['kex']['client']->getServerHostKeyAlgos() as $algo) {
            if (isset($context['serverKeys'][$algo])) {
                $hostAlgo = $algo;
                break;
            }
        }
        if ($hostAlgo === null) {
            throw new \RuntimeException();
        }
        $response   = $this->createResponse($decoder, $transport, $context, $hostAlgo);

        $logging    = \Plop\Plop::getInstance();
        $secret = gmp_strval($response->getSharedSecret(), 16);
        $logging->debug(
            "Shared secret:\r\n%s",
            array(
                wordwrap($secret, 16, ' ', true)
            )
        );

        $logging->debug(
            'Hash: %s',
            array(
                wordwrap(bin2hex($response->getExchangeHash()), 16, ' ', true)
            )
        );

        if (!isset($context['sessionIdentifier'])) {
            $context['sessionIdentifier'] = $response->getExchangeHash();
        }
        $context['DH'] = $response;
        $transport->writeMessage($response);
        return true;
    }