Skip to content

Commit b7157b6

Browse files
committed
Add login
Resolves #51
1 parent bae70f1 commit b7157b6

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

docs/android-app-inspection.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Inspecting the SoundCloud Android App
2+
3+
## Prerequisites
4+
5+
* Ubuntu 18.04
6+
* Android Studio 4
7+
* mitmproxy (https://mitmproxy.org/)
8+
* Add Android Sdk tools to `PATH`:
9+
```bash
10+
# Android Sdk
11+
ANDROID_SDK_ROOT=~/Android/Sdk
12+
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools/29.0.2
13+
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
14+
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
15+
```
16+
17+
## Download and patch APK
18+
19+
* Open Android Virtual Device Manager and start a device with Play Store.
20+
* Install the SoundCloud-App from the Play Store.
21+
* Install [Split APKs Installer (SAI)](https://play.google.com/store/apps/details?id=com.aefyr.sai)
22+
and backup (export) the SoundCloud app to the `Downloads` folder.
23+
* Download the exported `*.apks` file:
24+
```bash
25+
adb pull /sdcard/Download/SoundCloud_com,soundcloud,android_2021,06,02-release.apks
26+
mv SoundCloud_com,soundcloud,android_2021,06,02-release.apks com.soundcloud.android.apks
27+
```
28+
* Patch the APK:
29+
```bash
30+
npx apk-mitm com.soundcloud.android.apks
31+
```
32+
* Push the patched APK file back to the virtual device:
33+
```shell
34+
adb push com.soundcloud.android-patched.apks /sdcard/Download/
35+
```
36+
* Uninstall the original SoundCloud app.
37+
* Install the patched APK with SAI.
38+
39+
## Inspect traffic
40+
41+
* Start mitmproxy by running `mitmweb`.
42+
* Start the app on your virtual device. Add the proxy config to the emulator settings.
43+
(Your IP [`ip a`] and port `8080`)
44+
* Install the mitm certificate inside Android by visiting [mitm.it](mitm.it).
45+
* You should now be able to inspect all network traffic.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import requests
2+
3+
4+
class ApiMobile:
5+
"""This class uses the unofficial API used by the SoundCloud mobile app."""
6+
7+
api_host = "https://api-mobile.soundcloud.com"
8+
api_client_id = "dbdsA8b6V6Lw7wzu1x0T4CLxt58yd4Bf"
9+
api_client_secret = "aBK1xbehZvrBw0dtVYNY3BuJJOuDFrYs"
10+
api_user_agent = "SoundCloud/2021.06.02-release (Android 11; Google sdk_gphone_x86)"
11+
api_udid = "4787dcf7a801d396b5f3cfa654fd89ae" # Unique Device Identifier
12+
13+
def __init__(self, settings, lang, cache):
14+
self.cache = cache
15+
self.settings = settings
16+
self.lang = lang
17+
18+
def authenticate(self, identifier, password):
19+
url = self.api_host + "/sign_in"
20+
21+
params = {
22+
"client_id": self.api_client_id,
23+
}
24+
25+
headers = {
26+
"Content-Type": "application/json; charset=utf-8",
27+
"User-Agent": self.api_user_agent,
28+
"UDID": self.api_udid,
29+
}
30+
31+
payload = {
32+
"auth_method": "password",
33+
"captcha_pubkey": "6LfuZ08UAAAAAEzW09iSDSG5t4ygnyGNz5ZGfj5h",
34+
"captcha_solution": None,
35+
"client_id": self.api_client_id,
36+
"client_secret": self.api_client_secret,
37+
"create_if_not_found": False,
38+
"credentials": {
39+
"identifier": identifier,
40+
"password": password,
41+
},
42+
"flags": {},
43+
"signature": "2:f3b1d672",
44+
}
45+
46+
response = requests.post(url, params=params, json=payload, headers=headers).json()
47+
48+
return response.token.access_token
49+

0 commit comments

Comments
 (0)