代码拉取完成,页面将自动刷新
#!/bin/bash
# Script to attempt to extract files from a SquashFS image using all of the available unsquashfs utilities in FMK until one is successful.
#
# Craig Heffner
# 27 August 2011
IMG="$1"
DIR="$2"
ROOT="./src"
SUBDIRS="squashfs-2.1-r2 \
squashfs-3.0 \
squashfs-3.0-lzma-damn-small-variant \
others/squashfs-2.0-nb4 \
others/squashfs-3.0-e2100 \
others/squashfs-3.2-r2 \
others/squashfs-3.2-r2-lzma \
others/squashfs-3.2-r2-lzma/squashfs3.2-r2/squashfs-tools \
others/squashfs-3.2-r2-hg612-lzma \
others/squashfs-3.2-r2-wnr1000 \
others/squashfs-3.2-r2-rtn12 \
others/squashfs-3.3 \
others/squashfs-3.3-lzma/squashfs3.3/squashfs-tools \
others/squashfs-3.3-grml-lzma/squashfs3.3/squashfs-tools \
others/squashfs-3.4-cisco \
others/squashfs-3.4-nb4 \
others/squashfs-4.2-official \
others/squashfs-4.2 \
others/squashfs-4.0-lzma \
others/squashfs-4.0-realtek \
others/squashfs-hg55x-bin"
TIMEOUT="15"
MKFS=""
DEST=""
function wait_for_complete()
{
I=0
PNAME="$1"
while [ $I -lt $TIMEOUT ]
do
sleep 1
if [ "$(pgrep $PNAME)" == "" ]
then
break
fi
((I=$I+1))
done
if [ "$I" == "$TIMEOUT" ]
then
kill -9 $(pgrep $PNAME) 2>/dev/null
fi
}
if [ "$IMG" == "" ] || [ "$IMG" == "-h" ]
then
echo "Usage: $0 <squashfs image> [output directory]"
exit 1
fi
if [ "$DIR" == "" ]
then
BDIR="./squashfs-root"
DIR=$BDIR
I=1
while [ -e $DIR ]
do
DIR=$BDIR-$I
((I=$I+1))
done
fi
IMG=$(readlink -f $IMG)
DIR=$(readlink -f $DIR)
# Make sure we're operating out of the FMK directory
cd $(dirname $(readlink -f $0))
DEST="-dest $DIR"
MAJOR=$(./src/binwalk -m ./src/binwalk-*/src/magic.binwalk -l 1 "$IMG" | head -4 | tail -1 | sed -e 's/.*version //' | cut -d'.' -f1)
echo -e "Attempting to extract SquashFS $MAJOR.X file system...\n"
for SUBDIR in $SUBDIRS
do
if [ "$(echo $SUBDIR | grep "$MAJOR\.")" == "" ]
then
echo "Skipping $SUBDIR (wrong version)..."
continue
fi
unsquashfs="$ROOT/$SUBDIR/unsquashfs"
mksquashfs="$ROOT/$SUBDIR/mksquashfs"
if [ -e $unsquashfs ]
then
echo -ne "\nTrying $unsquashfs... "
$unsquashfs $DEST $IMG 2>/dev/null &
#sleep $TIMEOUT && kill $! 1>&2 >/dev/null
wait_for_complete $unsquashfs
if [ -d "$DIR" ]
then
if [ "$(ls $DIR)" != "" ]
then
# Most systems will have busybox - make sure it's a non-zero file size
if [ -e "$DIR/bin/sh" ]
then
if [ "$(wc -c $DIR/bin/sh | cut -d' ' -f1)" != "0" ]
then
MKFS="$mksquashfs"
fi
else
MKFS="$mksquashfs"
fi
fi
if [ "$MKFS" == "" ]
then
rm -rf "$DIR"
fi
fi
fi
if [ "$MKFS" == "" ] && [ -e $unsquashfs-lzma ]
then
echo -ne "\nTrying $unsquashfs-lzma... "
$unsquashfs-lzma $DEST $IMG 2>/dev/null &
#sleep $TIMEOUT && kill $! 1>&2 >/dev/null
wait_for_complete $unsquashfs-lzma
if [ -d "$DIR" ]
then
if [ "$(ls $DIR)" != "" ]
then
# Most systems will have busybox - make sure it's a non-zero file size
if [ -e "$DIR/bin/sh" ]
then
if [ "$(wc -c $DIR/bin/sh | cut -d' ' -f1)" != "0" ]
then
MKFS="$mksquashfs-lzma"
fi
else
MKFS="$mksquashfs-lzma"
fi
fi
if [ "$MKFS" == "" ]
then
rm -rf "$DIR"
fi
fi
fi
if [ "$MKFS" != "" ]
then
echo "File system sucessfully extracted!"
echo "MKFS=\"$MKFS\""
exit 0
fi
done
echo "File extraction failed!"
exit 1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。