def decode_offset(offset): offset = offset.replace("0x", "") try: offset = binascii.unhexlify(offset) offset = offset[::-1] print "hex pattern decoded as: " + offset return offset except TypeError: sploit.show_error("Invalid input offset.")
def orjohn(): try: with open(sys.argv[1], "rb") as csvfile: reader = csv.reader(csvfile, delimiter=",", quotechar="\"") try: for row in reader: if len(str(row[3])) == 16: print str(row[1]).lower() + ":0$" + row[1] + "#" + row[3] except IndexError: sploit.show_error("The input file must be a valid CSV file that uses , as delimiter and \" as quote char.") except IOError: sploit.show_error("You need to specify an input CSV file.")
def orjohn(): try: with open(sys.argv[1], 'rb') as csvfile: reader = csv.reader(csvfile, delimiter=',', quotechar='"') try: for row in reader: if len(str(row[3])) == 16: print str(row[1]).lower() + ":0$" + row[1] + "#" + row[3] except IndexError: sploit.show_error("The input file must be a valid CSV file that uses , as delimiter and \" as quote char.") except IOError: sploit.show_error("You need to specify an input CSV file.")
def hextobin(infile, outfile): if infile == "-": hexstring = "".join(re.sub(pattern, "", line) for line in sys.stdin) else: try: with open(infile) as hexfile: hexstring = "".join(re.sub(pattern, "", line) for line in hexfile) except IOError: sploit.show_error("Could not read the input file. Check that the file exists and it can be read.") binstring = binascii.unhexlify(hexstring) if outfile == "-": sys.stdout.write(binstring) else: try: with open(outfile, "w") as binfile: binfile.write(binstring) except IOError: sploit.show_error("Could not write the output file. Check the permissions.")
def hextobin(infile, outfile): if infile == "-": hexstring = "".join(re.sub(pattern, "", line) for line in sys.stdin) else: try: with open(infile) as hexfile: hexstring = "".join( re.sub(pattern, "", line) for line in hexfile) except IOError: sploit.show_error( "Could not read the input file. Check that the file exists and it can be read." ) binstring = binascii.unhexlify(hexstring) if outfile == "-": sys.stdout.write(binstring) else: try: with open(outfile, "w") as binfile: binfile.write(binstring) except IOError: sploit.show_error( "Could not write the output file. Check the permissions.")
offset = decode_offset(offset) show_offset(offset, size) if __name__ == "__main__": if len(sys.argv) == 1: show_help() elif sys.argv[1] != "create" and sys.argv[1] != "offset": show_help() try: try: if sys.argv[1] == "create" and sys.argv[2].isdigit(): show_pattern(sys.argv[2]) except IndexError: sploit.show_error( "You need to supply the <int> value for the create action.") try: if sys.argv[1] == "offset" and sys.argv[2]: try: size = int(sys.argv[3]) except IndexError: size = 0 show_offset(sys.argv[2], size) except IndexError: sploit.show_error( "You need to supply the <str> value for the offset action.") except KeyboardInterrupt: sploit.show_error( "Keyboard interrupt received. Educated guess: the script took too long to execute. You used a really long size, didn't you?"
print os.linesep.join(position) except ValueError: offset = decode_offset(offset) show_offset(offset, size) if __name__ == "__main__": if len(sys.argv) == 1: show_help() elif sys.argv[1] != "create" and sys.argv[1] != "offset": show_help() try: try: if sys.argv[1] == "create" and sys.argv[2].isdigit(): show_pattern(sys.argv[2]) except IndexError: sploit.show_error("You need to supply the <int> value for the create action.") try: if sys.argv[1] == "offset" and sys.argv[2]: try: size = int(sys.argv[3]) except IndexError: size = 0 show_offset(sys.argv[2], size) except IndexError: sploit.show_error("You need to supply the <str> value for the offset action.") except KeyboardInterrupt: sploit.show_error("Keyboard interrupt received. Educated guess: the script took too long to execute. You used a really long size, didn't you?")