Ejemplo n.º 1
0
 def __init__(self):
     self.isLeaf = False
     sitefac = SiteFacade()
     Resource.__init__(self)
     for site in sitefac.available_sites():
         #print site
         self.putChild(site, AutomaterRouter(site))
     self.putChild("allsources", AutomaterRouter("allsources"))
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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')

    # 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()

    # 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
    source = "allsources"
    if parser.hasSource():
        source = parser.Source

    # a file input capability provides a possibility of
    # multiple lines of targets
    targetlist = []
    if parser.hasInputFile():
        for tgtstr in TargetFile.TargetList(parser.InputFile):
            if IPWrapper.isIPorIPList(tgtstr):
                for targ in IPWrapper.getTarget(tgtstr):
                    targetlist.append(targ)
            else:
                targetlist.append(tgtstr)
    else:  # one target or list of range of targets added on console
        target = parser.Target
        if IPWrapper.isIPorIPList(target):
            for targ in IPWrapper.getTarget(target):
                targetlist.append(targ)
        else:
            targetlist.append(target)

    sitefac = SiteFacade()
    sitefac.runSiteAutomation(parser.Delay,
                              targetlist,
                              source,
                              parser.hasPost())
    sites = sitefac.Sites
    if sites is not None:
        SiteDetailOutput(sites).createOutputInfo(parser)
Ejemplo n.º 5
0
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')

    # 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()

    # 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
    source = "allsources"
    if parser.hasSource():
        source = parser.Source

    # a file input capability provides a possibility of
    # multiple lines of targets
    targetlist = []
    if parser.hasInputFile():
        for tgtstr in TargetFile.TargetList(parser.InputFile):
            if IPWrapper.isIPorIPList(tgtstr):
                for targ in IPWrapper.getTarget(tgtstr):
                    targetlist.append(targ)
            else:
                targetlist.append(tgtstr)
    else:  # one target or list of range of targets added on console
        target = parser.Target
        if IPWrapper.isIPorIPList(target):
            for targ in IPWrapper.getTarget(target):
                targetlist.append(targ)
        else:
            targetlist.append(target)

    sitefac = SiteFacade()
    sitefac.runSiteAutomation(parser.Delay, targetlist, source,
                              parser.hasPost())
    sites = sitefac.Sites
    if sites is not None:
        SiteDetailOutput(sites).createOutputInfo(parser)
Ejemplo n.º 6
0
def run_automater(cmd,targets):
    """
    Runs Automator on list of target strings
    and returns results as json encoded string object.
    """
    targetlist = targets
    source = cmd #"allsources"
    sitefac = SiteFacade()
    try:
        sitefac.runSiteAutomation(1,None,
                              targetlist,
                              source,
                              False,"Automater/2.1",quiet=True)
        sites = sitefac.Sites
        if sites is not None:
            out = SiteDetailOutput(sites)
            return out.jsonOutput()
        return None
            # If you just want results as string just return output.getvalue()
    except Exception as e:
        print e.message
        return None
Ejemplo n.º 7
0
 def run_automater(self):
   """
   Runs Automator on list of target strings
   and returns results as json encoded string object.
   """
   targetlist = self.target
   sitefac = SiteFacade()
   #print targetlist
   #print self.site
   try:
       sitefac.runSiteAutomation(1,None,
                                 [targetlist],
                                 self.site,
                                 False,"Automater/2.1", quiet=False) 
       sites = sitefac.Sites
       if sites is not None:
           out = SiteDetailOutput(sites)
           return out.jsonOutput()
       else:
           return "{}"
   except Exception as e:
       print e.message
       return None
Ejemplo n.º 8
0
    def post(self, cible):
        """
        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.
        """

        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        __VERSION__ = '0.21'
        __GITLOCATION__ = 'https://github.com/1aN0rmus/TekDefense-Automater'
        __GITFILEPREFIX__ = 'https://raw.githubusercontent.com/1aN0rmus/TekDefense-Automater/master/'

        sites = []
        parser = Parser('IP, URL, and Hash Passive Analysis tool', __VERSION__,
                        cible)

        # 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

            target = cible
            #print("---------------------------------------------------------------------------------------------")
            #print(target)

            tgtstrstripped = target.replace('[.]', '.').replace('{.}',
                                                                '.').replace(
                                                                    '(.)', '.')
            if IPWrapper.isIPorIPList(tgtstrstripped):
                for targ in IPWrapper.getTarget(tgtstrstripped):
                    targetlist.append(targ)
            else:
                targetlist.append(tgtstrstripped)
        #print(targetlist)
        sitefac = SiteFacade(parser.Verbose)
        sitefac.runSiteAutomation(parser.Delay, parser.Proxy, targetlist,
                                  sourcelist, parser.UserAgent,
                                  parser.hasBotOut, parser.RefreshRemoteXML,
                                  __GITLOCATION__)
        sites = sitefac.Sites
        if sites:
            resultTemp = SiteDetailOutput(sites).createOutputInfo(parser)
            #print("---------------------------------------------------------------------------------------------")
            #print(sites)
            #print("---------------------------------------------------------------------------------------------")

            #-------------------PARSE RESULT--------------------------------------
            tabTemp = resultTemp.split("\n")

            result = {}
            for i in range(len(tabTemp)):

                tabTemp[i] = tabTemp[i].replace("[+]", "")
                tabTemp[i] = tabTemp[i].strip()
                if (":" in tabTemp[i]):
                    tab = tabTemp[i].split(":", 1)
                    if (i == 1):
                        result["target"] = tab[1].replace(
                            "____________________", " ").strip()
                    elif (tab[0] in result):

                        result[tab[0]] = result[tab[0]] + " " + tab[1]
                    else:
                        result[tab[0]] = tab[1]

            results.append(result)
            #print(results)

        return result, 201
Ejemplo n.º 9
0
    def GetResults(self, Target):
        targetlist = []
        resultList = []
        for tgt in Target:
            tgt = tgt.replace('[.]', '.').replace('{.}', '.').replace('(.)', '.')
            if IPWrapper.isIPorIPList(tgt):
                for targ in IPWrapper.getTarget(tgt):
                    targetlist.append(targ)
            else:
                targetlist.append(tgt)

        sitefac = SiteFacade(self.Verbose)
        sitefac.runSiteAutomation(self.Delay, self.Proxy, Target, self.sourcelist, self.UserAgent, self.hasBotOut,
                                  self.RefreshRemoteXML, __GITLOCATION__)

        sites = sorted(sitefac.Sites, key=attrgetter('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 siteimpprop is None or len(siteimpprop)==0:
                            continue
                        else:
                            if siteimpprop[index] is None or len(siteimpprop[index])==0:
                                continue
                            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:
                                        resultList.append([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:
                                            resultList.append([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:
                        continue
                    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:
                                resultList.append([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:
                                    resultList.append([tgt,typ,source,res])
                                    laststring = "" + tgt + typ + source + str(res)
        return resultList