iWrench

Unpack embedded linux images

Jun 11th, 2021
670
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. clear
  3. cd "$(pwd)"
  4. echo $(pwd) > log.txt
  5. files=($(ls *.bin ))
  6. for i in ${files[@]}
  7. do
  8.     cp -a "$i" "$i.zip"
  9.     echo -n "PK" | dd of="$i.zip"   conv=notrunc
  10.     7z x -aoa -o"${i%.bin}" "$i.zip"; rm "$i.zip"
  11.     Filenames=$(ls ${i%.bin}/*.img)
  12.     for f in ${Filenames[@]}
  13.     do
  14.         clear
  15.         Path=$(echo "$f" | cut -d"/" -f1)/$(echo "$f" | cut -d"/" -f2 | cut -d"-" -f1)
  16.         7z x -aoa -o"$Path" $f
  17.         if ! [ -d "$Path" ]; then
  18.             rm $f
  19.         fi
  20.     done
  21. done
RAW Paste Data