forked from storoj/idevice-packet-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathioslog2html.awk
59 lines (45 loc) · 1.36 KB
/
ioslog2html.awk
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
57
58
59
BEGIN {
hex = ""
system("cat header.html")
}
{
if ($1 == "<" || $1 == ">") {
print "<div class=\"packet\">"
print " <p class=\"title"
if ($1 == ">") {
print " to-device\">TO DEVICE: "
} else {
print " from-device\">FROM DEVICE: "
}
print "<span>"$0"</span></p>"
print "<div class=\"packet-contents\">"
} else if ($0 == "--") {
tmp_file = "/tmp/hex.log"
bin_file = tmp_file".bin"
# copy hex contents to tmp_file
print hex > tmp_file
# without closing will append to file
close(tmp_file)
# convert hex to binary
# to look for plists inside
system("rm -f "bin_file)
system("xxd -r -p "tmp_file" "bin_file)
# look for plists
system("/bin/bash prettify.sh "bin_file)
# system("rm "bin_file)
# close "packet-contents" div
print "</div>"
# close "packet" class dic
print "</div>"
hex = ""
} else {
# xxd has mad bug that causes curruption of binary file
# so we have to remove right part with plain-text
# http://www.mail-archive.com/[email protected]/msg747054.html
split($0, splitted, " ")
hex = hex""splitted[1]"\n"
}
}
END {
system("cat footer.html")
}