U
    @6^                     @   s0   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                   @   sJ   e Zd ZdZi Zi ZdZe fddZdd Z	dd Z
d	d
 Zdd ZdS )sfp_openbugbountyzOpen Bug Bounty:Footprint,Investigate,Passive:Leaks, Dumps and Breaches::Check external vulnerability scanning/reporting service openbugbounty.org to see if the target is listed.Nc                 C   s4   || _ |  | _t| D ]}|| | j|< qd S )N)sftempStorageresultslistkeysopts)selfsfcuserOptsopt r   </var/www/spiderfoot.crq.systems/modules/sfp_openbugbounty.pysetup"   s    
zsfp_openbugbounty.setupc                 C   s   dgS )NINTERNET_NAMEr   )r   r   r   r   watchedEvents-   s    zsfp_openbugbounty.watchedEventsc                 C   s
   dg}|S )NVULNERABILITYr   )r   retr   r   r   producedEvents1   s    z sfp_openbugbounty.producedEventsc           	   
   C   s   t  }d}d| }| jj|d| jd d}|d d krF| jd d S zftd| d	 tj}||d D ]<}|d
 |ks|d
 	d| rl|
d| |d  d  qlW n> tk
r } z | jdt| d W Y d S d }~X Y nX |S )Nzhttps://www.openbugbounty.orgz-https://www.openbugbounty.org/search/?search=   
_useragent)timeout	useragentcontentz*No content returned from openbugbounty.orgz'.*<div class=.cell1.><a href=.(.*).>(.*z).*?</a></div>.*   .zFrom openbugbounty.org: <SFURL>r   z</SFURL>z2Error processing response from openbugbounty.org: F)r	   r   fetchUrlr   debugrecompile
IGNORECASEfindallendswithappend	Exceptionerrorstr)	r   qryr   baseurlresrxmer   r   r   queryOBB7   s      zsfp_openbugbounty.queryOBBc           	      C   s   |j }|j}|j}t }| jd| d |  || jkrR| jd| d  d S d| j|< | |}|rt|| |D ]}t	d|| j
|}| | qxd S )NzReceived event, z, from z	Skipping z as already mapped.Tr   )	eventTypemoduledatar	   r   r    r   r1   extendr   __name__notifyListeners)	r   event	eventNamesrcModuleName	eventDatar4   obbnr0   r   r   r   handleEventM   s    



zsfp_openbugbounty.handleEvent)r6   
__module____qualname____doc__r   optdescsr   dictr   r   r   r1   r>   r   r   r   r   r      s   r   )r!   sflibr   r   r   r   r   r   r   r   <module>   s   