def get_nslookup(self, request_info, host=None, **kwargs): """ Perform a nslookup. """ if host is None: return self.render_error_json( "Unable to perform network operation: no host argument provided" ) try: output = nslookup(host, source="network_tools_controller", logger=logger) # Everything worked, return accordingly return { 'payload': output, # Payload of the request. 'status': 200 # HTTP status code } except: self.logger.exception( "Exception generated when attempting to perform an operation") return self.render_error_json( "Unable to perform network operation")
def test_do_nslookup(self): """ Test performing an nslookup. """ output = nslookup('google.com') self.assertGreater(len(output), 0)
def test_do_nslookup_reverse(self): """ Test performing an nslookup. """ output = nslookup('172.217.6.14') self.assertGreater(len(output), 0)
def test_do_nslookup_bug_2480(self): """ Test performing an nslookup on a domain that is recognized as IPv6. """ output = nslookup('textcritical.net') self.assertGreater(len(output), 0)
def test_do_nslookup(self): """ Test performing an nslookup. """ output = nslookup('textcritical.net') self.assertGreater(len(output), 0)
def do_lookup(self, host): """ Perform an nslookup lookup against the given host. """ self.logger.info("Running nslookup against host=%s", host) output = dict(nslookup(host=host, index=None)) if 'host' in output: output['hostname'] = output['host'] del output['host'] return output
def handle_results(self, results, session_key, in_preview): # FYI: we ignore results since this is a generating command # Make sure that the host field was provided if self.host is None: self.logger.warn("No host was provided") return # Get the index if self.index is not None: index = self.index else: index = get_default_index(session_key) # Do the nslookup result = nslookup(host=self.host, server=self.server, index=index, logger=self.logger) # Output the results self.output_results([result])