AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/sos/cleaner/parsers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/sos/cleaner/parsers/__pycache__/__init__.cpython-310.pyc
o

���b�@sddlZGdd�d�ZdS)�Nc@sleZdZdZdZgZgZgZdZdZ	ifdd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�ZdS)�SoSCleanerParsera�Parsers are used to build objects that will take a line as input,
    parse it for a particular pattern (E.G. IP addresses) and then make any
    necessary subtitutions by referencing the SoSMap() associated with the
    parser.

    Ideally a new parser subclass will only need to set the class level attrs
    in order to be fully functional.

    :param conf_file: The configuration file to read from
    :type conf_file: ``str``

    :cvar name:     The parser name, used in logging errors
    :vartype name: ``str``

    :cvar regex_patterns:   A list of regex patterns to iterate over for every
                            line processed
    :vartype regex_patterns: ``list``

    :cvar mapping: Used by the parser to store and obfuscate matches
    :vartype mapping: ``SoSMap()``


    :cvar map_file_key: The key in the ``map_file`` to read when loading
                        previous obfuscation matches
    :vartype map_file_key: ``str``
    zUndefined Parser�unsetTcCs(|j|vr|j�||j�|��dS)N)�map_file_key�mapping�conf_update�_generate_skip_regexes)�self�config�r
�>/usr/lib/python3/dist-packages/sos/cleaner/parsers/__init__.py�__init__1s
zSoSCleanerParser.__init__cCs(g|_|jD]}|j�t�|��qdS)z�Generate the regexes for the parser's configured `skip_files`,
        so that we don't regenerate them on every file being examined for if
        the parser should skip a given file.
        N)�
skip_patterns�
skip_files�append�re�compile)r�pr
r
rr6s
�z'SoSCleanerParser._generate_skip_regexescCs(|jsdS|jjD]}|j�|�q	dS)z�Generate regexes for items the parser will be searching for
        repeatedly without needing to generate them for every file and/or line
        we process

        Not used by all parsers.
        N)�compile_regexesr�dataset�add_regex_item)r�obitemr
r
r�generate_item_regexes?s
�z&SoSCleanerParser.generate_item_regexescCsfd}|jD]}t�||tj�r||fSq|jr$|�|�\}}||7}|�|�\}}||7}||fS)a�This will be called for every line in every file we process, so that
        every parser has a chance to scrub everything.

        This will first try to identify needed obfuscations for items we have
        already encountered (if the parser uses compiled regexes that is) and
        make those substitutions early on. After which, we will then parse the
        line again looking for new matches.
        r)�skip_line_patternsr�match�Ir�!_parse_line_with_compiled_regexes�_parse_line)r�line�count�skip_pattern�_rcount�_countr
r
r�
parse_lineKs	
�zSoSCleanerParser.parse_linecCsLd}|jjD]\}}|�|�r!|�|j�|���|�\}}||7}q||fS)ahCheck the provided line against known items we have encountered
        before and have pre-generated regex Pattern() objects for.

        :param line:    The line to parse for possible matches for obfuscation
        :type line:     ``str``

        :returns:   The obfuscated line and the number of changes made
        :rtype:     ``str``, ``int``
        r)r�compiled_regexes�search�subn�get�lower)rrr�item�regr!r
r
rr_s

�z2SoSCleanerParser._parse_line_with_compiled_regexescCs�d}|jD]@}dd�t�||tj�D�}|rE|jdtd�|t|�7}|D]}|��}||jj�	�vr4q%|j�
|�}||krD|�||�}q%q||fS)aRCheck the provided line against the parser regex patterns to try
        and discover _new_ items to obfuscate

        :param line: The line to parse for possible matches for obfuscation
        :type line: ``str``

        :returns: The obfsucated line, and the number of changes made
        :rtype: ``tuple``, ``(str, int))``
        rcSsg|]}|d�qS)rr
)�.0�mr
r
r�
<listcomp>|sz0SoSCleanerParser._parse_line.<locals>.<listcomp>T��reverse�key)�regex_patternsr�findallr�sort�len�striprr�valuesr&�replace)rrr�pattern�matchesr�	new_matchr
r
rrps

�zSoSCleanerParser._parse_linecCs�|jr|jjD]\}}|�|�r|�|j�|�|�}q|St|jj��ddd�d�D]\}}||jj	vr5q*||vr?|�
||�}q*|S)a�Parse a given string for instances of any obfuscated items, without
        applying the normal regex comparisons first. This is mainly used to
        obfuscate filenames that have, for example, hostnames in them.

        Rather than try to regex match the string_data, just use the builtin
        checks for substrings matching known obfuscated keys

        :param string_data: The line to be parsed
        :type string_data: ``str``

        :returns: The obfuscated line
        :rtype: ``str``
        TcSst|d�S)Nr)r3)�xr
r
r�<lambda>�sz8SoSCleanerParser.parse_string_for_keys.<locals>.<lambda>r-)rrr#r$�subr&�sortedr�items�	skip_keysr6)r�string_datar(r)�k�obr
r
r�parse_string_for_keys�s
����z&SoSCleanerParser.parse_string_for_keyscCs|jjS)z�Get the contents of the mapping used by the parser

        :returns: All matches and their obfuscate counterparts
        :rtype: ``dict``
        )rr)rr
r
r�get_map_contents�sz!SoSCleanerParser.get_map_contentsN)�__name__�
__module__�__qualname__�__doc__�namer0rrrrrrrr"rrrCrDr
r
r
rrs 	r)rrr
r
r
r�<module>s


Anon7 - 2022
AnonSec Team