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 addresses for module input (see \'info\' for options)') = {
                     'Name': ' NetBIOS Lookup',
                     'Author': 'Brendan Coles (bcoles[at]',
                     'Description': 'Leverages to gather NetBIOS information from the given host IP addresses.',
                     'Comments': [
                                  'Source options: [ db | <address> | ./path/to/file | query <sql> ]',
    def module_run(self):
        hosts = self.get_source(self.options['source']['value'], 'SELECT DISTINCT ip_address FROM hosts WHERE ip_address IS NOT NULL')

        for host in hosts:
            # request NetBIOS info
            url = '!&clean_opt=1&host=%s' % (host)
            self.verbose('URL: %s' % url)
            resp = self.request(url, timeout=20)

            # extract and present results
            content = resp.text
            result ='<pre>(.+?)\r\n\r\n', content, re.S)
            if result:
                self.alert("NetBIOS is enabled.\n%s" %
                self.verbose(' was unable to retrieve NetBIOS information from %s.' % host)