コード例 #1
0
    def checkHashType(self, hash_type):
        """
		Check if input hash type is a...
			correct number
			valid string corresponding a hash type number in the hash_types.json file

		"""
        try:
            # if it is already a valid number
            if hash_type.isdigit() and int(hash_type) in range(0, 99999):
                return hash_type
            # if it is a string with the title of the format
            else:
                with open(os.path.join(self.source_dir, "hash_types.json"),
                          "r",
                          encoding="utf-8") as f:
                    types = json.load(f)
                lower_keys = {
                    k.lower(): v
                    for k, v in types.items()
                }  #r take ['MD5': '0'...] and return ['md5': '0']
                hash_type = hash_type.lower()  # lower input type MD5 to md5
                if hash_type in lower_keys.keys():
                    return lower_keys[hash_type]
                else:
                    Color.showError(
                        "Invalid hash type number or title. Check valid list here: https://hashcat.net/wiki/doku.php?id=example_hashes",
                        True)

        except Exception as e:
            Color.showException(e)
コード例 #2
0
ファイル: test_canvas.py プロジェクト: qTipTip/RayTracer
    def test_canvas_to_ppm_body(self):
        c = Canvas(5, 3)
        c1 = Color(1.5, 0, 0)
        c2 = Color(0, 0.5, 0)
        c3 = Color(-0.5, 0, 1)

        c.write_pixel(0, 0, c1)
        c.write_pixel(2, 1, c2)
        c.write_pixel(4, 2, c3)

        outfile = 'test_canvas_to_ppm_body.ppm'
        c.to_ppm(outfile)

        with open(outfile, 'r') as infile:
            [infile.readline() for i in range(3)]  # skip header
            body = list(map(str.strip, infile.readlines()))
            l1 = "255 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
            l2 = "0 0 0 0 0 0 0 128 0 0 0 0 0 0 0"
            l3 = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 255"
            assert body[0] == l1
            assert body[1] == l2
            assert body[2] == l3
        try:
            os.remove(outfile)
        except FileNotFoundError:
            pass
コード例 #3
0
	def OneWordPerHashAttacks(self, attack_name, attacks, all_wordlists):
		"""
		Parse configuration's ONE WORD PER HASH attack parameters and call the corresponding hashcat class method
		One_hash:one_word line by line from hashlist:wordlist
		Note: useful to try username as the password
		"""
		for attack in attacks: # for every attack
			f = open(self.hashcat.hash_file, "r")
			hash_lines = f.read().splitlines() # get haslist
			f.close()
			wordlists = Attacks.get_file_from_index(attack["wordlists"], all_wordlists) # get wordlists

			for wordlist in wordlists: # for every wordlist
				f = open(wordlist, "r")
				word_lines = f.read().splitlines() # get wordlist
				f.close()

				if len(hash_lines) == len(word_lines):
					for i in range(len(hash_lines)):
						one_hash = hash_lines[i]
						one_word = word_lines[i] # its line corresponding hash:word
						self.hashcat.one_hash_one_word(one_hash,one_word)
				else:
					Color.showError("Hash file and Wordlist file need same length to try hash[i]:word[i]", True)
		return
コード例 #4
0
ファイル: clock.py プロジェクト: BrianTheArcane/RTC
def run() -> None:
    STEPS = 180
    SIZE = 600
    MIDDLE = SIZE // 2

    canvas = Canvas(SIZE, SIZE)
    color = Color(1, 0, 0)
    color_increment = Color(0, 0, 1.0 / STEPS)

    position = point(0, 1, 0)

    rotate = rotation_z(-2 * math.pi / STEPS)
    translate = translation(MIDDLE, MIDDLE, 0)
    scale = scaling(SIZE // 3, SIZE // 3, 1)

    for i in range(STEPS):
        canvas_position = translate * scale * position
        assert isinstance(canvas_position, Point)
        canvas.write_pixel(
            int(round(canvas_position.x)),
            SIZE - int(round(canvas_position.y)),
            color,
        )
        position = rotate * position
        color += color_increment

    ppm = PPM(canvas)

    file_name = "clocks.ppm"
    ppm.save_to_file(file_name)
    print(f"Output stored to {file_name}")
コード例 #5
0
	def straight_attacks(self, attack_name, attacks, all_wordlists, all_rules):
		"""
		Parse configuration's STRAIGHT attack parameters and call the corresponding hashcat class method
		"""
		for attack in attacks: # for every attack
			wordlists = Attacks.get_file_from_index(attack["wordlists"], all_wordlists)
			if "rules" in attack:
				if attack_name == "straight_with_rules_manual":
					r = attack["rules"]
				else:
					rules = Attacks.get_file_from_index(attack["rules"], all_rules)

			for w in wordlists: # for every wordlist
				if attack_name == "straight":
					self.hashcat.straight(w)
				elif attack_name == "straight_with_combined_rules_files":
					if len(rules) == 2: # only if 2 rule files are given
						self.hashcat.straight_with_combined_rules_files(w, rules[0], rules[1])
					else:
						Color.showError("Straight combined rules: You have to define two rule files!", False)
				elif attack_name == "straight_with_rules_manual":
							self.hashcat.straight_with_rules_manual(w, r)
				elif attack_name == "straight_with_rules_files":
					for r in rules: # apply all the defined rules
						self.hashcat.straight_with_rules_file(w, r)
		return
コード例 #6
0
def test_lightning_light_behind():
    m = DefaultMaterial()
    position = Point(0, 0, 0)
    eyev = Vector(0, 0, -1)
    normalv = Vector(0, 0, -1)
    light = PointLight(Point(0, 0, 10), Color(1, 1, 1))

    result = m.lighting(light, position, eyev, normalv)
    assert result == Color(0.1, 0.1, 0.1)
コード例 #7
0
def test_lighting_direct():
    m = DefaultMaterial()
    position = Point(0, 0, 0)
    eyev = Vector(0, 0, -1)
    normalv = Vector(0, 0, -1)
    light = PointLight(Point(0, 0, -10), Color(1, 1, 1))

    result = m.lighting(light, position, eyev, normalv)
    assert result == Color(1.9, 1.9, 1.9)
コード例 #8
0
def test_lightning_eye_angle():
    m = DefaultMaterial()
    position = Point(0, 0, 0)
    eyev = Vector(0, sqrt(2) / 2, -sqrt(2) / 2)
    normalv = Vector(0, 0, -1)
    light = PointLight(Point(0, 0, -10), Color(1, 1, 1))

    result = m.lighting(light, position, eyev, normalv)
    assert result == Color(1.0, 1.0, 1.0)
コード例 #9
0
ファイル: results.py プロジェクト: serralba/autocrackeo
 def count_lines(file_path):
     try:
         f = open(file_path, "r")
         count = len(f.readlines())
         f.close()
         return count
     except Exception as e:
         f.close()
         Color.show_error(str(e))
         return -1
コード例 #10
0
def test_lightning_light_angle():
    m = DefaultMaterial()
    position = Point(0, 0, 0)
    eyev = Vector(0, 0, -1)
    normalv = Vector(0, 0, -1)
    light = PointLight(Point(0, 10, -10), Color(1, 1, 1))

    result = m.lighting(light, position, eyev, normalv)
    assert result == Color(0.7363961030678927, 0.7363961030678927,
                           0.7363961030678927)
コード例 #11
0
    def getConfigFilesArray(attack_file):
        if attack_file:
            if attack_file == "all":
                attack_file_list = Configuration.parseConfigFilesList(
                    attack_file + ".json")
            else:
                attack_file_list = [attack_file + ".json"]

            return attack_file_list
        else:
            Color.showError("Invalid attacks config file", True)
コード例 #12
0
    def save_cracked(self):
        """
		 Call hashcat's show command and save the cracked hashes from a given hashfile, hashtype and potfile
		"""
        cmd = f"{self.executable} {self.hash_type} \"{self.hash_file}\" {self.pot_file} {self.out_file_format_pwd} {self.extra_params} {self.show}"
        if self.verbose: Color.showCmd(cmd)
        with open(self.out_file_cracked_path, 'w') as f:
            p = subprocess.call(cmd, stdout=f, shell=True)
        if self.verbose:
            Color.showVerbose("Cracked hashes saved in " +
                              self.out_file_cracked_path)
        return
コード例 #13
0
    def parseHashFilesList(hash_files_list_path):
        """
		 Parse hash files list with the hash_file, hash_type, extra_params in json format
		"""
        try:

            with open(hash_files_list_path, "r", encoding="utf-8") as f:
                json_file = json.load(f)
                files_list = json_file["list"]
                return files_list

        except Exception as e:
            Color.showException(e)
コード例 #14
0
    def parseConfigFilesList(all_attacks_file):
        """
		 Parse attacks_files list from json file
		"""
        try:
            path = os.path.join(Configuration.getBaseDir(), "attacks",
                                all_attacks_file)
            with open(path, "r", encoding="utf-8") as f:
                json_file = json.load(f)
                files_list = json_file["attacks_files"]
                return files_list

        except Exception as e:
            Color.showException(e)
コード例 #15
0
def test_default_material():
    m = DefaultMaterial()
    assert m.color == Color(1, 1, 1)
    assert m.ambient == 0.1
    assert m.diffuse == 0.9
    assert m.specular == 0.9
    assert m.shininess == 200
コード例 #16
0
    def execute(self, cmd):
        """
		Execute a os command with given string
		"""
        if self.verbose: Color.showCmd(cmd)  # show on screen
        now = Color.timedelta_to_string(datetime.now())
        self.color.logThis("[+] " + now + ", " + cmd)  # log on file
        p = subprocess.call(cmd, shell=True)
        '''
		p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
		(output, err) = p.communicate()
		p_status = p.wait()
		#print("Command output: ", output)
		#print("Command exit status/return code: ", p_status)
		'''
        return
コード例 #17
0
def default_world() -> World:
    """A default world with 2 spheres and a light"""
    sphere_1 = Sphere()
    sphere_1.material = Material()
    sphere_1.material.color = Color(0.8, 1.0, 0.6)
    sphere_1.material.diffuse = 0.7
    sphere_1.material.specular = 0.2
    sphere_2 = Sphere()
    sphere_2.transform = scaling(0.5, 0.5, 0.5)

    world = World()
    world.light = PointLight(point(-10, 10, -10), Color(1, 1, 1))
    world.objects.append(sphere_1)
    world.objects.append(sphere_2)

    return world
コード例 #18
0
def color_at(world: World, ray: Ray) -> Color:
    xs = intersect_world(world, ray)
    hit = find_hit(xs)
    if hit is None:
        return Color(0, 0, 0)

    comps = PreparedComputation(hit, ray)
    return shade_hit(world, comps)
コード例 #19
0
	def combinator_attacks(self, attack_name, attacks, all_wordlists):
		"""
		Parse configuration's COMBINATOR attack parameters and call the corresponding hashcat class method
		"""
		for attack in attacks: # for every attack
			wordlists = Attacks.get_file_from_index(attack["wordlists"], all_wordlists)
			if len(wordlists) == 2: # only if 2 wordlists are given
				w1 = wordlists[0]
				w2 = wordlists[1]
				if attack_name == "combinator":
					self.hashcat.combinator(w1, w2)
				elif attack_name == "":
					j = attack["rules_left"]
					k = attack["rules_right"]
					self.hashcat.combinator(w1, w2, j, k)
			else:
				Color.showError("Combined rules: You have to define two rule files!", False)
		return
コード例 #20
0
ファイル: canvas.py プロジェクト: BrianTheArcane/RTC
def check_all_canvas_pixels(context, var, x, y, z):
    canvas = context.variables[var]
    expected = Color(x, y, z)

    def check_pixel(p: Color) -> None:
        assert p == expected
        return None

    canvas.for_each_pixel(check_pixel)
コード例 #21
0
 def getHashFilesArray(hash_file, hash_type, extra_params, hash_files):
     # get hash_files, hash_types, and extra_params from input params
     if hash_file:
         if hash_type:
             if extra_params == None:
                 extra_params = ""
             hash_files_list = [{
                 "hash_file": hash_file,
                 "hash_type": hash_type,
                 "extra_params": extra_params
             }]
         else:
             Color.showError(
                 "Error: the argument -m [HASH_TYPE] is required", True)
     # or get hash_files, hash_types, and extra_params from json file
     elif hash_files:
         hash_files_list = Configuration.parseHashFilesList(hash_files)
     return hash_files_list
コード例 #22
0
 def _get_feat(self, db, f_class):
   if f_class == 'color':
     f_c = Color()
   elif f_class == 'daisy':
     f_c = Daisy()
   elif f_class == 'edge':
     f_c = Edge()
   elif f_class == 'gabor':
     f_c = Gabor()
   elif f_class == 'hog':
     f_c = HOG()
   elif f_class == 'vgg':
     f_c = VGGNetFeat()
   elif f_class == 'res':
     f_c = ResNetFeat()
   return f_c.make_samples(db, verbose=False)
コード例 #23
0
ファイル: scene.py プロジェクト: BrianTheArcane/RTC
def create_objects() -> List[Sphere]:
    middle = Sphere()
    middle.transform = translation(-0.5, 1, 0.5)
    middle.material.color = Color(0.1, 1, 0.5)
    middle.material.diffuse = 0.7
    middle.material.specular = 0.3

    right = Sphere()
    right.transform = translation(1.5, 0.5, -0.5) * scaling(0.5, 0.5, 0.5)
    right.material.color = Color(0.5, 1, 0.1)
    right.material.diffuse = 0.7
    right.material.specular = 0.3

    left = Sphere()
    left.transform = translation(-1.5, 0.33, -0.75) * scaling(0.33, 0.33, 0.33)
    left.material.color = Color(1, 0.8, 0.1)
    left.material.diffuse = 0.7
    left.material.specular = 0.3

    return [middle, right, left]
コード例 #24
0
ファイル: materials.py プロジェクト: qTipTip/RayTracer
    def lighting(self, light, position, eyev, normalv):
        effective_color = self.color * light.intensity
        lightv = (light.position - position).normalize()
        ambient = effective_color * self.ambient
        light_dot_normal = lightv.dot(normalv)

        if light_dot_normal < 0:
            diffuse = Color(0, 0, 0)
            specular = Color(0, 0, 0)
        else:
            diffuse = effective_color * self.diffuse * light_dot_normal
            reflectv = -lightv.reflect(normalv)
            reflect_dot_eye = pow(reflectv.dot(eyev), self.shininess)

            if reflect_dot_eye <= 0:
                specular = Color(0, 0, 0)
            else:
                specular = light.intensity * self.specular * reflect_dot_eye
        color_vec = ambient + diffuse + specular
        return Color(color_vec.x, color_vec.y, color_vec.z)
コード例 #25
0
ファイル: scene.py プロジェクト: BrianTheArcane/RTC
def run() -> None:
    room = create_room()
    objects = create_objects()
    world = World()
    world.light = PointLight(point(-10, 10, -10), Color(1, 1, 1))
    world.objects.extend(room)
    world.objects.extend(objects)
    camera = Camera(400, 200, math.pi / 3)
    camera.transform = view_transform(point(0, 1.5, -5), point(0, 1, 0),
                                      vector(0, 1, 0))
    canvas = camera.render(world)
    PPM(canvas).save_to_file("scene.ppm")
コード例 #26
0
	def save_cracked(self):
		"""
		 Call hashcat's show command and save the cracked hashes from a given hashfile, hashtype and potfile
		"""
		cmd = f"{self.executable} {self.hash_type} {self.hash_file} {self.pot_file} {self.out_file_format_pwd} {self.extra_params} {self.show}"
		print(Color.cyan("\n" + cmd))
		f = open(self.results.out_file_cracked_path, 'w')
		p = subprocess.call(cmd, stdout=f, shell=True)
		f.close()
		count = self.results.count_lines(self.results.out_file_cracked_path)
		self.results.cracked_total = count
		print("Cracked hashes saved in " + self.results.out_file_cracked_path + " ...")
		return 
コード例 #27
0
	def checkHashType(self, hash_type):
		"""
		Check if input hash type is a...
			correct number
			valid string corresponding a hash type number in the hash_types.json file

		"""
		try:
			# if it is already a valid number
			if hash_type.isdigit() and int(hash_type) in range(0,99999):
				return hash_type
			# if it is a string with the title of the format
			else:
				with open(os.path.join("src", "hash_types.json"), "r") as f:
					types = json.load(f)
				if hash_type in types.keys():
					return types[hash_type]
				else:
					Color.show_error_text("Invalid hash type number or title. Check valid list here: https://hashcat.net/wiki/doku.php?id=example_hashes")

		except Exception as e:
			Color.show_error(e)
コード例 #28
0
ファイル: rays.py プロジェクト: BrianTheArcane/RTC
def check_attribute_point(context, var, att, tuple_type, x, y, z):
    if tuple_type == "point":
        expected = point(x, y, z)
    elif tuple_type == "vector":
        expected = vector(x, y, z)
    elif tuple_type == "color":
        expected = Color(x, y, z)  # type: ignore
    else:
        raise ValueError(f"tuple type '{tuple_type}' not recognized")

    my_variable = context.variables[var]
    assert (getattr(
        my_variable,
        att) == expected), f"{getattr(my_variable, att)} == {expected}"
コード例 #29
0
ファイル: shading.py プロジェクト: BrianTheArcane/RTC
def run() -> None:
    # Eye is at (0,0, 5)
    origin = point(0, 0, 5)

    shape = Sphere()
    # shape.set_transform(scaling(0.5, 1, 1))
    shape.material.color = Color(0.9, 0.2, 1)

    light = PointLight(point(-10, 10, 10), Color(1, 1, 1))
    canvas = Canvas(CANVAS_SIZE, CANVAS_SIZE)

    for i in range(CANVAS_SIZE):
        for j in range(CANVAS_SIZE):
            target = canvas_to_world(point(i, j, 0))
            ray = Ray(origin, normalize(target - origin))
            hit = find_hit(shape.intersect(ray))
            if hit is not None:
                hit_point = position(ray, hit.t)
                normal = hit.shape.normal_at(hit_point)
                pixel_color = lighting(hit.shape.material, light, hit_point,
                                       -ray.direction, normal)
                canvas.write_pixel(i, j, pixel_color)

    PPM(canvas).save_to_file("sphere.ppm")
コード例 #30
0
def create_structure(
    structure_type: str, x: float, y: float, z: float
) -> Union[Tuple, Color, Matrix]:
    if structure_type == "vector":
        return vector(x, y, z)
    elif structure_type == "point":
        return point(x, y, z)
    elif structure_type == "color":
        return Color(x, y, z)
    elif structure_type == "scaling":
        return scaling(x, y, z)
    elif structure_type == "translation":
        return translation(x, y, z)
    else:
        raise NotImplementedError(f"structure type '{structure_type}' not recognized")