AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.133.151.199
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python2.7/site-packages/ansible/plugins/connection/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyc
�
��\c@`s�ddlmZmZmZeZdZddlZddlZddl	Z	ddl
mZmZddl
m
Z
ddlmZddlmZmZmZddlmZdd	lmZdd
lmZddlmZeZdZy�ddl m!Z!m"Z"dd
l#m$Z$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2Wne3k
r�Z4e5Ze4ZnXyddl6m7Z7Wn*e3k
r�ddl8m9Z9e9�Z7nXdefd��YZ:dS(i(tabsolute_importtdivisiontprint_functions
author: Ansible Core Team
connection: psrp
short_description: Run tasks over Microsoft PowerShell Remoting Protocol
description:
- Run commands or put/fetch on a target via PSRP (WinRM plugin)
- This is similar to the I(winrm) connection plugin which uses the same
  underlying transport but instead runs in a PowerShell interpreter.
version_added: "2.7"
requirements:
- pypsrp (Python library)
options:
  # transport options
  remote_addr:
    description:
    - The hostname or IP address of the remote host.
    default: inventory_hostname
    vars:
    - name: ansible_host
    - name: ansible_psrp_host
  remote_user:
    description:
    - The user to log in as.
    vars:
    - name: ansible_user
    - name: ansible_psrp_user
  port:
    description:
    - The port for PSRP to connect on the remote target.
    - Default is C(5986) if I(protocol) is not defined or is C(https),
      otherwise the port is C(5985).
    vars:
    - name: ansible_port
    - name: ansible_psrp_port
  protocol:
    description:
    - Set the protocol to use for the connection.
    - Default is C(https) if I(port) is not defined or I(port) is not C(5985).
    choices:
    - http
    - https
    vars:
    - name: ansible_psrp_protocol
  path:
    description:
    - The URI path to connect to.
    vars:
    - name: ansible_psrp_path
    default: 'wsman'
  auth:
    description:
    - The authentication protocol to use when authenticating the remote user.
    - The default, C(negotiate), will attempt to use C(Kerberos) if it is
      available and fall back to C(NTLM) if it isn't.
    vars:
    - name: ansible_psrp_auth
    choices:
    - basic
    - certificate
    - negotiate
    - kerberos
    - ntlm
    - credssp
    default: negotiate
  cert_validation:
    description:
    - Whether to validate the remote server's certificate or not.
    - Set to C(ignore) to not validate any certificates.
    - I(cert_trust_path) can be set to the path of a PEM certificate chain to
      use in the validation.
    choices:
    - validate
    - ignore
    default: validate
    vars:
    - name: ansible_psrp_cert_validation
  cert_trust_path:
    description:
    - The path to a PEM certificate chain to use when validating the server's
      certificate.
    - This value is ignored if I(cert_validation) is set to C(ignore).
    vars:
    - name: ansible_psrp_cert_trust_path
  connection_timeout:
    description:
    - The connection timeout for making the request to the remote host.
    - This is measured in seconds.
    vars:
    - name: ansible_psrp_connection_timeout
    default: 30
  message_encryption:
    description:
    - Controls the message encryption settings, this is different from TLS
      encryption when I(ansible_psrp_protocol) is C(https).
    - Only the auth protocols C(negotiate), C(kerberos), C(ntlm), and
      C(credssp) can do message encryption. The other authentication protocols
      only support encryption when C(protocol) is set to C(https).
    - C(auto) means means message encryption is only used when not using
      TLS/HTTPS.
    - C(always) is the same as C(auto) but message encryption is always used
      even when running over TLS/HTTPS.
    - C(never) disables any encryption checks that are in place when running
      over HTTP and disables any authentication encryption processes.
    vars:
    - name: ansible_psrp_message_encryption
    choices:
    - auto
    - always
    - never
    default: auto
  proxy:
    description:
    - Set the proxy URL to use when connecting to the remote host.
    vars:
    - name: ansible_psrp_proxy
  ignore_proxy:
    description:
    - Will disable any environment proxy settings and connect directly to the
      remote host.
    - This option is ignored if C(proxy) is set.
    vars:
    - name: ansible_psrp_ignore_proxy
    type: bool
    default: 'no'

  # protocol options
  operation_timeout:
    description:
    - Sets the WSMan timeout for each operation.
    - This is measured in seconds.
    - This should not exceed the value for C(connection_timeout).
    vars:
    - name: ansible_psrp_operation_timeout
    default: 20
  max_envelope_size:
    description:
    - Sets the maximum size of each WSMan message sent to the remote host.
    - This is measured in bytes.
    - Defaults to C(150KiB) for compatibility with older hosts.
    vars:
    - name: ansible_psrp_max_envelope_size
    default: 153600
  configuration_name:
    description:
    - The name of the PowerShell configuration endpoint to connect to.
    vars:
    - name: ansible_psrp_configuration_name
    default: Microsoft.PowerShell
N(tAnsibleConnectionFailuretAnsibleError(tAnsibleFileNotFound(tboolean(tto_bytest	to_nativetto_text(tConnectionBase(t_common_args(tsecure_hash(t
makedirs_safe(tGenericComplexObjecttRunspacePoolState(tAuthenticationErrort
WinRMError(tPSHosttPSHostUserInterface(t
PowerShelltRunspacePool(tProcesst
SignalCodetWinRS(tWSMantAUTH_KWARGS(tdisplay(tDisplayt
ConnectioncB`s�eZdZdZdgZeZeZeZ	d�Z
d�Zd�Zded�Zd	�Zd
�Zd�Zd�Zded
�Zd�ZRS(tpsrps.ps1s.exettrunascO`sJt|_t|_d|_d|_d|_tt|�j	||�dS(Nt
powershell(
tTruetalways_pipeline_modulesthas_native_asynctNonetrunspacethostt_shell_typetsuperRt__init__(tselftargstkwargs((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR*�s					cC`sotstdtt���ntt|�j�|j�tj	d|j
|j|jfd|j�|j
skt|j�}t�}tddtdd|d�|_t|d|jd|j�|_
tjd|j|j|jjfd|j�y|j
j�WnQtk
r6}tdt|���n)tk
r^}tdt|���nXt|_ n|S(	Ns,pypsrp or dependencies are not installed: %ss7ESTABLISH PSRP CONNECTION FOR USER: %s ON PORT %s TO %sR'sAnsible PSRP Hosttconfiguration_names8PSRP OPEN RUNSPACE: auth=%s configuration=%s endpoint=%ss*failed to authenticate with the server: %ss0psrp connection failure during runspace open: %s(!t
HAS_PYPSRPRRtPYPSRP_IMP_ERRR)Rt_connectt
_build_kwargsRtvvvt
_psrp_usert
_psrp_portt
_psrp_hostR&Rt_psrp_conn_kwargsRRR%tFalseR'Rt_psrp_configuration_nametvvvvvt
_psrp_autht	transporttendpointtopenRRRR"t
_connected(R+t
connectionthost_uite((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR1�s>
	
		cC`s-tjdd|j�d|_|j�dS(NsPSRP: Reset ConnectionR'(RR:R6R%R&R1(R+((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pytreset�s	cC`s\tt|�j|d|d|�|jdjt�d�rtj|jd�d�}t	|d�}t	|ddd	d
�}|r�|jd�r�t
|j�dd
�}td|��n|j
jddd�}||kr�tjd�q4tjd|d|j�n |}tjd|d|j�|j||�\}}	}
||	|
fS(Ntin_datatsudoablet s -EncodedCommandi����s	utf-16-leterrorstsurrogate_or_strictt	nonstringtpassthruu#!iis=cannot run the interpreter '%s' on the psrp connection pluginRs!PSRP: EXEC (via pipeline wrapper)s
PSRP: EXEC %sR'(R)Rtexec_commandt
startswithtjoinRtbase64t	b64decodetsplitR	Rt
splitlinesRt_shelltbuild_module_commandRR3R6t_exec_psrp_script(R+tcmdRDREt	b_commandtscripttinterpretertbootstrap_wrappertrctstdouttstderr((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyRK�s$
c`s�tt|�j||�tjd||fd|j�|jj|�}d|jj|�}|jj	|dt
dtdt�}t|dd�}t
jj|�s�td	t|���nt
jj|�}t|jjjd
d��t|jjdd
��}t||d|d�}|j�d}	t|d����x�t��fd�d�D]t}
|	t|
�7}	tjd|||	t|
�fd|j�tj|
�d}|j |d�j!�|k�qdW|	dkr�|j ddt
�nWdQX|j"�|j#t$j%�WdQX|j&dkrKt't|j(���nt)j*|j+�}|j,d�}
|
s�t'dt|j+�t|j(�f��nt-|�}|
|ks�t'dt|
�t|�f��ndS(NsPUT %s TO %sR'ukbegin {
    $ErrorActionPreference = "Stop"

    $path = '%s'
    $fd = [System.IO.File]::Create($path)
    $algo = [System.Security.Cryptography.SHA1CryptoServiceProvider]::Create()
    $bytes = @()
} process {
    $bytes = [System.Convert]::FromBase64String($input)
    $algo.TransformBlock($bytes, 0, $bytes.Length, $bytes, 0) > $null
    $fd.Write($bytes, 0, $bytes.Length)
} end {
    $fd.Close()
    $algo.TransformFinalBlock($bytes, 0, 0) > $null
    $hash = [System.BitConverter]::ToString($algo.Hash)
    $hash = $hash.Replace("-", "").ToLowerInvariant()

    Write-Output -InputObject "{`"sha1`":`"$hash`"}"
}tas_listtstrict_modetpreserve_rcRGRHs#file or module does not exist: "%s"iitcodepagei�iitrbc`s
�j��S(N(tread((tbuffer_sizetsrc_file(sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyt<lambda>QsRs%PSRP PUT %s to %s (offset=%d, size=%ds
tendtsha1s8Remote sha1 was not returned, stdout: '%s', stderr: '%s's0Remote sha1 hash %s does not match local hash %s(.R)Rtput_fileRR3R6RRt_unquotet_escapet_encode_scriptR"R8RtostpathtexistsRRtgetsizetintR&R@tmax_payload_sizeRRtbegin_invokeR>titertlenR:RNt	b64encodetsendttellt
end_invoketsignalRtCTRL_CRZRR\tjsontloadsR[tgetR(R+tin_pathtout_pathRWt	cmd_partst	b_in_pathtin_sizetshelltprocesstoffsettdatatb64_datat
put_outputtremote_sha1t
local_sha1((RcRdsC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyRh$sT 	
"	
#
	c	C`s]tt|�j||�tjd||fd|j�|jj|�}|jdd�}t	|j
jj|j
jjdd�}||d}d|jj
|�|f}d	}|j|d
t�\}}}	|dkrtd|t|	�f��n |j�d
kr t|�dSt|dd�}
ttjj|
��d}t|
d���}x�trtjd|||fd|j�|j||�\}}}	|dkr�td|t|	�f��ntj|j��}
|j|
�t|
�|krcPqcqcW|jd�\}}}	|dkrStjd|t|	�f�nWdQXdS(NsFETCH %s TO %sR's\t/iiis�$ErrorActionPreference = "Stop"
$path = "%s"

if (Test-Path -Path $path -PathType Leaf) {
    $fs = New-Object -TypeName System.IO.FileStream -ArgumentList @(
        $path,
        [System.IO.FileMode]::Open,
        [System.IO.FileAccess]::Read,
        [System.IO.FileShare]::Read
    )
    $buffer_size = %d
} elseif (Test-Path -Path $path -PathType Container) {
    Write-Output -InputObject "[DIR]"
} else {
    Write-Error -Message "$path does not exist"
    $host.SetShouldExit(1)
}sU$ErrorActionPreference = "Stop"
$fs.Seek(%d, [System.IO.SeekOrigin]::Begin) > $null
$buffer = New-Object -TypeName byte[] -ArgumentList $buffer_size
$bytes_read = $fs.Read($buffer, 0, $buffer_size)

if ($bytes_read -gt 0) {
    $bytes = $buffer[0..($bytes_read - 1)]
    Write-Output -InputObject ([System.Convert]::ToBase64String($bytes))
}tuse_local_scopeis.failed to setup file stream for fetch '%s': %ss[DIR]RGRHtwbsPSRP FETCH %s to %s (offset=%ds#failed to transfer file to '%s': %ss$fs.Close()s3failed to close remote file stream of file '%s': %s( R)Rt
fetch_fileRR3R6RRRitreplaceRpR&R@RqRjRTR8RRtstripR
RRlRmtdirnameR>R"R:RNROtwriteRttwarning(R+R~Rtmax_b64_sizeRctsetup_scripttread_scriptRZR[R\t
b_out_pathR�tout_fileR�((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR�qsJ

		
	cC`sd|jrN|jjtjkrNtjd|jjd|j�|jj�nd|_t
|_dS(NsPSRP CLOSE RUNSPACE: %sR'(R&tstateRtOPENEDRR:tidR6tcloseR%R8R?(R+((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR��s
	cC`s�|jj|_|jj|_|jj|_|jd�|_|jd�|_	|jj
|_|jd�}|jd�}|dkr�|dkr�d}d}nT|dkr�t
|�dkr�dnd}n'|dkr�|dkr�dnd}n||_t
|�|_|jd	�|_|jd
�|_|jd�}|jd�}|d
krkt|_n!|dk	r�||_n	t|_t
|jd��|_|jd�|_|jd�|_t|jd��|_t
|jd��|_t
|jd��|_|jd�|_g}x!tj�D]}|j|�q5Wt g|jd�D]}|j!dd�^q_�}|j"|�}	x|	D]}
t#j$d|
�q�Wt%d|jd|jd|j	d|jd|jdkd	|jd
|jd|jd|jd|jd|jd|jd|jd|j�|_&x;|j'|�D]*}
|jd�d|
}||j&|
<qQWdS( Ntremote_addrtremote_usertprotocoltportthttpsibiathttpRmtauthtcert_validationtcert_trust_pathtignoretconnection_timeouttmessage_encryptiontproxytignore_proxytoperation_timeouttmax_envelope_sizeR.t_extrast
ansible_psrp_RsDansible_psrp_%s is unsupported by the current psrp version installedtservertusernametpasswordtsslt
encryptiontno_proxysansible_psrp_%s((t
_play_contextt
become_methodt_become_methodtbecome_usert_become_usertbecome_passt_become_passt
get_optionR6R4R�t
_psrp_passR%Rpt_psrp_protocolR5t
_psrp_pathR;R8t_psrp_cert_validationR"t_psrp_connection_timeoutt_psrp_message_encryptiont_psrp_proxyRt_psrp_ignore_proxyt_psrp_operation_timeoutt_psrp_max_envelope_sizeR9RtvaluestextendtsetR�t
differenceRR�tdictR7tintersection(R+R�R�R�R�tsupported_argst
auth_kwargtvt
extra_argstunsupported_argstargtoption((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR2�sn	!		.
				cC`sWt|j�}|j|d|�|jd|�|j|�\}}}|||fS(NR�tinput(RR&t
add_scripttinvoket_parse_pipeline_result(R+RWt
input_dataR�tpsRZR[R\((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyRT
s
cC`s�|jjp|jrdnd}g}x�|jD]�}t|t�r�|jdkr�|j}x4|j	j
�D]#\}}|jd||f�qnWx4|jj
�D]#\}}|jd||f�q�Wdj
|�}nt|dd�}|j|�q1Wdj
|�}	t|jjj�dkrN|	ddj
|jjj�7}	ng}
x�|jjD]v}d	|jt|�|j|j|jf}|j}
|jjd
kr�|
dk	r�|d|
7}n|
j|�qaWdj
|
�}t|jjj�dkr(|dd
j
|jjj�7}ntjd|d|j�tjd|	d|j�tjd|d|j�d|j_g|jj_g|jj_|t |	dd�t |dd�fS(s}
        PSRP doesn't have the same concept as other protocols with its output.
        We need some extra logic to convert the pipeline streams and host
        output into the format that Ansible understands.

        :param pipeline: The finished PowerShell pipeline that invoked our
            commands
        :return: rc, stdout, stderr based on the pipeline output
        iiu%s: %su
RIt
simplerepru
usO%s : %s
%s
    + CategoryInfo          : %s
    + FullyQualifiedErrorId : %sis
StackTrace:
%ss
RsPSRP RC: %dR'sPSRP STDOUT: %ssPSRP STDERR: %stencodingsutf-8N(!R'RZt
had_errorstoutputt
isinstanceRt	to_stringR%t
property_setstadapted_propertiestitemstappendtextended_propertiesRMR	RttuiR[tstreamsterrortcommand_nametstrtinvocation_position_messagetmessagetfq_errortscript_stacktraceR�t	verbosityR\RR:R6R(R+tpipelineRZtstdout_listR�t	obj_linestkeytvaluet
output_msgR[tstderr_listR�t	error_msgt
stacktraceR\((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR�sF
!	#
	#(s.ps1s.exeRN(t__name__t
__module__R<t!module_implementation_preferencestbecome_methodsR8tallow_executableR"thas_pipeliningtallow_extrasR*R1RCR%RKRhR�R�R2RTR�(((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyR�s 		
	(	&	M	O		E(;t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONRNR{Rltansible.errorsRRRt)ansible.module_utils.parsing.convert_boolRtansible.module_utils._textRRR	tansible.plugins.connectionR
t ansible.plugins.shell.powershellRtansible.utils.hashingRtansible.utils.pathR
R"R/R%R0tpypsrp.complex_objectsRRtpypsrp.exceptionsRRtpypsrp.hostRRtpypsrp.powershellRRtpypsrp.shellRRRtpypsrp.wsmanRRtImportErrorterrR8t__main__Rtansible.utils.displayRR(((sC/usr/lib/python2.7/site-packages/ansible/plugins/connection/psrp.pyt<module>s>�




Anon7 - 2022
AnonSec Team