3
@6^                 @   s4   d dl mZ d dlmZmZmZ G dd deZdS )    )	IPNetwork)
SpiderFootSpiderFootPluginSpiderFootEventc               @   sp   e Zd ZdZdddddZdddddZd	Zd
ddZe fddZ	dd Z
dd Zdd Zdd Zdd Zd	S )sfp_uceprotectzUCEPROTECT:Investigate,Passive:Reputation Systems::Query the UCEPROTECT databases for open relays, open proxies, vulnerable servers, etc.T   )netblocklookupmaxnetblocksubnetlookup	maxsubnetzLook up all IPs on netblocks deemed to be owned by your target for possible blacklisted hosts on the same target subdomain/domain?zyIf looking up owned netblocks, the maximum netblock size to look up all IPs within (CIDR value, 24 = /24, 16 = /16, etc.)zKLook up all IPs on subnets which your target is a part of for blacklisting?zsIf looking up subnets, the maximum subnet size to look up all the IPs within (CIDR value, 24 = /24, 16 = /16, etc.)Nz&UCEPROTECT - Level 1 (high likelihood)z+UCEPROTECT - Level 2 (some false positives))zdnsbl-1.uceprotect.netzdnsbl-2.uceprotect.netc             C   s8   || _ | j | _x"t|j D ]}|| | j|< qW d S )N)sftempStorageresultslistkeysopts)selfsfcuserOptsopt r   9/var/www/spiderfoot.crq.systems/modules/sfp_uceprotect.pysetup3   s    
zsfp_uceprotect.setupc             C   s   ddddgS )N
IP_ADDRESSAFFILIATE_IPADDRNETBLOCK_OWNERNETBLOCK_MEMBERr   )r   r   r   r   watchedEvents;   s    zsfp_uceprotect.watchedEventsc             C   s   ddddgS )NBLACKLISTED_IPADDRBLACKLISTED_AFFILIATE_IPADDRBLACKLISTED_SUBNETBLACKLISTED_NETBLOCKr   )r   r   r   r   producedEventsB   s    zsfp_uceprotect.producedEventsc             C   s   dj t|jdS )N.)joinreversedsplit)r   ipaddrr   r   r   reverseAddrG   s    zsfp_uceprotect.reverseAddrc             C   s  |j }x| jD ]}| j r"d S y:| j|d | }| jjd|  | jj|}| jjdt|  |snwd }x|D ]}t| j| tkr| j| d | d }P qxt|t	| j| j
 kr| jjdt|  qxt|}	| j| |	 d | d }P qxW |d k	r\|dkrd}
|d	kr&d
}
|dkr4d}
|dkrBd}
t|
|| j|}| j| W q tk
r }
 z*| jjd| d | d t|
  W Y d d }
~
X qX qW d S )Nr#   zChecking Blacklist: zAddresses returned: z ()zReturn code not found in list: r   r   r   r   r   r!   r   r    zUnable to resolve z / z: )	eventTypecheckscheckForStopr(   r   debugresolveHoststrtyper   r   r   __name__notifyListenersBaseException)r   qaddrparentEvent	eventNamedomainlookupaddrstextaddrkeevtr   r   r   	queryAddrJ   sH    





:zsfp_uceprotect.queryAddrc             C   sT  |j }|j}|j}|}t }| jjd| d |  || jkrBd S d| j|< |dkr| jd sbd S t|j	| jd k r| jjdt
t|j	 d t
| jd   d S |d	kr| jd
 sd S t|j	| jd k r| jjdt
t|j	 d t
| jd   d S |jdrDx>t|D ]$}| j r,d S | jt
|| qW n| j|| d S )NzReceived event, z, from Tr   r   r	   z$Network size bigger than permitted: z > r   r
   r   	NETBLOCK_)r*   moduledatar   r   r-   r   r   r   	prefixlenr/   
startswithr,   r?   )r   eventr6   srcModuleName	eventDatar5   addrlistr;   r   r   r   handleEvent{   s>    





zsfp_uceprotect.handleEvent)r1   
__module____qualname____doc__r   optdescsr   r+   dictr   r   r"   r(   r?   rI   r   r   r   r   r      s$   1r   N)netaddrr   sflibr   r   r   r   r   r   r   r   <module>   s   