My favorites | Sign in
Project Logo
                
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#
# fwcrack.sh - script to use a brute force method to determine the
# contents of a binary firmware upgrade file for an embedded linux
# system (such as a router, internet radio etc.)
#
# The script first scans through the firmware file to find a mountable
# filesystem.
# I'll decide what to do when that works...
#
#
# 23Aug2009 GJ ORIGINAL VERSION
#
###########################################################################
#
# Copyright (C) 2009 Graham Jones
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

tmpmnt=tmpmnt
tstimg=test.img

mnttypes="ext2 ext3 msdos reiserfs vfat squashfs cramfs rootfs"

fs_start=0
fs_end=0

case $# in
1)
fname=$1
echo "fwcrack: Using specified file name: "$host
;;
*)
echo 'Usage fwcrack.sh filename'
exit -1
;;
esac

if [ ! -d $tmpmnt ]; then
echo "creating directory "$tmpmnt
mkdir $tmpmnt
fi

filesize=$(du --apparent-size --block-size=1 $1 | cut -f 1)
echo "filesize="$filesize


#start=786000
start=0
found=0
while [ $found -eq 0 ]
do
echo start=$start
# dd "if=$fname" "of=$tstimg" bs=1 skip=$start
# ls -la $tstimg
for mnt in $mnttypes
do
mount -o loop,offset=$start -t $mnt $tstimg $tmpmnt 2> /dev/null
retval=$?
# echo "mount "$mnt" ="$retval
if [ $retval -eq 32 ]; then
umount $tmpmnt 2> /dev/null
else
echo "*********MOUNT WORKED - Start=$start, mnt=$mnt ********"
echo "mounted using mount -o loop,offset=$start -t $mnt $tstimg $tmpmnt"
found=1
exit
fi
done

if [ $start -eq $filesize ]; then
echo "*************got to end********************"
found=1
fi
start=$[ $start + 1 ]
done


Show details Hide details

Change log

r35 by grahamjones139 on Sep 28, 2009   Diff
Early draft
Go to: 
Project members, sign in to write a code review

Older revisions

r7 by grahamjones139 on Aug 23, 2009   Diff
Added fwcrack script to look for
mountable filesystems in firmware
binary files.

All revisions of this file

File info

Size: 2286 bytes, 90 lines

File properties

svn:executable
*
Hosted by Google Code