Advertisement
datacompboy

unpack ts38 fw

Apr 15th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. fw=${1?Please give firmware bin as argument}
  2. if [ -e $fw.unpack ]; then
  3.     echo "Already exists: $fw.unpack"
  4.     exit 1
  5. fi
  6. # Check format
  7. if [ "$(dd if=$1 bs=8 count=1 2>/dev/null)" != "FIRMWARE" ]; then
  8.     echo "Wrong file"
  9.     exit 1
  10. fi
  11. mkdir -p $fw.unpack
  12. dd if=$1 of=$fw.unpack/00header bs=1556 count=1 2>/dev/null
  13. ksize=$(dd if=$1 bs=1 count=4 skip=24 2>/dev/null | perl -e 'print unpack("l", <>);')
  14. dd if=$1 of=$fw.unpack/01kernel bs=1 skip=1556 count=$ksize 2>/dev/null
  15. foff=$(dd if=$1 bs=1 count=4 skip=288 2>/dev/null | perl -e 'print unpack("l", <>);')
  16. echo foff=$foff
  17. dd if=$1 of=$fw.unpack/02cramfs bs=$foff skip=1 #2>/dev/null
  18. cd $fw.unpack
  19. fakeroot -s .fakeroot cramfsck -x root 02cramfs
  20. echo "Done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement