Пример #1
0
def write_in_file(result):
    if constant.output == 'json' or constant.output == 'all':
        try:
            # Human readable Json format
            prettyJson = json.dumps(result,
                                    sort_keys=True,
                                    indent=4,
                                    separators=(',', ': '))
            with open(
                    constant.folder_name + os.sep +
                    constant.file_name_results + '.json', 'a+b') as f:
                f.write(prettyJson.decode('unicode-escape').encode('UTF-8'))
            constant.st.do_print('[+] File written: ' + constant.folder_name +
                                 os.sep + constant.file_name_results + '.json')
        except Exception as e:
            print_debug('ERROR', 'Error writing the output file: %s' % e)

    if constant.output == 'txt' or constant.output == 'all':
        try:
            with open(
                    constant.folder_name + os.sep +
                    constant.file_name_results + '.txt', 'a+b') as f:
                a = parseJsonResultToBuffer(result)
                f.write(a.encode("UTF-8"))
            constant.st.write_footer()
            constant.st.do_print('[+] File written: ' + constant.folder_name +
                                 os.sep + constant.file_name_results + '.txt')
        except Exception as e:
            print_debug('ERROR', 'Error writing the output file: %s' % e)
Пример #2
0
def write_in_file(result):
	try:
		if constant.output == 'json' or constant.output == 'all':
			# Human readable Json format 
			prettyJson = json.dumps(result, sort_keys=True, indent=4, separators=(',', ': '))
			with open(constant.folder_name + os.sep + constant.file_name_results + '.json', 'w+') as f:
				f.write(prettyJson.encode('utf-8', errors='replace'))
			print '[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.json'

		if constant.output == 'txt' or constant.output == 'all':
			with open(constant.folder_name + os.sep + constant.file_name_results + '.txt', 'a+b') as f:
				f.write(parseJsonResultToBuffer(result))
			write_footer()
			print '[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.txt'

	except Exception as e:
		print_debug('ERROR', 'Error writing the output file: %s' % e)
Пример #3
0
def write_in_file(result):
	try:
		if constant.output == 'json' or constant.output == 'all':
			# Human readable Json format 
			prettyJson = json.dumps(result, sort_keys=True, indent=4, separators=(',', ': '))
			with open(constant.folder_name + os.sep + constant.file_name_results + '.json', 'w+') as f:
				f.write(prettyJson.encode('utf-8', errors='replace'))
			print '[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.json'

		if constant.output == 'txt' or constant.output == 'all':
			with open(constant.folder_name + os.sep + constant.file_name_results + '.txt', 'a+b') as f:
				f.write(parseJsonResultToBuffer(result))
			write_footer()
			print '[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.txt'

	except Exception as e:
		print_debug('ERROR', 'Error writing the output file: %s' % e)
Пример #4
0
def write_in_file(result):
	if constant.output == 'json' or constant.output == 'all':
		try:
			# Human readable Json format
			prettyJson = json.dumps(result, sort_keys=True, indent=4, separators=(',', ': '))
			with open(constant.folder_name + os.sep + constant.file_name_results + '.json', 'a+b') as f:
				f.write(prettyJson.decode('unicode-escape').encode('UTF-8'))
			constant.st.do_print('[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.json')
		except Exception as e:
			print_debug('ERROR', 'Error writing the output file: %s' % e)

	if constant.output == 'txt' or constant.output == 'all':
		try:
			with open(constant.folder_name + os.sep + constant.file_name_results + '.txt', 'a+b') as f:
				a = parseJsonResultToBuffer(result)
				f.write(a.encode("UTF-8"))
			constant.st.write_footer()
			constant.st.do_print('[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.txt')
		except Exception as e:
			print_debug('ERROR', 'Error writing the output file: %s' % e)
Пример #5
0
        try:
            stdoutRes += user_pwd_temp
            if constant.output == 'json' or constant.output == 'all':
                with open(
                        constant.folder_name + os.sep +
                        constant.file_name_results + '.json', 'w') as f:
                    json.dump(json.dumps(stdoutRes), f)
                print '[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.json'

            # Write to a txt file
            if constant.output != 'json':
                with open(
                        constant.folder_name + os.sep +
                        constant.file_name_results + '.txt', 'a+b') as f:
                    f.write(parseJsonResultToBuffer(stdoutRes).encode('utf-8'))
                print '[+] File written: ' + constant.folder_name + os.sep + constant.file_name_results + '.txt'

        except Exception as e:
            print_debug('ERROR', 'Error writing the output file: %s' % e)

else:
    if isChild:
        # - Normal execution
        # - Redirect output to a temp file
        # - Quit
        constant.output = 'json'
        stopExecute = False
    else:
        print_debug('INFO', 'We do not have system privileges')
Пример #6
0
# ------------------------------------------- Parse arguments -------------------------------------------
args = dict(parser.parse_args()._get_kwargs())
arguments = parser.parse_args()
start_time = time.time()
output()
verbosity()

user = getpass.getuser()
constant.finalResults = {}
constant.finalResults['User'] = user

print '\n\n########## User: %s ##########\n' % user
arguments.func()

if constant.output == 'json' or constant.output == 'all':
	# Human readable Json format 
	prettyJson = json.dumps(constant.finalResults, sort_keys=True, indent=4, separators=(',', ': '))
	with open(constant.folder_name + os.sep + constant.file_name_results + '.json', 'w+') as f:
		json.dump(prettyJson, f)

# Print the number of passwords found
if constant.output == 'txt' or constant.output == 'all':
	with open(constant.folder_name + os.sep + constant.file_name_results + '.txt', 'a+b') as f:
		f.write(parseJsonResultToBuffer(constant.finalResults).encode('utf-8'))
	write_footer()

print_footer()

elapsed_time = time.time() - start_time
print '\nelapsed time = ' + str(elapsed_time)
Пример #7
0
            stdoutRes.append(constant.finalResults)
        except Exception, e:
            print_debug("ERROR", e)
            pass

        try:
            stdoutRes += user_pwd_temp
            if constant.output == "json" or constant.output == "all":
                with open(constant.folder_name + os.sep + constant.file_name_results + ".json", "w") as f:
                    json.dump(json.dumps(stdoutRes), f)
                print "[+] File written: " + constant.folder_name + os.sep + constant.file_name_results + ".json"

                # Write to a txt file
            if constant.output != "json":
                with open(constant.folder_name + os.sep + constant.file_name_results + ".txt", "a+b") as f:
                    f.write(parseJsonResultToBuffer(stdoutRes).encode("utf-8"))
                print "[+] File written: " + constant.folder_name + os.sep + constant.file_name_results + ".txt"

        except Exception as e:
            print_debug("ERROR", "Error writing the output file: %s" % e)

else:
    if isChild:
        # - Normal execution
        # - Redirect output to a temp file
        # - Quit
        constant.output = "json"
        stopExecute = False
    else:
        print_debug("INFO", "We do not have system privileges")