U
    @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   s4   || _ |  | _t| D ]}|| | j|< q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 s(|dkr(d S || jkrJ| jd| d  d S d| j|< | jjd|dd | jd	 | jd
 d}|d ks|	ds| j
d d S d|d kr|  rd S td|d tjtjB }d}|D ]}|| jkrqqd| j|< | jd|  | j|dr|  r, d S | jd rT| jj|| jd
 | jd	 d}	|	d d krz| jd| d  q||	d kr| jd| d |  qtd|| j|}
| |
 z&|	d |d }|t| d }W n8 tk
r } z| jd W Y qW 5 d }~X Y nX |	d || }tdd| d | j|
}
| |
 d}qtd|| j|}
| |
 d}q|rtd|d | 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   s    

 





 


 zsfp_ahmia.handleEvent)r5   
__module____qualname____doc__r   optdescsr
   dictr   r   r   rC   r   r   r   r   r      s   r   )sflibr   r   r   r/   r   r   r   r   r   <module>   s   