コード例 #1
0
ファイル: cli.py プロジェクト: mcclurmc/juju
def parse_port_protocol(port_protocol_string):
    """Returns (`port`, `protocol`) by converting `port_protocol_string`.

    `port` is an integer for a valid port (1 through 65535).

    `protocol` is restricted to TCP and UDP. TCP is the default.

    Otherwise raises ArgumentTypeError(msg).
    """
    split = port_protocol_string.split("/")
    if len(split) == 2:
        port_string, protocol = split
    elif len(split) == 1:
        port_string, protocol = split[0], "tcp"
    else:
        raise ArgumentTypeError(
            "Invalid format for port/protocol, got %r" % port_protocol_string)

    try:
        port = int(port_string)
    except ValueError:
        raise ArgumentTypeError(
            "Invalid port, must be an integer, got %r" % port_string)
        raise

    if port < 1 or port > 65535:
        raise ArgumentTypeError(
            "Invalid port, must be from 1 to 65535, got %r" % port)

    if protocol.lower() not in ("tcp", "udp"):
        raise ArgumentTypeError(
            "Invalid protocol, must be 'tcp' or 'udp', got %r" % protocol)

    return port, protocol.lower()
コード例 #2
0
ファイル: cli.py プロジェクト: anbangr/trusted-juju
def parse_port_protocol(port_protocol_string):
    """Returns (`port`, `protocol`) by converting `port_protocol_string`.

    `port` is an integer for a valid port (1 through 65535).

    `protocol` is restricted to TCP and UDP. TCP is the default.

    Otherwise raises ArgumentTypeError(msg).
    """
    split = port_protocol_string.split("/")
    if len(split) == 2:
        port_string, protocol = split
    elif len(split) == 1:
        port_string, protocol = split[0], "tcp"
    else:
        raise ArgumentTypeError("Invalid format for port/protocol, got %r" % port_protocol_string)

    try:
        port = int(port_string)
    except ValueError:
        raise ArgumentTypeError("Invalid port, must be an integer, got %r" % port_string)
        raise

    if port < 1 or port > 65535:
        raise ArgumentTypeError("Invalid port, must be from 1 to 65535, got %r" % port)

    if protocol.lower() not in ("tcp", "udp"):
        raise ArgumentTypeError("Invalid protocol, must be 'tcp' or 'udp', got %r" % protocol)

    return port, protocol.lower()
コード例 #3
0
        if int(low_port) < 1024:
            if display_low_port_message:
                print(
                    'Your service configuration suggests that you want to run on at least one low port!'
                )
                print(
                    'To enable port redirection run the following ipt-kit (https://github.com/foospidy/ipt-kit) commands as root:'
                )
                print('')
                display_low_port_message = False

            print('./ipt_set_' + low_protocol + ' ' + low_port + ' ' + port)

        try:
            if 'tcp' == protocol.lower():
                # run tcp service
                service_object = reactor.listenTCP(
                    int(port), plugin.pluginFactory(service))
            else:
                # run udp service
                service_object = reactor.listenUDP(
                    int(port),
                    plugin.pluginMain(service, socket.gethostname(), port))

            if service_object:
                # stop services from listening immediately if not starting in daemon mode.
                if False == args.d:
                    service_object.stopListening()

                # save service objects to array, to be used by HoneyPy Console
コード例 #4
0
ファイル: Honey.py プロジェクト: 3130000547/HoneyPy
		[protocol, port]         = service_config.get(service, 'port').split(':')
		plugin_module            = 'plugins.' + service_config.get(service, 'plugin')
		plugin                   = importlib.import_module(plugin_module)
		service_object           = None

		if int(low_port) < 1024:
			if display_low_port_message:
				print('Your service configuration suggests that you want to run on at least one low port!')
				print('To enable port redirection run the following ipt-kit (https://github.com/foospidy/ipt-kit) commands as root:')
				print('')
				display_low_port_message = False
				
			print('./ipt_set_' + low_protocol + ' ' + low_port + ' ' + port	)

		try:
			if 'tcp' == protocol.lower():
				# run tcp service
				service_object = reactor.listenTCP(int(port), plugin.pluginFactory(service))
			else:
				# run udp service
				service_object = reactor.listenUDP(int(port), plugin.pluginMain(service, socket.gethostname(), port))

			if service_object:
				# stop services from listening immediately if not starting in daemon mode.
				if False == args.d:
					service_object.stopListening()

				# save service objects to array, to be used by HoneyPy Console
				services[0].append(service)
				services[1].append(service_object)
コード例 #5
0
ファイル: Honey.py プロジェクト: silverfoxy/HoneyPy
        [low_protocol, low_port] = service_config.get(service, 'low_port').split(':')
        [protocol, port] = service_config.get(service, 'port').split(':')
        plugin_module = 'plugins.' + service_config.get(service, 'plugin')
        plugin = importlib.import_module(plugin_module)
        service_object = None

        if args.d is False:
            if int(low_port) < 1024:
                if display_low_port_message:
                    print 'Your service configuration suggests that you want to run on at least one low port!'
                    print 'To enable port redirection run the following ipt-kit (https://github.com/foospidy/ipt-kit) commands as root:'
                    print ''
                    display_low_port_message = False

        try:
            if protocol.lower() == 'tcp':
                # run tcp service
                service_object = reactor.listenTCP(int(port), plugin.pluginFactory(service))
            else:
                # run udp service
                service_object = reactor.listenUDP(int(port), plugin.pluginMain(service, get_ip_address(), port))

            if service_object:
                # stop services from listening immediately if not starting in daemon mode.
                if args.d is False:
                    service_object.stopListening()

                # save service objects to array, to be used by HoneyPy Console
                services[0].append(service)
                services[1].append(service_object)
コード例 #6
0
ファイル: Honey.py プロジェクト: foospidy/HoneyPy
        [low_protocol, low_port] = service_config.get(service, 'low_port').split(':')
        [protocol, port] = service_config.get(service, 'port').split(':')
        plugin_module = 'plugins.' + service_config.get(service, 'plugin')
        plugin = importlib.import_module(plugin_module)
        service_object = None

        if args.d is False:
            if int(low_port) < 1024:
                if display_low_port_message:
                    print 'Your service configuration suggests that you want to run on at least one low port!'
                    print 'To enable port redirection run the following ipt-kit (https://github.com/foospidy/ipt-kit) commands as root:'
                    print ''
                    display_low_port_message = False

        try:
            if protocol.lower() == 'tcp':
                # run tcp service
                service_object = reactor.listenTCP(int(port), plugin.pluginFactory(service))
            else:
                # run udp service
                service_object = reactor.listenUDP(int(port), plugin.pluginMain(service, get_ip_address(), port))

            if service_object:
                # stop services from listening immediately if not starting in daemon mode.
                if args.d is False:
                    service_object.stopListening()

                # save service objects to array, to be used by HoneyPy Console
                services[0].append(service)
                services[1].append(service_object)