19 __switch_payload__ =
False
21 if __name__ ==
'__main__':
23 with open(sys.argv[1],
'rb')
as in_file:
24 pr_file = bytearray(in_file.read())
27 requestString =
"POST /configure HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nContent-Type: application/x-www-form-urlencodedAB\r\n\r\n"
30 pr_words =
int(pr_len/4)
31 assert(pr_len %4 == 0)
32 print(
"loaded pr bin file of size {} bytes ({} words)...".format(hex(pr_len), hex(pr_words)))
33 byteData = bytearray(requestString.encode())
34 if __switch_payload__:
35 pr_file_size = len(pr_file)
36 assert((pr_file_size % 4) == 0)
37 number_of_words =
int(pr_file_size/4)
38 for i
in range(0, number_of_words):
39 byteData.append(pr_file[i*4+3])
40 byteData.append(pr_file[i*4+2])
41 byteData.append(pr_file[i*4+1])
42 byteData.append(pr_file[i*4+0])
44 byteData.extend(pr_file)
46 byteData.extend(bytearray(
"\r\n\r\n".encode()))
55 with open(sys.argv[2],
'wb')
as outfile:
56 outfile.write(byteData)
58 print(
"POST request exported to: {}".format(sys.argv[2]))