Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full install fixes #436

Merged
merged 10 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions helpers/helpers_emba_dependency_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,14 @@ setup_unblob() {
if ! [[ -d "$HOME"/.cache ]]; then
mkdir "$HOME"/.cache
fi
cp -pr "$EXT_DIR"/unblob/root_cache/* "$HOME"/.cache/
if [[ "$IN_DOCKER" -eq 1 ]]; then
if [[ -d "$EXT_DIR"/unblob/root_cache ]]; then
cp -pr "$EXT_DIR"/unblob/root_cache/* "$HOME"/.cache/
else
echo -e "$RED""not ok""$NC"
DEP_EXIT=1
fi
fi
if [[ -e $(cat "$EXT_DIR"/unblob/unblob_path.cfg)/bin/"$UNBLOB_BIN" ]]; then
UNBLOB_PATH="$(cat "$EXT_DIR"/unblob/unblob_path.cfg)""/bin/"
export PATH=$PATH:"$UNBLOB_PATH"
Expand All @@ -215,17 +222,22 @@ setup_unblob() {
fi
print_output " ""sasquatch"" - \\c" "no_log"
if [[ -f /usr/local/bin/sasquatch_binwalk ]]; then
if [[ -L "$UNBLOB_PATH"/sasquatch ]]; then
rm "$UNBLOB_PATH"/sasquatch
fi
ln -s /usr/local/bin/sasquatch_binwalk "$UNBLOB_PATH"/sasquatch
echo -e "$GREEN""ok""$NC"
elif [[ -f /usr/local/bin/sasquatch_unblob ]]; then
if [[ -L "$UNBLOB_PATH"/sasquatch ]]; then
rm "$UNBLOB_PATH"/sasquatch
fi
ln -s /usr/local/bin/sasquatch_unblob "$UNBLOB_PATH"/sasquatch
echo -e "$ORANGE""warning""$NC"
DEP_EXIT=1
else
echo -e "$RED""not ok""$NC"
DEP_EXIT=1
fi

}

dependency_check()
Expand Down
6 changes: 5 additions & 1 deletion installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ if [[ "$IN_DOCKER" -eq 0 ]]; then
echo -e "\\n""$ORANGE""EMBA installation in default mode needs a minimum of 13Gig for the docker image""$NC"
echo -e "\\n""$ORANGE""Please free enough space on /var/lib/docker""$NC"
echo ""
df -h
df -h || true
echo ""
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
fi
Expand All @@ -214,6 +214,10 @@ if [[ $LIST_DEP -eq 0 ]] ; then
# the freetz installation is running as freetzuser and needs write access:
chown "$ORIG_USER":"$ORIG_GROUP" ./external
chmod 777 ./external
else
echo -e "\\n""$ORANGE""WARNING: external directory available: ./external""$NC"
echo -e "$ORANGE""Please remove it before proceeding ... exit now""$NC"
exit 1
fi

echo -e "\\n""$ORANGE""Update package lists.""$NC"
Expand Down
5 changes: 1 addition & 4 deletions installer/I120_cwe_checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ I120_cwe_checker() {
print_git_info "cwe-checker" "EMBA-support-repos/cwe_checker" "cwe_checker is a suite of checks to detect common bug classes such as use of dangerous functions and simple integer overflows."
echo -e "$ORANGE""cwe-checker will be downloaded.""$NC"
print_file_info "OpenJDK" "OpenJDK for cwe-checker" "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz" "external/jdk.tar.gz"
print_file_info "GHIDRA" "Ghidra for cwe-checker" "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.2_build/ghidra_10.1.2_PUBLIC_20220125.zip" "external/ghidra.zip"
print_file_info "GHIDRA" "Ghidra for cwe-checker" "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.5_build/ghidra_10.1.5_PUBLIC_20220726.zip" "external/ghidra.zip"

if [[ "$LIST_DEP" -eq 1 ]] || [[ $DOCKER_SETUP -eq 1 ]] ; then
Expand Down Expand Up @@ -77,7 +76,7 @@ I120_cwe_checker() {
mkdir ./external/cwe_checker 2>/dev/null
git clone https://github.com/EMBA-support-repos/cwe_checker.git external/cwe_checker
cd external/cwe_checker || ( echo "Could not install EMBA component cwe_checker" && exit 1 )
make all GHIDRA_PATH="$HOME_PATH""/external/ghidra/ghidra_10.1.2_PUBLIC"
make all GHIDRA_PATH="$HOME_PATH""/external/ghidra/ghidra_10.1.5_PUBLIC"
cd "$HOME_PATH" || ( echo "Could not install EMBA component cwe_checker" && exit 1 )

if [[ "$IN_DOCKER" -eq 1 ]]; then
Expand All @@ -87,9 +86,7 @@ I120_cwe_checker() {
# save .config as we remount /root with tempfs -> now we can restore it in the module
cp -pr /root/.config ./external/cwe_checker/
cp -pr /root/.local ./external/cwe_checker/
fi

if [[ "$IN_DOCKER" -eq 1 ]]; then
# cleanup
rm "$HOME"/.cargo -r -f || true
rm "$HOME"/.config -r -f || true
Expand Down
6 changes: 6 additions & 0 deletions installer/I199_default_tools_github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ I199_default_tools_github() {

# jchroot
echo -e "\\n""$ORANGE""$BOLD""Download and install jchroot""$NC"
if [[ -d "external/jchroot" ]]; then
rm -r external/jchroot
fi
git clone https://github.com/EMBA-support-repos/jchroot.git external/jchroot
cd ./external/jchroot/ || ( echo "Could not install EMBA component jchroot" && exit 1 )
make
if [[ -e ./jchroot ]] && [[ -e "/usr/sbin/jchroot" ]]; then
rm /usr/sbin/jchroot
fi
if [[ -e ./jchroot ]]; then
cp -r jchroot /usr/sbin/
fi
Expand Down
6 changes: 4 additions & 2 deletions installer/IP12_avm_freetz_ng_extract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ IP12_avm_freetz_ng_extract() {
rm external/execstack_0.0.20131005-1+b10_amd64.deb

if ! [[ -d external/freetz-ng ]]; then
mkdir external/freetz-ng
if [[ -d /tmp/freetz-ng ]]; then
rm -r /tmp/freetz-ng
fi

su - freetzuser -c "git clone https://github.com/Freetz-NG/freetz-ng.git /tmp/freetz-ng"
su - freetzuser -c "cd /tmp/freetz-ng/ && make allnoconfig"
# we currently running into an error that does not hinder us in using Freetz-NG
# sudo -u freetzuser make || true
su - freetzuser -c "cd /tmp/freetz-ng/ && make tools"
cd "$HOME_PATH" || ( echo "Could not install EMBA component Freetz-NG" && exit 1 )
mv /tmp/freetz-ng/* external/freetz-ng/
mv /tmp/freetz-ng external/
chown -R root:root external/freetz-ng
if [[ "$IN_DOCKER" -eq 1 ]]; then
# do some cleanup of the docker image
Expand Down
4 changes: 2 additions & 2 deletions installer/IP61_unblob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ IP61_unblob() {
echo
fi

echo -e "${GREEN}Backup unblob environment for read only docker container: $ORANGE$UNBLOB_PATH$NC"
echo "$UNBLOB_PATH" > external/unblob/unblob_path.cfg
if [[ -d "$HOME"/.cache ]]; then
if [[ -d "$HOME"/.cache ]] && [[ "$IN_DOCKER" -eq 1 ]]; then
echo -e "${GREEN}Backup unblob environment for read only docker container: $ORANGE$UNBLOB_PATH$NC"
cp -pr "$HOME"/.cache external/unblob/root_cache
rm -rf "$HOME"/.cache || true
fi
Expand Down
8 changes: 6 additions & 2 deletions modules/S115_usermode_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ S115_usermode_emulator() {
setup_chroot
else
print_output "[-] No chroot binary found ..."
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
return
fi

Expand Down Expand Up @@ -225,8 +226,11 @@ copy_firmware() {

setup_jchroot() {
export CHROOT="jchroot"
# OPTS see https://github.com/vincentbernat/jchroot#security-note
OPTS=(-U -u 0 -g 0 -M "0 $(id -u) 1" -G "0 $(id -g) 1")
export OPTS=()
if [[ "$IN_DOCKER" -eq 1 ]]; then
# OPTS see https://github.com/vincentbernat/jchroot#security-note
OPTS=(-U -u 0 -g 0 -M "0 $(id -u) 1" -G "0 $(id -g) 1")
fi
print_output "[*] Using ${ORANGE}jchroot${NC} for building more secure chroot environments"
}

Expand Down