nwo
stringlengths
6
76
sha
stringlengths
40
40
path
stringlengths
5
118
language
stringclasses
1 value
identifier
stringlengths
1
89
parameters
stringlengths
2
5.4k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
51.1k
docstring
stringlengths
1
17.6k
docstring_summary
stringlengths
0
7.02k
docstring_tokens
sequence
function
stringlengths
30
51.1k
function_tokens
sequence
url
stringlengths
85
218
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.Method
(self)
return self._method
Determines if a method (GET or POST) was established for this specific site. Defaults to GET Argument(s): No arguments are required. Return value(s): string -- representation of the method used to access the site GET or POST. Restriction(s): This Method is tagged as a Property.
Determines if a method (GET or POST) was established for this specific site. Defaults to GET
[ "Determines", "if", "a", "method", "(", "GET", "or", "POST", ")", "was", "established", "for", "this", "specific", "site", ".", "Defaults", "to", "GET" ]
def Method(self): """ Determines if a method (GET or POST) was established for this specific site. Defaults to GET Argument(s): No arguments are required. Return value(s): string -- representation of the method used to access the site GET or POST. Restriction(s): This Method is tagged as a Property. """ if self._method is None: return "GET" if len(self._method) == 0: return "GET" return self._method
[ "def", "Method", "(", "self", ")", ":", "if", "self", ".", "_method", "is", "None", ":", "return", "\"GET\"", "if", "len", "(", "self", ".", "_method", ")", "==", "0", ":", "return", "\"GET\"", "return", "self", ".", "_method" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L958-L976
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.Method
(self, method)
Ensures the method type is set to either GET or POST. By default GET is assigned Argument(s): method -- string repr GET or POST. If neither, GET is assigned. Return value(s): Nothing is returned from this Method. Restriction(s): This Method is tagged as a Setter.
Ensures the method type is set to either GET or POST. By default GET is assigned
[ "Ensures", "the", "method", "type", "is", "set", "to", "either", "GET", "or", "POST", ".", "By", "default", "GET", "is", "assigned" ]
def Method(self, method): """ Ensures the method type is set to either GET or POST. By default GET is assigned Argument(s): method -- string repr GET or POST. If neither, GET is assigned. Return value(s): Nothing is returned from this Method. Restriction(s): This Method is tagged as a Setter. """ if not self.PostData: self._method = "GET" return if len(method) > 0: if method.upper() == "GET" or method.upper() == "POST": self._method = method.upper() return self._method = "GET"
[ "def", "Method", "(", "self", ",", "method", ")", ":", "if", "not", "self", ".", "PostData", ":", "self", ".", "_method", "=", "\"GET\"", "return", "if", "len", "(", "method", ")", ">", "0", ":", "if", "method", ".", "upper", "(", ")", "==", "\"GET\"", "or", "method", ".", "upper", "(", ")", "==", "\"POST\"", ":", "self", ".", "_method", "=", "method", ".", "upper", "(", ")", "return", "self", ".", "_method", "=", "\"GET\"" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L979-L1000
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.Results
(self)
return self._results
Checks the instance variable _results is empty or None. Returns _results (the results list) or None if it is empty. Argument(s): No arguments are required. Return value(s): list -- list of results discovered from the site being investigated. None -- if _results is empty or None. Restriction(s): This Method is tagged as a Property.
Checks the instance variable _results is empty or None. Returns _results (the results list) or None if it is empty. Argument(s): No arguments are required. Return value(s): list -- list of results discovered from the site being investigated. None -- if _results is empty or None. Restriction(s): This Method is tagged as a Property.
[ "Checks", "the", "instance", "variable", "_results", "is", "empty", "or", "None", ".", "Returns", "_results", "(", "the", "results", "list", ")", "or", "None", "if", "it", "is", "empty", ".", "Argument", "(", "s", ")", ":", "No", "arguments", "are", "required", ".", "Return", "value", "(", "s", ")", ":", "list", "--", "list", "of", "results", "discovered", "from", "the", "site", "being", "investigated", ".", "None", "--", "if", "_results", "is", "empty", "or", "None", ".", "Restriction", "(", "s", ")", ":", "This", "Method", "is", "tagged", "as", "a", "Property", "." ]
def Results(self): """ Checks the instance variable _results is empty or None. Returns _results (the results list) or None if it is empty. Argument(s): No arguments are required. Return value(s): list -- list of results discovered from the site being investigated. None -- if _results is empty or None. Restriction(s): This Method is tagged as a Property. """ if self._results is None or len(self._results) == 0: return None return self._results
[ "def", "Results", "(", "self", ")", ":", "if", "self", ".", "_results", "is", "None", "or", "len", "(", "self", ".", "_results", ")", "==", "0", ":", "return", "None", "return", "self", ".", "_results" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1003-L1017
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.addResults
(self, results)
Assigns the argument to the _results instance variable to build the list or results retrieved from the site. Assign None to the _results instance variable if the argument is empty. Argument(s): results -- list of results retrieved from the site. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Assigns the argument to the _results instance variable to build the list or results retrieved from the site. Assign None to the _results instance variable if the argument is empty.
[ "Assigns", "the", "argument", "to", "the", "_results", "instance", "variable", "to", "build", "the", "list", "or", "results", "retrieved", "from", "the", "site", ".", "Assign", "None", "to", "the", "_results", "instance", "variable", "if", "the", "argument", "is", "empty", "." ]
def addResults(self, results): """ Assigns the argument to the _results instance variable to build the list or results retrieved from the site. Assign None to the _results instance variable if the argument is empty. Argument(s): results -- list of results retrieved from the site. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ if results is None or len(results) == 0: self._results = None else: self._results = results
[ "def", "addResults", "(", "self", ",", "results", ")", ":", "if", "results", "is", "None", "or", "len", "(", "results", ")", "==", "0", ":", "self", ".", "_results", "=", "None", "else", ":", "self", ".", "_results", "=", "results" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1019-L1037
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.postMessage
(self, message)
Prints multiple messages to inform the user of progress. Argument(s): message -- string to be utilized as a message to post. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Prints multiple messages to inform the user of progress.
[ "Prints", "multiple", "messages", "to", "inform", "the", "user", "of", "progress", "." ]
def postMessage(self, message): """ Prints multiple messages to inform the user of progress. Argument(s): message -- string to be utilized as a message to post. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ if self.BotOutputRequested: pass else: SiteDetailOutput.PrintStandardOutput(message, verbose=self._verbose)
[ "def", "postMessage", "(", "self", ",", "message", ")", ":", "if", "self", ".", "BotOutputRequested", ":", "pass", "else", ":", "SiteDetailOutput", ".", "PrintStandardOutput", "(", "message", ",", "verbose", "=", "self", ".", "_verbose", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1039-L1055
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.postErrorMessage
(self, message)
Prints multiple error messages to inform the user of progress. Argument(s): message -- string to be utilized as an error message to post. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Prints multiple error messages to inform the user of progress.
[ "Prints", "multiple", "error", "messages", "to", "inform", "the", "user", "of", "progress", "." ]
def postErrorMessage(self, message): """ Prints multiple error messages to inform the user of progress. Argument(s): message -- string to be utilized as an error message to post. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ self.postMessage(message)
[ "def", "postErrorMessage", "(", "self", ",", "message", ")", ":", "self", ".", "postMessage", "(", "message", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1057-L1070
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.getImportantProperty
(self, index)
return siteimpprop()
Gets the property information from the property value listed in the xml file for that specific site in the importantproperty xml tag. This Method allows for the property that will be printed to be changed using the configuration file. Returns the return value listed in the property attribute discovered. Argument(s): index -- integer representing which important property is retrieved if more than one important property value is listed in the config file. Return value(s): Multiple options -- returns the return value of the property listed in the config file. Most likely a string or a list. Restriction(s): The Method has no restrictions.
Gets the property information from the property value listed in the xml file for that specific site in the importantproperty xml tag. This Method allows for the property that will be printed to be changed using the configuration file. Returns the return value listed in the property attribute discovered.
[ "Gets", "the", "property", "information", "from", "the", "property", "value", "listed", "in", "the", "xml", "file", "for", "that", "specific", "site", "in", "the", "importantproperty", "xml", "tag", ".", "This", "Method", "allows", "for", "the", "property", "that", "will", "be", "printed", "to", "be", "changed", "using", "the", "configuration", "file", ".", "Returns", "the", "return", "value", "listed", "in", "the", "property", "attribute", "discovered", "." ]
def getImportantProperty(self, index): """ Gets the property information from the property value listed in the xml file for that specific site in the importantproperty xml tag. This Method allows for the property that will be printed to be changed using the configuration file. Returns the return value listed in the property attribute discovered. Argument(s): index -- integer representing which important property is retrieved if more than one important property value is listed in the config file. Return value(s): Multiple options -- returns the return value of the property listed in the config file. Most likely a string or a list. Restriction(s): The Method has no restrictions. """ if isinstance(self._importantProperty, basestring): siteimpprop = getattr(self, "get" + self._importantProperty, Site.getResults) else: siteimpprop = getattr(self, "get" + self._importantProperty[index], Site.getResults) return siteimpprop()
[ "def", "getImportantProperty", "(", "self", ",", "index", ")", ":", "if", "isinstance", "(", "self", ".", "_importantProperty", ",", "basestring", ")", ":", "siteimpprop", "=", "getattr", "(", "self", ",", "\"get\"", "+", "self", ".", "_importantProperty", ",", "Site", ".", "getResults", ")", "else", ":", "siteimpprop", "=", "getattr", "(", "self", ",", "\"get\"", "+", "self", ".", "_importantProperty", "[", "index", "]", ",", "Site", ".", "getResults", ")", "return", "siteimpprop", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1072-L1095
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.getTarget
(self)
return self.Target
Returns the Target property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions.
Returns the Target property information.
[ "Returns", "the", "Target", "property", "information", "." ]
def getTarget(self): """ Returns the Target property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions. """ return self.Target
[ "def", "getTarget", "(", "self", ")", ":", "return", "self", ".", "Target" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1097-L1110
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.getResults
(self)
return self.Results
Returns the Results property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions.
Returns the Results property information.
[ "Returns", "the", "Results", "property", "information", "." ]
def getResults(self): """ Returns the Results property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions. """ return self.Results
[ "def", "getResults", "(", "self", ")", ":", "return", "self", ".", "Results" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1112-L1125
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.getFullURL
(self)
return self.FullURL
Returns the FullURL property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions.
Returns the FullURL property information.
[ "Returns", "the", "FullURL", "property", "information", "." ]
def getFullURL(self): """ Returns the FullURL property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions. """ return self.FullURL
[ "def", "getFullURL", "(", "self", ")", ":", "return", "self", ".", "FullURL" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1127-L1140
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.getSourceURL
(self)
return self.SourceURL
Returns the SourceURL property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions.
Returns the SourceURL property information.
[ "Returns", "the", "SourceURL", "property", "information", "." ]
def getSourceURL(self): """ Returns the SourceURL property information. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions. """ return self.SourceURL
[ "def", "getSourceURL", "(", "self", ")", ":", "return", "self", ".", "SourceURL" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1142-L1155
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.getWebScrape
(self)
Attempts to retrieve a string from a web site. String retrieved is the entire web site including HTML markup. Requests via proxy if --proxy option was chosen during execution of the Automater. Returns the string representing the entire web site including the HTML markup retrieved from the site. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions.
Attempts to retrieve a string from a web site. String retrieved is the entire web site including HTML markup. Requests via proxy if --proxy option was chosen during execution of the Automater. Returns the string representing the entire web site including the HTML markup retrieved from the site.
[ "Attempts", "to", "retrieve", "a", "string", "from", "a", "web", "site", ".", "String", "retrieved", "is", "the", "entire", "web", "site", "including", "HTML", "markup", ".", "Requests", "via", "proxy", "if", "--", "proxy", "option", "was", "chosen", "during", "execution", "of", "the", "Automater", ".", "Returns", "the", "string", "representing", "the", "entire", "web", "site", "including", "the", "HTML", "markup", "retrieved", "from", "the", "site", "." ]
def getWebScrape(self): """ Attempts to retrieve a string from a web site. String retrieved is the entire web site including HTML markup. Requests via proxy if --proxy option was chosen during execution of the Automater. Returns the string representing the entire web site including the HTML markup retrieved from the site. Argument(s): No arguments are required. Return value(s): string. Restriction(s): The Method has no restrictions. """ delay = self.WebRetrieveDelay headers, params, proxy = self.getHeaderParamProxyInfo() try: time.sleep(delay) resp = requests.get(self.FullURL, headers=headers, params=params, proxies=proxy, verify=False, timeout=5) return str(resp.content) except ConnectionError as ce: try: self.postErrorMessage('[-] Cannot connect to {url}. Server response is {resp} Server error code is {code}'. format(url=self.FullURL, resp=ce.message[0], code=ce.message[1][0])) except: self.postErrorMessage('[-] Cannot connect to ' + self.FullURL) except: self.postErrorMessage('[-] Cannot connect to ' + self.FullURL)
[ "def", "getWebScrape", "(", "self", ")", ":", "delay", "=", "self", ".", "WebRetrieveDelay", "headers", ",", "params", ",", "proxy", "=", "self", ".", "getHeaderParamProxyInfo", "(", ")", "try", ":", "time", ".", "sleep", "(", "delay", ")", "resp", "=", "requests", ".", "get", "(", "self", ".", "FullURL", ",", "headers", "=", "headers", ",", "params", "=", "params", ",", "proxies", "=", "proxy", ",", "verify", "=", "False", ",", "timeout", "=", "5", ")", "return", "str", "(", "resp", ".", "content", ")", "except", "ConnectionError", "as", "ce", ":", "try", ":", "self", ".", "postErrorMessage", "(", "'[-] Cannot connect to {url}. Server response is {resp} Server error code is {code}'", ".", "format", "(", "url", "=", "self", ".", "FullURL", ",", "resp", "=", "ce", ".", "message", "[", "0", "]", ",", "code", "=", "ce", ".", "message", "[", "1", "]", "[", "0", "]", ")", ")", "except", ":", "self", ".", "postErrorMessage", "(", "'[-] Cannot connect to '", "+", "self", ".", "FullURL", ")", "except", ":", "self", ".", "postErrorMessage", "(", "'[-] Cannot connect to '", "+", "self", ".", "FullURL", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1173-L1203
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.addMultiResults
(self, results, index)
Assigns the argument to the _results instance variable to build the list or results retrieved from the site. Assign None to the _results instance variable if the argument is empty. Argument(s): results -- list of results retrieved from the site. index -- integer value representing the index of the result found. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Assigns the argument to the _results instance variable to build the list or results retrieved from the site. Assign None to the _results instance variable if the argument is empty.
[ "Assigns", "the", "argument", "to", "the", "_results", "instance", "variable", "to", "build", "the", "list", "or", "results", "retrieved", "from", "the", "site", ".", "Assign", "None", "to", "the", "_results", "instance", "variable", "if", "the", "argument", "is", "empty", "." ]
def addMultiResults(self, results, index): """ Assigns the argument to the _results instance variable to build the list or results retrieved from the site. Assign None to the _results instance variable if the argument is empty. Argument(s): results -- list of results retrieved from the site. index -- integer value representing the index of the result found. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ # if no return from site, seed the results with an empty list if results is None or len(results) == 0: self._results[index] = None else: self._results[index] = results
[ "def", "addMultiResults", "(", "self", ",", "results", ",", "index", ")", ":", "# if no return from site, seed the results with an empty list", "if", "results", "is", "None", "or", "len", "(", "results", ")", "==", "0", ":", "self", ".", "_results", "[", "index", "]", "=", "None", "else", ":", "self", ".", "_results", "[", "index", "]", "=", "results" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1205-L1225
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.submitPost
(self)
Submits information to a web site being used as a resource that requires a post of information. Submits via proxy if --proxy option was chosen during execution of the Automater. Returns a string that contains entire web site being used as a resource including HTML markup information. Argument(s): raw_params -- string info detailing parameters provided from xml configuration file in the params XML tag. headers -- string info detailing headers provided from xml configuration file in the headers XML tag. Return value(s): string -- contains entire web site being used as a resource including HTML markup information. Restriction(s): The Method has no restrictions.
Submits information to a web site being used as a resource that requires a post of information. Submits via proxy if --proxy option was chosen during execution of the Automater. Returns a string that contains entire web site being used as a resource including HTML markup information.
[ "Submits", "information", "to", "a", "web", "site", "being", "used", "as", "a", "resource", "that", "requires", "a", "post", "of", "information", ".", "Submits", "via", "proxy", "if", "--", "proxy", "option", "was", "chosen", "during", "execution", "of", "the", "Automater", ".", "Returns", "a", "string", "that", "contains", "entire", "web", "site", "being", "used", "as", "a", "resource", "including", "HTML", "markup", "information", "." ]
def submitPost(self): """ Submits information to a web site being used as a resource that requires a post of information. Submits via proxy if --proxy option was chosen during execution of the Automater. Returns a string that contains entire web site being used as a resource including HTML markup information. Argument(s): raw_params -- string info detailing parameters provided from xml configuration file in the params XML tag. headers -- string info detailing headers provided from xml configuration file in the headers XML tag. Return value(s): string -- contains entire web site being used as a resource including HTML markup information. Restriction(s): The Method has no restrictions. """ headers, params, proxy = self.getHeaderParamProxyInfo() try: resp = requests.post(self.FullURL, data=self.PostData, headers=headers, params=params, proxies=proxy, verify=False) return str(resp.content) except ConnectionError as ce: try: self.postErrorMessage('[-] Cannot connect to {url}. Server response is {resp} Server error code is {code}'. format(url=self.FullURL, resp=ce.message[0], code=ce.message[1][0])) except: self.postErrorMessage('[-] Cannot connect to ' + self.FullURL) except: self.postErrorMessage('[-] Cannot connect to ' + self.FullURL)
[ "def", "submitPost", "(", "self", ")", ":", "headers", ",", "params", ",", "proxy", "=", "self", ".", "getHeaderParamProxyInfo", "(", ")", "try", ":", "resp", "=", "requests", ".", "post", "(", "self", ".", "FullURL", ",", "data", "=", "self", ".", "PostData", ",", "headers", "=", "headers", ",", "params", "=", "params", ",", "proxies", "=", "proxy", ",", "verify", "=", "False", ")", "return", "str", "(", "resp", ".", "content", ")", "except", "ConnectionError", "as", "ce", ":", "try", ":", "self", ".", "postErrorMessage", "(", "'[-] Cannot connect to {url}. Server response is {resp} Server error code is {code}'", ".", "format", "(", "url", "=", "self", ".", "FullURL", ",", "resp", "=", "ce", ".", "message", "[", "0", "]", ",", "code", "=", "ce", ".", "message", "[", "1", "]", "[", "0", "]", ")", ")", "except", ":", "self", ".", "postErrorMessage", "(", "'[-] Cannot connect to '", "+", "self", ".", "FullURL", ")", "except", ":", "self", ".", "postErrorMessage", "(", "'[-] Cannot connect to '", "+", "self", ".", "FullURL", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1227-L1259
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
SingleResultsSite.__init__
(self, site)
Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Argument(s): site -- the site that we will decorate. Return value(s): Nothing is returned from this Method.
Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern.
[ "Class", "constructor", ".", "Assigns", "a", "site", "from", "the", "parameter", "into", "the", "_site", "instance", "variable", ".", "This", "is", "a", "play", "on", "the", "decorator", "pattern", "." ]
def __init__(self, site): """ Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Argument(s): site -- the site that we will decorate. Return value(s): Nothing is returned from this Method. """ self._site = site super(SingleResultsSite, self).__init__(self._site.URL, self._site.WebRetrieveDelay, self._site.Proxy, self._site.TargetType, self._site.ReportStringForResult, self._site.Target, self._site.UserAgent, self._site.FriendlyName, self._site.RegEx, self._site.FullURL, self._site.BotOutputRequested, self._site.ImportantPropertyString, self._site.Params, self._site.Headers, self._site.Method, self._site.PostData, site._verbose) self.postMessage(self.UserMessage + " " + self.FullURL) websitecontent = self.getContentList(self.getWebScrape()) if websitecontent: self.addResults(websitecontent)
[ "def", "__init__", "(", "self", ",", "site", ")", ":", "self", ".", "_site", "=", "site", "super", "(", "SingleResultsSite", ",", "self", ")", ".", "__init__", "(", "self", ".", "_site", ".", "URL", ",", "self", ".", "_site", ".", "WebRetrieveDelay", ",", "self", ".", "_site", ".", "Proxy", ",", "self", ".", "_site", ".", "TargetType", ",", "self", ".", "_site", ".", "ReportStringForResult", ",", "self", ".", "_site", ".", "Target", ",", "self", ".", "_site", ".", "UserAgent", ",", "self", ".", "_site", ".", "FriendlyName", ",", "self", ".", "_site", ".", "RegEx", ",", "self", ".", "_site", ".", "FullURL", ",", "self", ".", "_site", ".", "BotOutputRequested", ",", "self", ".", "_site", ".", "ImportantPropertyString", ",", "self", ".", "_site", ".", "Params", ",", "self", ".", "_site", ".", "Headers", ",", "self", ".", "_site", ".", "Method", ",", "self", ".", "_site", ".", "PostData", ",", "site", ".", "_verbose", ")", "self", ".", "postMessage", "(", "self", ".", "UserMessage", "+", "\" \"", "+", "self", ".", "FullURL", ")", "websitecontent", "=", "self", ".", "getContentList", "(", "self", ".", "getWebScrape", "(", ")", ")", "if", "websitecontent", ":", "self", ".", "addResults", "(", "websitecontent", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1274-L1296
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
SingleResultsSite.getContentList
(self, webcontent)
Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered. Argument(s): webcontent -- actual content of the web page that's been returned from a request. Return value(s): list -- information found from a web site being used as a resource. Restriction(s): The Method has no restrictions.
Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered.
[ "Retrieves", "a", "list", "of", "information", "retrieved", "from", "the", "sites", "defined", "in", "the", "xml", "configuration", "file", ".", "Returns", "the", "list", "of", "found", "information", "from", "the", "sites", "being", "used", "as", "resources", "or", "returns", "None", "if", "the", "site", "cannot", "be", "discovered", "." ]
def getContentList(self, webcontent): """ Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered. Argument(s): webcontent -- actual content of the web page that's been returned from a request. Return value(s): list -- information found from a web site being used as a resource. Restriction(s): The Method has no restrictions. """ try: repattern = re.compile(self.RegEx, re.IGNORECASE) foundlist = re.findall(repattern, webcontent) return foundlist except: self.postErrorMessage(self.ErrorMessage + " " + self.FullURL) return None
[ "def", "getContentList", "(", "self", ",", "webcontent", ")", ":", "try", ":", "repattern", "=", "re", ".", "compile", "(", "self", ".", "RegEx", ",", "re", ".", "IGNORECASE", ")", "foundlist", "=", "re", ".", "findall", "(", "repattern", ",", "webcontent", ")", "return", "foundlist", "except", ":", "self", ".", "postErrorMessage", "(", "self", ".", "ErrorMessage", "+", "\" \"", "+", "self", ".", "FullURL", ")", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1298-L1321
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
MultiResultsSite.__init__
(self, site)
Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Argument(s): site -- the site that we will decorate. Return value(s): Nothing is returned from this Method.
Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern.
[ "Class", "constructor", ".", "Assigns", "a", "site", "from", "the", "parameter", "into", "the", "_site", "instance", "variable", ".", "This", "is", "a", "play", "on", "the", "decorator", "pattern", "." ]
def __init__(self, site): """ Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Argument(s): site -- the site that we will decorate. Return value(s): Nothing is returned from this Method. """ self._site = site super(MultiResultsSite, self).__init__(self._site.URL, self._site.WebRetrieveDelay, self._site.Proxy, self._site.TargetType, self._site.ReportStringForResult, self._site.Target, self._site.UserAgent, self._site.FriendlyName, self._site.RegEx, self._site.FullURL, self._site.BotOutputRequested, self._site.ImportantPropertyString, self._site.Params, self._site.Headers, self._site.Method, self._site.PostData, site._verbose) self._results = [[] for x in xrange(len(self._site.RegEx))] self.postMessage(self.UserMessage + " " + self.FullURL) webcontent = self.getWebScrape() for index in xrange(len(self.RegEx)): websitecontent = self.getContentList(webcontent, index) if websitecontent: self.addMultiResults(websitecontent, index)
[ "def", "__init__", "(", "self", ",", "site", ")", ":", "self", ".", "_site", "=", "site", "super", "(", "MultiResultsSite", ",", "self", ")", ".", "__init__", "(", "self", ".", "_site", ".", "URL", ",", "self", ".", "_site", ".", "WebRetrieveDelay", ",", "self", ".", "_site", ".", "Proxy", ",", "self", ".", "_site", ".", "TargetType", ",", "self", ".", "_site", ".", "ReportStringForResult", ",", "self", ".", "_site", ".", "Target", ",", "self", ".", "_site", ".", "UserAgent", ",", "self", ".", "_site", ".", "FriendlyName", ",", "self", ".", "_site", ".", "RegEx", ",", "self", ".", "_site", ".", "FullURL", ",", "self", ".", "_site", ".", "BotOutputRequested", ",", "self", ".", "_site", ".", "ImportantPropertyString", ",", "self", ".", "_site", ".", "Params", ",", "self", ".", "_site", ".", "Headers", ",", "self", ".", "_site", ".", "Method", ",", "self", ".", "_site", ".", "PostData", ",", "site", ".", "_verbose", ")", "self", ".", "_results", "=", "[", "[", "]", "for", "x", "in", "xrange", "(", "len", "(", "self", ".", "_site", ".", "RegEx", ")", ")", "]", "self", ".", "postMessage", "(", "self", ".", "UserMessage", "+", "\" \"", "+", "self", ".", "FullURL", ")", "webcontent", "=", "self", ".", "getWebScrape", "(", ")", "for", "index", "in", "xrange", "(", "len", "(", "self", ".", "RegEx", ")", ")", ":", "websitecontent", "=", "self", ".", "getContentList", "(", "webcontent", ",", "index", ")", "if", "websitecontent", ":", "self", ".", "addMultiResults", "(", "websitecontent", ",", "index", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1337-L1363
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
MultiResultsSite.getContentList
(self, webcontent, index)
Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered. Argument(s): webcontent -- actual content of the web page that's been returned from a request. index -- the integer representing the index of the regex list. Return value(s): list -- information found from a web site being used as a resource. Restriction(s): The Method has no restrictions.
Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered.
[ "Retrieves", "a", "list", "of", "information", "retrieved", "from", "the", "sites", "defined", "in", "the", "xml", "configuration", "file", ".", "Returns", "the", "list", "of", "found", "information", "from", "the", "sites", "being", "used", "as", "resources", "or", "returns", "None", "if", "the", "site", "cannot", "be", "discovered", "." ]
def getContentList(self, webcontent, index): """ Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered. Argument(s): webcontent -- actual content of the web page that's been returned from a request. index -- the integer representing the index of the regex list. Return value(s): list -- information found from a web site being used as a resource. Restriction(s): The Method has no restrictions. """ try: repattern = re.compile(self.RegEx[index], re.IGNORECASE) foundlist = re.findall(repattern, webcontent) return foundlist except: self.postErrorMessage(self.ErrorMessage + " " + self.FullURL) return None
[ "def", "getContentList", "(", "self", ",", "webcontent", ",", "index", ")", ":", "try", ":", "repattern", "=", "re", ".", "compile", "(", "self", ".", "RegEx", "[", "index", "]", ",", "re", ".", "IGNORECASE", ")", "foundlist", "=", "re", ".", "findall", "(", "repattern", ",", "webcontent", ")", "return", "foundlist", "except", ":", "self", ".", "postErrorMessage", "(", "self", ".", "ErrorMessage", "+", "\" \"", "+", "self", ".", "FullURL", ")", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1365-L1389
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
MethodPostSite.__init__
(self, site)
Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Also assigns the postbydefault parameter to the _postByDefault instance variable to determine if the Automater should post information to a site. By default Automater will NOT post information. Argument(s): site -- the site that we will decorate. postbydefault -- a Boolean representing whether a post will occur. Return value(s): Nothing is returned from this Method.
Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Also assigns the postbydefault parameter to the _postByDefault instance variable to determine if the Automater should post information to a site. By default Automater will NOT post information.
[ "Class", "constructor", ".", "Assigns", "a", "site", "from", "the", "parameter", "into", "the", "_site", "instance", "variable", ".", "This", "is", "a", "play", "on", "the", "decorator", "pattern", ".", "Also", "assigns", "the", "postbydefault", "parameter", "to", "the", "_postByDefault", "instance", "variable", "to", "determine", "if", "the", "Automater", "should", "post", "information", "to", "a", "site", ".", "By", "default", "Automater", "will", "NOT", "post", "information", "." ]
def __init__(self, site): """ Class constructor. Assigns a site from the parameter into the _site instance variable. This is a play on the decorator pattern. Also assigns the postbydefault parameter to the _postByDefault instance variable to determine if the Automater should post information to a site. By default Automater will NOT post information. Argument(s): site -- the site that we will decorate. postbydefault -- a Boolean representing whether a post will occur. Return value(s): Nothing is returned from this Method. """ self._site = site super(MethodPostSite, self).__init__(self._site.URL, self._site.WebRetrieveDelay, self._site.Proxy, self._site.TargetType, self._site.ReportStringForResult, self._site.Target, self._site.UserAgent, self._site.FriendlyName, self._site.RegEx, self._site.FullURL, self._site.BotOutputRequested, self._site.ImportantPropertyString, self._site.Params, self._site.Headers, self._site.Method, self._site.PostData, site._verbose) self.postMessage(self.UserMessage + " " + self.FullURL) SiteDetailOutput.PrintStandardOutput('[-] {url} requires a submission for {target}. ' 'Submitting now, this may take a moment.'. format(url=self._site.URL, target=self._site.Target), verbose=site._verbose) content = self.submitPost() if content: if not isinstance(self.FriendlyName, basestring): # this is a multi instance self._results = [[] for x in xrange(len(self.RegEx))] for index in range(len(self.RegEx)): self.addMultiResults(self.getContentList(content, index), index) else: # this is a single instance self.addResults(self.getContentList(content))
[ "def", "__init__", "(", "self", ",", "site", ")", ":", "self", ".", "_site", "=", "site", "super", "(", "MethodPostSite", ",", "self", ")", ".", "__init__", "(", "self", ".", "_site", ".", "URL", ",", "self", ".", "_site", ".", "WebRetrieveDelay", ",", "self", ".", "_site", ".", "Proxy", ",", "self", ".", "_site", ".", "TargetType", ",", "self", ".", "_site", ".", "ReportStringForResult", ",", "self", ".", "_site", ".", "Target", ",", "self", ".", "_site", ".", "UserAgent", ",", "self", ".", "_site", ".", "FriendlyName", ",", "self", ".", "_site", ".", "RegEx", ",", "self", ".", "_site", ".", "FullURL", ",", "self", ".", "_site", ".", "BotOutputRequested", ",", "self", ".", "_site", ".", "ImportantPropertyString", ",", "self", ".", "_site", ".", "Params", ",", "self", ".", "_site", ".", "Headers", ",", "self", ".", "_site", ".", "Method", ",", "self", ".", "_site", ".", "PostData", ",", "site", ".", "_verbose", ")", "self", ".", "postMessage", "(", "self", ".", "UserMessage", "+", "\" \"", "+", "self", ".", "FullURL", ")", "SiteDetailOutput", ".", "PrintStandardOutput", "(", "'[-] {url} requires a submission for {target}. '", "'Submitting now, this may take a moment.'", ".", "format", "(", "url", "=", "self", ".", "_site", ".", "URL", ",", "target", "=", "self", ".", "_site", ".", "Target", ")", ",", "verbose", "=", "site", ".", "_verbose", ")", "content", "=", "self", ".", "submitPost", "(", ")", "if", "content", ":", "if", "not", "isinstance", "(", "self", ".", "FriendlyName", ",", "basestring", ")", ":", "# this is a multi instance", "self", ".", "_results", "=", "[", "[", "]", "for", "x", "in", "xrange", "(", "len", "(", "self", ".", "RegEx", ")", ")", "]", "for", "index", "in", "range", "(", "len", "(", "self", ".", "RegEx", ")", ")", ":", "self", ".", "addMultiResults", "(", "self", ".", "getContentList", "(", "content", ",", "index", ")", ",", "index", ")", "else", ":", "# this is a single instance", "self", ".", "addResults", "(", "self", ".", "getContentList", "(", "content", ")", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1408-L1446
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
MethodPostSite.getContentList
(self, content, index=-1)
Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered. Argument(s): content -- string representation of the web site being used as a resource. index -- the integer representing the index of the regex list. Return value(s): list -- information found from a web site being used as a resource. Restriction(s): The Method has no restrictions.
Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered.
[ "Retrieves", "a", "list", "of", "information", "retrieved", "from", "the", "sites", "defined", "in", "the", "xml", "configuration", "file", ".", "Returns", "the", "list", "of", "found", "information", "from", "the", "sites", "being", "used", "as", "resources", "or", "returns", "None", "if", "the", "site", "cannot", "be", "discovered", "." ]
def getContentList(self, content, index=-1): """ Retrieves a list of information retrieved from the sites defined in the xml configuration file. Returns the list of found information from the sites being used as resources or returns None if the site cannot be discovered. Argument(s): content -- string representation of the web site being used as a resource. index -- the integer representing the index of the regex list. Return value(s): list -- information found from a web site being used as a resource. Restriction(s): The Method has no restrictions. """ try: if index == -1: # this is a return for a single instance site repattern = re.compile(self.RegEx, re.IGNORECASE) foundlist = re.findall(repattern, content) return foundlist else: # this is the return for a multisite repattern = re.compile(self.RegEx[index], re.IGNORECASE) foundlist = re.findall(repattern, content) return foundlist except: self.postErrorMessage(self.ErrorMessage + " " + self.FullURL) return None
[ "def", "getContentList", "(", "self", ",", "content", ",", "index", "=", "-", "1", ")", ":", "try", ":", "if", "index", "==", "-", "1", ":", "# this is a return for a single instance site", "repattern", "=", "re", ".", "compile", "(", "self", ".", "RegEx", ",", "re", ".", "IGNORECASE", ")", "foundlist", "=", "re", ".", "findall", "(", "repattern", ",", "content", ")", "return", "foundlist", "else", ":", "# this is the return for a multisite", "repattern", "=", "re", ".", "compile", "(", "self", ".", "RegEx", "[", "index", "]", ",", "re", ".", "IGNORECASE", ")", "foundlist", "=", "re", ".", "findall", "(", "repattern", ",", "content", ")", "return", "foundlist", "except", ":", "self", ".", "postErrorMessage", "(", "self", ".", "ErrorMessage", "+", "\" \"", "+", "self", ".", "FullURL", ")", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L1448-L1477
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.__init__
(self,sitelist)
Class constructor. Stores the incoming list of sites in the _listofsites list. Argument(s): sitelist -- list containing site result information to be printed. Return value(s): Nothing is returned from this Method.
Class constructor. Stores the incoming list of sites in the _listofsites list.
[ "Class", "constructor", ".", "Stores", "the", "incoming", "list", "of", "sites", "in", "the", "_listofsites", "list", "." ]
def __init__(self,sitelist): """ Class constructor. Stores the incoming list of sites in the _listofsites list. Argument(s): sitelist -- list containing site result information to be printed. Return value(s): Nothing is returned from this Method. """ self._listofsites = [] self._listofsites = sitelist
[ "def", "__init__", "(", "self", ",", "sitelist", ")", ":", "self", ".", "_listofsites", "=", "[", "]", "self", ".", "_listofsites", "=", "sitelist" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L37-L48
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.ListOfSites
(self)
return self._listofsites
Checks instance variable _listofsites for content. Returns _listofsites if it has content or None if it does not. Argument(s): No arguments are required. Return value(s): _listofsites -- list containing list of site results if variable contains data. None -- if _listofsites is empty or not assigned. Restriction(s): This Method is tagged as a Property.
Checks instance variable _listofsites for content. Returns _listofsites if it has content or None if it does not.
[ "Checks", "instance", "variable", "_listofsites", "for", "content", ".", "Returns", "_listofsites", "if", "it", "has", "content", "or", "None", "if", "it", "does", "not", "." ]
def ListOfSites(self): """ Checks instance variable _listofsites for content. Returns _listofsites if it has content or None if it does not. Argument(s): No arguments are required. Return value(s): _listofsites -- list containing list of site results if variable contains data. None -- if _listofsites is empty or not assigned. Restriction(s): This Method is tagged as a Property. """ if self._listofsites is None or len(self._listofsites) == 0: return None return self._listofsites
[ "def", "ListOfSites", "(", "self", ")", ":", "if", "self", ".", "_listofsites", "is", "None", "or", "len", "(", "self", ".", "_listofsites", ")", "==", "0", ":", "return", "None", "return", "self", ".", "_listofsites" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L51-L68
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.createOutputInfo
(self,parser)
Checks parser information calls correct print methods based on parser requirements. Returns nothing. Argument(s): parser -- Parser object storing program input parameters used when program was run. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Checks parser information calls correct print methods based on parser requirements. Returns nothing.
[ "Checks", "parser", "information", "calls", "correct", "print", "methods", "based", "on", "parser", "requirements", ".", "Returns", "nothing", "." ]
def createOutputInfo(self,parser): """ Checks parser information calls correct print methods based on parser requirements. Returns nothing. Argument(s): parser -- Parser object storing program input parameters used when program was run. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ self.PrintToScreen(parser.hasBotOut()) if parser.hasCEFOutFile(): self.PrintToCEFFile(parser.CEFOutFile) if parser.hasTextOutFile(): self.PrintToTextFile(parser.TextOutFile) if parser.hasHTMLOutFile(): self.PrintToHTMLFile(parser.HTMLOutFile) if parser.hasCSVOutSet(): self.PrintToCSVFile(parser.CSVOutFile)
[ "def", "createOutputInfo", "(", "self", ",", "parser", ")", ":", "self", ".", "PrintToScreen", "(", "parser", ".", "hasBotOut", "(", ")", ")", "if", "parser", ".", "hasCEFOutFile", "(", ")", ":", "self", ".", "PrintToCEFFile", "(", "parser", ".", "CEFOutFile", ")", "if", "parser", ".", "hasTextOutFile", "(", ")", ":", "self", ".", "PrintToTextFile", "(", "parser", ".", "TextOutFile", ")", "if", "parser", ".", "hasHTMLOutFile", "(", ")", ":", "self", ".", "PrintToHTMLFile", "(", "parser", ".", "HTMLOutFile", ")", "if", "parser", ".", "hasCSVOutSet", "(", ")", ":", "self", ".", "PrintToCSVFile", "(", "parser", ".", "CSVOutFile", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L70-L92
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToScreen
(self, printinbotformat)
Calls correct function to ensure site information is printed to the user's standard output correctly. Returns nothing. Argument(s): printinbotformat -- True or False argument representing minimized output. True if minimized requested. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Calls correct function to ensure site information is printed to the user's standard output correctly. Returns nothing.
[ "Calls", "correct", "function", "to", "ensure", "site", "information", "is", "printed", "to", "the", "user", "s", "standard", "output", "correctly", ".", "Returns", "nothing", "." ]
def PrintToScreen(self, printinbotformat): """ Calls correct function to ensure site information is printed to the user's standard output correctly. Returns nothing. Argument(s): printinbotformat -- True or False argument representing minimized output. True if minimized requested. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ if printinbotformat: self.PrintToScreenBot() else: self.PrintToScreenNormal()
[ "def", "PrintToScreen", "(", "self", ",", "printinbotformat", ")", ":", "if", "printinbotformat", ":", "self", ".", "PrintToScreenBot", "(", ")", "else", ":", "self", ".", "PrintToScreenNormal", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L94-L112
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToScreenBot
(self)
Formats site information minimized and prints it to the user's standard output. Returns nothing. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Formats site information minimized and prints it to the user's standard output. Returns nothing.
[ "Formats", "site", "information", "minimized", "and", "prints", "it", "to", "the", "user", "s", "standard", "output", ".", "Returns", "nothing", "." ]
def PrintToScreenBot(self): """ Formats site information minimized and prints it to the user's standard output. Returns nothing. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = sorted(self.ListOfSites, key=attrgetter('Target')) target = "" if sites is not None: for site in sites: if not isinstance(site._regex,basestring): # this is a multisite for index in range(len(site.RegEx)): # the regexs will ensure we have the exact number of lookups siteimpprop = site.getImportantProperty(index) if target != site.Target: print "\n**_ Results found for: " + site.Target + " _**" target = site.Target # Check for them ALL to be None or 0 length sourceurlhasnoreturn = True for answer in siteimpprop: if answer is not None: if len(answer) > 0: sourceurlhasnoreturn = False if sourceurlhasnoreturn: print '[+] ' + site.SourceURL + ' No results found' break else: if siteimpprop is None or len(siteimpprop) == 0: print "No results in the " + site.FriendlyName[index] + " category" else: if siteimpprop[index] is None or len(siteimpprop[index]) == 0: print site.ReportStringForResult[index] + ' No results found' else: laststring = "" # if it's just a string we don't want it output like a list if isinstance(siteimpprop[index], basestring): if "" + site.ReportStringForResult[index] + " " + str(siteimpprop) != laststring: print "" + site.ReportStringForResult[index] + " " + str(siteimpprop).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult[index] + " " + str(siteimpprop) # must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop[index]: if "" + site.ReportStringForResult[index] + " " + str(siteresult) != laststring: print "" + site.ReportStringForResult[index] + " " + str(siteresult).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult[index] + " " + str(siteresult) else:#this is a singlesite siteimpprop = site.getImportantProperty(0) if target != site.Target: print "\n**_ Results found for: " + site.Target + " _**" target = site.Target if siteimpprop is None or len(siteimpprop)==0: print '[+] ' + site.FriendlyName + ' No results found' else: laststring = "" #if it's just a string we don't want it output like a list if isinstance(siteimpprop, basestring): if "" + site.ReportStringForResult + " " + str(siteimpprop) != laststring: print "" + site.ReportStringForResult + " " + str(siteimpprop).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult + " " + str(siteimpprop) #must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop: if "" + site.ReportStringForResult + " " + str(siteresult) != laststring: print "" + site.ReportStringForResult + " " + str(siteresult).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult + " " + str(siteresult) else: pass
[ "def", "PrintToScreenBot", "(", "self", ")", ":", "sites", "=", "sorted", "(", "self", ".", "ListOfSites", ",", "key", "=", "attrgetter", "(", "'Target'", ")", ")", "target", "=", "\"\"", "if", "sites", "is", "not", "None", ":", "for", "site", "in", "sites", ":", "if", "not", "isinstance", "(", "site", ".", "_regex", ",", "basestring", ")", ":", "# this is a multisite", "for", "index", "in", "range", "(", "len", "(", "site", ".", "RegEx", ")", ")", ":", "# the regexs will ensure we have the exact number of lookups", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "index", ")", "if", "target", "!=", "site", ".", "Target", ":", "print", "\"\\n**_ Results found for: \"", "+", "site", ".", "Target", "+", "\" _**\"", "target", "=", "site", ".", "Target", "# Check for them ALL to be None or 0 length", "sourceurlhasnoreturn", "=", "True", "for", "answer", "in", "siteimpprop", ":", "if", "answer", "is", "not", "None", ":", "if", "len", "(", "answer", ")", ">", "0", ":", "sourceurlhasnoreturn", "=", "False", "if", "sourceurlhasnoreturn", ":", "print", "'[+] '", "+", "site", ".", "SourceURL", "+", "' No results found'", "break", "else", ":", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "print", "\"No results in the \"", "+", "site", ".", "FriendlyName", "[", "index", "]", "+", "\" category\"", "else", ":", "if", "siteimpprop", "[", "index", "]", "is", "None", "or", "len", "(", "siteimpprop", "[", "index", "]", ")", "==", "0", ":", "print", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "' No results found'", "else", ":", "laststring", "=", "\"\"", "# if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", "[", "index", "]", ",", "basestring", ")", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "# must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", "[", "index", "]", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", "else", ":", "#this is a singlesite", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "0", ")", "if", "target", "!=", "site", ".", "Target", ":", "print", "\"\\n**_ Results found for: \"", "+", "site", ".", "Target", "+", "\" _**\"", "target", "=", "site", ".", "Target", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "print", "'[+] '", "+", "site", ".", "FriendlyName", "+", "' No results found'", "else", ":", "laststring", "=", "\"\"", "#if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "#must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", "else", ":", "pass" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L114-L190
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToScreenNormal
(self)
Formats site information correctly and prints it to the user's standard output. Returns nothing. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Formats site information correctly and prints it to the user's standard output. Returns nothing.
[ "Formats", "site", "information", "correctly", "and", "prints", "it", "to", "the", "user", "s", "standard", "output", ".", "Returns", "nothing", "." ]
def PrintToScreenNormal(self): """ Formats site information correctly and prints it to the user's standard output. Returns nothing. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = sorted(self.ListOfSites, key=attrgetter('Target')) target = "" if sites is not None: for site in sites: if not isinstance(site._regex, basestring): # this is a multisite for index in range(len(site.RegEx)): # the regexs will ensure we have the exact number of lookups siteimpprop = site.getImportantProperty(index) if target != site.Target: print "\n____________________ Results found for: " + site.Target + " ____________________" target = site.Target if siteimpprop is None or len(siteimpprop) == 0: print "No results in the " + site.FriendlyName[index] + " category" else: if siteimpprop[index] is None or len(siteimpprop[index]) == 0: print site.ReportStringForResult[index] + ' No results found' else: laststring = "" # if it's just a string we don't want it output like a list if isinstance(siteimpprop[index], basestring): if "" + site.ReportStringForResult[index] + " " + str(siteimpprop) != laststring: print "" + site.ReportStringForResult[index] + " " + str(siteimpprop).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult[index] + " " + str(siteimpprop) # must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop[index]: if "" + site.ReportStringForResult[index] + " " + str(siteresult) != laststring: print "" + site.ReportStringForResult[index] + " " + str(siteresult).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult[index] + " " + str(siteresult) else: # this is a singlesite siteimpprop = site.getImportantProperty(0) if target != site.Target: print "\n____________________ Results found for: " + site.Target + " ____________________" target = site.Target if siteimpprop is None or len(siteimpprop) == 0: print "No results found in the " + site.FriendlyName else: laststring = "" # if it's just a string we don't want it output like a list if isinstance(siteimpprop, basestring): if "" + site.ReportStringForResult + " " + str(siteimpprop) != laststring: print "" + site.ReportStringForResult + " " + str(siteimpprop).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult + " " + str(siteimpprop) # must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop: if "" + site.ReportStringForResult + " " + str(siteresult) != laststring: print "" + site.ReportStringForResult + " " + str(siteresult).replace('www.', 'www[.]').replace('http', 'hxxp') laststring = "" + site.ReportStringForResult + " " + str(siteresult) else: pass
[ "def", "PrintToScreenNormal", "(", "self", ")", ":", "sites", "=", "sorted", "(", "self", ".", "ListOfSites", ",", "key", "=", "attrgetter", "(", "'Target'", ")", ")", "target", "=", "\"\"", "if", "sites", "is", "not", "None", ":", "for", "site", "in", "sites", ":", "if", "not", "isinstance", "(", "site", ".", "_regex", ",", "basestring", ")", ":", "# this is a multisite", "for", "index", "in", "range", "(", "len", "(", "site", ".", "RegEx", ")", ")", ":", "# the regexs will ensure we have the exact number of lookups", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "index", ")", "if", "target", "!=", "site", ".", "Target", ":", "print", "\"\\n____________________ Results found for: \"", "+", "site", ".", "Target", "+", "\" ____________________\"", "target", "=", "site", ".", "Target", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "print", "\"No results in the \"", "+", "site", ".", "FriendlyName", "[", "index", "]", "+", "\" category\"", "else", ":", "if", "siteimpprop", "[", "index", "]", "is", "None", "or", "len", "(", "siteimpprop", "[", "index", "]", ")", "==", "0", ":", "print", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "' No results found'", "else", ":", "laststring", "=", "\"\"", "# if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", "[", "index", "]", ",", "basestring", ")", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "# must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", "[", "index", "]", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", "else", ":", "# this is a singlesite", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "0", ")", "if", "target", "!=", "site", ".", "Target", ":", "print", "\"\\n____________________ Results found for: \"", "+", "site", ".", "Target", "+", "\" ____________________\"", "target", "=", "site", ".", "Target", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "print", "\"No results found in the \"", "+", "site", ".", "FriendlyName", "else", ":", "laststring", "=", "\"\"", "# if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "# must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", "!=", "laststring", ":", "print", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", ".", "replace", "(", "'www.'", ",", "'www[.]'", ")", ".", "replace", "(", "'http'", ",", "'hxxp'", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", "else", ":", "pass" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L192-L257
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToCEFFile
(self,cefoutfile)
Formats site information correctly and prints it to an output file in CEF format. CEF format specification from http://mita-tac.wikispaces.com/file/view/CEF+White+Paper+071709.pdf "Jan 18 11:07:53 host message" where message: "CEF:Version|Device Vendor|Device Product|Device Version|Signature ID|Name|Severity|Extension" Returns nothing. Argument(s): cefoutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Formats site information correctly and prints it to an output file in CEF format. CEF format specification from http://mita-tac.wikispaces.com/file/view/CEF+White+Paper+071709.pdf "Jan 18 11:07:53 host message" where message: "CEF:Version|Device Vendor|Device Product|Device Version|Signature ID|Name|Severity|Extension" Returns nothing.
[ "Formats", "site", "information", "correctly", "and", "prints", "it", "to", "an", "output", "file", "in", "CEF", "format", ".", "CEF", "format", "specification", "from", "http", ":", "//", "mita", "-", "tac", ".", "wikispaces", ".", "com", "/", "file", "/", "view", "/", "CEF", "+", "White", "+", "Paper", "+", "071709", ".", "pdf", "Jan", "18", "11", ":", "07", ":", "53", "host", "message", "where", "message", ":", "CEF", ":", "Version|Device", "Vendor|Device", "Product|Device", "Version|Signature", "ID|Name|Severity|Extension", "Returns", "nothing", "." ]
def PrintToCEFFile(self,cefoutfile): """ Formats site information correctly and prints it to an output file in CEF format. CEF format specification from http://mita-tac.wikispaces.com/file/view/CEF+White+Paper+071709.pdf "Jan 18 11:07:53 host message" where message: "CEF:Version|Device Vendor|Device Product|Device Version|Signature ID|Name|Severity|Extension" Returns nothing. Argument(s): cefoutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = sorted(self.ListOfSites, key=attrgetter('Target')) curr_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') hostname = socket.gethostname() prefix = ' '.join([curr_date,hostname]) cef_version = "CEF:Version1.1" cef_deviceVendor = "TekDefense" cef_deviceProduct = "Automater" cef_deviceVersion = "2.1" cef_SignatureID = "0" cef_Severity = "2" cef_Extension = " " cef_fields = [cef_version,cef_deviceVendor,cef_deviceProduct,cef_deviceVersion, \ cef_SignatureID, cef_Severity, cef_Extension] pattern = "^\[\+\]\s+" target = "" print '\n[+] Generating CEF output: ' + cefoutfile f = open(cefoutfile, "wb") csv.register_dialect('escaped', delimiter='|', escapechar='\\', doublequote=False, quoting=csv.QUOTE_NONE) cefRW = csv.writer(f, 'escaped') # cefRW.writerow(['Target', 'Type', 'Source', 'Result']) if sites is not None: for site in sites: if not isinstance(site._regex,basestring): # this is a multisite: for index in range(len(site.RegEx)): # the regexs will ensure we have the exact number of lookups siteimpprop = site.getImportantProperty(index) if siteimpprop is None or len(siteimpprop)==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = "No results found" cefRW.writerow([prefix] + cef_fields[:5] + \ ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+res])+"] "] + \ [1] + [tgt]) else: if siteimpprop[index] is None or len(siteimpprop[index])==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = "No results found" cefRW.writerow([prefix] + cef_fields[:5] + \ ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+res])+"] "] + \ [1] + [tgt]) else: laststring = "" # if it's just a string we don't want it to output like a list if isinstance(siteimpprop, basestring): tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteimpprop if "" + tgt + typ + source + res != laststring: cefRW.writerow([prefix] + cef_fields[:5] + \ ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+res])+"] " + \ re.sub(pattern,"",site.ReportStringForResult[index])+ str(siteimpprop)] + \ [cef_Severity] + [tgt]) laststring = "" + tgt + typ + source + res # must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop[index]: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = siteresult if "" + tgt + typ + source + str(res) != laststring: cefRW.writerow([prefix] + cef_fields[:5] + ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+str(res)])+"] " + re.sub(pattern, "", site.ReportStringForResult[index]) + str(siteresult)] + [cef_Severity] + [tgt]) laststring = "" + tgt + typ + source + str(res) else: # this is a singlesite siteimpprop = site.getImportantProperty(0) if siteimpprop is None or len(siteimpprop)==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName res = "No results found" cefRW.writerow([prefix] + cef_fields[:5] + \ ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+res])+"] "] + \ [1] + [tgt]) else: laststring = "" # if it's just a string we don't want it output like a list if isinstance(siteimpprop, basestring): tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteimpprop if "" + tgt + typ + source + res != laststring: cefRW.writerow([prefix] + cef_fields[:5] + \ ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+res])+"] " + \ re.sub(pattern,"",site.ReportStringForResult)+ str(siteimpprop)] + \ [cef_Severity] + [tgt]) laststring = "" + tgt + typ + source + res else: laststring = "" for siteresult in siteimpprop: tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteresult if "" + tgt + typ + source + str(res) != laststring: cefRW.writerow([prefix] + cef_fields[:5] + \ ["["+",".join(["tgt="+tgt,"typ="+typ,"src="+source,"res="+str(res)])+"] " + \ re.sub(pattern,"",site.ReportStringForResult)+ str(siteimpprop)] + \ [cef_Severity] + [tgt]) laststring = "" + tgt + typ + source + str(res) f.flush() f.close() print "" + cefoutfile + " Generated"
[ "def", "PrintToCEFFile", "(", "self", ",", "cefoutfile", ")", ":", "sites", "=", "sorted", "(", "self", ".", "ListOfSites", ",", "key", "=", "attrgetter", "(", "'Target'", ")", ")", "curr_date", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y-%m-%d %H:%M:%S'", ")", "hostname", "=", "socket", ".", "gethostname", "(", ")", "prefix", "=", "' '", ".", "join", "(", "[", "curr_date", ",", "hostname", "]", ")", "cef_version", "=", "\"CEF:Version1.1\"", "cef_deviceVendor", "=", "\"TekDefense\"", "cef_deviceProduct", "=", "\"Automater\"", "cef_deviceVersion", "=", "\"2.1\"", "cef_SignatureID", "=", "\"0\"", "cef_Severity", "=", "\"2\"", "cef_Extension", "=", "\" \"", "cef_fields", "=", "[", "cef_version", ",", "cef_deviceVendor", ",", "cef_deviceProduct", ",", "cef_deviceVersion", ",", "cef_SignatureID", ",", "cef_Severity", ",", "cef_Extension", "]", "pattern", "=", "\"^\\[\\+\\]\\s+\"", "target", "=", "\"\"", "print", "'\\n[+] Generating CEF output: '", "+", "cefoutfile", "f", "=", "open", "(", "cefoutfile", ",", "\"wb\"", ")", "csv", ".", "register_dialect", "(", "'escaped'", ",", "delimiter", "=", "'|'", ",", "escapechar", "=", "'\\\\'", ",", "doublequote", "=", "False", ",", "quoting", "=", "csv", ".", "QUOTE_NONE", ")", "cefRW", "=", "csv", ".", "writer", "(", "f", ",", "'escaped'", ")", "# cefRW.writerow(['Target', 'Type', 'Source', 'Result'])", "if", "sites", "is", "not", "None", ":", "for", "site", "in", "sites", ":", "if", "not", "isinstance", "(", "site", ".", "_regex", ",", "basestring", ")", ":", "# this is a multisite:", "for", "index", "in", "range", "(", "len", "(", "site", ".", "RegEx", ")", ")", ":", "# the regexs will ensure we have the exact number of lookups", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "index", ")", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "\"No results found\"", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "res", "]", ")", "+", "\"] \"", "]", "+", "[", "1", "]", "+", "[", "tgt", "]", ")", "else", ":", "if", "siteimpprop", "[", "index", "]", "is", "None", "or", "len", "(", "siteimpprop", "[", "index", "]", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "\"No results found\"", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "res", "]", ")", "+", "\"] \"", "]", "+", "[", "1", "]", "+", "[", "tgt", "]", ")", "else", ":", "laststring", "=", "\"\"", "# if it's just a string we don't want it to output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteimpprop", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "!=", "laststring", ":", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "res", "]", ")", "+", "\"] \"", "+", "re", ".", "sub", "(", "pattern", ",", "\"\"", ",", "site", ".", "ReportStringForResult", "[", "index", "]", ")", "+", "str", "(", "siteimpprop", ")", "]", "+", "[", "cef_Severity", "]", "+", "[", "tgt", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "# must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", "[", "index", "]", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "siteresult", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "!=", "laststring", ":", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "str", "(", "res", ")", "]", ")", "+", "\"] \"", "+", "re", ".", "sub", "(", "pattern", ",", "\"\"", ",", "site", ".", "ReportStringForResult", "[", "index", "]", ")", "+", "str", "(", "siteresult", ")", "]", "+", "[", "cef_Severity", "]", "+", "[", "tgt", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "else", ":", "# this is a singlesite", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "0", ")", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "\"No results found\"", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "res", "]", ")", "+", "\"] \"", "]", "+", "[", "1", "]", "+", "[", "tgt", "]", ")", "else", ":", "laststring", "=", "\"\"", "# if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteimpprop", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "!=", "laststring", ":", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "res", "]", ")", "+", "\"] \"", "+", "re", ".", "sub", "(", "pattern", ",", "\"\"", ",", "site", ".", "ReportStringForResult", ")", "+", "str", "(", "siteimpprop", ")", "]", "+", "[", "cef_Severity", "]", "+", "[", "tgt", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteresult", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "!=", "laststring", ":", "cefRW", ".", "writerow", "(", "[", "prefix", "]", "+", "cef_fields", "[", ":", "5", "]", "+", "[", "\"[\"", "+", "\",\"", ".", "join", "(", "[", "\"tgt=\"", "+", "tgt", ",", "\"typ=\"", "+", "typ", ",", "\"src=\"", "+", "source", ",", "\"res=\"", "+", "str", "(", "res", ")", "]", ")", "+", "\"] \"", "+", "re", ".", "sub", "(", "pattern", ",", "\"\"", ",", "site", ".", "ReportStringForResult", ")", "+", "str", "(", "siteimpprop", ")", "]", "+", "[", "cef_Severity", "]", "+", "[", "tgt", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "f", ".", "flush", "(", ")", "f", ".", "close", "(", ")", "print", "\"\"", "+", "cefoutfile", "+", "\" Generated\"" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L259-L384
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToTextFile
(self,textoutfile)
Formats site information correctly and prints it to an output file in text format. Returns nothing. Argument(s): textoutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Formats site information correctly and prints it to an output file in text format. Returns nothing.
[ "Formats", "site", "information", "correctly", "and", "prints", "it", "to", "an", "output", "file", "in", "text", "format", ".", "Returns", "nothing", "." ]
def PrintToTextFile(self,textoutfile): """ Formats site information correctly and prints it to an output file in text format. Returns nothing. Argument(s): textoutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = sorted(self.ListOfSites, key=attrgetter('Target')) target = "" print "\n[+] Generating text output: " + textoutfile f = open(textoutfile, "w") if sites is not None: for site in sites: if not isinstance(site._regex,basestring): #this is a multisite for index in range(len(site.RegEx)): #the regexs will ensure we have the exact number of lookups siteimpprop = site.getImportantProperty(index) if target != site.Target: f.write("\n____________________ Results found for: " + site.Target + " ____________________") target = site.Target if siteimpprop is None or len(siteimpprop)==0: f.write("\nNo results in the " + site.FriendlyName[index] + " category") else: if siteimpprop[index] is None or len(siteimpprop[index]) == 0: f.write('\n' + site.ReportStringForResult[index] + ' No results found') else: laststring = "" #if it's just a string we don't want it to output like a list if isinstance(siteimpprop[index], basestring): if "" + site.ReportStringForResult[index] + " " + str(siteimpprop) != laststring: f.write("\n" + site.ReportStringForResult[index] + " " + str(siteimpprop)) laststring = "" + site.ReportStringForResult[index] + " " + str(siteimpprop) #must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop[index]: if "" + site.ReportStringForResult[index] + " " + str(siteresult) != laststring: f.write("\n" + site.ReportStringForResult[index] + " " + str(siteresult)) laststring = "" + site.ReportStringForResult[index] + " " + str(siteresult) else:#this is a singlesite siteimpprop = site.getImportantProperty(0) if target != site.Target: f.write("\n____________________ Results found for: " + site.Target + " ____________________") target = site.Target if siteimpprop is None or len(siteimpprop)==0: f.write("\nNo results found in the " + site.FriendlyName) else: laststring = "" #if it's just a string we don't want it output like a list if isinstance(siteimpprop, basestring): if "" + site.ReportStringForResult + " " + str(siteimpprop) != laststring: f.write("\n" + site.ReportStringForResult + " " + str(siteimpprop)) laststring = "" + site.ReportStringForResult + " " + str(siteimpprop) else: laststring = "" for siteresult in siteimpprop: if "" + site.ReportStringForResult + " " + str(siteresult) != laststring: f.write("\n" + site.ReportStringForResult + " " + str(siteresult)) laststring = "" + site.ReportStringForResult + " " + str(siteresult) f.flush() f.close() print "" + textoutfile + " Generated"
[ "def", "PrintToTextFile", "(", "self", ",", "textoutfile", ")", ":", "sites", "=", "sorted", "(", "self", ".", "ListOfSites", ",", "key", "=", "attrgetter", "(", "'Target'", ")", ")", "target", "=", "\"\"", "print", "\"\\n[+] Generating text output: \"", "+", "textoutfile", "f", "=", "open", "(", "textoutfile", ",", "\"w\"", ")", "if", "sites", "is", "not", "None", ":", "for", "site", "in", "sites", ":", "if", "not", "isinstance", "(", "site", ".", "_regex", ",", "basestring", ")", ":", "#this is a multisite", "for", "index", "in", "range", "(", "len", "(", "site", ".", "RegEx", ")", ")", ":", "#the regexs will ensure we have the exact number of lookups", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "index", ")", "if", "target", "!=", "site", ".", "Target", ":", "f", ".", "write", "(", "\"\\n____________________ Results found for: \"", "+", "site", ".", "Target", "+", "\" ____________________\"", ")", "target", "=", "site", ".", "Target", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "f", ".", "write", "(", "\"\\nNo results in the \"", "+", "site", ".", "FriendlyName", "[", "index", "]", "+", "\" category\"", ")", "else", ":", "if", "siteimpprop", "[", "index", "]", "is", "None", "or", "len", "(", "siteimpprop", "[", "index", "]", ")", "==", "0", ":", "f", ".", "write", "(", "'\\n'", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "' No results found'", ")", "else", ":", "laststring", "=", "\"\"", "#if it's just a string we don't want it to output like a list", "if", "isinstance", "(", "siteimpprop", "[", "index", "]", ",", "basestring", ")", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "!=", "laststring", ":", "f", ".", "write", "(", "\"\\n\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "#must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", "[", "index", "]", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", "!=", "laststring", ":", "f", ".", "write", "(", "\"\\n\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "[", "index", "]", "+", "\" \"", "+", "str", "(", "siteresult", ")", "else", ":", "#this is a singlesite", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "0", ")", "if", "target", "!=", "site", ".", "Target", ":", "f", ".", "write", "(", "\"\\n____________________ Results found for: \"", "+", "site", ".", "Target", "+", "\" ____________________\"", ")", "target", "=", "site", ".", "Target", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "f", ".", "write", "(", "\"\\nNo results found in the \"", "+", "site", ".", "FriendlyName", ")", "else", ":", "laststring", "=", "\"\"", "#if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "!=", "laststring", ":", "f", ".", "write", "(", "\"\\n\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteimpprop", ")", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", ":", "if", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", "!=", "laststring", ":", "f", ".", "write", "(", "\"\\n\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", ")", "laststring", "=", "\"\"", "+", "site", ".", "ReportStringForResult", "+", "\" \"", "+", "str", "(", "siteresult", ")", "f", ".", "flush", "(", ")", "f", ".", "close", "(", ")", "print", "\"\"", "+", "textoutfile", "+", "\" Generated\"" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L387-L454
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToCSVFile
(self,csvoutfile)
Formats site information correctly and prints it to an output file with comma-seperators. Returns nothing. Argument(s): csvoutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Formats site information correctly and prints it to an output file with comma-seperators. Returns nothing.
[ "Formats", "site", "information", "correctly", "and", "prints", "it", "to", "an", "output", "file", "with", "comma", "-", "seperators", ".", "Returns", "nothing", "." ]
def PrintToCSVFile(self,csvoutfile): """ Formats site information correctly and prints it to an output file with comma-seperators. Returns nothing. Argument(s): csvoutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = sorted(self.ListOfSites, key=attrgetter('Target')) target = "" print '\n[+] Generating CSV output: ' + csvoutfile f = open(csvoutfile, "wb") csvRW = csv.writer(f, quoting=csv.QUOTE_ALL) csvRW.writerow(['Target', 'Type', 'Source', 'Result']) if sites is not None: for site in sites: if not isinstance(site._regex,basestring): #this is a multisite: for index in range(len(site.RegEx)): #the regexs will ensure we have the exact number of lookups siteimpprop = site.getImportantProperty(index) if siteimpprop is None or len(siteimpprop)==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = "No results found" csvRW.writerow([tgt,typ,source,res]) else: if siteimpprop[index] is None or len(siteimpprop[index])==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = "No results found" csvRW.writerow([tgt,typ,source,res]) else: laststring = "" #if it's just a string we don't want it to output like a list if isinstance(siteimpprop, basestring): tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteimpprop if "" + tgt + typ + source + res != laststring: csvRW.writerow([tgt,typ,source,res]) laststring = "" + tgt + typ + source + res #must be a list since it failed the isinstance check on string else: laststring = "" for siteresult in siteimpprop[index]: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = siteresult if "" + tgt + typ + source + str(res) != laststring: csvRW.writerow([tgt,typ,source,res]) laststring = "" + tgt + typ + source + str(res) else:#this is a singlesite siteimpprop = site.getImportantProperty(0) if siteimpprop is None or len(siteimpprop)==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName res = "No results found" csvRW.writerow([tgt,typ,source,res]) else: laststring = "" #if it's just a string we don't want it output like a list if isinstance(siteimpprop, basestring): tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteimpprop if "" + tgt + typ + source + res != laststring: csvRW.writerow([tgt,typ,source,res]) laststring = "" + tgt + typ + source + res else: laststring = "" for siteresult in siteimpprop: tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteresult if "" + tgt + typ + source + str(res) != laststring: csvRW.writerow([tgt,typ,source,res]) laststring = "" + tgt + typ + source + str(res) f.flush() f.close() print "" + csvoutfile + " Generated"
[ "def", "PrintToCSVFile", "(", "self", ",", "csvoutfile", ")", ":", "sites", "=", "sorted", "(", "self", ".", "ListOfSites", ",", "key", "=", "attrgetter", "(", "'Target'", ")", ")", "target", "=", "\"\"", "print", "'\\n[+] Generating CSV output: '", "+", "csvoutfile", "f", "=", "open", "(", "csvoutfile", ",", "\"wb\"", ")", "csvRW", "=", "csv", ".", "writer", "(", "f", ",", "quoting", "=", "csv", ".", "QUOTE_ALL", ")", "csvRW", ".", "writerow", "(", "[", "'Target'", ",", "'Type'", ",", "'Source'", ",", "'Result'", "]", ")", "if", "sites", "is", "not", "None", ":", "for", "site", "in", "sites", ":", "if", "not", "isinstance", "(", "site", ".", "_regex", ",", "basestring", ")", ":", "#this is a multisite:", "for", "index", "in", "range", "(", "len", "(", "site", ".", "RegEx", ")", ")", ":", "#the regexs will ensure we have the exact number of lookups", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "index", ")", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "\"No results found\"", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "else", ":", "if", "siteimpprop", "[", "index", "]", "is", "None", "or", "len", "(", "siteimpprop", "[", "index", "]", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "\"No results found\"", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "else", ":", "laststring", "=", "\"\"", "#if it's just a string we don't want it to output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteimpprop", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "!=", "laststring", ":", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "#must be a list since it failed the isinstance check on string", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", "[", "index", "]", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "siteresult", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "!=", "laststring", ":", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "else", ":", "#this is a singlesite", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "0", ")", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "\"No results found\"", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "else", ":", "laststring", "=", "\"\"", "#if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteimpprop", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "!=", "laststring", ":", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "res", "else", ":", "laststring", "=", "\"\"", "for", "siteresult", "in", "siteimpprop", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteresult", "if", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "!=", "laststring", ":", "csvRW", ".", "writerow", "(", "[", "tgt", ",", "typ", ",", "source", ",", "res", "]", ")", "laststring", "=", "\"\"", "+", "tgt", "+", "typ", "+", "source", "+", "str", "(", "res", ")", "f", ".", "flush", "(", ")", "f", ".", "close", "(", ")", "print", "\"\"", "+", "csvoutfile", "+", "\" Generated\"" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L456-L548
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.PrintToHTMLFile
(self, htmloutfile)
Formats site information correctly and prints it to an output file using HTML markup. Returns nothing. Argument(s): htmloutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Formats site information correctly and prints it to an output file using HTML markup. Returns nothing.
[ "Formats", "site", "information", "correctly", "and", "prints", "it", "to", "an", "output", "file", "using", "HTML", "markup", ".", "Returns", "nothing", "." ]
def PrintToHTMLFile(self, htmloutfile): """ Formats site information correctly and prints it to an output file using HTML markup. Returns nothing. Argument(s): htmloutfile -- A string representation of a file that will store the output. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = sorted(self.ListOfSites, key=attrgetter('Target')) target = "" print '\n[+] Generating HTML output: ' + htmloutfile f = open(htmloutfile, "w") f.write(self.getHTMLOpening()) if sites is not None: for site in sites: if not isinstance(site._regex,basestring): #this is a multisite: for index in range(len(site.RegEx)): #the regexs will ensure we have the exact number of lookups siteimpprop = site.getImportantProperty(index) if siteimpprop is None or len(siteimpprop)==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = "No results found" tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) else: if siteimpprop[index] is None or len(siteimpprop[index])==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = "No results found" tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) else: # if it's just a string we don't want it to output like a list if isinstance(siteimpprop, basestring): tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteimpprop tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) else: for siteresult in siteimpprop[index]: tgt = site.Target typ = site.TargetType source = site.FriendlyName[index] res = siteresult tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) else: # this is a singlesite siteimpprop = site.getImportantProperty(0) if siteimpprop is None or len(siteimpprop)==0: tgt = site.Target typ = site.TargetType source = site.FriendlyName res = "No results found" tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) else: # if it's just a string we don't want it output like a list if isinstance(siteimpprop, basestring): tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteimpprop tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) else: for siteresult in siteimpprop: tgt = site.Target typ = site.TargetType source = site.FriendlyName res = siteresult tableData = '<tr><td>' + tgt + '</td><td>' + typ + '</td><td>' + source + '</td><td>' + str(res) + '</td></tr>' f.write(tableData) f.write(self.getHTMLClosing()) f.flush() f.close() print "" + htmloutfile + " Generated"
[ "def", "PrintToHTMLFile", "(", "self", ",", "htmloutfile", ")", ":", "sites", "=", "sorted", "(", "self", ".", "ListOfSites", ",", "key", "=", "attrgetter", "(", "'Target'", ")", ")", "target", "=", "\"\"", "print", "'\\n[+] Generating HTML output: '", "+", "htmloutfile", "f", "=", "open", "(", "htmloutfile", ",", "\"w\"", ")", "f", ".", "write", "(", "self", ".", "getHTMLOpening", "(", ")", ")", "if", "sites", "is", "not", "None", ":", "for", "site", "in", "sites", ":", "if", "not", "isinstance", "(", "site", ".", "_regex", ",", "basestring", ")", ":", "#this is a multisite:", "for", "index", "in", "range", "(", "len", "(", "site", ".", "RegEx", ")", ")", ":", "#the regexs will ensure we have the exact number of lookups", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "index", ")", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "\"No results found\"", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "else", ":", "if", "siteimpprop", "[", "index", "]", "is", "None", "or", "len", "(", "siteimpprop", "[", "index", "]", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "\"No results found\"", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "else", ":", "# if it's just a string we don't want it to output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteimpprop", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "else", ":", "for", "siteresult", "in", "siteimpprop", "[", "index", "]", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "[", "index", "]", "res", "=", "siteresult", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "else", ":", "# this is a singlesite", "siteimpprop", "=", "site", ".", "getImportantProperty", "(", "0", ")", "if", "siteimpprop", "is", "None", "or", "len", "(", "siteimpprop", ")", "==", "0", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "\"No results found\"", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "else", ":", "# if it's just a string we don't want it output like a list", "if", "isinstance", "(", "siteimpprop", ",", "basestring", ")", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteimpprop", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "else", ":", "for", "siteresult", "in", "siteimpprop", ":", "tgt", "=", "site", ".", "Target", "typ", "=", "site", ".", "TargetType", "source", "=", "site", ".", "FriendlyName", "res", "=", "siteresult", "tableData", "=", "'<tr><td>'", "+", "tgt", "+", "'</td><td>'", "+", "typ", "+", "'</td><td>'", "+", "source", "+", "'</td><td>'", "+", "str", "(", "res", ")", "+", "'</td></tr>'", "f", ".", "write", "(", "tableData", ")", "f", ".", "write", "(", "self", ".", "getHTMLClosing", "(", ")", ")", "f", ".", "flush", "(", ")", "f", ".", "close", "(", ")", "print", "\"\"", "+", "htmloutfile", "+", "\" Generated\"" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L550-L635
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.getHTMLOpening
(self)
return '''<style type="text/css"> #table-3 { border: 1px solid #DFDFDF; background-color: #F9F9F9; width: 100%; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; font-family: Arial,"Bitstream Vera Sans",Helvetica,Verdana,sans-serif; color: #333; } #table-3 td, #table-3 th { border-top-color: white; border-bottom: 1px solid #DFDFDF; color: #555; } #table-3 th { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: left; line-height: 1.3em; font-size: 14px; } #table-3 td { font-size: 12px; padding: 4px 7px 2px; vertical-align: top; }res h1 { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: Center; line-height: 1.3em; font-size: 40px; } h2 { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: left; line-height: 1.3em; font-size: 16px; } h4 { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: left; line-height: 1.3em; font-size: 10px; } </style> <html> <body> <title> Automater Results </title> <h1> Automater Results </h1> <table id="table-3"> <tr> <th>Target</th> <th>Type</th> <th>Source</th> <th>Result</th> </tr> '''
Creates HTML markup to provide correct formatting for initial HTML file requirements. Returns string that contains opening HTML markup information for HTML output file. Argument(s): No arguments required. Return value(s): string. Restriction(s): The Method has no restrictions.
Creates HTML markup to provide correct formatting for initial HTML file requirements. Returns string that contains opening HTML markup information for HTML output file.
[ "Creates", "HTML", "markup", "to", "provide", "correct", "formatting", "for", "initial", "HTML", "file", "requirements", ".", "Returns", "string", "that", "contains", "opening", "HTML", "markup", "information", "for", "HTML", "output", "file", "." ]
def getHTMLOpening(self): """ Creates HTML markup to provide correct formatting for initial HTML file requirements. Returns string that contains opening HTML markup information for HTML output file. Argument(s): No arguments required. Return value(s): string. Restriction(s): The Method has no restrictions. """ return '''<style type="text/css"> #table-3 { border: 1px solid #DFDFDF; background-color: #F9F9F9; width: 100%; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; font-family: Arial,"Bitstream Vera Sans",Helvetica,Verdana,sans-serif; color: #333; } #table-3 td, #table-3 th { border-top-color: white; border-bottom: 1px solid #DFDFDF; color: #555; } #table-3 th { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: left; line-height: 1.3em; font-size: 14px; } #table-3 td { font-size: 12px; padding: 4px 7px 2px; vertical-align: top; }res h1 { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: Center; line-height: 1.3em; font-size: 40px; } h2 { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: left; line-height: 1.3em; font-size: 16px; } h4 { text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-weight: normal; padding: 7px 7px 8px; text-align: left; line-height: 1.3em; font-size: 10px; } </style> <html> <body> <title> Automater Results </title> <h1> Automater Results </h1> <table id="table-3"> <tr> <th>Target</th> <th>Type</th> <th>Source</th> <th>Result</th> </tr> '''
[ "def", "getHTMLOpening", "(", "self", ")", ":", "return", "'''<style type=\"text/css\">\n #table-3 {\n border: 1px solid #DFDFDF;\n background-color: #F9F9F9;\n width: 100%;\n -moz-border-radius: 3px;\n -webkit-border-radius: 3px;\n border-radius: 3px;\n font-family: Arial,\"Bitstream Vera Sans\",Helvetica,Verdana,sans-serif;\n color: #333;\n }\n #table-3 td, #table-3 th {\n border-top-color: white;\n border-bottom: 1px solid #DFDFDF;\n color: #555;\n }\n #table-3 th {\n text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px;\n font-family: Georgia,\"Times New Roman\",\"Bitstream Charter\",Times,serif;\n font-weight: normal;\n padding: 7px 7px 8px;\n text-align: left;\n line-height: 1.3em;\n font-size: 14px;\n }\n #table-3 td {\n font-size: 12px;\n padding: 4px 7px 2px;\n vertical-align: top;\n }res\n h1 {\n text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px;\n font-family: Georgia,\"Times New Roman\",\"Bitstream Charter\",Times,serif;\n font-weight: normal;\n padding: 7px 7px 8px;\n text-align: Center;\n line-height: 1.3em;\n font-size: 40px;\n }\n h2 {\n text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px;\n font-family: Georgia,\"Times New Roman\",\"Bitstream Charter\",Times,serif;\n font-weight: normal;\n padding: 7px 7px 8px;\n text-align: left;\n line-height: 1.3em;\n font-size: 16px;\n }\n h4 {\n text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px;\n font-family: Georgia,\"Times New Roman\",\"Bitstream Charter\",Times,serif;\n font-weight: normal;\n padding: 7px 7px 8px;\n text-align: left;\n line-height: 1.3em;\n font-size: 10px;\n }\n </style>\n <html>\n <body>\n <title> Automater Results </title>\n <h1> Automater Results </h1>\n <table id=\"table-3\">\n <tr>\n <th>Target</th>\n <th>Type</th>\n <th>Source</th>\n <th>Result</th>\n </tr>\n '''" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L647-L730
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
outputs.py
python
SiteDetailOutput.getHTMLClosing
(self)
return ''' </table> <br> <br> <p>Created using Automater.py by @TekDefense <a href="http://www.tekdefense.com">http://www.tekdefense.com</a>; <a href="https://github.com/1aN0rmus/TekDefense">https://github.com/1aN0rmus/TekDefense</a></p> </body> </html> '''
Creates HTML markup to provide correct formatting for closing HTML file requirements. Returns string that contains closing HTML markup information for HTML output file. Argument(s): No arguments required. Return value(s): string. Restriction(s): The Method has no restrictions.
Creates HTML markup to provide correct formatting for closing HTML file requirements. Returns string that contains closing HTML markup information for HTML output file.
[ "Creates", "HTML", "markup", "to", "provide", "correct", "formatting", "for", "closing", "HTML", "file", "requirements", ".", "Returns", "string", "that", "contains", "closing", "HTML", "markup", "information", "for", "HTML", "output", "file", "." ]
def getHTMLClosing(self): """ Creates HTML markup to provide correct formatting for closing HTML file requirements. Returns string that contains closing HTML markup information for HTML output file. Argument(s): No arguments required. Return value(s): string. Restriction(s): The Method has no restrictions. """ return ''' </table> <br> <br> <p>Created using Automater.py by @TekDefense <a href="http://www.tekdefense.com">http://www.tekdefense.com</a>; <a href="https://github.com/1aN0rmus/TekDefense">https://github.com/1aN0rmus/TekDefense</a></p> </body> </html> '''
[ "def", "getHTMLClosing", "(", "self", ")", ":", "return", "'''\n </table>\n <br>\n <br>\n <p>Created using Automater.py by @TekDefense <a href=\"http://www.tekdefense.com\">http://www.tekdefense.com</a>; <a href=\"https://github.com/1aN0rmus/TekDefense\">https://github.com/1aN0rmus/TekDefense</a></p>\n </body>\n </html>\n '''" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/outputs.py#L732-L753
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
Automater.py
python
main
()
Serves as the instantiation point to start Automater. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions.
Serves as the instantiation point to start Automater.
[ "Serves", "as", "the", "instantiation", "point", "to", "start", "Automater", "." ]
def main(): """ Serves as the instantiation point to start Automater. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Method. Restriction(s): The Method has no restrictions. """ sites = [] parser = Parser('IP, URL, and Hash Passive Analysis tool', __VERSION__) # if no target run and print help if parser.hasNoTarget(): print '[!] No argument given.' parser.print_help() # need to fix this. Will later sys.exit() if parser.VersionCheck: Site.checkmoduleversion(__GITFILEPREFIX__, __GITLOCATION__, parser.Proxy, parser.Verbose) # user may only want to run against one source - allsources # is the seed used to check if the user did not enter an s tag sourcelist = ['allsources'] if parser.hasSource(): sourcelist = parser.Source.split(';') # a file input capability provides a possibility of # multiple lines of targets targetlist = [] if parser.hasInputFile(): for tgtstr in TargetFile.TargetList(parser.InputFile, parser.Verbose): tgtstrstripped = tgtstr.replace('[.]', '.').replace('{.}', '.').replace('(.)', '.') if IPWrapper.isIPorIPList(tgtstrstripped): for targ in IPWrapper.getTarget(tgtstrstripped): targetlist.append(targ) else: targetlist.append(tgtstrstripped) else: # one target or list of range of targets added on console target = parser.Target tgtstrstripped = target.replace('[.]', '.').replace('{.}', '.').replace('(.)', '.') if IPWrapper.isIPorIPList(tgtstrstripped): for targ in IPWrapper.getTarget(tgtstrstripped): targetlist.append(targ) else: targetlist.append(tgtstrstripped) sitefac = SiteFacade(parser.Verbose) sitefac.runSiteAutomation(parser.Delay, parser.Proxy, targetlist, sourcelist, parser.UserAgent, parser.hasBotOut, parser.RefreshRemoteXML, __GITLOCATION__) sites = sitefac.Sites if sites: SiteDetailOutput(sites).createOutputInfo(parser)
[ "def", "main", "(", ")", ":", "sites", "=", "[", "]", "parser", "=", "Parser", "(", "'IP, URL, and Hash Passive Analysis tool'", ",", "__VERSION__", ")", "# if no target run and print help", "if", "parser", ".", "hasNoTarget", "(", ")", ":", "print", "'[!] No argument given.'", "parser", ".", "print_help", "(", ")", "# need to fix this. Will later", "sys", ".", "exit", "(", ")", "if", "parser", ".", "VersionCheck", ":", "Site", ".", "checkmoduleversion", "(", "__GITFILEPREFIX__", ",", "__GITLOCATION__", ",", "parser", ".", "Proxy", ",", "parser", ".", "Verbose", ")", "# user may only want to run against one source - allsources", "# is the seed used to check if the user did not enter an s tag", "sourcelist", "=", "[", "'allsources'", "]", "if", "parser", ".", "hasSource", "(", ")", ":", "sourcelist", "=", "parser", ".", "Source", ".", "split", "(", "';'", ")", "# a file input capability provides a possibility of", "# multiple lines of targets", "targetlist", "=", "[", "]", "if", "parser", ".", "hasInputFile", "(", ")", ":", "for", "tgtstr", "in", "TargetFile", ".", "TargetList", "(", "parser", ".", "InputFile", ",", "parser", ".", "Verbose", ")", ":", "tgtstrstripped", "=", "tgtstr", ".", "replace", "(", "'[.]'", ",", "'.'", ")", ".", "replace", "(", "'{.}'", ",", "'.'", ")", ".", "replace", "(", "'(.)'", ",", "'.'", ")", "if", "IPWrapper", ".", "isIPorIPList", "(", "tgtstrstripped", ")", ":", "for", "targ", "in", "IPWrapper", ".", "getTarget", "(", "tgtstrstripped", ")", ":", "targetlist", ".", "append", "(", "targ", ")", "else", ":", "targetlist", ".", "append", "(", "tgtstrstripped", ")", "else", ":", "# one target or list of range of targets added on console", "target", "=", "parser", ".", "Target", "tgtstrstripped", "=", "target", ".", "replace", "(", "'[.]'", ",", "'.'", ")", ".", "replace", "(", "'{.}'", ",", "'.'", ")", ".", "replace", "(", "'(.)'", ",", "'.'", ")", "if", "IPWrapper", ".", "isIPorIPList", "(", "tgtstrstripped", ")", ":", "for", "targ", "in", "IPWrapper", ".", "getTarget", "(", "tgtstrstripped", ")", ":", "targetlist", ".", "append", "(", "targ", ")", "else", ":", "targetlist", ".", "append", "(", "tgtstrstripped", ")", "sitefac", "=", "SiteFacade", "(", "parser", ".", "Verbose", ")", "sitefac", ".", "runSiteAutomation", "(", "parser", ".", "Delay", ",", "parser", ".", "Proxy", ",", "targetlist", ",", "sourcelist", ",", "parser", ".", "UserAgent", ",", "parser", ".", "hasBotOut", ",", "parser", ".", "RefreshRemoteXML", ",", "__GITLOCATION__", ")", "sites", "=", "sitefac", ".", "Sites", "if", "sites", ":", "SiteDetailOutput", "(", "sites", ")", ".", "createOutputInfo", "(", "parser", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/Automater.py#L49-L106
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
inputs.py
python
TargetFile.TargetList
(self, filename, verbose)
Opens a file for reading. Returns each string from each line of a single or multi-line file. Argument(s): filename -- string based name of the file that will be retrieved and parsed. verbose -- boolean value representing whether output will be printed to stdout Return value(s): Iterator of string(s) found in a single or multi-line file. Restriction(s): This Method is tagged as a Class Method
Opens a file for reading. Returns each string from each line of a single or multi-line file. Argument(s): filename -- string based name of the file that will be retrieved and parsed. verbose -- boolean value representing whether output will be printed to stdout
[ "Opens", "a", "file", "for", "reading", ".", "Returns", "each", "string", "from", "each", "line", "of", "a", "single", "or", "multi", "-", "line", "file", ".", "Argument", "(", "s", ")", ":", "filename", "--", "string", "based", "name", "of", "the", "file", "that", "will", "be", "retrieved", "and", "parsed", ".", "verbose", "--", "boolean", "value", "representing", "whether", "output", "will", "be", "printed", "to", "stdout" ]
def TargetList(self, filename, verbose): """ Opens a file for reading. Returns each string from each line of a single or multi-line file. Argument(s): filename -- string based name of the file that will be retrieved and parsed. verbose -- boolean value representing whether output will be printed to stdout Return value(s): Iterator of string(s) found in a single or multi-line file. Restriction(s): This Method is tagged as a Class Method """ try: target = '' with open(filename) as f: li = f.readlines() for i in li: target = str(i).strip() yield target except IOError: SiteDetailOutput.PrintStandardOutput('There was an error reading from the target input file.', verbose=verbose)
[ "def", "TargetList", "(", "self", ",", "filename", ",", "verbose", ")", ":", "try", ":", "target", "=", "''", "with", "open", "(", "filename", ")", "as", "f", ":", "li", "=", "f", ".", "readlines", "(", ")", "for", "i", "in", "li", ":", "target", "=", "str", "(", "i", ")", ".", "strip", "(", ")", "yield", "target", "except", "IOError", ":", "SiteDetailOutput", ".", "PrintStandardOutput", "(", "'There was an error reading from the target input file.'", ",", "verbose", "=", "verbose", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/inputs.py#L44-L68
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
inputs.py
python
SitesFile.getXMLTree
(cls, filename, verbose)
return None
Opens a config file for reading. Returns XML Elementree object representing XML Config file. Argument(s): No arguments are required. Return value(s): ElementTree Restrictions: File must be named sites.xml and must be in same directory as caller. This Method is tagged as a Class Method
Opens a config file for reading. Returns XML Elementree object representing XML Config file. Argument(s): No arguments are required. Return value(s): ElementTree Restrictions: File must be named sites.xml and must be in same directory as caller. This Method is tagged as a Class Method
[ "Opens", "a", "config", "file", "for", "reading", ".", "Returns", "XML", "Elementree", "object", "representing", "XML", "Config", "file", ".", "Argument", "(", "s", ")", ":", "No", "arguments", "are", "required", ".", "Return", "value", "(", "s", ")", ":", "ElementTree", "Restrictions", ":", "File", "must", "be", "named", "sites", ".", "xml", "and", "must", "be", "in", "same", "directory", "as", "caller", ".", "This", "Method", "is", "tagged", "as", "a", "Class", "Method" ]
def getXMLTree(cls, filename, verbose): """ Opens a config file for reading. Returns XML Elementree object representing XML Config file. Argument(s): No arguments are required. Return value(s): ElementTree Restrictions: File must be named sites.xml and must be in same directory as caller. This Method is tagged as a Class Method """ if SitesFile.fileExists(filename): try: with open(filename) as f: sitetree = ElementTree() sitetree.parse(f) return sitetree except: SiteDetailOutput.PrintStandardOutput('There was an error reading from the {xmlfile} input file.\n' 'Please check that the {xmlfile} file is present and correctly ' 'formatted.'.format(xmlfile=filename), verbose=verbose) else: SiteDetailOutput.PrintStandardOutput('No local {xmlfile} file present.'.format(xmlfile=filename), verbose=verbose) return None
[ "def", "getXMLTree", "(", "cls", ",", "filename", ",", "verbose", ")", ":", "if", "SitesFile", ".", "fileExists", "(", "filename", ")", ":", "try", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "sitetree", "=", "ElementTree", "(", ")", "sitetree", ".", "parse", "(", "f", ")", "return", "sitetree", "except", ":", "SiteDetailOutput", ".", "PrintStandardOutput", "(", "'There was an error reading from the {xmlfile} input file.\\n'", "'Please check that the {xmlfile} file is present and correctly '", "'formatted.'", ".", "format", "(", "xmlfile", "=", "filename", ")", ",", "verbose", "=", "verbose", ")", "else", ":", "SiteDetailOutput", ".", "PrintStandardOutput", "(", "'No local {xmlfile} file present.'", ".", "format", "(", "xmlfile", "=", "filename", ")", ",", "verbose", "=", "verbose", ")", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/inputs.py#L158-L186
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
inputs.py
python
SitesFile.fileExists
(cls, filename)
return os.path.exists(filename) and os.path.isfile(filename)
Checks if a file exists. Returns boolean representing if file exists. Argument(s): No arguments are required. Return value(s): Boolean Restrictions: File must be named sites.xml and must be in same directory as caller. This Method is tagged as a Class Method
Checks if a file exists. Returns boolean representing if file exists. Argument(s): No arguments are required. Return value(s): Boolean Restrictions: File must be named sites.xml and must be in same directory as caller. This Method is tagged as a Class Method
[ "Checks", "if", "a", "file", "exists", ".", "Returns", "boolean", "representing", "if", "file", "exists", ".", "Argument", "(", "s", ")", ":", "No", "arguments", "are", "required", ".", "Return", "value", "(", "s", ")", ":", "Boolean", "Restrictions", ":", "File", "must", "be", "named", "sites", ".", "xml", "and", "must", "be", "in", "same", "directory", "as", "caller", ".", "This", "Method", "is", "tagged", "as", "a", "Class", "Method" ]
def fileExists(cls, filename): """ Checks if a file exists. Returns boolean representing if file exists. Argument(s): No arguments are required. Return value(s): Boolean Restrictions: File must be named sites.xml and must be in same directory as caller. This Method is tagged as a Class Method """ return os.path.exists(filename) and os.path.isfile(filename)
[ "def", "fileExists", "(", "cls", ",", "filename", ")", ":", "return", "os", ".", "path", ".", "exists", "(", "filename", ")", "and", "os", ".", "path", ".", "isfile", "(", "filename", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/inputs.py#L189-L203
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.__init__
(self, desc, version)
Class constructor. Adds the argparse info into the instance variables. Argument(s): desc -- ArgumentParser description. Return value(s): Nothing is returned from this Method.
Class constructor. Adds the argparse info into the instance variables.
[ "Class", "constructor", ".", "Adds", "the", "argparse", "info", "into", "the", "instance", "variables", "." ]
def __init__(self, desc, version): """ Class constructor. Adds the argparse info into the instance variables. Argument(s): desc -- ArgumentParser description. Return value(s): Nothing is returned from this Method. """ # Adding arguments self._parser = argparse.ArgumentParser(description=desc) self._parser.add_argument('target', help='List one IP Address (CIDR or dash notation accepted), URL or Hash to query or pass the filename of a file containing IP Address info, URL or Hash to query each separated by a newline.') self._parser.add_argument('-o', '--output', help='This option will output the results to a file.') self._parser.add_argument('-b', '--bot', action="store_true", help='This option will output minimized results for a bot.') self._parser.add_argument('-f', '--cef', help='This option will output the results to a CEF formatted file.') self._parser.add_argument('-w', '--web', help='This option will output the results to an HTML file.') self._parser.add_argument('-c', '--csv', help='This option will output the results to a CSV file.') self._parser.add_argument('-d', '--delay', type=int, default=2, help='This will change the delay to the inputted seconds. Default is 2.') self._parser.add_argument('-s', '--source', help='This option will only run the target against a specific source engine to pull associated domains. Options are defined in the name attribute of the site element in the XML configuration file. This can be a list of names separated by a semicolon.') self._parser.add_argument('--proxy', help='This option will set a proxy to use (eg. proxy.example.com:8080)') self._parser.add_argument('-a', '--useragent', default='Automater/{version}'.format(version=version), help='This option allows the user to set the user-agent seen by web servers being utilized. By default, the user-agent is set to Automater/version') self._parser.add_argument('-V', '--vercheck', action='store_true', help='This option checks and reports versioning for Automater. Checks each python module in the Automater scope. Default, (no -V) is False') self._parser.add_argument('-r', '--refreshxml', action='store_true', help='This option refreshes the tekdefense.xml file from the remote GitHub site. Default (no -r) is False.') self._parser.add_argument('-v', '--verbose', action='store_true', help='This option prints messages to the screen. Default (no -v) is False.') self.args = self._parser.parse_args()
[ "def", "__init__", "(", "self", ",", "desc", ",", "version", ")", ":", "# Adding arguments", "self", ".", "_parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "desc", ")", "self", ".", "_parser", ".", "add_argument", "(", "'target'", ",", "help", "=", "'List one IP Address (CIDR or dash notation accepted), URL or Hash to query or pass the filename of a file containing IP Address info, URL or Hash to query each separated by a newline.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-o'", ",", "'--output'", ",", "help", "=", "'This option will output the results to a file.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-b'", ",", "'--bot'", ",", "action", "=", "\"store_true\"", ",", "help", "=", "'This option will output minimized results for a bot.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-f'", ",", "'--cef'", ",", "help", "=", "'This option will output the results to a CEF formatted file.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-w'", ",", "'--web'", ",", "help", "=", "'This option will output the results to an HTML file.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-c'", ",", "'--csv'", ",", "help", "=", "'This option will output the results to a CSV file.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-d'", ",", "'--delay'", ",", "type", "=", "int", ",", "default", "=", "2", ",", "help", "=", "'This will change the delay to the inputted seconds. Default is 2.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-s'", ",", "'--source'", ",", "help", "=", "'This option will only run the target against a specific source engine to pull associated domains. Options are defined in the name attribute of the site element in the XML configuration file. This can be a list of names separated by a semicolon.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'--proxy'", ",", "help", "=", "'This option will set a proxy to use (eg. proxy.example.com:8080)'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-a'", ",", "'--useragent'", ",", "default", "=", "'Automater/{version}'", ".", "format", "(", "version", "=", "version", ")", ",", "help", "=", "'This option allows the user to set the user-agent seen by web servers being utilized. By default, the user-agent is set to Automater/version'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-V'", ",", "'--vercheck'", ",", "action", "=", "'store_true'", ",", "help", "=", "'This option checks and reports versioning for Automater. Checks each python module in the Automater scope. Default, (no -V) is False'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-r'", ",", "'--refreshxml'", ",", "action", "=", "'store_true'", ",", "help", "=", "'This option refreshes the tekdefense.xml file from the remote GitHub site. Default (no -r) is False.'", ")", "self", ".", "_parser", ".", "add_argument", "(", "'-v'", ",", "'--verbose'", ",", "action", "=", "'store_true'", ",", "help", "=", "'This option prints messages to the screen. Default (no -v) is False.'", ")", "self", ".", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L55-L80
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasBotOut
(self)
Checks to determine if user requested an output file minimized for use with a Bot. Returns True if user requested minimized Bot output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if user requested an output file minimized for use with a Bot. Returns True if user requested minimized Bot output, False if not.
[ "Checks", "to", "determine", "if", "user", "requested", "an", "output", "file", "minimized", "for", "use", "with", "a", "Bot", ".", "Returns", "True", "if", "user", "requested", "minimized", "Bot", "output", "False", "if", "not", "." ]
def hasBotOut(self): """ Checks to determine if user requested an output file minimized for use with a Bot. Returns True if user requested minimized Bot output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.bot: return True else: return False
[ "def", "hasBotOut", "(", "self", ")", ":", "if", "self", ".", "args", ".", "bot", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L82-L99
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasCEFOutFile
(self)
Checks to determine if user requested an output file formatted in CEF. Returns True if user requested CEF output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if user requested an output file formatted in CEF. Returns True if user requested CEF output, False if not.
[ "Checks", "to", "determine", "if", "user", "requested", "an", "output", "file", "formatted", "in", "CEF", ".", "Returns", "True", "if", "user", "requested", "CEF", "output", "False", "if", "not", "." ]
def hasCEFOutFile(self): """ Checks to determine if user requested an output file formatted in CEF. Returns True if user requested CEF output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.cef: return True else: return False
[ "def", "hasCEFOutFile", "(", "self", ")", ":", "if", "self", ".", "args", ".", "cef", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L101-L118
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.CEFOutFile
(self)
Checks if there is an CEF output requested. Returns string name of CEF output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an output file to write to system. None -- if CEF output was not requested. Restriction(s): This Method is tagged as a Property.
Checks if there is an CEF output requested. Returns string name of CEF output file if requested or None if not requested.
[ "Checks", "if", "there", "is", "an", "CEF", "output", "requested", ".", "Returns", "string", "name", "of", "CEF", "output", "file", "if", "requested", "or", "None", "if", "not", "requested", "." ]
def CEFOutFile(self): """ Checks if there is an CEF output requested. Returns string name of CEF output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an output file to write to system. None -- if CEF output was not requested. Restriction(s): This Method is tagged as a Property. """ if self.hasCEFOutFile(): return self.args.cef else: return None
[ "def", "CEFOutFile", "(", "self", ")", ":", "if", "self", ".", "hasCEFOutFile", "(", ")", ":", "return", "self", ".", "args", ".", "cef", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L121-L140
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasHTMLOutFile
(self)
Checks to determine if user requested an output file formatted in HTML. Returns True if user requested HTML output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if user requested an output file formatted in HTML. Returns True if user requested HTML output, False if not.
[ "Checks", "to", "determine", "if", "user", "requested", "an", "output", "file", "formatted", "in", "HTML", ".", "Returns", "True", "if", "user", "requested", "HTML", "output", "False", "if", "not", "." ]
def hasHTMLOutFile(self): """ Checks to determine if user requested an output file formatted in HTML. Returns True if user requested HTML output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.web: return True else: return False
[ "def", "hasHTMLOutFile", "(", "self", ")", ":", "if", "self", ".", "args", ".", "web", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L142-L159
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.HTMLOutFile
(self)
Checks if there is an HTML output requested. Returns string name of HTML output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an output file to write to system. None -- if web output was not requested. Restriction(s): This Method is tagged as a Property.
Checks if there is an HTML output requested. Returns string name of HTML output file if requested or None if not requested.
[ "Checks", "if", "there", "is", "an", "HTML", "output", "requested", ".", "Returns", "string", "name", "of", "HTML", "output", "file", "if", "requested", "or", "None", "if", "not", "requested", "." ]
def HTMLOutFile(self): """ Checks if there is an HTML output requested. Returns string name of HTML output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an output file to write to system. None -- if web output was not requested. Restriction(s): This Method is tagged as a Property. """ if self.hasHTMLOutFile(): return self.args.web else: return None
[ "def", "HTMLOutFile", "(", "self", ")", ":", "if", "self", ".", "hasHTMLOutFile", "(", ")", ":", "return", "self", ".", "args", ".", "web", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L162-L181
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasTextOutFile
(self)
Checks to determine if user requested an output text file. Returns True if user requested text file output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if user requested an output text file. Returns True if user requested text file output, False if not.
[ "Checks", "to", "determine", "if", "user", "requested", "an", "output", "text", "file", ".", "Returns", "True", "if", "user", "requested", "text", "file", "output", "False", "if", "not", "." ]
def hasTextOutFile(self): """ Checks to determine if user requested an output text file. Returns True if user requested text file output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.output: return True else: return False
[ "def", "hasTextOutFile", "(", "self", ")", ":", "if", "self", ".", "args", ".", "output", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L183-L200
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.TextOutFile
(self)
Checks if there is a text output requested. Returns string name of text output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an output file to write to system. None -- if output file was not requested. Restriction(s): This Method is tagged as a Property.
Checks if there is a text output requested. Returns string name of text output file if requested or None if not requested.
[ "Checks", "if", "there", "is", "a", "text", "output", "requested", ".", "Returns", "string", "name", "of", "text", "output", "file", "if", "requested", "or", "None", "if", "not", "requested", "." ]
def TextOutFile(self): """ Checks if there is a text output requested. Returns string name of text output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an output file to write to system. None -- if output file was not requested. Restriction(s): This Method is tagged as a Property. """ if self.hasTextOutFile(): return self.args.output else: return None
[ "def", "TextOutFile", "(", "self", ")", ":", "if", "self", ".", "hasTextOutFile", "(", ")", ":", "return", "self", ".", "args", ".", "output", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L203-L222
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.versionCheck
(self)
Checks to determine if the user wants the program to check for versioning. By default this is True which means the user wants to check for versions. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if the user wants the program to check for versioning. By default this is True which means the user wants to check for versions.
[ "Checks", "to", "determine", "if", "the", "user", "wants", "the", "program", "to", "check", "for", "versioning", ".", "By", "default", "this", "is", "True", "which", "means", "the", "user", "wants", "to", "check", "for", "versions", "." ]
def versionCheck(self): """ Checks to determine if the user wants the program to check for versioning. By default this is True which means the user wants to check for versions. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.vercheck: return True else: return False
[ "def", "versionCheck", "(", "self", ")", ":", "if", "self", ".", "args", ".", "vercheck", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L224-L241
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.VersionCheck
(self)
return self.versionCheck()
Checks to determine if the user wants the program to check for versioning. By default this is True which means the user wants to check for versions. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if the user wants the program to check for versioning. By default this is True which means the user wants to check for versions.
[ "Checks", "to", "determine", "if", "the", "user", "wants", "the", "program", "to", "check", "for", "versioning", ".", "By", "default", "this", "is", "True", "which", "means", "the", "user", "wants", "to", "check", "for", "versions", "." ]
def VersionCheck(self): """ Checks to determine if the user wants the program to check for versioning. By default this is True which means the user wants to check for versions. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ return self.versionCheck()
[ "def", "VersionCheck", "(", "self", ")", ":", "return", "self", ".", "versionCheck", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L244-L258
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.verbose
(self)
Checks to determine if the user wants the program to send standard output to the screen. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if the user wants the program to send standard output to the screen.
[ "Checks", "to", "determine", "if", "the", "user", "wants", "the", "program", "to", "send", "standard", "output", "to", "the", "screen", "." ]
def verbose(self): """ Checks to determine if the user wants the program to send standard output to the screen. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.verbose: return True else: return False
[ "def", "verbose", "(", "self", ")", ":", "if", "self", ".", "args", ".", "verbose", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L260-L276
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.Verbose
(self)
return self.verbose()
Checks to determine if the user wants the program to send standard output to the screen. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if the user wants the program to send standard output to the screen.
[ "Checks", "to", "determine", "if", "the", "user", "wants", "the", "program", "to", "send", "standard", "output", "to", "the", "screen", "." ]
def Verbose(self): """ Checks to determine if the user wants the program to send standard output to the screen. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ return self.verbose()
[ "def", "Verbose", "(", "self", ")", ":", "return", "self", ".", "verbose", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L279-L292
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.refreshRemoteXML
(self)
Checks to determine if the user wants the program to grab the tekdefense.xml information each run. By default this is True. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if the user wants the program to grab the tekdefense.xml information each run. By default this is True.
[ "Checks", "to", "determine", "if", "the", "user", "wants", "the", "program", "to", "grab", "the", "tekdefense", ".", "xml", "information", "each", "run", ".", "By", "default", "this", "is", "True", "." ]
def refreshRemoteXML(self): """ Checks to determine if the user wants the program to grab the tekdefense.xml information each run. By default this is True. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.refreshxml: return True else: return False
[ "def", "refreshRemoteXML", "(", "self", ")", ":", "if", "self", ".", "args", ".", "refreshxml", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L294-L311
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.RefreshRemoteXML
(self)
return self.refreshRemoteXML()
Checks to determine if the user wants the program to grab the tekdefense.xml information each run. By default this is True. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if the user wants the program to grab the tekdefense.xml information each run. By default this is True.
[ "Checks", "to", "determine", "if", "the", "user", "wants", "the", "program", "to", "grab", "the", "tekdefense", ".", "xml", "information", "each", "run", ".", "By", "default", "this", "is", "True", "." ]
def RefreshRemoteXML(self): """ Checks to determine if the user wants the program to grab the tekdefense.xml information each run. By default this is True. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ return self.refreshRemoteXML()
[ "def", "RefreshRemoteXML", "(", "self", ")", ":", "return", "self", ".", "refreshRemoteXML", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L314-L328
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasCSVOutSet
(self)
Checks to determine if user requested an output file delimited by commas. Returns True if user requested file output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if user requested an output file delimited by commas. Returns True if user requested file output, False if not.
[ "Checks", "to", "determine", "if", "user", "requested", "an", "output", "file", "delimited", "by", "commas", ".", "Returns", "True", "if", "user", "requested", "file", "output", "False", "if", "not", "." ]
def hasCSVOutSet(self): """ Checks to determine if user requested an output file delimited by commas. Returns True if user requested file output, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.csv: return True else: return False
[ "def", "hasCSVOutSet", "(", "self", ")", ":", "if", "self", ".", "args", ".", "csv", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L330-L347
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.CSVOutFile
(self)
Checks if there is a comma delimited output requested. Returns string name of comma delimited output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an comma delimited file to write to system. None -- if comma delimited output was not requested. Restriction(s): This Method is tagged as a Property.
Checks if there is a comma delimited output requested. Returns string name of comma delimited output file if requested or None if not requested.
[ "Checks", "if", "there", "is", "a", "comma", "delimited", "output", "requested", ".", "Returns", "string", "name", "of", "comma", "delimited", "output", "file", "if", "requested", "or", "None", "if", "not", "requested", "." ]
def CSVOutFile(self): """ Checks if there is a comma delimited output requested. Returns string name of comma delimited output file if requested or None if not requested. Argument(s): No arguments are required. Return value(s): string -- Name of an comma delimited file to write to system. None -- if comma delimited output was not requested. Restriction(s): This Method is tagged as a Property. """ if self.hasCSVOutSet(): return self.args.csv else: return None
[ "def", "CSVOutFile", "(", "self", ")", ":", "if", "self", ".", "hasCSVOutSet", "(", ")", ":", "return", "self", ".", "args", ".", "csv", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L350-L369
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.Delay
(self)
return self.args.delay
Returns delay set by input parameters to the program. Argument(s): No arguments are required. Return value(s): string -- String containing integer to tell program how long to delay between each site query. Default delay is 2 seconds. Restriction(s): This Method is tagged as a Property.
Returns delay set by input parameters to the program.
[ "Returns", "delay", "set", "by", "input", "parameters", "to", "the", "program", "." ]
def Delay(self): """ Returns delay set by input parameters to the program. Argument(s): No arguments are required. Return value(s): string -- String containing integer to tell program how long to delay between each site query. Default delay is 2 seconds. Restriction(s): This Method is tagged as a Property. """ return self.args.delay
[ "def", "Delay", "(", "self", ")", ":", "return", "self", ".", "args", ".", "delay" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L372-L386
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasProxy
(self)
Checks to determine if user requested a proxy. Returns True if user requested a proxy, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if user requested a proxy. Returns True if user requested a proxy, False if not.
[ "Checks", "to", "determine", "if", "user", "requested", "a", "proxy", ".", "Returns", "True", "if", "user", "requested", "a", "proxy", "False", "if", "not", "." ]
def hasProxy(self): """ Checks to determine if user requested a proxy. Returns True if user requested a proxy, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.proxy: return True else: return False
[ "def", "hasProxy", "(", "self", ")", ":", "if", "self", ".", "args", ".", "proxy", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L388-L405
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.Proxy
(self)
Returns proxy set by input parameters to the program. Argument(s): No arguments are required. Return value(s): string -- String containing proxy server in format server:port, default is none Restriction(s): This Method is tagged as a Property.
Returns proxy set by input parameters to the program.
[ "Returns", "proxy", "set", "by", "input", "parameters", "to", "the", "program", "." ]
def Proxy(self): """ Returns proxy set by input parameters to the program. Argument(s): No arguments are required. Return value(s): string -- String containing proxy server in format server:port, default is none Restriction(s): This Method is tagged as a Property. """ if self.hasProxy(): return self.args.proxy else: return None
[ "def", "Proxy", "(", "self", ")", ":", "if", "self", ".", "hasProxy", "(", ")", ":", "return", "self", ".", "args", ".", "proxy", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L408-L425
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.print_help
(self)
Returns standard help information to determine usage for program. Argument(s): No arguments are required. Return value(s): string -- Standard argparse help information to show program usage. Restriction(s): This Method has no restrictions.
Returns standard help information to determine usage for program.
[ "Returns", "standard", "help", "information", "to", "determine", "usage", "for", "program", "." ]
def print_help(self): """ Returns standard help information to determine usage for program. Argument(s): No arguments are required. Return value(s): string -- Standard argparse help information to show program usage. Restriction(s): This Method has no restrictions. """ self._parser.print_help()
[ "def", "print_help", "(", "self", ")", ":", "self", ".", "_parser", ".", "print_help", "(", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L427-L440
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasTarget
(self)
Checks to determine if a target was provided to the program. Returns True if a target was provided, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if a target was provided to the program. Returns True if a target was provided, False if not.
[ "Checks", "to", "determine", "if", "a", "target", "was", "provided", "to", "the", "program", ".", "Returns", "True", "if", "a", "target", "was", "provided", "False", "if", "not", "." ]
def hasTarget(self): """ Checks to determine if a target was provided to the program. Returns True if a target was provided, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.target is None: return False else: return True
[ "def", "hasTarget", "(", "self", ")", ":", "if", "self", ".", "args", ".", "target", "is", "None", ":", "return", "False", "else", ":", "return", "True" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L442-L459
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasNoTarget
(self)
return not(self.hasTarget())
Checks to determine if a target was provided to the program. Returns False if a target was provided, True if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if a target was provided to the program. Returns False if a target was provided, True if not.
[ "Checks", "to", "determine", "if", "a", "target", "was", "provided", "to", "the", "program", ".", "Returns", "False", "if", "a", "target", "was", "provided", "True", "if", "not", "." ]
def hasNoTarget(self): """ Checks to determine if a target was provided to the program. Returns False if a target was provided, True if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ return not(self.hasTarget())
[ "def", "hasNoTarget", "(", "self", ")", ":", "return", "not", "(", "self", ".", "hasTarget", "(", ")", ")" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L461-L475
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.Target
(self)
Checks to determine the target info provided to the program. Returns string name of target or string name of file or None if a target is not provided. Argument(s): No arguments are required. Return value(s): string -- String target info or filename based on target parameter to program. Restriction(s): This Method is tagged as a Property.
Checks to determine the target info provided to the program. Returns string name of target or string name of file or None if a target is not provided.
[ "Checks", "to", "determine", "the", "target", "info", "provided", "to", "the", "program", ".", "Returns", "string", "name", "of", "target", "or", "string", "name", "of", "file", "or", "None", "if", "a", "target", "is", "not", "provided", "." ]
def Target(self): """ Checks to determine the target info provided to the program. Returns string name of target or string name of file or None if a target is not provided. Argument(s): No arguments are required. Return value(s): string -- String target info or filename based on target parameter to program. Restriction(s): This Method is tagged as a Property. """ if self.hasNoTarget(): return None else: return self.args.target
[ "def", "Target", "(", "self", ")", ":", "if", "self", ".", "hasNoTarget", "(", ")", ":", "return", "None", "else", ":", "return", "self", ".", "args", ".", "target" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L478-L496
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasInputFile
(self)
Checks to determine if input file is the target of the program. Returns True if a target is an input file, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if input file is the target of the program. Returns True if a target is an input file, False if not.
[ "Checks", "to", "determine", "if", "input", "file", "is", "the", "target", "of", "the", "program", ".", "Returns", "True", "if", "a", "target", "is", "an", "input", "file", "False", "if", "not", "." ]
def hasInputFile(self): """ Checks to determine if input file is the target of the program. Returns True if a target is an input file, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if os.path.exists(self.args.target) and os.path.isfile(self.args.target): return True else: return False
[ "def", "hasInputFile", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "args", ".", "target", ")", "and", "os", ".", "path", ".", "isfile", "(", "self", ".", "args", ".", "target", ")", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L498-L515
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.Source
(self)
Checks to determine if a source parameter was provided to the program. Returns string name of source or None if a source is not provided Argument(s): No arguments are required. Return value(s): string -- String source name based on source parameter to program. None -- If the -s parameter is not used. Restriction(s): This Method is tagged as a Property.
Checks to determine if a source parameter was provided to the program. Returns string name of source or None if a source is not provided
[ "Checks", "to", "determine", "if", "a", "source", "parameter", "was", "provided", "to", "the", "program", ".", "Returns", "string", "name", "of", "source", "or", "None", "if", "a", "source", "is", "not", "provided" ]
def Source(self): """ Checks to determine if a source parameter was provided to the program. Returns string name of source or None if a source is not provided Argument(s): No arguments are required. Return value(s): string -- String source name based on source parameter to program. None -- If the -s parameter is not used. Restriction(s): This Method is tagged as a Property. """ if self.hasSource(): return self.args.source else: return None
[ "def", "Source", "(", "self", ")", ":", "if", "self", ".", "hasSource", "(", ")", ":", "return", "self", ".", "args", ".", "source", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L518-L536
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.hasSource
(self)
Checks to determine if -s parameter and source name was provided to the program. Returns True if source name was provided, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions.
Checks to determine if -s parameter and source name was provided to the program. Returns True if source name was provided, False if not.
[ "Checks", "to", "determine", "if", "-", "s", "parameter", "and", "source", "name", "was", "provided", "to", "the", "program", ".", "Returns", "True", "if", "source", "name", "was", "provided", "False", "if", "not", "." ]
def hasSource(self): """ Checks to determine if -s parameter and source name was provided to the program. Returns True if source name was provided, False if not. Argument(s): No arguments are required. Return value(s): Boolean. Restriction(s): The Method has no restrictions. """ if self.args.source: return True else: return False
[ "def", "hasSource", "(", "self", ")", ":", "if", "self", ".", "args", ".", "source", ":", "return", "True", "else", ":", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L538-L556
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.InputFile
(self)
Checks to determine if an input file string representation of a target was provided as a parameter to the program. Returns string name of file or None if file name is not provided Argument(s): No arguments are required. Return value(s): string -- String file name based on target filename parameter to program. None -- If the target is not a filename. Restriction(s): This Method is tagged as a Property.
Checks to determine if an input file string representation of a target was provided as a parameter to the program. Returns string name of file or None if file name is not provided
[ "Checks", "to", "determine", "if", "an", "input", "file", "string", "representation", "of", "a", "target", "was", "provided", "as", "a", "parameter", "to", "the", "program", ".", "Returns", "string", "name", "of", "file", "or", "None", "if", "file", "name", "is", "not", "provided" ]
def InputFile(self): """ Checks to determine if an input file string representation of a target was provided as a parameter to the program. Returns string name of file or None if file name is not provided Argument(s): No arguments are required. Return value(s): string -- String file name based on target filename parameter to program. None -- If the target is not a filename. Restriction(s): This Method is tagged as a Property. """ if self.hasNoTarget(): return None elif self.hasInputFile(): return self.Target else: return None
[ "def", "InputFile", "(", "self", ")", ":", "if", "self", ".", "hasNoTarget", "(", ")", ":", "return", "None", "elif", "self", ".", "hasInputFile", "(", ")", ":", "return", "self", ".", "Target", "else", ":", "return", "None" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L559-L580
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
Parser.UserAgent
(self)
return self.args.useragent
Returns useragent setting invoked by user at command line or the default user agent provided by the program. Argument(s): No arguments are required. Return value(s): string -- Name utilized as the useragent for the program. Restriction(s): This Method is tagged as a Property.
Returns useragent setting invoked by user at command line or the default user agent provided by the program.
[ "Returns", "useragent", "setting", "invoked", "by", "user", "at", "command", "line", "or", "the", "default", "user", "agent", "provided", "by", "the", "program", "." ]
def UserAgent(self): """ Returns useragent setting invoked by user at command line or the default user agent provided by the program. Argument(s): No arguments are required. Return value(s): string -- Name utilized as the useragent for the program. Restriction(s): This Method is tagged as a Property. """ return self.args.useragent
[ "def", "UserAgent", "(", "self", ")", ":", "return", "self", ".", "args", ".", "useragent" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L583-L597
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
IPWrapper.isIPorIPList
(cls, target)
return False
Checks if an input string is an IP Address or if it is an IP Address in CIDR or dash notation. Returns True if IP Address or CIDR/dash. Returns False if not. Argument(s): target -- string target provided as the first argument to the program. Return value(s): Boolean. Restriction(s): This Method is tagged as a Class Method
Checks if an input string is an IP Address or if it is an IP Address in CIDR or dash notation. Returns True if IP Address or CIDR/dash. Returns False if not.
[ "Checks", "if", "an", "input", "string", "is", "an", "IP", "Address", "or", "if", "it", "is", "an", "IP", "Address", "in", "CIDR", "or", "dash", "notation", ".", "Returns", "True", "if", "IP", "Address", "or", "CIDR", "/", "dash", ".", "Returns", "False", "if", "not", "." ]
def isIPorIPList(cls, target): """ Checks if an input string is an IP Address or if it is an IP Address in CIDR or dash notation. Returns True if IP Address or CIDR/dash. Returns False if not. Argument(s): target -- string target provided as the first argument to the program. Return value(s): Boolean. Restriction(s): This Method is tagged as a Class Method """ # IP Address range using prefix syntax #ipRangePrefix = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}') #ipRgeFind = re.findall(ipRangePrefix, target) #if ipRgeFind is not None or len(ipRgeFind) != 0: # return True ipRangeDash = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}-\d{1,3}') ipRgeDashFind = re.findall(ipRangeDash,target) if ipRgeDashFind is not None or len(ipRgeDashFind) != 0: return True ipAddress = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') ipFind = re.findall(ipAddress, target) if ipFind is not None and len(ipFind) != 0: return True return False
[ "def", "isIPorIPList", "(", "cls", ",", "target", ")", ":", "# IP Address range using prefix syntax", "#ipRangePrefix = re.compile('\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\/\\d{1,2}')", "#ipRgeFind = re.findall(ipRangePrefix, target)", "#if ipRgeFind is not None or len(ipRgeFind) != 0:", "# return True", "ipRangeDash", "=", "re", ".", "compile", "(", "'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}-\\d{1,3}'", ")", "ipRgeDashFind", "=", "re", ".", "findall", "(", "ipRangeDash", ",", "target", ")", "if", "ipRgeDashFind", "is", "not", "None", "or", "len", "(", "ipRgeDashFind", ")", "!=", "0", ":", "return", "True", "ipAddress", "=", "re", ".", "compile", "(", "'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'", ")", "ipFind", "=", "re", ".", "findall", "(", "ipAddress", ",", "target", ")", "if", "ipFind", "is", "not", "None", "and", "len", "(", "ipFind", ")", "!=", "0", ":", "return", "True", "return", "False" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L614-L643
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
utilities.py
python
IPWrapper.getTarget
(cls, target)
Determines whether the target provided is an IP Address or an IP Address in dash notation. Then creates a list that can be utilized as targets by the program. Returns a list of string IP Addresses that can be used as targets. Argument(s): target -- string target provided as the first argument to the program. Return value(s): Iterator of string(s) representing IP Addresses. Restriction(s): This Method is tagged as a Class Method
Determines whether the target provided is an IP Address or an IP Address in dash notation. Then creates a list that can be utilized as targets by the program. Returns a list of string IP Addresses that can be used as targets.
[ "Determines", "whether", "the", "target", "provided", "is", "an", "IP", "Address", "or", "an", "IP", "Address", "in", "dash", "notation", ".", "Then", "creates", "a", "list", "that", "can", "be", "utilized", "as", "targets", "by", "the", "program", ".", "Returns", "a", "list", "of", "string", "IP", "Addresses", "that", "can", "be", "used", "as", "targets", "." ]
def getTarget(cls, target): """ Determines whether the target provided is an IP Address or an IP Address in dash notation. Then creates a list that can be utilized as targets by the program. Returns a list of string IP Addresses that can be used as targets. Argument(s): target -- string target provided as the first argument to the program. Return value(s): Iterator of string(s) representing IP Addresses. Restriction(s): This Method is tagged as a Class Method """ # IP Address range using prefix syntax ipRangeDash = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}-\d{1,3}') ipRgeDashFind = re.findall(ipRangeDash, target) # IP Address range seperated with a dash if ipRgeDashFind is not None and len(ipRgeDashFind) > 0: iplist = target[:target.index("-")].split(".") iplast = target[target.index("-") + 1:] if int(iplist[3]) < int(iplast): for lastoctet in xrange(int(iplist[3]), int(iplast) + 1): yield target[:target.rindex(".") + 1] + str(lastoctet) else: yield target[:target.rindex(".") + 1] + str(iplist[3]) # it's just an IP address at this point else: yield target
[ "def", "getTarget", "(", "cls", ",", "target", ")", ":", "# IP Address range using prefix syntax", "ipRangeDash", "=", "re", ".", "compile", "(", "'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}-\\d{1,3}'", ")", "ipRgeDashFind", "=", "re", ".", "findall", "(", "ipRangeDash", ",", "target", ")", "# IP Address range seperated with a dash", "if", "ipRgeDashFind", "is", "not", "None", "and", "len", "(", "ipRgeDashFind", ")", ">", "0", ":", "iplist", "=", "target", "[", ":", "target", ".", "index", "(", "\"-\"", ")", "]", ".", "split", "(", "\".\"", ")", "iplast", "=", "target", "[", "target", ".", "index", "(", "\"-\"", ")", "+", "1", ":", "]", "if", "int", "(", "iplist", "[", "3", "]", ")", "<", "int", "(", "iplast", ")", ":", "for", "lastoctet", "in", "xrange", "(", "int", "(", "iplist", "[", "3", "]", ")", ",", "int", "(", "iplast", ")", "+", "1", ")", ":", "yield", "target", "[", ":", "target", ".", "rindex", "(", "\".\"", ")", "+", "1", "]", "+", "str", "(", "lastoctet", ")", "else", ":", "yield", "target", "[", ":", "target", ".", "rindex", "(", "\".\"", ")", "+", "1", "]", "+", "str", "(", "iplist", "[", "3", "]", ")", "# it's just an IP address at this point", "else", ":", "yield", "target" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/utilities.py#L646-L676
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler.__init__
(self)
Initializes the Crawl class
Initializes the Crawl class
[ "Initializes", "the", "Crawl", "class" ]
def __init__(self): """ Initializes the Crawl class """ self._config = {} self._links = [] self._start_time = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_config", "=", "{", "}", "self", ".", "_links", "=", "[", "]", "self", ".", "_start_time", "=", "None" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L26-L32
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._request
(self, url)
return response
Sends a POST/GET requests using a random user agent :param url: the url to visit :return: the response Requests object
Sends a POST/GET requests using a random user agent :param url: the url to visit :return: the response Requests object
[ "Sends", "a", "POST", "/", "GET", "requests", "using", "a", "random", "user", "agent", ":", "param", "url", ":", "the", "url", "to", "visit", ":", "return", ":", "the", "response", "Requests", "object" ]
def _request(self, url): """ Sends a POST/GET requests using a random user agent :param url: the url to visit :return: the response Requests object """ random_user_agent = random.choice(self._config["user_agents"]) headers = {'user-agent': random_user_agent} response = requests.get(url, headers=headers, timeout=5) return response
[ "def", "_request", "(", "self", ",", "url", ")", ":", "random_user_agent", "=", "random", ".", "choice", "(", "self", ".", "_config", "[", "\"user_agents\"", "]", ")", "headers", "=", "{", "'user-agent'", ":", "random_user_agent", "}", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "headers", ",", "timeout", "=", "5", ")", "return", "response" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L40-L51
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._normalize_link
(link, root_url)
return link
Normalizes links extracted from the DOM by making them all absolute, so we can request them, for example, turns a "/images" link extracted from https://imgur.com to "https://imgur.com/images" :param link: link found in the DOM :param root_url: the URL the DOM was loaded from :return: absolute link
Normalizes links extracted from the DOM by making them all absolute, so we can request them, for example, turns a "/images" link extracted from https://imgur.com to "https://imgur.com/images" :param link: link found in the DOM :param root_url: the URL the DOM was loaded from :return: absolute link
[ "Normalizes", "links", "extracted", "from", "the", "DOM", "by", "making", "them", "all", "absolute", "so", "we", "can", "request", "them", "for", "example", "turns", "a", "/", "images", "link", "extracted", "from", "https", ":", "//", "imgur", ".", "com", "to", "https", ":", "//", "imgur", ".", "com", "/", "images", ":", "param", "link", ":", "link", "found", "in", "the", "DOM", ":", "param", "root_url", ":", "the", "URL", "the", "DOM", "was", "loaded", "from", ":", "return", ":", "absolute", "link" ]
def _normalize_link(link, root_url): """ Normalizes links extracted from the DOM by making them all absolute, so we can request them, for example, turns a "/images" link extracted from https://imgur.com to "https://imgur.com/images" :param link: link found in the DOM :param root_url: the URL the DOM was loaded from :return: absolute link """ try: parsed_url = urlparse(link) except ValueError: # urlparse can get confused about urls with the ']' # character and thinks it must be a malformed IPv6 URL return None parsed_root_url = urlparse(root_url) # '//' means keep the current protocol used to access this URL if link.startswith("//"): return "{}://{}{}".format(parsed_root_url.scheme, parsed_url.netloc, parsed_url.path) # possibly a relative path if not parsed_url.scheme: return urljoin(root_url, link) return link
[ "def", "_normalize_link", "(", "link", ",", "root_url", ")", ":", "try", ":", "parsed_url", "=", "urlparse", "(", "link", ")", "except", "ValueError", ":", "# urlparse can get confused about urls with the ']'", "# character and thinks it must be a malformed IPv6 URL", "return", "None", "parsed_root_url", "=", "urlparse", "(", "root_url", ")", "# '//' means keep the current protocol used to access this URL", "if", "link", ".", "startswith", "(", "\"//\"", ")", ":", "return", "\"{}://{}{}\"", ".", "format", "(", "parsed_root_url", ".", "scheme", ",", "parsed_url", ".", "netloc", ",", "parsed_url", ".", "path", ")", "# possibly a relative path", "if", "not", "parsed_url", ".", "scheme", ":", "return", "urljoin", "(", "root_url", ",", "link", ")", "return", "link" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L54-L79
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._is_valid_url
(url)
return re.match(regex, url) is not None
Check if a url is a valid url. Used to filter out invalid values that were found in the "href" attribute, for example "javascript:void(0)" taken from https://stackoverflow.com/questions/7160737 :param url: url to be checked :return: boolean indicating whether the URL is valid or not
Check if a url is a valid url. Used to filter out invalid values that were found in the "href" attribute, for example "javascript:void(0)" taken from https://stackoverflow.com/questions/7160737 :param url: url to be checked :return: boolean indicating whether the URL is valid or not
[ "Check", "if", "a", "url", "is", "a", "valid", "url", ".", "Used", "to", "filter", "out", "invalid", "values", "that", "were", "found", "in", "the", "href", "attribute", "for", "example", "javascript", ":", "void", "(", "0", ")", "taken", "from", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "7160737", ":", "param", "url", ":", "url", "to", "be", "checked", ":", "return", ":", "boolean", "indicating", "whether", "the", "URL", "is", "valid", "or", "not" ]
def _is_valid_url(url): """ Check if a url is a valid url. Used to filter out invalid values that were found in the "href" attribute, for example "javascript:void(0)" taken from https://stackoverflow.com/questions/7160737 :param url: url to be checked :return: boolean indicating whether the URL is valid or not """ regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|[/?]\S+)$', re.IGNORECASE) return re.match(regex, url) is not None
[ "def", "_is_valid_url", "(", "url", ")", ":", "regex", "=", "re", ".", "compile", "(", "r'^(?:http|ftp)s?://'", "# http:// or https://", "r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|'", "# domain...", "r'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})'", "# ...or ip", "r'(?::\\d+)?'", "# optional port", "r'(?:/?|[/?]\\S+)$'", ",", "re", ".", "IGNORECASE", ")", "return", "re", ".", "match", "(", "regex", ",", "url", ")", "is", "not", "None" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L82-L97
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._is_blacklisted
(self, url)
return any(blacklisted_url in url for blacklisted_url in self._config["blacklisted_urls"])
Checks is a URL is blacklisted :param url: full URL :return: boolean indicating whether a URL is blacklisted or not
Checks is a URL is blacklisted :param url: full URL :return: boolean indicating whether a URL is blacklisted or not
[ "Checks", "is", "a", "URL", "is", "blacklisted", ":", "param", "url", ":", "full", "URL", ":", "return", ":", "boolean", "indicating", "whether", "a", "URL", "is", "blacklisted", "or", "not" ]
def _is_blacklisted(self, url): """ Checks is a URL is blacklisted :param url: full URL :return: boolean indicating whether a URL is blacklisted or not """ return any(blacklisted_url in url for blacklisted_url in self._config["blacklisted_urls"])
[ "def", "_is_blacklisted", "(", "self", ",", "url", ")", ":", "return", "any", "(", "blacklisted_url", "in", "url", "for", "blacklisted_url", "in", "self", ".", "_config", "[", "\"blacklisted_urls\"", "]", ")" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L99-L105
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._should_accept_url
(self, url)
return url and self._is_valid_url(url) and not self._is_blacklisted(url)
filters url if it is blacklisted or not valid, we put filtering logic here :param url: full url to be checked :return: boolean of whether or not the url should be accepted and potentially visited
filters url if it is blacklisted or not valid, we put filtering logic here :param url: full url to be checked :return: boolean of whether or not the url should be accepted and potentially visited
[ "filters", "url", "if", "it", "is", "blacklisted", "or", "not", "valid", "we", "put", "filtering", "logic", "here", ":", "param", "url", ":", "full", "url", "to", "be", "checked", ":", "return", ":", "boolean", "of", "whether", "or", "not", "the", "url", "should", "be", "accepted", "and", "potentially", "visited" ]
def _should_accept_url(self, url): """ filters url if it is blacklisted or not valid, we put filtering logic here :param url: full url to be checked :return: boolean of whether or not the url should be accepted and potentially visited """ return url and self._is_valid_url(url) and not self._is_blacklisted(url)
[ "def", "_should_accept_url", "(", "self", ",", "url", ")", ":", "return", "url", "and", "self", ".", "_is_valid_url", "(", "url", ")", "and", "not", "self", ".", "_is_blacklisted", "(", "url", ")" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L107-L113
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._extract_urls
(self, body, root_url)
return filtered_urls
gathers links to be visited in the future from a web page's body. does it by finding "href" attributes in the DOM :param body: the HTML body to extract links from :param root_url: the root URL of the given body :return: list of extracted links
gathers links to be visited in the future from a web page's body. does it by finding "href" attributes in the DOM :param body: the HTML body to extract links from :param root_url: the root URL of the given body :return: list of extracted links
[ "gathers", "links", "to", "be", "visited", "in", "the", "future", "from", "a", "web", "page", "s", "body", ".", "does", "it", "by", "finding", "href", "attributes", "in", "the", "DOM", ":", "param", "body", ":", "the", "HTML", "body", "to", "extract", "links", "from", ":", "param", "root_url", ":", "the", "root", "URL", "of", "the", "given", "body", ":", "return", ":", "list", "of", "extracted", "links" ]
def _extract_urls(self, body, root_url): """ gathers links to be visited in the future from a web page's body. does it by finding "href" attributes in the DOM :param body: the HTML body to extract links from :param root_url: the root URL of the given body :return: list of extracted links """ pattern = r"href=[\"'](?!#)(.*?)[\"'].*?" # ignore links starting with #, no point in re-visiting the same page urls = re.findall(pattern, str(body)) normalize_urls = [self._normalize_link(url, root_url) for url in urls] filtered_urls = list(filter(self._should_accept_url, normalize_urls)) return filtered_urls
[ "def", "_extract_urls", "(", "self", ",", "body", ",", "root_url", ")", ":", "pattern", "=", "r\"href=[\\\"'](?!#)(.*?)[\\\"'].*?\"", "# ignore links starting with #, no point in re-visiting the same page", "urls", "=", "re", ".", "findall", "(", "pattern", ",", "str", "(", "body", ")", ")", "normalize_urls", "=", "[", "self", ".", "_normalize_link", "(", "url", ",", "root_url", ")", "for", "url", "in", "urls", "]", "filtered_urls", "=", "list", "(", "filter", "(", "self", ".", "_should_accept_url", ",", "normalize_urls", ")", ")", "return", "filtered_urls" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L115-L129
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._remove_and_blacklist
(self, link)
Removes a link from our current links list and blacklists it so we don't visit it in the future :param link: link to remove and blacklist
Removes a link from our current links list and blacklists it so we don't visit it in the future :param link: link to remove and blacklist
[ "Removes", "a", "link", "from", "our", "current", "links", "list", "and", "blacklists", "it", "so", "we", "don", "t", "visit", "it", "in", "the", "future", ":", "param", "link", ":", "link", "to", "remove", "and", "blacklist" ]
def _remove_and_blacklist(self, link): """ Removes a link from our current links list and blacklists it so we don't visit it in the future :param link: link to remove and blacklist """ self._config['blacklisted_urls'].append(link) del self._links[self._links.index(link)]
[ "def", "_remove_and_blacklist", "(", "self", ",", "link", ")", ":", "self", ".", "_config", "[", "'blacklisted_urls'", "]", ".", "append", "(", "link", ")", "del", "self", ".", "_links", "[", "self", ".", "_links", ".", "index", "(", "link", ")", "]" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L131-L138
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._browse_from_links
(self, depth=0)
Selects a random link out of the available link list and visits it. Blacklists any link that is not responsive or that contains no other links. Please note that this function is recursive and will keep calling itself until a dead end has reached or when we ran out of links :param depth: our current link depth
Selects a random link out of the available link list and visits it. Blacklists any link that is not responsive or that contains no other links. Please note that this function is recursive and will keep calling itself until a dead end has reached or when we ran out of links :param depth: our current link depth
[ "Selects", "a", "random", "link", "out", "of", "the", "available", "link", "list", "and", "visits", "it", ".", "Blacklists", "any", "link", "that", "is", "not", "responsive", "or", "that", "contains", "no", "other", "links", ".", "Please", "note", "that", "this", "function", "is", "recursive", "and", "will", "keep", "calling", "itself", "until", "a", "dead", "end", "has", "reached", "or", "when", "we", "ran", "out", "of", "links", ":", "param", "depth", ":", "our", "current", "link", "depth" ]
def _browse_from_links(self, depth=0): """ Selects a random link out of the available link list and visits it. Blacklists any link that is not responsive or that contains no other links. Please note that this function is recursive and will keep calling itself until a dead end has reached or when we ran out of links :param depth: our current link depth """ is_depth_reached = depth >= self._config['max_depth'] if not len(self._links) or is_depth_reached: logging.debug("Hit a dead end, moving to the next root URL") # escape from the recursion, we don't have links to continue or we have reached the max depth return if self._is_timeout_reached(): raise self.CrawlerTimedOut random_link = random.choice(self._links) try: logging.info("Visiting {}".format(random_link)) sub_page = self._request(random_link).content sub_links = self._extract_urls(sub_page, random_link) # sleep for a random amount of time time.sleep(random.randrange(self._config["min_sleep"], self._config["max_sleep"])) # make sure we have more than 1 link to pick from if len(sub_links) > 1: # extract links from the new page self._links = self._extract_urls(sub_page, random_link) else: # else retry with current link list # remove the dead-end link from our list self._remove_and_blacklist(random_link) except requests.exceptions.RequestException: logging.debug("Exception on URL: %s, removing from list and trying again!" % random_link) self._remove_and_blacklist(random_link) self._browse_from_links(depth + 1)
[ "def", "_browse_from_links", "(", "self", ",", "depth", "=", "0", ")", ":", "is_depth_reached", "=", "depth", ">=", "self", ".", "_config", "[", "'max_depth'", "]", "if", "not", "len", "(", "self", ".", "_links", ")", "or", "is_depth_reached", ":", "logging", ".", "debug", "(", "\"Hit a dead end, moving to the next root URL\"", ")", "# escape from the recursion, we don't have links to continue or we have reached the max depth", "return", "if", "self", ".", "_is_timeout_reached", "(", ")", ":", "raise", "self", ".", "CrawlerTimedOut", "random_link", "=", "random", ".", "choice", "(", "self", ".", "_links", ")", "try", ":", "logging", ".", "info", "(", "\"Visiting {}\"", ".", "format", "(", "random_link", ")", ")", "sub_page", "=", "self", ".", "_request", "(", "random_link", ")", ".", "content", "sub_links", "=", "self", ".", "_extract_urls", "(", "sub_page", ",", "random_link", ")", "# sleep for a random amount of time", "time", ".", "sleep", "(", "random", ".", "randrange", "(", "self", ".", "_config", "[", "\"min_sleep\"", "]", ",", "self", ".", "_config", "[", "\"max_sleep\"", "]", ")", ")", "# make sure we have more than 1 link to pick from", "if", "len", "(", "sub_links", ")", ">", "1", ":", "# extract links from the new page", "self", ".", "_links", "=", "self", ".", "_extract_urls", "(", "sub_page", ",", "random_link", ")", "else", ":", "# else retry with current link list", "# remove the dead-end link from our list", "self", ".", "_remove_and_blacklist", "(", "random_link", ")", "except", "requests", ".", "exceptions", ".", "RequestException", ":", "logging", ".", "debug", "(", "\"Exception on URL: %s, removing from list and trying again!\"", "%", "random_link", ")", "self", ".", "_remove_and_blacklist", "(", "random_link", ")", "self", ".", "_browse_from_links", "(", "depth", "+", "1", ")" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L140-L179
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler.load_config_file
(self, file_path)
Loads and decodes a JSON config file, sets the config of the crawler instance to the loaded one :param file_path: path of the config file :return:
Loads and decodes a JSON config file, sets the config of the crawler instance to the loaded one :param file_path: path of the config file :return:
[ "Loads", "and", "decodes", "a", "JSON", "config", "file", "sets", "the", "config", "of", "the", "crawler", "instance", "to", "the", "loaded", "one", ":", "param", "file_path", ":", "path", "of", "the", "config", "file", ":", "return", ":" ]
def load_config_file(self, file_path): """ Loads and decodes a JSON config file, sets the config of the crawler instance to the loaded one :param file_path: path of the config file :return: """ with open(file_path, 'r') as config_file: config = json.load(config_file) self.set_config(config)
[ "def", "load_config_file", "(", "self", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "config_file", ":", "config", "=", "json", ".", "load", "(", "config_file", ")", "self", ".", "set_config", "(", "config", ")" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L181-L190
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler.set_config
(self, config)
Sets the config of the crawler instance to the provided dict :param config: dict of configuration options, for example: { "root_urls": [], "blacklisted_urls": [], "click_depth": 5 ... }
Sets the config of the crawler instance to the provided dict :param config: dict of configuration options, for example: { "root_urls": [], "blacklisted_urls": [], "click_depth": 5 ... }
[ "Sets", "the", "config", "of", "the", "crawler", "instance", "to", "the", "provided", "dict", ":", "param", "config", ":", "dict", "of", "configuration", "options", "for", "example", ":", "{", "root_urls", ":", "[]", "blacklisted_urls", ":", "[]", "click_depth", ":", "5", "...", "}" ]
def set_config(self, config): """ Sets the config of the crawler instance to the provided dict :param config: dict of configuration options, for example: { "root_urls": [], "blacklisted_urls": [], "click_depth": 5 ... } """ self._config = config
[ "def", "set_config", "(", "self", ",", "config", ")", ":", "self", ".", "_config", "=", "config" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L192-L203
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler.set_option
(self, option, value)
Sets a specific key in the config dict :param option: the option key in the config, for example: "max_depth" :param value: value for the option
Sets a specific key in the config dict :param option: the option key in the config, for example: "max_depth" :param value: value for the option
[ "Sets", "a", "specific", "key", "in", "the", "config", "dict", ":", "param", "option", ":", "the", "option", "key", "in", "the", "config", "for", "example", ":", "max_depth", ":", "param", "value", ":", "value", "for", "the", "option" ]
def set_option(self, option, value): """ Sets a specific key in the config dict :param option: the option key in the config, for example: "max_depth" :param value: value for the option """ self._config[option] = value
[ "def", "set_option", "(", "self", ",", "option", ",", "value", ")", ":", "self", ".", "_config", "[", "option", "]", "=", "value" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L205-L211
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler._is_timeout_reached
(self)
return is_timeout_set and is_timed_out
Determines whether the specified timeout has reached, if no timeout is specified then return false :return: boolean indicating whether the timeout has reached
Determines whether the specified timeout has reached, if no timeout is specified then return false :return: boolean indicating whether the timeout has reached
[ "Determines", "whether", "the", "specified", "timeout", "has", "reached", "if", "no", "timeout", "is", "specified", "then", "return", "false", ":", "return", ":", "boolean", "indicating", "whether", "the", "timeout", "has", "reached" ]
def _is_timeout_reached(self): """ Determines whether the specified timeout has reached, if no timeout is specified then return false :return: boolean indicating whether the timeout has reached """ is_timeout_set = self._config["timeout"] is not False # False is set when no timeout is desired end_time = self._start_time + datetime.timedelta(seconds=self._config["timeout"]) is_timed_out = datetime.datetime.now() >= end_time return is_timeout_set and is_timed_out
[ "def", "_is_timeout_reached", "(", "self", ")", ":", "is_timeout_set", "=", "self", ".", "_config", "[", "\"timeout\"", "]", "is", "not", "False", "# False is set when no timeout is desired", "end_time", "=", "self", ".", "_start_time", "+", "datetime", ".", "timedelta", "(", "seconds", "=", "self", ".", "_config", "[", "\"timeout\"", "]", ")", "is_timed_out", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ">=", "end_time", "return", "is_timeout_set", "and", "is_timed_out" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L213-L223
1tayH/noisy
c21e7682d5626d96d0f6ee56a5ed749078d34aac
noisy.py
python
Crawler.crawl
(self)
Collects links from our root urls, stores them and then calls `_browse_from_links` to browse them
Collects links from our root urls, stores them and then calls `_browse_from_links` to browse them
[ "Collects", "links", "from", "our", "root", "urls", "stores", "them", "and", "then", "calls", "_browse_from_links", "to", "browse", "them" ]
def crawl(self): """ Collects links from our root urls, stores them and then calls `_browse_from_links` to browse them """ self._start_time = datetime.datetime.now() while True: url = random.choice(self._config["root_urls"]) try: body = self._request(url).content self._links = self._extract_urls(body, url) logging.debug("found {} links".format(len(self._links))) self._browse_from_links() except requests.exceptions.RequestException: logging.warn("Error connecting to root url: {}".format(url)) except MemoryError: logging.warn("Error: content at url: {} is exhausting the memory".format(url)) except LocationParseError: logging.warn("Error encountered during parsing of: {}".format(url)) except self.CrawlerTimedOut: logging.info("Timeout has exceeded, exiting") return
[ "def", "crawl", "(", "self", ")", ":", "self", ".", "_start_time", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "while", "True", ":", "url", "=", "random", ".", "choice", "(", "self", ".", "_config", "[", "\"root_urls\"", "]", ")", "try", ":", "body", "=", "self", ".", "_request", "(", "url", ")", ".", "content", "self", ".", "_links", "=", "self", ".", "_extract_urls", "(", "body", ",", "url", ")", "logging", ".", "debug", "(", "\"found {} links\"", ".", "format", "(", "len", "(", "self", ".", "_links", ")", ")", ")", "self", ".", "_browse_from_links", "(", ")", "except", "requests", ".", "exceptions", ".", "RequestException", ":", "logging", ".", "warn", "(", "\"Error connecting to root url: {}\"", ".", "format", "(", "url", ")", ")", "except", "MemoryError", ":", "logging", ".", "warn", "(", "\"Error: content at url: {} is exhausting the memory\"", ".", "format", "(", "url", ")", ")", "except", "LocationParseError", ":", "logging", ".", "warn", "(", "\"Error encountered during parsing of: {}\"", ".", "format", "(", "url", ")", ")", "except", "self", ".", "CrawlerTimedOut", ":", "logging", ".", "info", "(", "\"Timeout has exceeded, exiting\"", ")", "return" ]
https://github.com/1tayH/noisy/blob/c21e7682d5626d96d0f6ee56a5ed749078d34aac/noisy.py#L225-L251
360netlab/DGA
f6e1a197556e9925903b1940d401b02b3650e573
code/shiotob/dga.py
python
get_next_domain
(domain, crc, version)
return domain
calculate the new hostname length max: 255/16 = 15 min: 10
calculate the new hostname length max: 255/16 = 15 min: 10
[ "calculate", "the", "new", "hostname", "length", "max", ":", "255", "/", "16", "=", "15", "min", ":", "10" ]
def get_next_domain(domain, crc, version): qwerty = 'qwertyuiopasdfghjklzxcvbnm123945678' def sum_of_characters(domain): return sum([ord(d) for d in domain[:-3]]) sof = sum_of_characters(domain) if version == 2: sof ^= crc ascii_codes = [ord(d) for d in domain] + 100*[0] old_hostname_length = len(domain) - 4 for i in range(0, 66): for j in range(0, 66): edi = j + i if edi < 65: p = (old_hostname_length * ascii_codes[j]) cl = p ^ ascii_codes[edi] ^ sof ascii_codes[edi] = cl & 0xFF """ calculate the new hostname length max: 255/16 = 15 min: 10 """ cx = ((ascii_codes[2]*old_hostname_length) ^ ascii_codes[0]) & 0xFF hostname_length = int(cx/16) # at most 15 if hostname_length < 10: hostname_length = old_hostname_length """ generate hostname """ for i in range(hostname_length): index = int(ascii_codes[i]/8) # max 31 --> last 3 chars of qwerty unreachable bl = ord(qwerty[index]) ascii_codes[i] = bl hostname = ''.join([chr(a) for a in ascii_codes[:hostname_length]]) """ append .net or .com (alternating) """ tld = '.com' if domain.endswith('.net') else '.net' domain = hostname + tld return domain
[ "def", "get_next_domain", "(", "domain", ",", "crc", ",", "version", ")", ":", "qwerty", "=", "'qwertyuiopasdfghjklzxcvbnm123945678'", "def", "sum_of_characters", "(", "domain", ")", ":", "return", "sum", "(", "[", "ord", "(", "d", ")", "for", "d", "in", "domain", "[", ":", "-", "3", "]", "]", ")", "sof", "=", "sum_of_characters", "(", "domain", ")", "if", "version", "==", "2", ":", "sof", "^=", "crc", "ascii_codes", "=", "[", "ord", "(", "d", ")", "for", "d", "in", "domain", "]", "+", "100", "*", "[", "0", "]", "old_hostname_length", "=", "len", "(", "domain", ")", "-", "4", "for", "i", "in", "range", "(", "0", ",", "66", ")", ":", "for", "j", "in", "range", "(", "0", ",", "66", ")", ":", "edi", "=", "j", "+", "i", "if", "edi", "<", "65", ":", "p", "=", "(", "old_hostname_length", "*", "ascii_codes", "[", "j", "]", ")", "cl", "=", "p", "^", "ascii_codes", "[", "edi", "]", "^", "sof", "ascii_codes", "[", "edi", "]", "=", "cl", "&", "0xFF", "cx", "=", "(", "(", "ascii_codes", "[", "2", "]", "*", "old_hostname_length", ")", "^", "ascii_codes", "[", "0", "]", ")", "&", "0xFF", "hostname_length", "=", "int", "(", "cx", "/", "16", ")", "# at most 15", "if", "hostname_length", "<", "10", ":", "hostname_length", "=", "old_hostname_length", "\"\"\"\n generate hostname\n \"\"\"", "for", "i", "in", "range", "(", "hostname_length", ")", ":", "index", "=", "int", "(", "ascii_codes", "[", "i", "]", "/", "8", ")", "# max 31 --> last 3 chars of qwerty unreachable", "bl", "=", "ord", "(", "qwerty", "[", "index", "]", ")", "ascii_codes", "[", "i", "]", "=", "bl", "hostname", "=", "''", ".", "join", "(", "[", "chr", "(", "a", ")", "for", "a", "in", "ascii_codes", "[", ":", "hostname_length", "]", "]", ")", "\"\"\"\n append .net or .com (alternating)\n \"\"\"", "tld", "=", "'.com'", "if", "domain", ".", "endswith", "(", "'.net'", ")", "else", "'.net'", "domain", "=", "hostname", "+", "tld", "return", "domain" ]
https://github.com/360netlab/DGA/blob/f6e1a197556e9925903b1940d401b02b3650e573/code/shiotob/dga.py#L78-L124
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/globalobject.py
python
masterserviceHandle
(target)
供master调用的接口描述符
供master调用的接口描述符
[ "供master调用的接口描述符" ]
def masterserviceHandle(target): """供master调用的接口描述符 """ GlobalObject().masterremote._reference._service.mapTarget(target)
[ "def", "masterserviceHandle", "(", "target", ")", ":", "GlobalObject", "(", ")", ".", "masterremote", ".", "_reference", ".", "_service", ".", "mapTarget", "(", "target", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/globalobject.py#L36-L39
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/globalobject.py
python
netserviceHandle
(target)
供客户端连接调用的接口描述符
供客户端连接调用的接口描述符
[ "供客户端连接调用的接口描述符" ]
def netserviceHandle(target): """供客户端连接调用的接口描述符 """ GlobalObject().netfactory.service.mapTarget(target)
[ "def", "netserviceHandle", "(", "target", ")", ":", "GlobalObject", "(", ")", ".", "netfactory", ".", "service", ".", "mapTarget", "(", "target", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/globalobject.py#L41-L44
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/globalobject.py
python
rootserviceHandle
(target)
作为root节点,供remote节点调用的接口描述符
作为root节点,供remote节点调用的接口描述符
[ "作为root节点,供remote节点调用的接口描述符" ]
def rootserviceHandle(target): """作为root节点,供remote节点调用的接口描述符 """ GlobalObject().root.service.mapTarget(target)
[ "def", "rootserviceHandle", "(", "target", ")", ":", "GlobalObject", "(", ")", ".", "root", ".", "service", ".", "mapTarget", "(", "target", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/globalobject.py#L46-L49
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/globalobject.py
python
GlobalObject.config
(self,netfactory=None,root = None,remote=None,db=None)
配置存放的对象实例
配置存放的对象实例
[ "配置存放的对象实例" ]
def config(self,netfactory=None,root = None,remote=None,db=None): """配置存放的对象实例 """ self.netfactory = netfactory self.root = root self.remote = remote self.db = db
[ "def", "config", "(", "self", ",", "netfactory", "=", "None", ",", "root", "=", "None", ",", "remote", "=", "None", ",", "db", "=", "None", ")", ":", "self", ".", "netfactory", "=", "netfactory", "self", ".", "root", "=", "root", "self", ".", "remote", "=", "remote", "self", ".", "db", "=", "db" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/globalobject.py#L28-L34
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/globalobject.py
python
webserviceHandle.__init__
(self,url,**kw)
@param url: str http 访问的路径
[]
def __init__(self,url,**kw): """ @param url: str http 访问的路径 """ self._url = url self.kw = kw
[ "def", "__init__", "(", "self", ",", "url", ",", "*", "*", "kw", ")", ":", "self", ".", "_url", "=", "url", "self", ".", "kw", "=", "kw" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/globalobject.py#L55-L60
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/logobj.py
python
loogoo.__init__
(self,logpath)
配置日志路径
配置日志路径
[ "配置日志路径" ]
def __init__(self,logpath): '''配置日志路径 ''' self.file = file(logpath, 'w')
[ "def", "__init__", "(", "self", ",", "logpath", ")", ":", "self", ".", "file", "=", "file", "(", "logpath", ",", "'w'", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/logobj.py#L17-L20
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/logobj.py
python
loogoo.__call__
(self, eventDict)
日志处理
日志处理
[ "日志处理" ]
def __call__(self, eventDict): '''日志处理 ''' if 'logLevel' in eventDict: level = eventDict['logLevel'] elif eventDict['isError']: level = 'ERROR' else: level = 'INFO' text = log.textFromEventDict(eventDict) if text is None or level != 'ERROR': return nowdate = datetime.datetime.now() self.file.write('['+str(nowdate)+']\n'+str(level)+ '\n\t' + text + '\r\n') self.file.flush()
[ "def", "__call__", "(", "self", ",", "eventDict", ")", ":", "if", "'logLevel'", "in", "eventDict", ":", "level", "=", "eventDict", "[", "'logLevel'", "]", "elif", "eventDict", "[", "'isError'", "]", ":", "level", "=", "'ERROR'", "else", ":", "level", "=", "'INFO'", "text", "=", "log", ".", "textFromEventDict", "(", "eventDict", ")", "if", "text", "is", "None", "or", "level", "!=", "'ERROR'", ":", "return", "nowdate", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "self", ".", "file", ".", "write", "(", "'['", "+", "str", "(", "nowdate", ")", "+", "']\\n'", "+", "str", "(", "level", ")", "+", "'\\n\\t'", "+", "text", "+", "'\\r\\n'", ")", "self", ".", "file", ".", "flush", "(", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/logobj.py#L22-L36
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/server.py
python
serverStop
()
return True
停止服务进程
停止服务进程
[ "停止服务进程" ]
def serverStop(): """停止服务进程 """ log.msg('stop') if GlobalObject().stophandler: GlobalObject().stophandler() reactor.callLater(0.5,reactor.stop) return True
[ "def", "serverStop", "(", ")", ":", "log", ".", "msg", "(", "'stop'", ")", "if", "GlobalObject", "(", ")", ".", "stophandler", ":", "GlobalObject", "(", ")", ".", "stophandler", "(", ")", "reactor", ".", "callLater", "(", "0.5", ",", "reactor", ".", "stop", ")", "return", "True" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/server.py#L22-L29
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/server.py
python
FFServer.config
(self, config, servername=None, dbconfig=None, memconfig=None, masterconf=None)
配置服务器
配置服务器
[ "配置服务器" ]
def config(self, config, servername=None, dbconfig=None, memconfig=None, masterconf=None): '''配置服务器 ''' GlobalObject().json_config = config GlobalObject().remote_connect = self.remote_connect netport = config.get('netport')#客户端连接 webport = config.get('webport')#http连接 rootport = config.get('rootport')#root节点配置 self.remoteportlist = config.get('remoteport',[])#remote节点配置列表 if not servername: servername = config.get('name')#服务器名称 logpath = config.get('log')#日志 hasdb = config.get('db')#数据库连接 hasmem = config.get('mem')#memcached连接 app = config.get('app')#入口模块名称 cpuid = config.get('cpu')#绑定cpu mreload = config.get('reload')#重新加载模块名称 self.servername = servername if netport: self.netfactory = LiberateFactory() netservice = services.CommandService("netservice") self.netfactory.addServiceChannel(netservice) reactor.listenTCP(netport,self.netfactory) if webport: self.webroot = Flask("servername") GlobalObject().webroot = self.webroot reactor.listenWSGI(webport, self.webroot) if rootport: self.root = PBRoot() rootservice = services.Service("rootservice") self.root.addServiceChannel(rootservice) reactor.listenTCP(rootport, BilateralFactory(self.root)) for cnf in self.remoteportlist: rname = cnf.get('rootname') self.remote[rname] = RemoteObject(self.servername) if hasdb and dbconfig: if dbconfig.has_key("user") and dbconfig.has_key("host") and dbconfig.has_key("host"): dbpool.initPool({"default":dbconfig}) else: dbpool.initPool(dbconfig) if hasmem and memconfig: urls = memconfig.get('urls') # hostname = str(memconfig.get('hostname')) memcached_connect(urls) from gfirefly.dbentrust.util import M2DB_PORT,M2DB_HOST,ToDBAddress ToDBAddress().setToDBHost(memconfig.get("pubhost",M2DB_HOST)) ToDBAddress().setToDBPort(memconfig.get("pubport",M2DB_PORT)) if logpath: log.addObserver(loogoo(logpath))#日志处理 log.startLogging(sys.stdout) if cpuid: affinity.set_process_affinity_mask(os.getpid(), cpuid) GlobalObject().config(netfactory = self.netfactory, root=self.root, remote = self.remote) if app: __import__(app) if mreload: _path_list = mreload.split(".") GlobalObject().reloadmodule = __import__(mreload,fromlist=_path_list[:1]) if masterconf: masterport = masterconf.get('rootport') masterhost = masterconf.get('roothost') self.master_remote = RemoteObject(servername) GlobalObject().masterremote = self.master_remote import admin addr = ('localhost',masterport) if not masterhost else (masterhost,masterport) self.master_remote.connect(addr)
[ "def", "config", "(", "self", ",", "config", ",", "servername", "=", "None", ",", "dbconfig", "=", "None", ",", "memconfig", "=", "None", ",", "masterconf", "=", "None", ")", ":", "GlobalObject", "(", ")", ".", "json_config", "=", "config", "GlobalObject", "(", ")", ".", "remote_connect", "=", "self", ".", "remote_connect", "netport", "=", "config", ".", "get", "(", "'netport'", ")", "#客户端连接", "webport", "=", "config", ".", "get", "(", "'webport'", ")", "#http连接", "rootport", "=", "config", ".", "get", "(", "'rootport'", ")", "#root节点配置", "self", ".", "remoteportlist", "=", "config", ".", "get", "(", "'remoteport'", ",", "[", "]", ")", "#remote节点配置列表", "if", "not", "servername", ":", "servername", "=", "config", ".", "get", "(", "'name'", ")", "#服务器名称", "logpath", "=", "config", ".", "get", "(", "'log'", ")", "#日志", "hasdb", "=", "config", ".", "get", "(", "'db'", ")", "#数据库连接", "hasmem", "=", "config", ".", "get", "(", "'mem'", ")", "#memcached连接", "app", "=", "config", ".", "get", "(", "'app'", ")", "#入口模块名称", "cpuid", "=", "config", ".", "get", "(", "'cpu'", ")", "#绑定cpu", "mreload", "=", "config", ".", "get", "(", "'reload'", ")", "#重新加载模块名称", "self", ".", "servername", "=", "servername", "if", "netport", ":", "self", ".", "netfactory", "=", "LiberateFactory", "(", ")", "netservice", "=", "services", ".", "CommandService", "(", "\"netservice\"", ")", "self", ".", "netfactory", ".", "addServiceChannel", "(", "netservice", ")", "reactor", ".", "listenTCP", "(", "netport", ",", "self", ".", "netfactory", ")", "if", "webport", ":", "self", ".", "webroot", "=", "Flask", "(", "\"servername\"", ")", "GlobalObject", "(", ")", ".", "webroot", "=", "self", ".", "webroot", "reactor", ".", "listenWSGI", "(", "webport", ",", "self", ".", "webroot", ")", "if", "rootport", ":", "self", ".", "root", "=", "PBRoot", "(", ")", "rootservice", "=", "services", ".", "Service", "(", "\"rootservice\"", ")", "self", ".", "root", ".", "addServiceChannel", "(", "rootservice", ")", "reactor", ".", "listenTCP", "(", "rootport", ",", "BilateralFactory", "(", "self", ".", "root", ")", ")", "for", "cnf", "in", "self", ".", "remoteportlist", ":", "rname", "=", "cnf", ".", "get", "(", "'rootname'", ")", "self", ".", "remote", "[", "rname", "]", "=", "RemoteObject", "(", "self", ".", "servername", ")", "if", "hasdb", "and", "dbconfig", ":", "if", "dbconfig", ".", "has_key", "(", "\"user\"", ")", "and", "dbconfig", ".", "has_key", "(", "\"host\"", ")", "and", "dbconfig", ".", "has_key", "(", "\"host\"", ")", ":", "dbpool", ".", "initPool", "(", "{", "\"default\"", ":", "dbconfig", "}", ")", "else", ":", "dbpool", ".", "initPool", "(", "dbconfig", ")", "if", "hasmem", "and", "memconfig", ":", "urls", "=", "memconfig", ".", "get", "(", "'urls'", ")", "# hostname = str(memconfig.get('hostname'))", "memcached_connect", "(", "urls", ")", "from", "gfirefly", ".", "dbentrust", ".", "util", "import", "M2DB_PORT", ",", "M2DB_HOST", ",", "ToDBAddress", "ToDBAddress", "(", ")", ".", "setToDBHost", "(", "memconfig", ".", "get", "(", "\"pubhost\"", ",", "M2DB_HOST", ")", ")", "ToDBAddress", "(", ")", ".", "setToDBPort", "(", "memconfig", ".", "get", "(", "\"pubport\"", ",", "M2DB_PORT", ")", ")", "if", "logpath", ":", "log", ".", "addObserver", "(", "loogoo", "(", "logpath", ")", ")", "#日志处理", "log", ".", "startLogging", "(", "sys", ".", "stdout", ")", "if", "cpuid", ":", "affinity", ".", "set_process_affinity_mask", "(", "os", ".", "getpid", "(", ")", ",", "cpuid", ")", "GlobalObject", "(", ")", ".", "config", "(", "netfactory", "=", "self", ".", "netfactory", ",", "root", "=", "self", ".", "root", ",", "remote", "=", "self", ".", "remote", ")", "if", "app", ":", "__import__", "(", "app", ")", "if", "mreload", ":", "_path_list", "=", "mreload", ".", "split", "(", "\".\"", ")", "GlobalObject", "(", ")", ".", "reloadmodule", "=", "__import__", "(", "mreload", ",", "fromlist", "=", "_path_list", "[", ":", "1", "]", ")", "if", "masterconf", ":", "masterport", "=", "masterconf", ".", "get", "(", "'rootport'", ")", "masterhost", "=", "masterconf", ".", "get", "(", "'roothost'", ")", "self", ".", "master_remote", "=", "RemoteObject", "(", "servername", ")", "GlobalObject", "(", ")", ".", "masterremote", "=", "self", ".", "master_remote", "import", "admin", "addr", "=", "(", "'localhost'", ",", "masterport", ")", "if", "not", "masterhost", "else", "(", "masterhost", ",", "masterport", ")", "self", ".", "master_remote", ".", "connect", "(", "addr", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/server.py#L48-L125
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/server.py
python
FFServer.remote_connect
(self, rname, rhost)
进行rpc的连接
进行rpc的连接
[ "进行rpc的连接" ]
def remote_connect(self, rname, rhost): """进行rpc的连接 """ for cnf in self.remoteportlist: _rname = cnf.get('rootname') if rname == _rname: rport = cnf.get('rootport') if not rhost: addr = ('localhost',rport) else: addr = (rhost,rport) self.remote[rname].connect(addr) break
[ "def", "remote_connect", "(", "self", ",", "rname", ",", "rhost", ")", ":", "for", "cnf", "in", "self", ".", "remoteportlist", ":", "_rname", "=", "cnf", ".", "get", "(", "'rootname'", ")", "if", "rname", "==", "_rname", ":", "rport", "=", "cnf", ".", "get", "(", "'rootport'", ")", "if", "not", "rhost", ":", "addr", "=", "(", "'localhost'", ",", "rport", ")", "else", ":", "addr", "=", "(", "rhost", ",", "rport", ")", "self", ".", "remote", "[", "rname", "]", ".", "connect", "(", "addr", ")", "break" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/server.py#L127-L139
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/server.py
python
FFServer.start
(self)
启动服务器
启动服务器
[ "启动服务器" ]
def start(self): '''启动服务器 ''' log.msg('[%s] started...'%self.servername) log.msg('[%s] pid: %s'%(self.servername,os.getpid())) reactor.run()
[ "def", "start", "(", "self", ")", ":", "log", ".", "msg", "(", "'[%s] started...'", "%", "self", ".", "servername", ")", "log", ".", "msg", "(", "'[%s] pid: %s'", "%", "(", "self", ".", "servername", ",", "os", ".", "getpid", "(", ")", ")", ")", "reactor", ".", "run", "(", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/server.py#L141-L146
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/admin.py
python
serverStop
()
return True
供master调用的接口:关闭服务器
供master调用的接口:关闭服务器
[ "供master调用的接口:关闭服务器" ]
def serverStop(): """供master调用的接口:关闭服务器 """ log.msg('stop') if GlobalObject().stophandler: GlobalObject().stophandler() reactor.callLater(0.5,reactor.stop) return True
[ "def", "serverStop", "(", ")", ":", "log", ".", "msg", "(", "'stop'", ")", "if", "GlobalObject", "(", ")", ".", "stophandler", ":", "GlobalObject", "(", ")", ".", "stophandler", "(", ")", "reactor", ".", "callLater", "(", "0.5", ",", "reactor", ".", "stop", ")", "return", "True" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/admin.py#L15-L22
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/admin.py
python
sreload
()
return True
供master调用的接口:热更新模块
供master调用的接口:热更新模块
[ "供master调用的接口:热更新模块" ]
def sreload(): """供master调用的接口:热更新模块 """ log.msg('reload') if GlobalObject().reloadmodule: reload(GlobalObject().reloadmodule) return True
[ "def", "sreload", "(", ")", ":", "log", ".", "msg", "(", "'reload'", ")", "if", "GlobalObject", "(", ")", ".", "reloadmodule", ":", "reload", "(", "GlobalObject", "(", ")", ".", "reloadmodule", ")", "return", "True" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/admin.py#L25-L31
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/server/admin.py
python
remote_connect
(rname, rhost)
供master调用的接口:进行远程的rpc连接
供master调用的接口:进行远程的rpc连接
[ "供master调用的接口:进行远程的rpc连接" ]
def remote_connect(rname, rhost): """供master调用的接口:进行远程的rpc连接 """ GlobalObject().remote_connect(rname, rhost)
[ "def", "remote_connect", "(", "rname", ",", "rhost", ")", ":", "GlobalObject", "(", ")", ".", "remote_connect", "(", "rname", ",", "rhost", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/server/admin.py#L34-L37
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/utils/interfaces.py
python
IDataPackProtoc.getHeadlength
()
获取数据包的长度
获取数据包的长度
[ "获取数据包的长度" ]
def getHeadlength(): """获取数据包的长度 """ pass
[ "def", "getHeadlength", "(", ")", ":", "pass" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/utils/interfaces.py#L13-L16
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/utils/interfaces.py
python
IDataPackProtoc.unpack
()
解包
解包
[ "解包" ]
def unpack(): '''解包 '''
[ "def", "unpack", "(", ")", ":" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/utils/interfaces.py#L18-L20
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/utils/interfaces.py
python
IDataPackProtoc.pack
()
打包数据包
打包数据包
[ "打包数据包" ]
def pack(): '''打包数据包 '''
[ "def", "pack", "(", ")", ":" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/utils/interfaces.py#L22-L24
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/utils/services.py
python
Service.addUnDisplayTarget
(self,command)
Add a target unDisplay when client call it.
Add a target unDisplay when client call it.
[ "Add", "a", "target", "unDisplay", "when", "client", "call", "it", "." ]
def addUnDisplayTarget(self,command): '''Add a target unDisplay when client call it.''' self.unDisplay.add(command)
[ "def", "addUnDisplayTarget", "(", "self", ",", "command", ")", ":", "self", ".", "unDisplay", ".", "add", "(", "command", ")" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/utils/services.py#L27-L29
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/utils/services.py
python
Service.mapTarget
(self, target)
Add a target to the service.
Add a target to the service.
[ "Add", "a", "target", "to", "the", "service", "." ]
def mapTarget(self, target): """Add a target to the service.""" key = target.__name__ if self._targets.has_key(key): exist_target = self._targets.get(key) raise "target [%d] Already exists,\ Conflict between the %s and %s"%(key,exist_target.__name__,target.__name__) self._targets[key] = target
[ "def", "mapTarget", "(", "self", ",", "target", ")", ":", "key", "=", "target", ".", "__name__", "if", "self", ".", "_targets", ".", "has_key", "(", "key", ")", ":", "exist_target", "=", "self", ".", "_targets", ".", "get", "(", "key", ")", "raise", "\"target [%d] Already exists,\\\n Conflict between the %s and %s\"", "%", "(", "key", ",", "exist_target", ".", "__name__", ",", "target", ".", "__name__", ")", "self", ".", "_targets", "[", "key", "]", "=", "target" ]
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/utils/services.py#L31-L38