-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathisXb360Hd
executable file
·65 lines (59 loc) · 2.32 KB
/
isXb360Hd
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
#!/usr/bin/bash
# ./isXb360Hd /dev/sda && echo OK || echo KO
# KO
# ./isXb360Hd /dev/loop0 && echo OK || echo KO
# OK
# ./isXb360Hd /dev/loop0 -v && echo OK || echo KO
# device: /dev/loop0
# serial number: 6VCT9Z2W
# firmware revision: 0002CE02
# model number: ST9250315AS
# size: 488397168 bytes
# xtaf at 0x10c080000: ok
# xtaf at 0x118eb0000: ok
# xtaf at 0x120eb0000: ok
# xtaf at 0x130eb0000: ok
# OK
# strict mode
set -eu
# usage function
function usage {
echo "usage: $( basename "$0" ) device [-v|--verbose]" > /dev/stderr
exit 2
}
# script parameters
[ "${1:-x}" == 'x' ] && usage
[ "${2:-x}" != 'x' ] && [ "${2:-x}" != '-v' ] && [ "${2:-x}" != '--verbose' ] && usage
[ "${3:-x}" != 'x' ] && usage
# checking the "Josh" signature at offet 0x800
if [ "$( dd status=none if="$1" bs=1 skip=2048 count=4 | tr '\0' '\n' )" == $'Josh' ]
then
# checking the PNG signature at offset 0x2204
if [ "$( dd status=none if="$1" bs=1 skip=8708 count=5 | tr '\0' '\n' )" == $'\x89PNG\x0d' ]
then
if [ "${2:-x}" != 'x' ]
then
# verbose mode
echo "device: "$1
# reading informations at offset 0x2000
data=$( dd status=none if="$1" bs=1 skip=8192 count=48 )
echo "serial number: "$( echo ${data::20} )
echo "firmware revision: "$( echo ${data:20:8} )
echo "model number: "$( echo ${data:28} )
echo "size: "$( blockdev --getsz "$1" )" bytes"
# checking the "XTAF" signature of the four known xtaf partitions
echo -n "xtaf at 0x10c080000: "
[ "$( dd status=none if="$1" bs=1 skip=$((0x10c080000)) count=4 | tr '\0' '\n' )" == $'XTAF' ] && echo ok || echo KO
echo -n "xtaf at 0x118eb0000: "
[ "$( dd status=none if="$1" bs=1 skip=$((0x118eb0000)) count=4 | tr '\0' '\n' )" == $'XTAF' ] && echo ok || echo KO
echo -n "xtaf at 0x120eb0000: "
[ "$( dd status=none if="$1" bs=1 skip=$((0x120eb0000)) count=4 | tr '\0' '\n' )" == $'XTAF' ] && echo ok || echo KO
echo -n "xtaf at 0x130eb0000: "
[ "$( dd status=none if="$1" bs=1 skip=$((0x130eb0000)) count=4 | tr '\0' '\n' )" == $'XTAF' ] && echo ok || echo KO
fi
# return device is Xbox 360 hard disk
exit 0
fi
fi
# return device is not Xbox 360 hard disk
exit 1