Skip to content

Instantly share code, notes, and snippets.

@louis030195
Last active November 27, 2018 07:51
Show Gist options
  • Save louis030195/2d753e4c52b77f67b3fa5939c55b7334 to your computer and use it in GitHub Desktop.
Save louis030195/2d753e4c52b77f67b3fa5939c55b7334 to your computer and use it in GitHub Desktop.
import socket
from struct import *
def read_string(buffer):
s = ''
i = 0
while 1:
c = buffer[i]
if c == 0:
return s, (i+1)
s += chr(c)
i+=1
return '', 0
def read_headers(buffer):
(ff,id,size)=unpack_from('<BBH', buffer)
return (ff,id,size)
def read_sid_auth_info(buffer):
(logon_type, server_token, udp_value, mpq_filetime) = unpack_from('<IIIQ', buffer)
buffer=buffer[calcsize('<IIIQ'):]
(mpq_filename, offset) = read_string(buffer)
(valuestring, offset) = read_string(buffer[offset:])
return logon_type, server_token, udp_value, mpq_filetime, mpq_filename, valuestring
def file_transfer_protocol_v1(buffer):
(request_length,protocol_version,platform_id,product_id,banner_id,banner_file_extension,start_position_in_file,filetime_tmp,filename) \
= unpack_from('<HHIIIIIQ', buffer)
buffer=buffer[calcsize('<HHIIIIIQ'):]
(filename, offset) = read_string(buffer[offset:])
return request_length,protocol_version,platform_id,product_id,banner_id,banner_file_extension,start_position_in_file,filetime_tmp,filename
(request_length,protocol_version,platform_id,product_id,banner_id,banner_file_extension,start_position_in_file,filetime_tmp,filename) \
= file_transfer_protocol_v1("ff 50 65 00 00 00 00 00 96 66 4f 5a 0a 0c 00 00"
"00 e4 88 77 e9 2b d2 01 c4 35 51 5a 2e 6d 70 71"
"00 41 3d 33 38 34 35 35 38 31 36 33 34 20 42 3d"
"38 38 30 38 32 33 35 38 30 20 43 3d 31 33 36 33"
"39 33 37 31 30 33 20 34 20 41 3d 41 2d 53 20 42"
"3d 42 2d 43 20 43 3d 43 2d 41 20 41 3d 41 2d 42"
"00")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment