Skip to content

Instantly share code, notes, and snippets.

@faveoled
Last active January 11, 2023 11:17
Show Gist options
  • Select an option

  • Save faveoled/83cffdcba001ccd1185b00ca9ecd971e to your computer and use it in GitHub Desktop.

Select an option

Save faveoled/83cffdcba001ccd1185b00ca9ecd971e to your computer and use it in GitHub Desktop.
Unpack AppImage without root rights and AppImage execution
#!/bin/bash
# usage: ./unpack-appimage.sh <appimage_file.AppImage>
APP_IMAGE=$(readlink -f $1)
APP_IMAGE_FILE=$(basename ${APP_IMAGE})
APP_DIR=$(dirname $APP_IMAGE)
APP_IMAGE=$(readlink -f $1)
ELFSIZE=$(readelf -h $APP_IMAGE)
START_OF_SECTION=$(echo $ELFSIZE | grep -oP "(?<=Start of section headers: )[0-9]+")
SECTION_SIZE=$(echo $ELFSIZE | grep -oP "(?<=Size of section headers: )[0-9]+")
SECTION_NO=$(echo $ELFSIZE | grep -oP "(?<=Number of section headers: )[0-9]+")
APPIMG_OFFSET=$(( $START_OF_SECTION + $SECTION_SIZE * $SECTION_NO ))
unsquashfs -offset ${APPIMG_OFFSET} -dest ${APP_DIR}/squashfs-root ${APP_IMAGE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment