forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sercomm-payload.py
executable file
·56 lines (42 loc) · 994 Bytes
/
sercomm-payload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import argparse
import hashlib
import os
def create_output(args):
in_st = os.stat(args.input_file)
in_size = in_st.st_size
in_f = open(args.input_file, 'r+b')
in_bytes = in_f.read(in_size)
in_f.close()
sha256 = hashlib.sha256()
sha256.update(in_bytes)
out_f = open(args.output_file, 'w+b')
out_f.write(bytes.fromhex(args.pid))
out_f.write(sha256.digest())
out_f.write(in_bytes)
out_f.close()
def main():
global args
parser = argparse.ArgumentParser(description='')
parser.add_argument('--input-file',
dest='input_file',
action='store',
type=str,
help='Input file')
parser.add_argument('--output-file',
dest='output_file',
action='store',
type=str,
help='Output file')
parser.add_argument('--pid',
dest='pid',
action='store',
type=str,
help='Sercomm PID')
args = parser.parse_args()
if ((not args.input_file) or
(not args.output_file) or
(not args.pid)):
parser.print_help()
create_output(args)
main()