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                   @   sF   e Zd ZdZddiZddiZe fddZdd Zd	d
 Z	dd Z
dS )sfp_companyzjCompany Names:Footprint,Investigate,Passive:Content Analysis::Identify company names in any obtained data.filterjscssTzFilter out company names that originated from CSS/JS content. Enabling this avoids detection of popular Javascript and web framework author company names.c                 C   s*   || _ t| D ]}|| | j|< qd S )N)sflistkeysopts)selfsfcuserOptsopt r   6/var/www/spiderfoot.crq.systems/modules/sfp_company.pysetup    s    zsfp_company.setupc                 C   s   ddddddgS )NTARGET_WEB_CONTENTSSL_CERTIFICATE_ISSUEDZDOMAIN_WHOISZNETBLOCK_WHOISZAFFILIATE_DOMAIN_WHOISZAFFILIATE_WEB_CONTENTr   r   r   r   r   watchedEvents'   s      zsfp_company.watchedEventsc                 C   s   ddgS )NCOMPANY_NAMEAFFILIATE_COMPANY_NAMEr   r   r   r   r   producedEvents/   s    zsfp_company.producedEventsc                 C   s  |j }|j}|j}d}dddddddd	d
dddddddddddddddg}dddddddddd dd!dd"ddd#dd$dd%dg}d&}d'd(g}	|d)krd S |d*kr|j}
| jd+ rd,|
ksd-|
kr| jd. d S | jd/| d0 | d1 tt| d2  t	|tkrz>t	|t
tfkr"t|}n| jd3tt	|  W d S W n> tk
r } z| jd4t|  W Y d S d }~X Y nX z|d5kr|d6d7 }W n0 tk
r } z| jd8 W 5 d }~X Y nX t
 }|D ]}d9}|||}|d9kr|d: }|d9k rd9}|d; }|t|kr0t|d7 }||||  |t| }|||}qqt
 }|D ]N}|D ]@}t|d< | d= | |tjtjB }|D ]}d9}|D ]}t|d9kr|d77 }q|d7krqd>}|D ]:}d?}|	D ]}t||rd@}q|s||dA 7 }qtdBdA| }| jdC|  ||krb| jdD qn
|| dE|kr|dF}ndG}t||| j|}|jr|j|_ndH|_| | qqvqld S )INz(?=[,;:'">\(= ]|^)\s?([A-Z0-9\(\)][A-Za-z0-9\-&,\.][^ "';:><]*)?\s?([A-Z0-9\(\)][A-Za-z0-9\-&,\.]?[^ "';:><]*|[Aa]nd)?\s?([A-Z0-9\(\)][A-Za-z0-9\-&,\.]?[^ "';:><]*)?\s+ZLLCz
L\.L\.C\.?ZAGzA\.G\.?ZGmbHzPty\.?\s+Ltd\.?zLtd\.?zPte\.?zInc\.?zINC\.?ZIncorporatedZ
FoundationzCorp\.?ZCorporationZSAzS\.A\.?ZSIAZBVzB\.V\.?ZNVz
N\.V\.?PLCZLimitedzPvt\.?\s+Ltd\.?ZSARLzL.L.CzA.GZPtyZLtdZPteZIncZINCZCorpzS.AzB.VzN.VPLCzPvt.z(?=[ \.,:<\)'"]|[$
])Z	Copyrightz\d{4})r   r   r   r   z.jsz.cssz!Ignoring web content from CSS/JS.zReceived event, z, from z: z bytes.z&Unhandled type to find company names: z'Unable to convert list/dict to string: r   zO=   z+Couldn't strip out O=, proceeding anyway...r   2   
   () FT z\s+zFound company name: zAlready found from this source.Z
AFFILIATE_r   r   Unknown)	eventTypemoduledataactualSourcer
   r   debugstrlentyper   dictBaseExceptionsplitfindappendrefindall	MULTILINEDOTALLmatchsubstripinfor   __name__moduleDataSourcenotifyListeners)r   event	eventNamesrcModuleName	eventDataZpattern_prefixZpattern_match_reZpattern_matchZpattern_suffixZfilterpatternsurlechunkspatstartmendoffsetmyreschunkmatchesr2   matchedZfullcompanyfltfetypeevtr   r   r   handleEvent3   s                                          ,







&





zsfp_company.handleEventN)r6   
__module____qualname____doc__r
   optdescsr)   r   r   r   rM   r   r   r   r   r      s     r   )r.   sflibr   r   r   r   r   r   r   r   <module>   s   