
    h                         S SK r S SKrS SKJrJr  S SKJr  \R                  " \R                  SS9  \R                  " \
5      r " S S\5      rg)    N)DictAny)CountermeasurePluginz4%(asctime)s - %(name)s - %(levelname)s - %(message)s)levelformatc                   L    \ rS rSrSrS\\\4   S\\\4   4S jrS\4S jr	Sr
g)	InjectContentCountermeasure
   u>   
在响应内容中注入HTML或JS代码的反制动作实现
contextreturnc                     UR                  S0 5      nUR                  SS5      nUR                  SS5      nU(       d  [        R                  S5        SSS.$ [        R                  S	U S
USS  S35        SSUUS.S.$ )u  
执行内容注入动作。
注意：这个插件的设计是让规则引擎在需要时调用它，
并将注入的代码通过 context 传给它。
实际的注入逻辑需要在 HTTP 服务器层面实现，
这个 execute 方法主要用于记录和返回结果。
configlocationbefore_body_endcontent zNo content specified to inject.F)successmessagezPrepared to inject content at 'z': N2   z...TzContent injection prepared.)r   r   )r   r   inject_info)getloggerwarninginfo)selfr   r   inject_locationcontent_to_injects        <D:\code\IVE\countermeasures\inject_content\countermeasure.pyexecute#InjectContentCountermeasure.execute   s     Xr* **Z1BC"JJy"5 NN<=$1RSS5o5FcJ[\_]_J`Iaadef
 4+,
 	
    c                     g)NzDPrepares HTML/JS content to be injected into the HTTP response body. )r   s    r   get_description+InjectContentCountermeasure.get_description,   s    Ur!   r#   N)__name__
__module____qualname____firstlineno____doc__r   strr   r   r$   __static_attributes__r#   r!   r   r	   r	   
   s8    
tCH~ 
$sCx. 
:V Vr!   r	   )reloggingtypingr   r   pluginsr   basicConfigINFO	getLoggerr&   r   r	   r#   r!   r   <module>r4      sG    	   (   ',,/e f			8	$#V"6 #Vr!   