Exemplo n.º 1
0
 def goDiscover(self, domain):
     if "HOME" not in os.environ:
         print_error(
             "Don't know where to find discover files ($HOME not set)")
         return False
     path = 'file:///{}/data/{}'.format(os.environ['HOME'], domain)
     self.driver.get(path + '/data/hosts.htm')
     self.screenshot(
         'Host Enumeration {} using discover.png'.format(domain))
     self.driver.get(path + '/pages/netcraft.htm')
     self.screenshot(
         'Network History and Information of {} using discover.png'.format(
             domain))
     self.driver.get(path + '/data/emails.htm')
     self.screenshot(
         'Email Enumeration of {} using discover.png'.format(domain))
     emails = self.driver.find_element_by_tag_name('pre').text
     print_status('Saving {} emails to emails.discover'.format(
         len(emails.split('\n'))))
     with open('emails.discover', 'w') as f:
         f.write(emails)
     self.driver.get(path + '/data/names.htm')
     self.screenshot(
         'Name Enumeration of {} using discover.png'.format(domain))
     names = self.driver.find_element_by_tag_name('pre').text
     print_status('Saving {} names to names.discover'.format(
         len(names.split('\n'))))
     with open('names.discover', 'w') as f:
         f.write(names)
Exemplo n.º 2
0
    def goData(self, domain):
        creds = self.getCredentials('data.com')
        if creds == None:
            return
        self.driver.get('https://connect.data.com/')
        print_status('logging in to connect.data.com')
        self.driver.find_element_by_css_selector('#loginButton > div').click()
        self.driver.find_element_by_id('j_username').send_keys(creds['email'])
        self.driver.find_element_by_id('j_password').send_keys(
            creds['password'])
        self.driver.find_element_by_css_selector('#login_btn > span').click()
        print_status('using domain ' + domain)
        self.setValue(self.driver.find_element_by_id('homepageSBS'), domain)
        self.clickOn('#homepageSearchIcon')
        try:
            self.tryClick(
                '#findCompanies > div.search-result.general-display-none > div.column-right > div.result-table > table > tbody > tr > td.td-name.name > a'
            )
        except NoSuchElementException:
            print_error(
                'No company found with the domain %s on connect.data.com' %
                domain)
            return False

        #repeatOnError(self.clickOn, lambda x: True, '#findCompanies > div.search-result.general-display-none > div.column-right > div.result-table > table > tbody > tr > td.td-name.name > a')

        self.screenshot('Company Information Available on data.com.png')
        try:
            self.driver.find_element_by_xpath(
                '//a[contains(., "see all")]').click()
        except NoSuchElementException:
            #No active Contacts at this Company
            print_error('No contacts found in company on connect.data.com' %
                        domain)
            return False

        self.screenshot('Employee Information Available on data.com.png')

        with open(os.path.join(self.path, 'data.js')) as f:
            script = f.read()
        names = []
        while True:
            #self.driver.execute_script(script)
            names += [
                name.text.encode('utf-8') for name in
                self.driver.find_elements_by_css_selector('.td-name')
                if re.match('\S', name.text) is not None
            ]
            try:
                self.clickOn('img#next.table-navigation-next-image-active')
            except NoSuchElementException:
                break
        print_status('executing script to extract names')

        with open('names.data', 'w') as f:
            f.write('\n'.join(names))
        print_status('Saved %d names to "names.data"' % len(names))
        print_good('Finished enumeration using data.com')
        print
Exemplo n.º 3
0
 def getCredentials(self, section):
     creds = {}
     try:
         creds['email'] = self.creds.get(section, 'email')
         creds['password'] = self.creds.get(section, 'password')
     except NoOptionError, NoSectionError:
         print_error("Credentials for %s not found" % section)
         return None
Exemplo n.º 4
0
def repeatOnError(fn, test, *args, **kwargs):
    while (True):
        try:
            x = fn(*args, **kwargs)
        except Exception as e:
            print_error('{}: {}'.format(type(e), e.message))
            sleep(1)
            continue
        if (test(x)):
            return x
Exemplo n.º 5
0
                      '--credentials',
                      dest="credential_file",
                      help="ini style file with credentials")
    parser.add_option('-n', '--company', help='company name')
    parser.add_option('-d', '--domain', help='company domain')
    parser.add_option('-l',
                      '--headless',
                      action="store_true",
                      help='use phantomjs for headless operation')
    (options, args) = parser.parse_args()
    if options.credential_file is None or options.company is None or options.domain is None:
        parser.print_usage()
        parser.print_help()
        exit(1)
    if not os.path.isfile(options.credential_file):
        print_error("'{}' is not a file".format(options.credential_file))
        exit(1)
    if re.match('\S', options.company) is None:
        print_error("'{}' is not a valid company name".format(options.company))
        exit(1)
    if re.match('[^\.]{1,63}(\.[^\.]{1,63})+', options.domain) is None:
        print_error("'{}' is not a valid domain".format(options.domain))
        exit(1)
    try:
        getaddrinfo(options.domain, None)
    except gaierror:
        print_error("DNS lookup of '{}' failed".format(options.domain))
        exit(1)

    w = Web(options.credential_file, headless=options.headless)
    w.start()