shell bypass 403
3
���ex; � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZm Z m
Z
ddlmZ ddl
mZmZmZmZmZ eje�Zdj� Zejd�Zd Zd
d� ZG dd
� d
e�ZdS )� )�BytesION� )� sysconfig�detect_encoding�ZipFile)�finder)�FileOperator�get_export_entry�convert_path�get_executable�in_venva�
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="%s"
type="win32"/>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>s ^#!.*pythonw?[0-9.]*([ ].*)?$a| # -*- coding: utf-8 -*-
if __name__ == '__main__':
import sys, re
def _resolve(module, func):
__import__(module)
mod = sys.modules[module]
parts = func.split('.')
result = getattr(mod, parts.pop(0))
for p in parts:
result = getattr(result, p)
return result
try:
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
func = _resolve('%(module)s', '%(func)s')
rc = func() # None interpreted as 0
except Exception as e: # only supporting Python >= 2.6
sys.stderr.write('%%s\n' %% e)
rc = 1
sys.exit(rc)
c C sZ d| krV| j d�rD| jdd�\}}d|krV|j d� rVd||f } n| j d�sVd| } | S )N� z
/usr/bin/env r �"z%s "%s"z"%s")�
startswith�split)�
executable�envZ_executable� r �/usr/lib/python3.6/scripts.py�_enquote_executableB s
r c @ s� e Zd ZdZeZdZd%dd�Zdd� Ze j
jd �rBd
d� Zdd
� Z
d&dd�Zdd� ZeZdd� Zdd� Zd'dd�Zdd� Zedd� �Zejdd� �Zejdks�ejd kr�ejdkr�dd � Zd(d!d"�Zd)d#d$�ZdS )*�ScriptMakerz_
A class to copy or create scripts from source scripts or callable
specifications.
NTFc C sz || _ || _|| _d| _d| _tjdkp:tjdko:tjdk| _t d�| _
|pRt|�| _tjdkprtjdkortjdk| _
d S )NF�posix�java� �X.Y�nt)r r )�
source_dir�
target_dir�
add_launchers�force�clobber�os�name�_name�set_mode�set�variantsr �_fileop�_is_nt)�selfr r r �dry_runZfileopr r r �__init__[ s
zScriptMaker.__init__c C s@ |j dd�r<| jr<tjj|�\}}|jdd�}tjj||�}|S )N�guiF�pythonZpythonw)�getr( r! �pathr �replace�join)r) r �optionsZdn�fnr r r �_get_alternate_executablek s
z%ScriptMaker._get_alternate_executabler c C sL y"t |��}|jd�dkS Q R X W n$ ttfk
rF tjd|� dS X dS )zl
Determine if the specified executable is a script
(contains a #! line)
� z#!NzFailed to open %sF)�open�read�OSError�IOError�logger�warning)r) r �fpr r r � _is_shells s
zScriptMaker._is_shellc C sD | j |�r*dd l}|jjjd�dkr<|S n|j� jd�r<|S d| S )Nr zos.nameZLinuxz
jython.exez/usr/bin/env %s)r= r ZlangZSystemZgetProperty�lower�endswith)r) r r r r r �_fix_jython_executable s
z"ScriptMaker._fix_jython_executable� c C sd d}| j r| j }d}n^tj� s&t� }nNt� rLtjjtjd�dtj d� �}n(tjjtj d�dtj d�tj d�f �}|r�| j
||�}tjj
d �r�| j|�}tjj|�}|r�t|�}|jd
�}tjdkr�d|kr�d
|kr�|d7 }d| | d }y|jd
� W n" tk
�r td| ��Y nX |d
k�r`y|j|� W n& tk
�r^ td||f ��Y nX |S )NTF�scriptszpython%s�EXE�BINDIRz
python%s%s�VERSIONr zutf-8Zcliz -X:Framesz
-X:FullFramess
-X:Framess #!�
z,The shebang (%r) is not decodable from utf-8z?The shebang (%r) is not decodable from the script encoding (%r))r r �is_python_buildr r r! r/ r1 �get_path�get_config_varr4 �sys�platformr r@ �normcaser �encode�decode�UnicodeDecodeError�
ValueError)r) �encoding�post_interpr2 Zenquoter �shebangr r r �_get_shebang� sL
zScriptMaker._get_shebangc C s | j t|j|jd� S )N)�module�func)�script_template�dict�prefix�suffix)r) �entryr r r �_get_script_text� s
zScriptMaker._get_script_textc C s t jj|�}| j| S )N)r! r/ �basename�manifest)r) Zexename�baser r r �get_manifest� s zScriptMaker.get_manifestc C s� | j o
| j}tjjd�}|s*|| | }n^|dkr>| jd�}n
| jd�}t� } t| d��}
|
jd|� W d Q R X | j � }|| | | }�xd|D �]Z}tj
j| j|�}
|�rrtj
j
|
�\}}|jd�r�|}
d|
}
y| jj|
|� W n� tk
�rn tjd� d |
}tj
j|��r tj|� tj|
|� | jj|
|� tjd
� ytj|� W n tk
�rh Y nX Y nX np| j�r�|
jd| � �r�d|
|f }
tj
j|
��r�| j �r�tjd
|
� q�| jj|
|� | j�r�| jj|
g� |j|
� q�W d S )Nzutf-8�py�t�wz__main__.pyz.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz%s.deletemez0Able to replace executable using .deleteme logic�.z%s.%szSkipping existing file %s)r r( r! �lineseprM �
_get_launcherr r Zwritestr�getvaluer/ r1 r �splitextr r'