Created
October 31, 2021 07:59
-
-
Save aroly/a504a0f6018ca5844d7b9b12c6de24f8 to your computer and use it in GitHub Desktop.
Hackvertor - AMF tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string, struct | |
def encode(string, xml=False): | |
string = string.encode('utf-8') | |
if xml: | |
const = '\x0f' # AMF0 XML document | |
size = struct.pack("!L", len(string)) # Size on 4 bytes | |
else: | |
const = '' # AMF0 URI | |
size = struct.pack("!H", len(string)) # Size on 2 bytes | |
return const + size + string | |
def build_amf_packet(svc, xml_str): | |
# Message | |
array_with_one_entry = '\x0a' + '\x00\x00\x00\x01' # AMF0 Array | |
msg = array_with_one_entry + encode(xml_str, xml=True) | |
# Body | |
target_uri = encode(svc) # Target URI | |
response_uri = encode('foobar') # Response URI | |
sz_msg = struct.pack("!L", len(msg)) | |
body = target_uri + response_uri + sz_msg + msg | |
# Packet | |
version = '\x00\x03' # Version | |
headers = '\x00\x00' # No headers | |
bodies = '\x00\x01' + body # One body | |
packet = version + headers + bodies | |
return packet | |
output = build_amf_packet("foo",input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment