1
1
#! /bin/bash
2
2
3
- # set -e
3
+ set -e
4
4
APPVM_NAME=" haveno"
5
- TPL_ROOT=" qvm-run --pass-io -u root -- $APPVM_NAME "
6
5
7
6
# Options
8
7
clean=1
@@ -45,8 +44,7 @@ while getopts 'csauhn:r:f:' flag; do
45
44
exit 1
46
45
fi
47
46
;;
48
- n) APPVM_NAME=${OPTARG}
49
- TPL_ROOT=" qvm-run --pass-io -u root -- $APPVM_NAME " ;;
47
+ n) APPVM_NAME=${OPTARG} ;;
50
48
* ) print_usage
51
49
exit 1 ;;
52
50
esac
@@ -58,6 +56,8 @@ if ! [[ $unoffical -eq 0 ]] ; then
58
56
log " WARNING : you are installing the main haveno-dex repo but have no enabled build from source, as such this setting has been automatically toggled"
59
57
fi
60
58
59
+ TPL_ROOT=" qvm-run --pass-io -u root -- $APPVM_NAME "
60
+
61
61
if [ " $( hostname) " != " dom0" ]; then
62
62
echo " This script must be ran on dom0 to function"
63
63
exit 1;
@@ -80,13 +80,14 @@ log "cloning the template"
80
80
qvm-clone debian-12-minimal " $APPVM_NAME "
81
81
log " Installing necessary packages on template"
82
82
$TPL_ROOT " apt-get update && apt-get full-upgrade -y"
83
- $TPL_ROOT " apt-get install --no-install-recommends qubes-core-agent-networking qubes-core-agent-nautilus nautilus zenity curl -y && poweroff" || true
83
+ $TPL_ROOT " apt-get install --no-install-recommends qubes-core-agent-networking qubes-core-agent-passwordless-root qubes-core-agent- nautilus nautilus zenity curl -y && poweroff" || true
84
84
log " Setting $APPVM_NAME network to sys-whonix"
85
85
qvm-prefs $APPVM_NAME netvm sys-whonix
86
86
87
87
# prevents qrexec error by sleeping
88
88
sleep 5
89
89
SYS_WHONIX_IP=" $( qvm-prefs sys-whonix ip) "
90
+
90
91
$TPL_ROOT " echo 'nameserver $SYS_WHONIX_IP ' > /etc/resolv.conf"
91
92
92
93
log " Testing for successful sys-whonix config"
97
98
log " sys-whonix connection success, traffic is being routed through tor"
98
99
fi
99
100
101
+ log " Cleaning any previous haveno hidden service on sys-whonix"
102
+ qvm-run --pass-io -u root -- sys-whonix " rm -rf /var/lib/tor/haveno_service"
103
+ log " Creating a hidden service for haveno on whonix gateway"
104
+ read -p " Warning by default 50_user.conf on sys-whonix will be overwritten (baseline is empty
105
+ Enter any character to append instead (may require cleaning if you reinstall haveno later" -n 1 cont
106
+ if ! [[ " $key " = " " ]]; then
107
+ log " Appending to 50_user.conf instead of overwriting"
108
+ out=" >>"
109
+ else
110
+ log " Overwriting 50_user.conf"
111
+ out=" >"
112
+ fi
113
+ qvm-run --pass-io -u root -- sys-whonix " echo -e 'ConnectionPadding 1\nHiddenServiceDir /var/lib/tor/haveno_service/\nHiddenServicePort 9999 $( qvm-prefs $APPVM_NAME ip) :9999' $out /usr/local/etc/torrc.d/50_user.conf && service tor@default reload"
114
+
115
+ log " Open port 9999 on $APPVM_NAME to allow incoming peer data"
116
+ $TPL_ROOT " echo -e 'nft add rule ip qubes input tcp dport 9999 counter accept\necho nameserver $SYS_WHONIX_IP > /etc/resolv.conf' > /rw/config/rc.local"
117
+
118
+ sleep 1
119
+ SERVICE=" $( qvm-run --pass-io -u root -- sys-whonix ' cat /var/lib/tor/haveno_service/hostname' ) "
120
+
121
+ $TPL_ROOT " echo $SERVICE > /root/haveno-service-address"
100
122
101
123
version=" $( $TPL_ROOT curl -Ls -o /dev/null -w %{url_effective} $HAVENO_REPO /releases/latest) "
102
124
version=${version##*/ }
103
125
104
126
if [[ $from_source -eq 1 ]]; then
105
127
log " Downloading haveno release version $version "
106
- $TPL_ROOT " curl -Ls --remote-name-all $HAVENO_REPO /releases/download/$version /{$TARGET_DEB ,$TARGET_DEB .sig,$version -hashes.txt}"
128
+ $TPL_ROOT " curl -L --remote-name-all $HAVENO_REPO /releases/download/$version /{$TARGET_DEB ,$TARGET_DEB .sig,$version -hashes.txt}"
107
129
read -p " Enter url to verify signatures or anything else to skip:" key
108
130
if [[ $key =~ $regex ]]; then
109
131
$TPL_ROOT " apt-get install --no-install-recommends gnupg2 -y"
@@ -114,18 +136,18 @@ if [[ $from_source -eq 1 ]]; then
114
136
log " Signature invalid, exiting"
115
137
exit 1;
116
138
fi
117
- fi
118
139
119
140
log " Verifying SHA-512"
120
141
release_sum=$( $TPL_ROOT grep -A 1 " $TARGET_DEB " $version -hashes.txt | tail -n1 | tr -d ' \n\r' )
121
142
log " sha512sum of $TARGET_DEB according to release: $release_sum "
122
143
formated=" $release_sum $TARGET_DEB "
123
144
check=$( $TPL_ROOT " echo $formated | sha512sum -c" )
124
- if [[ " $check " =~ " OK" ]]; then
125
- log " sha512sums match, continuing"
126
- else
127
- log " sha512sums don't match, exiting"
128
- exit 1;
145
+ if [[ " $check " =~ " OK" ]]; then
146
+ log " sha512sums match, continuing"
147
+ else
148
+ log " sha512sums don't match, exiting"
149
+ exit 1;
150
+ fi
129
151
fi
130
152
# xdg-utils workaround
131
153
$TPL_ROOT " mkdir /usr/share/desktop-directories/"
@@ -138,14 +160,28 @@ if [[ $from_source -eq 1 ]]; then
138
160
patched_app_entry=" [Desktop Entry]
139
161
Name=Haveno
140
162
Comment=Haveno through sys-whonix
141
- Exec=/usr/local/sbin /Haveno
163
+ Exec=sudo /bin /Haveno
142
164
Icon=/opt/haveno/lib/Haveno.png
143
165
Terminal=false
144
166
Type=Application
145
167
Categories=Network
146
168
MimeType="
147
- $TPL_ROOT " echo -e '#\x21/bin/sh\n\n/ opt/haveno/bin/Haveno --useTorForXmr=OFF --torControlPort=9051 --torControlHost= $SYS_WHONIX_IP ' > /usr/local/sbin/ Haveno && chmod +x /usr/local/sbin/ Haveno && chmod u+s /usr/local/sbin /Haveno"
169
+ $TPL_ROOT " echo -e '#\x21/bin/sh\n\n#Proxying to gateway (anon-ws-disable-stacked-tor)\nsocat TCP-LISTEN:9050,fork,bind=127.0.0.1 TCP: $SYS_WHONIX_IP :9050 &\nPID=\x24\x21\nSERVICE=\x24\x28cat /root/haveno-service-address\x29\n\n/ opt/haveno/bin/Haveno --useTorForXmr=OFF --nodePort=9999 --hiddenServiceAddress=\x24SERVICE\nkill \x24PID ' > /bin/ Haveno && chmod +x /bin/ Haveno && chmod u+s /bin /Haveno"
148
170
171
+ elif [[ $from_source -eq 0 ]]; then
172
+ log " Installing required packages for build"
173
+ $TPL_ROOT " apt-get install --no-install-recommends make wget git zip unzip libxtst6 qubes-core-agent-passwordless-root -y"
174
+ log " Installing jdk 21"
175
+ $TPL_ROOT " curl -s https://get.sdkman.io | bash"
176
+ $TPL_ROOT " source /root/.sdkman/bin/sdkman-init.sh && sdk install java 21.0.2.fx-librca"
177
+ log " Checking out haveno repo"
178
+ CODE_DIR=" $( basename $HAVENO_REPO ) "
179
+ $TPL_ROOT " git clone $HAVENO_REPO "
180
+ $TPL_ROOT " source ~/.sdkman/bin/sdkman-init.sh && cd $CODE_DIR && git checkout master"
181
+ log " Making binary"
182
+ $TPL_ROOT " source ~/.sdkman/bin/sdkman-init.sh && cd $CODE_DIR && make skip-tests"
183
+ log " Compilation successful, creating a script to run compiled binary securly"
184
+ $TPL_ROOT " echo -e '#\x21/bin/sh\n\n#Proxying to gateway (anon-ws-disable-stacked-tor)\nsocat TCP-LISTEN:9050,fork,bind=127.0.0.1 TCP:$SYS_WHONIX_IP :9050 &\nPID=\x24\x21\nSERVICE=\x24\x28cat /root/haveno-service-address\x29\n\nsource /root/.sdkman/bin/sdkman-init.sh\n/root/$CODE_DIR /haveno-desktop --useTorForXmr=OFF --nodePort=9999 --hiddenServiceAddress=\x24SERVICE\nkill \x24PID' > /bin/Haveno && chmod +x /bin/Haveno && chmod u+s /bin/Haveno"
149
185
150
186
elif [[ $from_source -eq 0 ]]; then
151
187
log " Installing required packages for build"
@@ -160,13 +196,13 @@ elif [[ $from_source -eq 0 ]]; then
160
196
log " Making binary"
161
197
$TPL_ROOT " source ~/.sdkman/bin/sdkman-init.sh && cd $CODE_DIR && make skip-tests"
162
198
log " Compilation successful, creating a script to run compiled binary securly"
163
- $TPL_ROOT " echo -e '#\x21/bin/bash\nsource /root/.sdkman/bin/sdkman-init.sh\n/root/$CODE_DIR /haveno-desktop --torControlPort=9051 --useTorForXmr=OFF --torControlHost= $SYS_WHONIX_IP ' > /usr/local/ sbin/Haveno && chmod +x /usr/local/ sbin/Haveno && chmod u+s /usr/local /sbin/Haveno"
199
+ $TPL_ROOT " echo -e '#\x21/bin/bash\nsource /root/.sdkman/bin/sdkman-init.sh\n/root/$CODE_DIR /haveno-desktop --nodePort=9999 --useTorForXmr=OFF --hiddenServiceAddress= $SERVICE ' > /usr/sbin/Haveno && chmod +x /usr/sbin/Haveno && chmod u+s /usr/sbin/Haveno"
164
200
# Fix icon permissions
165
201
$TPL_ROOT " cp '/root/$CODE_DIR /desktop/package/linux/haveno.png' /opt/haveno.png && chmod 644 /opt/haveno.png"
166
202
patched_app_entry=" [Desktop Entry]
167
203
Name=Haveno
168
204
Comment=Haveno through sys-whonix
169
- Exec=sudo /usr/local/ sbin/Haveno
205
+ Exec=sudo /usr/sbin/Haveno
170
206
Icon=/opt/haveno.png
171
207
Terminal=false
172
208
Type=Application
@@ -192,30 +228,17 @@ else
192
228
# Remove unneeded packages
193
229
log " Removing unneeded packages to lessen attack surface"
194
230
if [ $from_source -eq 0 ]; then
195
- $TPL_ROOT " apt-get purge git wget make zip unzip curl -y"
231
+ $TPL_ROOT " apt purge git wget make zip unzip curl -y"
196
232
else
197
- $TPL_ROOT " apt-get purge curl unzip gnupg2 -y"
233
+ $TPL_ROOT " apt purge curl unzip gnupg2 -y"
198
234
fi
199
235
# Whonix-gateway hardening
200
- log " Hardening whonix-gateway template"
201
- qvm-run --pass-io -u root -- whonix-gateway-17 " echo -e 'Sandbox 1\nConnectionPadding 1\n' > /usr/local/etc/torrc.d/50_user.conf"
202
236
log " Hardening Completed"
203
237
log " Remeber technical controls are only part of the battle, robust security is reliant on how you utilize the system"
204
238
fi
205
239
206
- log " Enabling onion grater config on sys-whonix"
207
- if [[ " $( qvm-run -u root --pass-io -- whonix-gateway-17 ' sudo onion-grater-add 40_haveno' ) " =~ " OK" ]]; then
208
- log " Succesfully configured grater on sys-whonix"
209
- else
210
- log " Failed to configure grater on sys-whonix, updating whonix gateway template and trying again"
211
- qubes-vm-update -r --targets whonix-gateway-17
212
- if [[ " $( qvm-run -u root --pass-io -- whonix-gateway-17 ' sudo onion-grater-add 40_haveno' ) " =~ " OK" ]]; then
213
- log " Succeeded in configuring onion grater"
214
- else
215
- log " Failed for unkown reason, exiting"
216
- exit 1;
217
- fi
218
- fi
240
+
241
+
219
242
log " Restarting sys-whonix and $APPVM_NAME "
220
243
qvm-shutdown --wait $APPVM_NAME
221
244
qvm-shutdown --wait sys-whonix
0 commit comments