3
@6^L                 @   sP   d dl mZmZ d dlZd dlZd dlZd dlmZm	Z	m
Z
 G dd de	ZdS )    )PopenPIPEN)
SpiderFootSpiderFootPluginSpiderFootEventc               @   sR   e Zd ZdZdddZdddZdZdZe fd	d
Z	dd Z
dd Zdd ZdS )sfp_tool_cmseekzvTool - CMSeeK:Footprint,Investigate:Content Analysis:tool:Identify what Content Management System (CMS) might be used.python3 )
pythonpath
cmseekpathz_Path to Python 3 interpreter to use for CMSeeK. If just 'python3' then it must be in your PATH.z8Path to the where the cmseek.py file lives. Must be set.NFc             C   sD   || _ | j | _d| _d| _x"t|j D ]}|| | j|< q*W d S )NFzTarget Website)sftempStorageresults
errorState__dataSource__listkeysopts)selfsfcuserOptsopt r   :/var/www/spiderfoot.crq.systems/modules/sfp_tool_cmseek.pysetup&   s    
zsfp_tool_cmseek.setupc             C   s   dgS )NINTERNET_NAMEr   )r   r   r   r   watchedEvents0   s    zsfp_tool_cmseek.watchedEventsc             C   s   dgS )NWEBSERVER_TECHNOLOGYr   )r   r   r   r   producedEvents6   s    zsfp_tool_cmseek.producedEventsc             C   s  |j }|j}|j}| jjd| d |  | jr4d S || jkrV| jjd| d  d S d| j|< | jd s| jjdd d| _d S | jd j	d	r| jd }| jd j
d	d
 d }nJ| jd j	dr| jd d	 }| jd d }n| jd d }| jd d }tjj|s*| jjd| d d| _d S | jj|sJ| jjdd d S yt| jd |dd|gttd}|jd d\}}	|jd
kr|}
n*| jjdd | jjd|	 d |  d S d|
kr| jjd|  d S yJtj|d | d dd}tj|j }td|d | j|}| j| W n8 tk
rX } z| jjd t| d d S d }~X nX W n8 tk
r } z| jjd!t| d d S d }~X nX d S )"NzReceived event, z, from z	Skipping z as already scanned.Tr   z?You enabled sfp_tool_cmseek but did not set a path to the tool!Fz	cmseek.pyr   z/Result/Resultz
/cmseek.pyzFile does not exist: zInvalid input, refusing to run.r
   z--follow-redirectz-u)stdoutstderr)inputzUnable to read CMSeeK content.zError running CMSeeK: z, zCMS Detection failedzCouldn't detect the CMS for z	/cms.jsonzutf-8)encodingr   Zcms_namez*Couldn't parse the JSON output of CMSeeK: zUnable to run CMSeeK: )	eventTypemoduledatar   debugr   r   r   errorendswithsplitospathisfilesanitiseInputr   r   communicate
returncodeioopenjsonloadsreadr   __name__notifyListenersBaseExceptionstr)r   event	eventNamesrcModuleName	eventDataexeZ
resultpathpr!   r"   contentfjevter   r   r   handleEvent:   sh    






zsfp_tool_cmseek.handleEvent)r7   
__module____qualname____doc__r   optdescsr   r   dictr   r   r   rF   r   r   r   r   r      s   
r   )
subprocessr   r   r2   r4   os.pathr,   sflibr   r   r   r   r   r   r   r   <module>   s
   