选择文件�文件大�最�修改时间�作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
3 7²efS*ã@s´dZddlZddlZddlZddlZddlZddlZddlZddl Zddl Zddl Zej j jƒGdd„deƒZGdd„deƒZGdd„deƒZGd d „d eƒZGd d „d eƒZdS) ayNetworked spam-signature detection client. >>> import pyzor >>> import pyzor.client >>> import pyzor.digest >>> import pyzor.config To load the accounts file: >>> accounts = pyzor.config.load_accounts(filename) To create a client (to then issue commands): >>> client = pyzor.client.Client(accounts) To create a client, using the anonymous user: >>> client = pyzor.client.Client() To get a digest (of an email.message.Message object, or similar): >>> digest = pyzor.digest.DataDigester(msg).value To query a server (where address is a (host, port) pair): >>> client.ping(address) >>> client.info(digest, address) >>> client.report(digest, address) >>> client.whitelist(digest, address) >>> client.check(digest, address) To query the default server (public.pyzor.org): >>> client.ping() >>> client.info(digest) >>> client.report(digest) >>> client.whitelist(digest) >>> client.check(digest) Response will contain, depending on the type of request, some of the following keys (e.g. client.ping()['Code']): All responses will have: - 'Diag' 'OK' or error message - 'Code' '200' if OK - 'PV' Protocol Version - 'Thread' `info` and `check` responses will also contain: - '[WL-]Count' Whitelist/Blacklist count `info` responses will also have: - '[WL-]Entered' timestamp when message was first whitelisted/blacklisted - '[WL-]Updated' timestamp when message was last whitelisted/blacklisted éNc@s‚eZdZdZdZddd„Zddd „Zd d d „Zd"d d „Zd$dd„Z d&dd„Z d(dd„Z d)dd„Z d+dd„Z edd„ƒZdd„ZdS),ÚClientéi NcCsX|dkr i}tdd„|jƒDƒƒ|_|dkr4tjj}||_|dk rH||_tj dƒ|_ dS)Ncss&|]\\}}}|t|ƒf|fVqdS)N)Úint)Ú.0ÚhostZportÚaccount©rú/usr/lib/python3.6/client.pyú Psz"Client.__init__..Úpyzor) ÚdictÚitemsÚaccountsr ÚdigestZ digest_specÚspecÚtimeoutÚloggingÚ getLoggerÚlog)Úselfrrrrrr Ú__init__MszClient.__init__úpublic.pyzor.orgéy_cCs&tjjƒ}|j||ƒ}|j||jƒƒS)N)r ÚmessageZ PingRequestÚsendÚ read_responseÚ get_thread)rÚaddressÚmsgÚsockrrr ÚpingYs  z Client.pingcCs(tjj|ƒ}|j||ƒ}|j||jƒƒS)N)r rZ PongRequestrrr)rrrrrrrr Úpong^s  z Client.pongcCs(tjj|ƒ}|j||ƒ}|j||jƒƒS)N)r rZ InfoRequestrrr)rrrrrrrr Úinfocs  z Client.infocCs,tjj||jƒ}|j||ƒ}|j||jƒƒS)N)r rÚ ReportRequestrrrr)rrrrrrrr Úreporths z Client.reportcCs,tjj||jƒ}|j||ƒ}|j||jƒƒS)N)r rÚWhitelistRequestrrrr)rrrrrrrr Ú whitelistms zClient.whitelistcCs(tjj|ƒ}|j||ƒ}|j||jƒƒS)N)r rZ CheckRequestrrr)rrrrrrrr Úcheckrs  z Client.checkcCs,dtjjjtjfjdƒ}tj|tjjd�S)Nz:Code: %s Diag: OK PV: %s Thread: 1024 Count: 0 WL-Count: 0Úascii)Ú_class)r rÚResponseZok_codeZ proto_versionÚencodeÚemailÚmessage_from_bytes)rZdigestsrrrrr Ú _mock_checkwszClient._mock_checkc Csª|dt|dƒf}|jƒy|j|}Wntk rFtjj}YnXttjƒƒ}|j|d<t |ƒ|d<tjj tjj |j |jƒ||ƒ|d<|j jd|jƒƒ|j||ƒS)NréZUserZTimeZSigz sending: %r)rZinit_for_sendingrÚKeyErrorr rZAnonymousAccountÚtimeZusernameÚstrZsign_msgZhash_keyÚkeyrÚdebugÚ as_stringÚ_send)rrrrZ timestamprrr r}s    z Client.sendc Csòd}xÒtj|d|ddtjtjƒD]°}|\}}}}}ytj|||ƒ}Wntjk rdd}w$YnXy|j|jƒjdƒd|ƒWnNtjk r®|j ƒt j d|ƒ‚Yn$tjk rÐ|j ƒd}w$YnXPq$W|dkrît j d|ƒ‚|S)Nrr/Úutf8zSending to %s time-outedzUnable to send to %s:%s) ÚsocketZ getaddrinfoZ SOCK_DGRAMZ IPPROTO_UDPÚerrorZsendtor5r+rÚcloser Ú TimeoutErrorÚ CommError) rZaddrrÚresZafZsocktypeÚprotoÚ_Zsarrr r6Œs, z Client._sendcCs |j|jƒy|j|jƒ\}}Wnntjk rV}z|jƒtjdƒ‚WYdd}~Xn:tjk rŽ}z|jƒtj d|ƒ‚WYdd}~XnX|j j d||ƒt j |tjjd�}|jƒy>|jƒ}||krö|jƒrætjd||fƒ‚|j jd||ƒWn"tk �r|j jdƒYnX|S)NzReading response timed-out.z'Socket error while reading response: %szreceived: %r/%r)r)z.received unexpected thread id %d (expected %d)z)received error thread id %d (expected %d)zno thread id received)Z settimeoutrZrecvfromÚmax_packet_sizer8r:r r;r9r<rr4r,r-rr*Zensure_completerZ in_ok_rangeZ ProtocolErrorZwarningr0)rrZ expected_idZpacketrZexrZ thread_idrrr r¥s2   zClient.read_response)NNN©rr)rA©rr)rB©rr)rC©rr)rD©rr)rE©rr)rF)N©rr)rG)Ú__name__Ú __module__Ú __qualname__rr@rr r!r"r$r&r'r.rÚ staticmethodr6rrrrr rIs         rc@sNeZdZdZddd„Zddd „Zdd d „Zd d „Zdd„Zdd„Z dd„Z dS)Ú BatchClientz=Like the normal Client but with support for batching reports.Né cCs0tj||||d�||_i|_i|_|jƒdS)N)rrr)rrÚ batch_sizeÚ r_requestsÚ w_requestsÚflush)rrrrrNrrr rÅs zBatchClient.__init__úpublic.pyzor.orgéy_cCs|j|||jƒdS)N)Ú _add_digestrO)rrrrrr r$ÌszBatchClient.reportcCs|j|||jƒdS)N)rTrP)rrrrrr r&ÏszBatchClient.whitelistc CsL|dt|dƒf}||}|j|ƒ|j|jkrHz |j||ƒS||=XdS)Nrr/)rZ add_digestZ digest_countrNr)rrrZrequestsrrrr rTÒs   zBatchClient._add_digestcCs<tjtjtjj|jd�ƒ|_tjtjtjj |jd�ƒ|_ dS)z"Deleting any saved digest reports.)rN) Ú collectionsÚ defaultdictÚ functoolsÚpartialr rr#rrOr%rP)rrrr rQÝszBatchClient.flushc Cstx6|jjƒD](\}}y|j||ƒWq w Yq Xq Wx6|jjƒD](\}}y|j||ƒWqDwDYqDXqDWdS)z!Force send any remaining reports.N)rOr rrP)rrrrrr Úforceäs zBatchClient.forcecCs |jƒdS)N)rY)rrrr Ú__del__ñszBatchClient.__del__)NNNrM©rRrS)r[©rRrS)r\) rHrIrJÚ__doc__rr$r&rTrQrYrZrrrr rLÂs     rLc@s&eZdZdd„Zddd„Zdd„ZdS) Ú ClientRunnercCs"tjdƒ|_||_d|_g|_dS)Nr T)rrrÚroutineÚall_okÚresults)rr_rrr rös zClientRunner.__init__NcCsž|dkr i}d|}d}y|j||Ž}|j||ƒWndtjttfk r˜}z@|jjd||jt |ƒffƒ|j j d||j j |ƒd|_WYdd}~XnXdS)Nz%s:%s z%s%s z %s %s: %sF)r_Úhandle_responser r<r0Ú ValueErrorraÚappendÚcoder2rr9Ú __class__rHr`)rZserverÚargsÚkwargsrÚresponseÚerrr Úrunüs zClientRunner.runcCs*|jƒsd|_|jjd||jƒfƒdS)z)mesaage is a string we've built up so farFz%s%s N)Úis_okr`rardÚ head_tuple)rrirrrr rb szClientRunner.handle_response)N)rHrIrJrrkrbrrrr r^õs r^c@seZdZddd„Zdd„ZdS)ÚCheckClientRunnerrcCs4tj||ƒd|_d|_d|_d|_||_||_dS)NFr)r^rÚ found_hitÚ whitelistedÚ hit_countÚwhitelist_countÚ r_count_foundÚwl_count_clears)rr_Zr_countZwl_countrrr rs zCheckClientRunner.__init__cCsŽ|dt|jƒƒ7}|jƒrtt|dƒ|_t|dƒ|_|j|jkrLd|_n|j|jkr^d|_ |d|j|jf7}nd|_ |j j |dƒdS)Nz%s ÚCountzWL-CountTz%d %dFÚ ) r2rmrlrrqrrrtrprsror`rard)rrirrrr rbs  z!CheckClientRunner.handle_responseN)rr)rHrIrJrrbrrrr rns rnc@seZdZdd„ZdS)ÚInfoClientRunnercCs”|dt|jƒƒ7}|jƒrzxbd D]R}||kr"t||ƒ}d|krLt|ƒ}n|dkrZd }n tj|ƒ}|d ||f7}q"Wnd |_|jj|d ƒdS)Nz%s ruÚEnteredÚUpdatedúWL-Countú WL-Enteredú WL-Updatedr/ZNeverz %s: %s Frv)rurxryrzr{r|éÿÿÿÿ) r2rmrlrr1Zctimer`rard)rrirr3ÚvalZstringedrrr rb*s   z InfoClientRunner.handle_responseN)rHrIrJrbrrrr rw)srw)r]r1r,r8rrWrUZ pyzor.digestr Z pyzor.accountZ pyzor.messageZpyzor.hacks.py26ZhacksZpy26Z hack_emailÚobjectrrLr^rnrwrrrr Ú7s  y3