-
Notifications
You must be signed in to change notification settings - Fork 1
/
innodb_page_header.sh
executable file
·70 lines (62 loc) · 1.38 KB
/
innodb_page_header.sh
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
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Dump information from page header
# Print information about encryption
DIR="$( dirname "$0" )"
. ${DIR}/innodb_common.sh
FILE=$1
decode_encryption() {
PHY_SIZE=$1
OFFSET=0
case $PHY_SIZE in
65536)
OFFSET=41110
;;
32768)
OFFSET=20630
;;
16384)
OFFSET=10390
;;
8192)
OFFSET=5270
;;
4096)
OFFSET=2710
;;
2048)
OFFSET=1430
;;
1024)
OFFSET=790
;;
esac
if [ $OFFSET == 0 ]; then
echo "Invalid Page Size found. Cannot decode encryption information from Page 0"
return;
fi
echo "ENCRYPTION OFFSET : $OFFSET"
echo
echo "------ Encryption ------"
ENCRYPTION_KEY_MAGIC=$(xxd -p -s$OFFSET -l3 $FILE | xxd -r -p)
echo "ENCRYPTION_KEY_MAGIC: $ENCRYPTION_KEY_MAGIC"
OFFSET=$(($OFFSET + 3))
echo $OFFSET
MASTER_KEY_ID=$(xxd -b -s$OFFSET -l4 $FILE | awk '{print $2 $3 $4 $5}')
echo "MASTER_KEY_ID: $MASTER_KEY_ID ( $((2#$MASTER_KEY_ID)) )"
OFFSET=$(($OFFSET + 4))
SERVER_UUID=$(xxd -p -s$OFFSET -l36 $FILE | xxd -r -p | tr -d '\0')
echo "SERVER UUID: $SERVER_UUID"
echo "Key:"
OFFSET=$(($OFFSET + 36))
xxd -s$OFFSET -l32 $FILE
OFFSET=$(($OFFSET + 32))
echo "iv:"
xxd -s$OFFSET -l32 $FILE
}
echo "Reading FSP_FLAGS of ${FILE}"
SPACE_ID=$(od -An -j38 -D -N4 --endian=big $FILE)
echo "SPACE_ID of tablespace: $SPACE_ID"
echo
decode_page0_flags $FILE
print_decoded_flags
print_encryption