Beispiel #1
0
    def move_file_to_archive(self, file):
        now = datetime.datetime.now()
        current_date_time = now.strftime("%Y-%m-%d %H:%M:%S")
        input_file = self.input+file
        output_file = self.output+current_date_time+"__"+file
        os.rename(input_file, output_file)
        Log().save_to_logfile("Przenoszenie pliku {} do {}".format(input_file, output_file))

        return True
Beispiel #2
0
    def __init__(self, host, profile, verbose, desperate):
        self.plugins = self.load_plugins()
        self.host = host
        self.results = Results()
        self.cache = Cache()
        self.profile = Profile(profile)
        self.colorizer = Color()
        self.logs = Log()
        self.verbose = verbose

        self.check_url()
        self.redirect()
        self.cache.set_host(self.host)

        if desperate:
            self.desperate = Desperate()
        else:
            self.desperate = None
Beispiel #3
0
    def execute_file(self):

        for file in self.files:
            full_path = self.input + file
            if os.path.isfile(full_path):
                Log().save_to_logfile("Import pliku : {}".format(full_path))
                parsed_file = ParseFile(full_path).parse_file()
                self.move_file_to_archive(file)

        return True
Beispiel #4
0
	def __init__(self, host, profile, verbose):
		self.plugins = self.load_plugins()
		self.host = host
		self.results = Results()
		self.cache = Cache()
		self.profile = Profile(profile)
		self.check_url()
		self.redirect()
		self.colorizer = Color()
		self.logs = Log()
		self.verbose = verbose
    def update_record(self, data):
        sql = "UPDATE product_motion SET status='{1}' where number='{0}'".format(data[0][0], self.new_status)
        updated_row = 0
        try:
            cursor = self.conn.cursor()
            cursor.execute(sql)
            updated_row = cursor.rowcount
            Log().save_to_logfile("Update rekordu: {} na status: {}".format(data[0][0], self.new_status))
        except (Exception, psycopg2.DatabaseError) as error:
            print error

        return updated_row
Beispiel #6
0
	def __init__(self, host, profile, verbose, desperate):
		self.plugins = self.load_plugins()
		self.host = host
		self.results = Results()
		self.cache = Cache()		
		self.profile = Profile(profile)
		self.colorizer = Color()
		self.logs = Log()
		self.verbose = verbose

		self.check_url()
		self.redirect()
		self.cache.set_host(self.host)

		if desperate:
			self.desperate = Desperate()
		else:
			self.desperate = None
Beispiel #7
0
class Wig():

	def __init__(self, host, profile, verbose, desperate, plugin_name=None):
		self.plugins = self.load_plugins()
		self.host = host
		self.results = Results()
		self.cache = Cache()		
		self.profile = Profile(profile)
		self.colorizer = Color()
		self.logs = Log()
		self.verbose = verbose
		self.plugin_name = plugin_name

		self.check_url()
		self.redirect()
		self.cache.set_host(self.host)

		if desperate:
			self.desperate = Desperate()
		else:
			self.desperate = None


	def redirect(self):
		# detects redirection if this happend
		try:
			r = requests.get(self.host, verify=False)
		except:
			print("Invalid URL or host not found. Exiting...")
			sys.exit(0)

		if not r.url == self.host:

			# ensure that sub-folders and files are removed
			parts = r.url.split('//')
			http, url = parts[0:2]

			# remove subfolders and/or files
			# http://example.com/test -> http://example.com/
			if '/' in url:
				redirected = http + '//' + url.split('/')[0] + '/'
			else:
				redirected = http + '//' + url + '/'

			self.host = redirected

	
	def check_url(self):
		# adds http:// to input if not present
		if not self.host.startswith("http"):
			self.host = "http://" + self.host


	def load_plugins(self):
		# load all the plugins listed in plugins/__init__.py
		all_plugins = []
		for p in plugins.__all__:
			plugin_path = "plugins." + p
			__import__(plugin_path)
			all_plugins.append(sys.modules[plugin_path])

		return all_plugins


	def run(self):
		t = time.time()
		num_fps = 0
		num_plugins = 0
		# loops over all the plugins loaded
		for plugin in self.plugins:

			# a loaded plugin might have more than one plugin, so 'ps' is a list
			ps = plugin.get_instances(self.host, self.cache, self.results)
			num_plugins += len(ps)
			for p in ps:

				# give a status of which plugin is run
				print(p.name, end="                                                \r")
				sys.stdout.flush()

				# applies the choosen profile by removing fingerprints from the 
				# fingerprint set if these do not match the choosen profile
				p.set_profile(self.profile, self.plugin_name)

				# the main plugin method
				p.run()
				num_fps += p.get_num_fps()

				# check if running desperate mode.
				if self.desperate:
					# add the plugins fingerprints to the global fingerprint database
					self.desperate.add_fingerprints(p.get_items_for_desperate_mode())


				# add logs
				self.logs.add( p.get_logs() )


		if self.desperate:
			self.desperate.set_cache(self.cache)
			self.desperate.run()
			for i in self.desperate.get_matches():
				self.results.add('Desperate', i['cms'], i, i['count'])

		# check the response headers for information
		ch = CheckHeaders(self.cache, self.results, self.logs)
		ch.run()

		run_time = "%.1f" % (time.time() - t)
		num_urls = self.cache.get_num_urls()

		status = "Time: %s sec | Plugins: %s | Urls: %s | Fingerprints: %s" % (run_time, num_plugins, num_urls, num_fps)
		bar = "_"*len(status)
		self.results.set_width(len(status))

		print(self.results)
		print(bar)
		print(status + "\n")

		if self.verbose:
			print(bar)
			print(self.logs)
Beispiel #8
0
            public_key = RSA.import_key(
                json.load(publicclient)[nameid].get("pub_key").encode('utf-8'))
        ciphertext = PKCS1_OAEP.new(public_key).encrypt(cleartext)
        return ciphertext

    def decrypt(self, cryptedtext):
        private_key = RSA.import_key(open('prvkeyserv.pem').read(),
                                     passphrase=secret_code)
        # https://pycryptodome-master.readthedocs.io/en/latest/src/cipher/oaep.html
        decrypted = PKCS1_OAEP.new(private_key).decrypt(cryptedtext)
        return decrypted


# Initialisation du serveur - Mise en place du socket :
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
log = Log().get_daiquiri()
try:
    mySocket.bind((HOST, PORT))
    log.error("ca run !!", somekey="test1", anotherkey="test")
except socket.error:
    print("La liaison du socket à l'adresse choisie a échoué.")
    sys.exit()
f = open('prvkeyserv.pem', 'rb')
if "-----BEGIN RSA PRIVATE KEY-----" != f.readline().rstrip().decode("utf-8"):
    f.close()
    key = RSA.generate(2048)
    private_key = key.export_key(passphrase=secret_code,
                                 pkcs=8,
                                 protection="scryptAndAES128-CBC")
    public_key = key.publickey().export_key()
    f = open('prvkeyserv.pem', 'wb')
Beispiel #9
0
class Wig():
    def __init__(self, host, profile, verbose, desperate, plugin_name=None):
        self.plugins = self.load_plugins()
        self.host = host
        self.results = Results()
        self.cache = Cache()
        self.profile = Profile(profile)
        self.colorizer = Color()
        self.logs = Log()
        self.verbose = verbose
        self.plugin_name = plugin_name

        self.check_url()
        self.redirect()
        self.cache.set_host(self.host)

        if desperate:
            self.desperate = Desperate()
        else:
            self.desperate = None

    def redirect(self):
        # detects redirection if this happend
        try:
            r = requests.get(self.host, verify=False)
        except:
            print("Invalid URL or host not found. Exiting...")
            sys.exit(0)

        if not r.url == self.host:

            # ensure that sub-folders and files are removed
            parts = r.url.split('//')
            http, url = parts[0:2]

            # remove subfolders and/or files
            # http://example.com/test -> http://example.com/
            if '/' in url:
                redirected = http + '//' + url.split('/')[0] + '/'
            else:
                redirected = http + '//' + url + '/'

            self.host = redirected

    def check_url(self):
        # adds http:// to input if not present
        if not self.host.startswith("http"):
            self.host = "http://" + self.host

    def load_plugins(self):
        # load all the plugins listed in plugins/__init__.py
        all_plugins = []
        for p in plugins.__all__:
            plugin_path = "plugins." + p
            __import__(plugin_path)
            all_plugins.append(sys.modules[plugin_path])

        return all_plugins

    def run(self):
        t = time.time()
        num_fps = 0
        num_plugins = 0
        # loops over all the plugins loaded
        for plugin in self.plugins:

            # a loaded plugin might have more than one plugin, so 'ps' is a list
            ps = plugin.get_instances(self.host, self.cache, self.results)
            num_plugins += len(ps)
            for p in ps:

                # give a status of which plugin is run
                print(p.name,
                      end="                                                \r")
                sys.stdout.flush()

                # applies the choosen profile by removing fingerprints from the
                # fingerprint set if these do not match the choosen profile
                p.set_profile(self.profile, self.plugin_name)

                # the main plugin method
                p.run()
                num_fps += p.get_num_fps()

                # check if running desperate mode.
                if self.desperate:
                    # add the plugins fingerprints to the global fingerprint database
                    self.desperate.add_fingerprints(
                        p.get_items_for_desperate_mode())

                # add logs
                self.logs.add(p.get_logs())

        if self.desperate:
            self.desperate.set_cache(self.cache)
            self.desperate.run()
            for i in self.desperate.get_matches():
                self.results.add('Desperate', i['cms'], i, i['count'])

        # check the response headers for information
        ch = CheckHeaders(self.cache, self.results, self.logs)
        ch.run()

        run_time = "%.1f" % (time.time() - t)
        num_urls = self.cache.get_num_urls()

        status = "Time: %s sec | Plugins: %s | Urls: %s | Fingerprints: %s" % (
            run_time, num_plugins, num_urls, num_fps)
        bar = "_" * len(status)
        self.results.set_width(len(status))

        print(self.results)
        print(bar)
        print(status + "\n")

        if self.verbose:
            print(bar)
            print(self.logs)
Beispiel #10
0
class Wig():

	def __init__(self, host, profile, verbose):
		self.plugins = self.load_plugins()
		self.host = host
		self.results = Results()
		self.cache = Cache()
		self.profile = Profile(profile)
		self.check_url()
		self.redirect()
		self.colorizer = Color()
		self.logs = Log()
		self.verbose = verbose


	def redirect(self):
		# detects redirection if this happend
		r = requests.get(self.host, verify=False)
		if not r.url == self.host:

			# ensure that sub-folders and files are removed
			parts = r.url.split('//')
			http, url = parts[0:2]

			# remove subfolders and/or files
			# http://example.com/test -> http://example.com/
			if '/' in url:
				redirected = http + '//' + url.split('/')[0] + '/'
			else:
				redirected = http + '//' + url + '/'

			self.host = redirected

	
	def check_url(self):
		# adds http:// to input if not present
		if not self.host.startswith("http"):
			self.host = "http://" + self.host


	def load_plugins(self):
		# load all the plugins listed in plugins/__init__.py
		all_plugins = []
		for p in plugins.__all__:
			plugin_path = "plugins." + p
			__import__(plugin_path)
			all_plugins.append(sys.modules[plugin_path])

		return all_plugins


	def run(self):
		t = time.time()
		num_fps = 0
		num_plugins = 0
		# loops over all the plugins loaded
		for plugin in self.plugins:

			# a loaded plugin might have more than one plugin, so 'ps' is a list
			ps = plugin.get_instances(self.host, self.cache, self.results)
			num_plugins += len(ps)
			for p in ps:

				# give a status of which plugin is run
				print(p.name, end="                                                \r")
				sys.stdout.flush()

				# applies the choosen profile by removing fingerprints from the 
				# fingerprint set if these do not match the choosen profile
				p.set_profile(self.profile)

				# the main plugin method
				p.run()
				num_fps += p.get_num_fps()

				# add logs
				self.logs.add( p.get_logs() )


		run_time = "%.1f" % (time.time() - t)
		num_urls = self.cache.get_num_urls()

		status = "Time: %s sec | Plugins: %s | Urls: %s | Fingerprints: %s" % (run_time, num_plugins, num_urls, num_fps)
		bar = "_"*len(status)
		self.results.set_width(len(status))

		print(self.results)
		print(bar)
		print(status + "\n")

		if self.verbose:
			print(bar)
			print(self.logs)