3
@6^                 @   s8   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 )    N)
SpiderFootSpiderFootPluginSpiderFootEventc               @   st   e Zd ZdZddddddddddd
Zdddd	d
dddddd
ZdZe Ze	 fddZ
dd Zdd Zdd ZdS )sfp_archiveorgzArchive.org:Footprint,Passive:Search Engines:slow:Identifies historic versions of interesting files/pages from the Wayback Machine.z30,60,90TF)
farbackintfilespasswordpages	formpages
flashpages	javapagesstaticpagesuploadpageswebframeworkpagesjavascriptpageszNumber of days back to look for older versions of files/pages in the Wayback Machine snapshots. Comma-separate the values, so for example 30,60,90 means to look for snapshots 30 days, 60 days and 90 days back.zEQuery the Wayback Machine for historic versions of Interesting Files.zGQuery the Wayback Machine for historic versions of URLs with passwords.zCQuery the Wayback Machine for historic versions of URLs with forms.zJQuery the Wayback Machine for historic versions of URLs accepting uploads.zIQuery the Wayback Machine for historic versions of URLs containing Flash.zKQuery the Wayback Machine for historic versions of URLs using Java Applets.zFQuery the Wayback Machine for historic versions of purely static URLs.zTQuery the Wayback Machine for historic versions of URLs using Javascript frameworks.zIQuery the Wayback Machine for historic versions of URLs using Javascript.)
r   r   r   r	   r   r
   r   r   r   r   Nc             C   s@   || _ | j | _t | _x"t|j D ]}|| | j|< q&W d S )N)sftempStorageresultslist
foundDateskeysopts)selfsfcuserOptsopt r   9/var/www/spiderfoot.crq.systems/modules/sfp_archiveorg.pysetup5   s
    
zsfp_archiveorg.setupc          	   C   s   ddddddddd	g	S )
NINTERESTING_FILEURL_PASSWORDURL_FORM	URL_FLASH
URL_STATICURL_JAVA_APPLET
URL_UPLOADURL_JAVASCRIPTURL_WEB_FRAMEWORKr   )r   r   r   r   watchedEvents>   s    zsfp_archiveorg.watchedEventsc          	   C   s   ddddddddd	g	S )
NZINTERESTING_FILE_HISTORICZURL_PASSWORD_HISTORICZURL_FORM_HISTORICZURL_FLASH_HISTORICZURL_STATIC_HISTORICZURL_JAVA_APPLET_HISTORICZURL_UPLOAD_HISTORICZURL_WEB_FRAMEWORK_HISTORICZURL_JAVASCRIPT_HISTORICr   )r   r   r   r   producedEventsF   s
    zsfp_archiveorg.producedEventsc             C   s  |j }|j}|j}| jjd| d |  |dkrB| jd  rBd S |dkrZ| jd  rZd S |dkrr| jd  rrd S |d	kr| jd
  rd S |dkr| jd  rd S |dkr| jd  rd S |dkr| jd  rd S |dkr| jd  rd S |dko| jd  rd S || jkrd S d| j|< x~| jd jdD ]h}tjj	 tj
t|d }|jd}d| d | }| jj|| jd | jd d}	|	d d kr| jjd | d! q2ytj|	d }
W n( tk
r } z
d }
W Y d d }~X nX |
d kr
| jjd"| d! q2t|
d# d$k r0| jjd%|  q2|
d# d& d' }|| jkr\| jjd( q2| jj| |d) }| jjd*|  t||| j|}| j| q2W d S )+NzReceived event, z, from r   r   r   r   r"   r   r    r	   r$   r   r#   r   r!   r
   r%   r   r&   r   Tr   ,)daysz%Y%m%dz*https://archive.org/wayback/available?url=z&timestamp=_fetchtimeout
_useragent)timeout	useragentcontentzUnable to fetch Fz3Unable to process empty response from archive.org: Zarchived_snapshots   zNo archived snapshots for closesturlzSnapshot already fetched.Z	_HISTORICzFound a historic file: )	eventTypemoduledatar   debugr   r   splitdatetimenow	timedeltaintstrftimefetchUrlerrorjsonloadsBaseExceptionlenr   appendinfor   __name__notifyListeners)r   event	eventNamesrcModuleName	eventDatadaysbacknewDatemaxDater2   resreteZwbmlinknameevtr   r   r   handleEventN   sl    



zsfp_archiveorg.handleEvent)rE   
__module____qualname____doc__r   optdescsr   r   r   dictr   r'   r(   rS   r   r   r   r   r      s6   	r   )r8   r?   sflibr   r   r   r   r   r   r   r   <module>   s   