Recon-ng / modules / recon / hosts / enum / http / web /

import framework
# unique to module
import re

class Module(framework.module):

    def __init__(self, params):
        framework.module.__init__(self, params)
        self.register_option('source', 'db', 'yes', 'source of hosts for module input (see \'info\' for options)') = {
                     'Name': 'URLVoid Domain Lookup',
                     'Author': 'Micah Hoffman (@WebBreacher)',
                     'Description': 'Checks for information about the security of the given host.',
                     'Comments': [
                                  'Source options: [ db | <hostname> | ./path/to/file | query <sql> ]'
    def module_run(self):
        hosts = self.get_source(self.options['source']['value'], 'SELECT DISTINCT host FROM hosts WHERE host IS NOT NULL ORDER BY host')

        for host in hosts:
            url = '' % (host)
            self.verbose('URL: %s' % url)
            resp = self.request(url)

            if '<h1>AN ERROR OCCURRED</h1>' in resp.text:
                self.output('No data returned for \'%s\'' % (host))

            # Get and display the results
            blacklisted ='Blacklist Status</td><td><span.+>(\w.+)</span>', resp.text)
            if == "BLACKLISTED":
                self.alert('\'%s\' is BLACKLISTED! (ruhroh)' % (host))
                detection ='Detection Ratio</td><td>(\d+ / \d+) \(<font', resp.text)
                self.output('Detection Ratio was %s' %
                detected_sites = re.findall(r'Favicon" />(.+?)</td><td><img src=".+?" alt="Alert" title="Detected!".+?"nofollow" href="(.+?)" title', resp.text)
                tdata = [['Site', 'Link']]
                for site in detected_sites:
                    tdata.append([site[0].strip(), site[1].strip()])
                self.table(tdata, True)
                self.output('\'%s\' not blacklisted...whew!' % (host))