forked from muXxer/blue-app-iota-loader-alpine
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from muXxer/master
Added Ledger Blue
- Loading branch information
Showing
6 changed files
with
168 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os, sys | ||
|
||
python_cmd = "python3" | ||
target_id = 0x31010004 | ||
file_name = "/root/iota-ledger/download/app.hex" | ||
data_size = 0x00000000 # `cat debug/app.map |grep _nvram_data_size | tr -s ' ' | cut -f2 -d' '` | ||
icon_hex = "0456572200585e34005e623f00636748006a6e510074775e007f806c008a8c79009a9a8b00a9a89e00b4b3aa00c1c0b800d0d1ce00e2e4e200edf0ee00f9f9f900ffffffffffdf8b0400000000000000000070cafdffffffffffffffffffad050000000000000000000000000060eaffffffffffffff8d0000000000000000000000000000000000e9ffffffffffbf00000000000000000000000000000000000000fcffffffff0a00000000000000000000000000000000000000b0ffffffcf000000000000000000000000000000000000000000fcffff0d000000000000000000000000000000000000000000e0ffff090000000000000000000000000000c91a0000000000a0ffdf000000000000000000000000000090ffbf000000000000feaf0000000000000000000000000000c0ffdf000000000000fc5f000000000000000011000000000090ffbf000000000000f70d000000000030ab51ee668c00000000c91a000000000000e00b0000000000b0ff89ffb9cfc60700000000000000000000c0080000000000b0ff19bb527cfa8a0500a26b001100000000b005000000000040ab0120010081e50c00fbdf71dd080000008000000000000000b608e80cb80480c804fcffc2ff1e0000000000000000000010fd5efb2efd891bc503e7bfc0ff1d000000000000000070dd18fe5fc509c8c56f1700200450cc070000000000000000d0ff0db70800000050978f00a5070000000000000000000000c0ff0d000000a50632302910fd5ea09d00000000000000000060cc0710ec0bfc2ded360410fe5fe5ff63490000000000000000208861ff3efb2cedd71e00c709d2dfe5df0100000000000000c0ff2afd1c610254c11c6018005059f7ef0200000000000000e0ff0d51000000000000e59f10bb02b18d0000000000007028c0ff0a0000a107000000e59f80ff095600000000000000fbdf1378000014f70c000040661840dd86ef06000000000020feff09009057ae91060000d08f00982290ff07000000000020feff0800c01a6b808d0000c17e40fe07328900000000000000e8cf0100a5338cc0cf00c02d0256cb42ee040000000000000020020000f978cf505a00c11d20de0050ee05000000000000000000000071015700c25d10328cab30bc55000000000000000000000000f909ea08f7af00309d1068ce00000000000000000000000000d808fc0bc25d0000208baf2500000000000000000000000000601883120080cd03506d380000000000000000000000000000d09f40dd06c0ff090001000000000000000008000000000000c07e80ff09b0ef16570000000000000000600a000000000000008118bb220157c0ff0800000000000000800c00000000000000f96f00fa4d00f5ff0c60170000000000b00e00000000000000f85e00fd8f00d1ff09fbcf0100000000d07f0000000000000070567aea4d94478950ffff0700000000f5bf0000000000000000d1ef3421fd8f0040feff0700000000faef0000000000000000e2ff0560ffbf0000eabf0000000000fdff0900000000000000809c0010fd8f000030040000000090ffff0e000000000000000000000082060000000000000000e0ffffcf000000000000000000000000000000000000000000fcffffff0b00000000000000000000000000000000000000b0ffffffffcf00000000000000000000000000000000000000fcffffffffff8e0000000000000000000000000000000000d8ffffffffffffffad040000000000000000000000000040daffffffffffffffffffdf8b0400000000000000000050b8fdffffffffff" # python $(BOLOS_SDK)/icon.py $(ICONNAME) hexbitmaponly | ||
cmd_load_app = "-m ledgerblue.loadApp --path \"44'/4218'\" --path \"44'/01'\" --appFlags 0x40 --tlv --targetId 0x%08X --delete --fileName %s --appName \"IOTA\" --appVersion 0.5.0 --dataSize 0x%08X --icon %s" % (target_id, file_name, data_size, icon_hex) | ||
|
||
exit_code = 1 | ||
try: | ||
exit_code = os.system("%s %s" % (python_cmd, cmd_load_app)) | ||
if exit_code != 0: # muXxer: Otherwise it returned 256, which was recognized as 0 in the shell | ||
exit_code = 3 | ||
except: | ||
pass | ||
sys.exit(exit_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
apk update | ||
apk add --no-cache ncurses gnupg curl python3 python3-dev gcc git autoconf pkgconf musl-dev libffi-dev automake libtool libusb-dev eudev-dev linux-headers zlib-dev jpeg-dev | ||
gpg --import public.asc | ||
python3 -m ensurepip | ||
pip3 install --upgrade pip setuptools wheel | ||
pip3 install git+https://github.com/LedgerHQ/blue-loader-python.git | ||
cp iota_loader_blue /etc/init.d/ | ||
rc-update add iota_loader_blue | ||
pip3 uninstall pillow | ||
apk del --purge python3-dev gcc git autoconf pkgconf musl-dev libffi-dev automake libtool eudev-dev linux-headers zlib-dev jpeg-dev | ||
rm -r /root/.cache | ||
rm -r /tmp/* | ||
dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k ; rm /var/tmp/bigemptyfile | ||
history -c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/sbin/openrc-run | ||
# Copyright (c) 2018 muXxer | ||
|
||
## Functions | ||
_bold=$(tput bold) | ||
_reset=$(tput sgr0) | ||
|
||
_red=$(tput setaf 1) | ||
_green=$(tput setaf 2) | ||
_yellow=$(tput setaf 3) | ||
|
||
function print_ok { printf "${_bold}${_green}%s${_reset}\n" "$@"; } | ||
function print_err { printf "${_bold}${_red}%s${_reset}\n" "$@"; } | ||
function print_warn { printf "${_bold}${_yellow}%s${_reset}\n" "$@"; } | ||
|
||
depend() | ||
{ | ||
after networking sshd | ||
} | ||
|
||
start() | ||
{ | ||
ebegin "Downloading IOTA-Ledger App..." | ||
|
||
echo "" | ||
print_warn "Please read our documentation carefully at https://github.com/IOTA-Ledger/blue-app-iota/" | ||
|
||
echo "" | ||
print_ok "Downloading latest compiled binary from https://github.com/IOTA-Ledger/blue-app-iota/releases..." | ||
echo "" | ||
|
||
mkdir -p /root/iota-ledger/download/ | ||
cd /root/iota-ledger/download/ | ||
latest_file=`curl -s https://api.github.com/repos/IOTA-Ledger/blue-app-iota/releases | grep browser_download_url | grep blue-app | grep .zip | head -n 1 | cut -d '"' -f 4` | ||
retVal=$? | ||
if [ $retVal -ne 0 ]; then | ||
echo "" | ||
print_err "No compiled binary found in the GitHub repository! Do you have a working internet connection? Rebooting..." | ||
rm -R /root/iota-ledger/download/ | ||
sleep 10 | ||
reboot | ||
eend $retVal | ||
fi | ||
|
||
curl -L $latest_file -O | ||
retVal=$? | ||
if [ $retVal -ne 0 ]; then | ||
echo "" | ||
print_err "Downloading the latest compiled binary from GitHub failed! Do you have a working internet connection? Rebooting..." | ||
rm -R /root/iota-ledger/download/ | ||
sleep 10 | ||
reboot | ||
eend $retVal | ||
fi | ||
|
||
file_name=`echo $latest_file | rev | cut -d '/' -f 1 | rev` | ||
echo "" | ||
print_ok "Downloaded:" | ||
print_ok ' File name = "'${file_name}'"' | ||
|
||
echo "" | ||
#echo "Unzipping the file and comparing the checksum..." | ||
print_ok "Unzipping the file and verifying the digital signature..." | ||
echo "" | ||
unzip ${file_name} | ||
echo "" | ||
#sha256sum -c app.hex.sha256 | ||
gpg --verify app.hex.asc | ||
retVal=$? | ||
if [ $retVal -ne 0 ]; then | ||
echo "" | ||
#echo "Checksum missmatch! Something went wrong! Please try again! Rebooting..." | ||
print_err "Digital signature not valid! Something went wrong! Please try again! Rebooting..." | ||
rm -R /root/iota-ledger/download/ | ||
sleep 10 | ||
reboot | ||
eend $retVal | ||
fi | ||
echo "" | ||
print_ok "File unzipped and digital signature valid!" | ||
|
||
echo "" | ||
print_warn "Plugin your Ledger Blue now and forward it in VirtualBox! You have 5 minutes to do this." | ||
print_warn "Searching for Ledger Blue..." | ||
echo "" | ||
|
||
time_ms=0 | ||
while [ $time_ms -le 300000 ] | ||
do | ||
if [ -e /dev/hidraw1 ]; then | ||
break | ||
fi | ||
|
||
usleep 500000 | ||
time_ms=$(( $time_ms + 500 )) | ||
done | ||
|
||
cd /root/iota-ledger/ | ||
python3 download_app_blue.py | ||
retVal=$? | ||
rm -R /root/iota-ledger/download/ | ||
if [ $retVal -ne 0 ]; then | ||
echo "" | ||
if [ $retVal -eq 2 ]; then | ||
print_err "Ledger Blue Firmware is too old! Please update your Ledger Blue Firmware and try again! Shutting down VM..." | ||
sleep 5 | ||
poweroff | ||
else | ||
print_err "Something went wrong! Please try again! Rebooting..." | ||
sleep 5 | ||
reboot | ||
fi | ||
else | ||
echo "" | ||
print_ok "IOTA App installed successfully! Shutting down VM..." | ||
sleep 3 | ||
poweroff | ||
fi | ||
eend 0 | ||
} | ||
|
||
stop() | ||
{ | ||
ebegin "" | ||
eend 0 | ||
} | ||
|