3
@6^                 @   s0   d dl mZmZmZ d dlZG dd deZdS )    )
SpiderFootSpiderFootPluginSpiderFootEventNc               @   sN   e Zd ZdZdddZdddZdZe fddZd	d
 Z	dd Z
dd ZdS )	sfp_ahmiazoAhmia:Footprint,Investigate:Search Engines::Search Tor 'Ahmia' search engine for mentions of the target domain.T)
fetchlinks	fullnameszQFetch the darknet pages (via TOR, if enabled) to verify they mention your target.zSearch for human names?Nc             C   s8   || _ | j | _x"t|j D ]}|| | j|< qW d S )N)sftempStorageresultslistkeysopts)selfsfcuserOptsopt r   4/var/www/spiderfoot.crq.systems/modules/sfp_ahmia.pysetup%   s    
zsfp_ahmia.setupc             C   s
   dddgS )NDOMAIN_NAME
HUMAN_NAME	EMAILADDRr   )r   r   r   r   watchedEvents-   s    zsfp_ahmia.watchedEventsc             C   s
   dddgS )NDARKNET_MENTION_URLDARKNET_MENTION_CONTENTSEARCH_ENGINE_WEB_CONTENTr   )r   r   r   r   producedEvents3   s    zsfp_ahmia.producedEventsc             C   s  |j }|j}|j}| jd  r*|dkr*d S || jkrL| jjd| d  d S d| j|< | jjd|jdd | jd	 | jd
 d}|d ks|j	d r| jj
d d S d|d kr| j rd S tjd|d tjtjB }d}x|D ]}|| jkrqqd| j|< | jjd|  | jj|jdr| j r2d S | jd rT| jj|| jd
 | jd	 d}	|	d d kr| jjd| d  q||	d kr| jjd| d |  qtd|| j|}
| j|
 y&|	d j|d }|t| d }W n2 tk
r } z| jjd wW Y d d }~X nX |	d || }tdd| d | j|
}
| j|
 d}qtd|| j|}
| j|
 d}qW |rtd|d | j|}
| j|
 d S )Nr   r   zAlready did a search for z, skipping.Tzhttps://ahmia.fi/search/?q= z%20
_useragent_fetchtimeout)	useragenttimeoutcontentz"No results returned from ahmia.fi.zredirect_url=zredirect_url=(.[^"]+)"FzFound a darknet mention: z.onionr   )r!   r    z	Ignoring z as no data returnedz as no mention of r   x      zString not found in content.r   z...r   )	eventTypemoduledatar   r
   r   debugfetchUrlreplacegetinfocheckForStoprefindall
IGNORECASEDOTALLurlFQDNendswithr   __name__notifyListenersindexlenBaseException)r   event	eventNamesrcModuleName	eventDatar'   linksZreportedlinkresevtZ
startIndexZendIndexeZwdatar   r   r   handleEvent6   st    










zsfp_ahmia.handleEvent)r4   
__module____qualname____doc__r   optdescsr
   dictr   r   r   rB   r   r   r   r   r      s   r   )sflibr   r   r   r.   r   r   r   r   r   <module>   s   