ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
K\¬Qc@sÏdZdZdgZddlZddlZddlZddlZddlZddlZddl    Z    dej
fd„ƒYZ d„Z e ad„Zd„Ze ejd    „Zed
krËeƒndS( súCGI-savvy HTTP Server.
 
This module builds on SimpleHTTPServer by implementing GET and POST
requests to cgi-bin scripts.
 
If the os.fork() function is not present (e.g. on Windows),
os.popen2() is used as a fallback, with slightly altered semantics; if
that function is not present either (e.g. on Macintosh), only Python
scripts are supported, and they are executed by the current process.
 
In all cases, the implementation is intentionally naive -- all
requests are executed sychronously.
 
SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.
 
Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).
s0.4tCGIHTTPRequestHandleriÿÿÿÿNcBsƒeZdZeedƒZeedƒZeedƒZdZd„Z    d„Z
d„Z dd    gZ d
„Z d „Zd „ZRS( s­Complete HTTP server with GET, HEAD and POST commands.
 
    GET and HEAD also support running CGI scripts.
 
    The POST command is *only* implemented for CGI scripts.
 
    tforktpopen2tpopen3icCs-|jƒr|jƒn|jddƒdS(sRServe a POST request.
 
        This is only implemented for CGI scripts.
 
        iõsCan only POST to CGI scriptsN(tis_cgitrun_cgit
send_error(tself((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pytdo_POST6s  cCs*|jƒr|jƒStjj|ƒSdS(s-Version of send_head that support CGI scriptsN(RRtSimpleHTTPServertSimpleHTTPRequestHandlert    send_head(R((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyR Bs 
cCs`t|jƒ}|jddƒ}|| ||d}}||jkr\||f|_tStS(s2Test whether self.path corresponds to a CGI script.
 
        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.
 
        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.
 
        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).
        t/i(t_url_collapse_pathtpathtfindtcgi_directoriestcgi_infotTruetFalse(Rtcollapsed_pathtdir_septheadttail((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyRIss/cgi-bins/htbincCs
t|ƒS(s1Test whether argument path is an executable file.(t
executable(RR((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyt is_executableascCs(tjj|ƒ\}}|jƒdkS(s.Test whether argument path is a Python script.s.pys.pyw(s.pys.pyw(tosRtsplitexttlower(RRRR((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyt    is_pythonesc( Csê|j}|j\}}|jdt|ƒdƒ}xv|dkr¬|| }||d}|j|ƒ}tjj|ƒr¨||}}|jdt|ƒdƒ}q7Pq7W|jdƒ}|dkrä|| ||d}}nd}|jdƒ}|dkr|| ||}    }n |d}    }|d|    }
|j|
ƒ} tjj| ƒsq|j    dd|
ƒdStjj
| ƒs›|j    d    d
|
ƒdS|j |
ƒ} | s |j pÈ|j pÈ|jsã|j    d    d |
ƒdS|j| ƒs |j    d    d |
ƒdSntjtjƒ} |jƒ| d <|jj| d<d| d<|j| d<t|jjƒ| d<|j| d<tj|ƒ}|| d<|j|ƒ| d<|
| d<|rÂ|| d<n|jƒ}||jdkrî|| d<n|jd| d<|jjdƒ}|rÚ|j ƒ}t|ƒdkrÚddl!}ddl"}|d| d<|dj#ƒdkr×y|j$|dƒ}Wn|j%k
ržqÔX|j dƒ}t|ƒdkrÔ|d| d <qÔq×qÚn|jj&dkrÿ|jj(| d!<n|jj&| d!<|jjd"ƒ}|r4|| d#<n|jjd$ƒ}|rY|| d%<ng}xW|jj)d&ƒD]C}|d d'krž|j*|j+ƒƒqr||d(j d)ƒ}qrWd)j,|ƒ| d*<|jjd+ƒ}|rñ|| d,<nt-d|jj.d-ƒƒ}|r(d.j,|ƒ| d/<nxdCD]}| j/|dƒq/W|j0d0d1ƒ|j1d2d3ƒ}|j rß|    g}d4|kr™|j*|ƒnt2ƒ}|j3j4ƒtj5ƒ}|dkr;tj6|dƒ\}}x<t7j7|j8gggdƒdr|j8j9dƒsâPqâqâW|r7|j:d5|ƒndSyqytj;|ƒWntj<k
renXtj=|j8j>ƒdƒtj=|j3j>ƒdƒtj?| || ƒWqæ|jj@|jA|jƒtjBd6ƒqæXnddlC}| g} |j | ƒrItDjE}!|!j#ƒjFd7ƒr6|!d8 |!d9}!n|!d:g| } nd4|kre| j*|ƒn|jGd;|jH| ƒƒytI|ƒ}"WntJtKfk
r­d}"nX|jL| d<|jMd=|jMd>|jMd?| ƒ}#|jj#ƒd@kr|"dkr|j8j9|"ƒ}$nd}$xBt7j7|j8jNgggdƒdr^|j8jNjOdƒsPqqW|#jP|$ƒ\}%}&|j3jQ|%ƒ|&r|j:dA|&ƒn|#jRjSƒ|#jTjSƒ|#jU}'|'rÙ|j:d5|'ƒn |jGdBƒdS(DsExecute a CGI script.R iit?ti”sNo such CGI script (%r)Ni“s#CGI script is not a plain file (%r)s&CGI script is not a Python script (%r)s!CGI script is not executable (%r)tSERVER_SOFTWAREt SERVER_NAMEsCGI/1.1tGATEWAY_INTERFACEtSERVER_PROTOCOLt SERVER_PORTtREQUEST_METHODt    PATH_INFOtPATH_TRANSLATEDt SCRIPT_NAMEt QUERY_STRINGt REMOTE_HOSTt REMOTE_ADDRt authorizationiiÿÿÿÿt    AUTH_TYPEtbasict:t REMOTE_USERt CONTENT_TYPEscontent-lengthtCONTENT_LENGTHtreferert HTTP_REFERERtaccepts    
 it,t HTTP_ACCEPTs
user-agenttHTTP_USER_AGENTtcookies, t HTTP_COOKIEiÈsScript output followst+t t=sCGI script exit status %#xisw.exeiûÿÿÿiüÿÿÿs-us command: %ststdintstdouttstderrtenvtposts%ssCGI script exited OK(R)R*R2R8R:R4(VRRRtlenttranslate_pathRtisdirtrfindtexistsRtisfileRt    have_forkt have_popen2t have_popen3Rtcopytdeepcopytenvirontversion_stringtservert server_nametprotocol_versiontstrt server_porttcommandturllibtunquotetaddress_stringtclient_addresstheaderst    getheadertsplittbase64tbinasciiRt decodestringtErrort
typeheadertNonettypetgetallmatchingheaderstappendtstriptjointfiltert
getheaderst
setdefaultt send_responsetreplacet
nobody_uidtwfiletflushRtwaitpidtselecttrfiletreadt    log_errortsetuidterrortdup2tfilenotexecvet handle_errortrequestt_exitt
subprocesstsysRtendswitht log_messaget list2cmdlinetintt    TypeErrort
ValueErrortPopentPIPEt_socktrecvt communicatetwriteR@tcloseR?t
returncode((RRtdirtresttitnextdirtnextrestt    scriptdirtquerytscriptt
scriptnamet
scriptfiletispyRAtuqrestthostR,R]R^tlengthR3R5tlinetuatcotkt decoded_querytargstnobodytpidtstsR}tcmdlinetinterptnbytestptdataR?R@tstatus((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyRjs8    
 
 
 
 
                %          
                 !(      (t__name__t
__module__t__doc__thasattrRRIRJRKtrbufsizeRR RRRRR(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyR#s                     cCsé|jdƒ}g}xM|d D]A}|dkr?|jƒq |r |dkr |j|ƒq q W|r·|jƒ}|r½|dkrœ|jƒd}q´|dkr´d}q´q½nd}ddj|ƒ|f}dj|ƒ}|S(s`
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a colllapsed path.
 
    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.
 
    Returns: A tuple of (head, tail) where tail is everything after the final /
    and head is everything before it.  Head will always start with a '/' and,
    if it contains anything else, never have a trailing '/'.
 
    Raises: IndexError if too many '..' occur within the path.
 
    R iÿÿÿÿs..t.R(R\tpopReRg(Rt
path_partst
head_partstpartt    tail_partt    splitpathR((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyR /s&    
     cCs€tr
tSyddl}Wntk
r.dSXy|jdƒdaWn3tk
r{dttd„|jƒƒƒanXtS(s$Internal routine to get nobody's uidiÿÿÿÿNR¡iicSs|dS(Ni((tx((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyt<lambda>gs(R¡tpwdt ImportErrortgetpwnamtKeyErrortmaxtmaptgetpwall(R¸((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyRm[s  &cCs<ytj|ƒ}Wntjk
r*tSX|jd@dkS(sTest for executable file.iIi(RtstatRvRtst_mode(Rtst((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyRks
cCstj||ƒdS(N(R    ttest(t HandlerClasst ServerClass((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyRÂtst__main__(R¬t __version__t__all__RR~RVtBaseHTTPServerR    RqRLR
RR RbR¡RmRt
HTTPServerRÂRª(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/CGIHTTPServer.pyt<module>s&           ÿ    *