HiveMinds / Collabora-Online

Sets up Collabora Online server with a single command through NextCloud. Ideally over Tor.
GNU Affero General Public License v3.0
0 stars 0 forks source link

Include torified android calendar app. #11

Closed a-t-0 closed 1 year ago

a-t-0 commented 1 year ago

Either

a-t-0 commented 1 year ago

This is exactly what the orbot app does.

To download the app from f-droid one:

  1. First installs the f-droid apk from f-droid.org.
  2. Next, in that f-droid app on the phone, one can go to: settings> (My Apps)> Repositories> (Enable) Guardian Project Official Releases.
  3. (Update the repositories with: `back> Updates> pull the window down to do an update of the repositories).
  4. Next, search in the market place search for: orbot and select the one that literally says: Orbot: Tor for Android. If that is not in there, verify you enabled the Guardian Project Official Releases and that you updated the fdroid market place/repositories.
  5. Install the Orbot app.
  6. Open the Orbot app.
  7. Enable "VPN Mode"
  8. Select "tor enabled apps" and choose which app you want to go over tor.
  9. Back in the main Orbot screen/window, press/hold "start" until you see a green onion.
  10. Now you can go to your app, e.g. Nextcloud and enter your https://some_onion.onion domain, to make the Nextcloud connect to your self-hosted Nextcloud server.

This is marvellous work by the Guardian Project I think. I am amazed by how well it works, and have not automated this yet through adb.

a-t-0 commented 1 year ago

For orbot, adding the nextcloud app resulted in adding the line:

    <string name="PrefTord">com.nextcloud.client|</string>

In file:

 /data/data/org.torproject.android/shared_prefs/org.torproject.android_preferences.xml

Yielding:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
    <boolean name="pref_connection_padding" value="false" />
    <boolean name="pref_reduced_circuit_padding" value="true" />
    <string name="pref_socks">9050</string>
    <string name="pref_dnsport">auto</string>
    <boolean name="pref_start_boot" value="true" />
    <boolean name="pref_reachable_addresses" value="false" />
    <boolean name="connect_first_time" value="false" />
    <string name="pref_or_nickname">OrbotRelay</string>
    <boolean name="pref_circuit_padding" value="true" />
    <boolean name="pref_reduced_connection_padding" value="true" />
    <boolean name="pref_enable_logging" value="false" />
    <string name="PrefTord">com.nextcloud.client|</string>
    <string name="pref_transport">auto</string>
    <int name="PREFS_DNS_PORT" value="5400" />
    <boolean name="pref_strict_nodes" value="false" />
    <boolean name="pref_isolate_dest" value="false" />
    <string name="pref_http">8118</string>
    <boolean name="pref_show_snowflake_proxy_msg" value="false" />
    <string name="pref_default_locale">en</string>
    <boolean name="pref_open_proxy_on_all_interfaces" value="false" />
    <boolean name="pref_disable_network" value="true" />
    <boolean name="pref_be_a_snowflake" value="false" />
    <boolean name="pref_expanded_notifications" value="true" />
    <string name="pref_or_port">9001</string>
    <boolean name="pref_enable_snowflake_logging" value="false" />
    <boolean name="pref_allow_background_starts" value="true" />
    <boolean name="pref_disable_ipv4" value="false" />
    <boolean name="pref_vpn" value="false" />
    <boolean name="pref_prefer_ipv6" value="true" />
    <string name="pref_reachable_addresses_ports">*:80,*:443</string>
    <boolean name="pref_or" value="false" />
</map>

Other files:

In termux:

sudo find / -name org.torproject.android -type d

Yielded:

/data/misc/profiles/cur/0/org.torproject.android
/data/misc/profiles/ref/org.torproject.android
/data/data/org.torproject.android
/data/system/graphicsstats/1672790400000/org.torproject.android
/data/user_de/0/org.torproject.android
/config/sdcardfs/org.torproject.android
find: ‘/proc/2341/net’: Invalid argument

Which were explored with adb:

adb shell
su

And the following was found:

/data/misc/profiles/cur/0/org.torproject.android (illegible)
/data/misc/profiles/ref/org.torproject.android (empty)
/data/data/org.torproject.android (Contained settings)
/data/system/graphicsstats/1672790400000/org.torproject.android
/data/user_de/0/org.torproject.android
/config/sdcardfs/org.torproject.android
a-t-0 commented 1 year ago

Attempts

#!/usr/bin/env bash

# Allow the Connection request prompt

# All activities
adb shell dumpsys package | grep -i "org.torproject.android" |grep Service

# Launch app:
adb shell am start -a android.intent.action.MAIN -n org.torproject.android/.OrbotMainActivity

#adb shell monkey -p 'org.torproject.android' -v 1

# Or:
adb shell monkey -p 'org.torproject.android' 1

# Tries to work
adb shell am startservice -n org.torproject.android/.service.OrbotService  
# Alternative:
adb shell su -c "start org.torproject.android"

# Tries to work
adb shell pm grant org.torproject.android android.permission.BIND_VPN_SERVICE

# Select the Davx5 app to be "torified"
#adb shell am start -n org.torproject.android/.SettingsBannedAppsActivity

# Get all activities
adb shell dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+org.torproject.android/[^[:space:]]+" | grep -oE "[^[:space:]]+$"

# Start the Orbot service
adb shell am startservice -n org.torproject.android/.OrbotService
#adb shell am start -a android.intent.action.MAIN -n org.torproject.android/.service.StartTorReceiver
#adb shell am start -a android.intent.action -n org.torproject.android/.service.StartTorReceiver
adb shell am start -n com.example.demo/com.example.featuremodule.FeatureActivity
adb shell am start -n org.torproject.android/org.torproject.android/.service.StartTorReceiver
adb shell am start -n org.torproject.android/.service.StartTorReceiver
adb shell am start -n /.service.StartTorReceiver
adb shell am start -n .service.StartTorReceiver
adb shell am start -n org.torproject.android/.service.StartTorReceiver
adb shell am start -a android.intent.action.MAIN -n org.torproject.android/.service.StartTorReceiver
adb shell am start -a android.intent.action.MAIN -n /.service.StartTorReceiver
adb shell am start -a android.intent.action.MAIN -n .service.StartTorReceiver
adb shell am start -a android.intent.action.MAIN -n org.torproject.android.service.StartTorReceiver
adb shell am start -a org.torproject.android.service.StartTorReceiver
adb shell am start -a org.torproject.android.intent.action.START
adb shell am start -a android.intent.action.MAIN -n org.torproject.android.intent.action.START
adb shell am start -a org.torproject.android.intent.action.START -n org.torproject.android/.service.OrbotService
adb shell am start -a android.intent.action.MAIN -n .START
adb shell am start -a android.intent.action.MAIN -n START

adb shell am start -n org.torproject.android/.START

# Based on dumpsys
`adb shell am start -a org.torproject.android.intent.action.START -n org.torproject.android/.service.OrbotService`
adb shell am start -a org.torproject.android.intent.action.START -n .service.OrbotService

# Get the activities
aapt l -a orbot.apk | sed -n -e '/manifest/,$p' > orbot_manifest.txt

# More summarised as if from manifest:
adb shell "dumpsys package | grep -i 'org.torproject.android'"

# Source: https://github.com/guardianproject/orbot/blob/3659e94095c86297df90dc115a5c5020d7ee8a5a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
# private static final String INTENT_ACTION_REQUEST_START_TOR = "org.torproject.android.START_TOR";
# Conversion explanation: https://android.stackexchange.com/questions/68105/sending-intents-using-adb-with-additional-action-data-and-extra
adb shell am startservice -a org.torproject.android.START_TOR true
adb shell am startservice -a org.torproject.android.START_TOR 
adb shell am startservice -a org.torproject.android/.OrbotMainActivity

adb shell am startservice -n org.torproject.android.StartTorReceiver
adb shell am startservice -n org.torproject.android.START_TOR 
adb shell am startservice -n org.torproject.android.OrbotMainActivity
adb shell am startservice -n org.torproject.android/.OrbotMainActivity

adb shell am startservice -n org.torproject.android/.service.OrbotService permission=android.permission.BIND_VPN_SERVICE
adb shell am startservice -n org.torproject.android/.service.OrbotService: android.permission.BIND_VPN_SERVICE

adb shell am startservice -n org.torproject.android/.StartTorReceiver
adb shell am startservice -n org.torproject.android/.START_TOR 
adb shell am startservice -n org.torproject.android/.OrbotMainActivity

adb shell input keyevent 66 # enter
adb shell input keyevent 20 # down
a-t-0 commented 1 year ago

Alternative to adb to automate some stuff on phone (monkeyrunner): https://developer.android.com/studio/test/monkeyrunner

Example:

# Imports the monkeyrunner modules used by this program.
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

# Connects to the current device, returning a MonkeyDevice object.
device = MonkeyRunner.waitForConnection()

# Installs the Android package. Notice that this method returns a boolean, so you can test
# whether the installation worked.
device.installPackage('myproject/bin/MyApplication.apk')

# Sets a variable with the package's internal name.
package = 'com.example.android.myapplication'

# Sets a variable with the name of an Activity in the package.
activity = 'com.example.android.myapplication.MainActivity'

# Sets the name of the component to start.
runComponent = package + '/' + activity

# Runs the component.
device.startActivity(component=runComponent)

# Presses the Menu button.
device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

# Takes a screenshot.
result = device.takeSnapshot()

# Writes the screenshot to a file.
result.writeToFile('myproject/shot1.png','png')
a-t-0 commented 1 year ago
:/ # find / -name *davdroid* -type d
/data/misc/profiles/cur/0/at.bitfire.davdroid
/data/misc/profiles/ref/at.bitfire.davdroid
/data/data/at.bitfire.davdroid
/data/app/at.bitfire.davdroid-UPmIzsKsI2GYeFaKDDNOxQ==
/data/user_de/0/at.bitfire.davdroid
/config/sdcardfs/at.bitfire.davdroid
a-t-0 commented 1 year ago

Done, Orbot torifies DAVx5. Both are installed and configured automatically.