def load_session(self, global_vars):

        self.session = pickle.load(
            open(config.SESSIONS_DIR + global_vars['session_name'], "rb"))
        self.session["opt"] = "load"
        #print session

        ##        requested_scanners_string=self.session["requested_scanners_string"]
        ##        proxychains_string=self.session["proxychains_string"]
        ##        save_dir=self.session["save_dir"]
        _scanners = scanners.Scanners()
        _scanners.load_scanners()
        if self.session["target_url"] != "":
            if self.session["scan"]:
                if not global_vars['next_url']:
                    _scanurl = scanurl.ScanUrl()
                    _scanurl.start_scan_by_url(self.session,
                                               _scanners.scanners, self)
                if self.session["targets_file"] != "":
                    self.session["urls_line"] = self.session["urls_line"] + 1
        if self.session["targets_file"] != "":
            _urlsfile = urlsfile.UrlsFile()
            _urlsfile.start_scan_by_file(self.session, _scanners.scanners,
                                         self)
        if self.session["dorks_file"] != "":
            _urlsdorksfile = urlsdorksfile.UrlsDorksFile()
            _urlsdorksfile.start_scan_by_dorks_file(self.session,
                                                    _scanners.scanners, self)
Beispiel #2
0
    def __init__(self):
        
        self.scanners = scanners.Scanners()
        self.groups = groups.Groups()
        self.session = session.Session()       
                  
        self.global_vars = {'requested_scanners_string':"all",
                   'requested_groups_string':"",
                   'proxychains_string':"",
                   'add_options_string':"",
                   'session_name':"",
                   'add_options_string':"",
                   'tflag':False,
                   'goodork_flag':False,
                   'dork':"",
                   'target_url':"",
                   'targets_file':"",
                   'dorks_file':"",
                   'save_dir':config.CURRENT_DIR + "/output/",
                   'dorks_country':"",
                   'next_url':False,
                   'delete_file':False,
                   'db_file':False,
                   'advanced_search_url':"",
                    }

        self.flags = {'uflag':False,
                    'fflag':False,
                    'dorks_flag':False,
                    'dorks_file_flag':False,
                    'sflag':False,
                    'save_dir_flag':False
                    }
    def test_part_one(self):
        "Test part one example of Scanners object"

        # 1. Create Scanners object from text
        myobj = scanners.Scanners(text=aoc_19.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
    def test_part_two(self):
        "Test part two example of Scanners object"

        # 1. Create Scanners object from text
        myobj = scanners.Scanners(part2=True,
                                  text=aoc_19.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
    def test_empty_init(self):
        "Test the default Scanners creation"

        # 1. Create default Scanners object
        myobj = scanners.Scanners()

        # 2. Make sure it has the default values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(myobj.text, None)
        self.assertEqual(myobj.scnrs, [])
    def test_text_init(self):
        "Test the Scanners object creation from text"

        # 1. Create Scanners object from text
        myobj = scanners.Scanners(text=aoc_19.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 132)
        self.assertEqual(len(myobj.scnrs), 5)

        # 3. Check methods
        self.assertEqual(len(myobj.all_beacons()), 79)
        self.assertEqual(myobj.greatest_distance(), 3621)
Beispiel #7
0
def part_two(args, input_lines):
    "Process part two of the puzzle"

    # 1. Create the puzzle solver
    solver = scanners.Scanners(part2=True, text=input_lines)

    # 2. Determine the solution for part two
    solution = solver.part_two(verbose=args.verbose, limit=args.limit)
    if solution is None:
        print("There is no solution")
    else:
        print("The solution for part two is %s" % (solution))

    # 3. Return result
    return solution is not None