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

Support downloading Viber stickers #144

Closed
princo1415 opened this issue Apr 17, 2024 · 4 comments
Closed

Support downloading Viber stickers #144

princo1415 opened this issue Apr 17, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@princo1415
Copy link

Hello Mr laggy killer.Does this app now support viber stickers exportation and if not ,what's the reason,is it because it's end to end encrypted

Best regards,

@laggykiller
Copy link
Owner

laggykiller commented Apr 17, 2024

v2.8.5 adds support for Viber sticker download and compressing files to Viber-compliant 490x490 png files, but not exporting.

I have attempted to reverse engineer Viber Android app. To export Viber stickers, we need to get member_id and udid, which should be the same for each user but not sure where they could be obtained. Even worse, we need to get m_token, which is changed everytime when app is restarted, and I have no idea how I can automatically get it.

This is best attempt for exporting Viber sticker, which obviously won't work:

import requests
import time

viber_version = "22.4.3.0"
user_agent = f"Mozilla/5.0 (Linux; Android 11; Android SDK built for x86 Build/RSR1.210210.001.A1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36 Viber/{viber_version}"

# Zip file containing 490x490 png images to upload (00.png, 01.png, ...)
with open("upload.zip", "rb") as f: 
    result = requests.post(
        "https://market.api.viber.com/2/users/custom-sticker-packs/create",
        files={
            "file": ("upload.zip", f)
        },
        data={
            "member_id": "REDACTED",  # Same for each user
            "m_token": "REDACTED",  # Changed when app is restarted
            "m_ts": str(int(time.time() * 1000)),
            "title": "my-custom-pack",
            "description": "My custom viber sticker pack",
            "shareable": "1",
            "udid": "REDACTED",  # Same for each user
            "phone_country": "US",
            "mcc": "000",  # Mobile Country Codes, see https://mcc-mnc.com/
            "mnc": "000",  # Mobile Network Codes, see https://mcc-mnc.com/
            "vv": viber_version,
            "sid": "1",
            "lang": "en",
            "privacy_flags": "7",
        },
        headers={
            "User-Agent": user_agent
        }
    )

    print(result.text)  # status should be 1 if success

If anyone want to reverse the Android app, I recommend using PCAPdroid on rooted Android emulator with mitm addon, with MagiskTrustUserCerts. Jadx decompilation might also be useful.

We can also analyze Windows version of Viber, but I am not familiar with it. What makes matter worse, Viber Windows start to store database with encrypted SQLCipher (Russian forum, use Google translate: https://4pda.to/forum/index.php?showtopic=714685&view=findpost&p=125818765), which means things like udid might be locked behind a database that is decrypted with unknown way.

Anyway, I don't think this is high prority and I probably won't continue investigating, as:

  • Few people use Viber
  • Viber automatically converts image to compliant format, which means it is already easy to create stickers using official Viber app.

If someone has solution, please comment / submit PR, thank you.

@laggykiller laggykiller added the enhancement New feature or request label Apr 17, 2024
@laggykiller laggykiller changed the title Viber support Support exporting Viber stickers Apr 17, 2024
@princo1415
Copy link
Author

Thank you for the thorough explanation. I meant to download to png format files not exporting. so that should work fine in the v2.8.5 version right? I need them to png files so I can import them to Signal app.

Kind regards,

@laggykiller
Copy link
Owner

You are correct, you can download Viber stickers in v2.8.5+, but not able to upload. Please try.

@laggykiller laggykiller changed the title Support exporting Viber stickers Support downloading Viber stickers Apr 20, 2024
@laggykiller
Copy link
Owner

I am closing this, issue of adding support for exporting Viber stickers is moved to #146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants