U
    @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   s4   || _ |  | _t| D ]}|| | j|< q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 t|dS )N.)joinreversedsplit)r   ipaddrr   r   r   reverseAddrG   s    zsfp_uceprotect.reverseAddrc                 C   s  |j }| jD ]}|  r  d S z@| |d | }| jd|  | j|}| jdt|  |snW qd }|D ]}t| j| tkr| j| d | d } qqvt|t	| j| 
 kr| jdt|  qvt|}	| j| |	 d | d } qqv|d k	r`|dkrd}
|d	kr*d
}
|dkr8d}
|dkrFd}
t|
|| j|}| | W q tk
r }
 z(| jd| d | d t|
  W 5 d }
~
X Y qX q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    




8zsfp_uceprotect.queryAddrc                 C   sR  |j }|j}|j}|}t }| jd| d |  || jkrBd S d| j|< |dkr| jd sbd S t|j	| jd k r| 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dt
t|j	 d t
| jd   d S |drBt|D ]&}|  r, d S | t
|| qn| || 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   	prefixlenr0   
startswithr-   r@   )r   eventr7   srcModuleName	eventDatar6   addrlistr<   r   r   r   handleEvent{   sN    





zsfp_uceprotect.handleEvent)r2   
__module____qualname____doc__r   optdescsr   r,   dictr   r   r#   r)   r@   rJ   r   r   r   r   r      s*   	1r   N)netaddrr   sflibr   r   r   r   r   r   r   r   <module>   s   