zefie

PSFW PUP Web2Disc

Sep 21st, 2021
886
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. if [ -z "$1" ] || [ -z "$2" ]; then
  3.     echo "Usage: ${0} [PS3|PS4|PS5] PUPFILE"
  4.     echo "Example: ${0} PS4 PS4UPDATE.PUP"
  5.     exit 1;
  6. fi
  7. PSSYS="$(echo "${1}" | tr '[:lower:]' '[:upper:]')"
  8. PUPFILE="${2}"
  9.  
  10. if [ ! -f "${PUPFILE}" ]; then
  11.     echo "${PUPFILE} not found."
  12.     exit 1;
  13. fi
  14.  
  15. case "${PSSYS}" in
  16.     PS3)
  17.         DEST_SIZE=256
  18.         ;;
  19.     PS4)
  20.         DEST_SIZE=1024
  21.         ;;
  22.     PS5)
  23.         DEST_SIZE=2048
  24.         ;;
  25.     *)
  26.         echo "Unknown system: ${PSSYS}"
  27.         exit 1;
  28.         ;;
  29. esac
  30.  
  31. ZERO_FILE_SIZE=$(((DEST_SIZE * 1024 * 1024) - $(ls -l ${PUPFILE} | cut -d' ' -f5)))
  32. echo "Need to pad ${ZERO_FILE_SIZE} null bytes (${PSSYS} Mode)..."
  33.  
  34. echo -n "Searching for optimal blocksize... "
  35.  
  36. # try larger blocksizes
  37. BLOCKSIZE=${ZERO_FILE_SIZE}
  38. ZERO_FILE_MULTIPLIER=1
  39.  
  40. #while (( $ZERO_FILE_SIZE % $BLOCKSIZE != 0 )); do
  41. #   ((BLOCKSIZE--))
  42. #done;
  43. #ZERO_FILE_MULTIPLIER=$(($ZERO_FILE_SIZE / $BLOCKSIZE))
  44.  
  45. #echo "${BLOCKSIZE} bytes."
  46. TMPFILE="${PUPFILE}.TMP"
  47. echo "Creating null file..."
  48. dd if=/dev/zero of=${TMPFILE} bs=${BLOCKSIZE} count=${ZERO_FILE_MULTIPLIER} 2>/dev/null
  49. echo "Merging firmware and null file..."
  50. cat $PUPFILE $TMPFILE > "${PUPFILE}.disc"
  51. rm ${TMPFILE}
  52. echo "Done."
  53. echo "-----------------------------------------------"
  54. md5sum "${PUPFILE}.disc"
  55.  
RAW Paste Data