Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
whoeevee committed Apr 20, 2024
0 parents commit f787d29
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/

._*
.theos
/packages
.theos/
packages/
.DS_Store
1 change: 1 addition & 0 deletions EeveeSpotify.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.spotify.client" ); }; }
Binary file added Images/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TARGET := iphone:clang:latest:14.0
INSTALL_TARGET_PROCESSES = Spotify

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = EeveeSpotify

EeveeSpotify_FILES = $(shell find Sources/EeveeSpotify -name '*.swift') $(shell find Sources/EeveeSpotifyC -name '*.m' -o -name '*.c' -o -name '*.mm' -o -name '*.cpp')
EeveeSpotify_SWIFTFLAGS = -ISources/EeveeSpotifyC/include
EeveeSpotify_CFLAGS = -fobjc-arc -ISources/EeveeSpotifyC/include

include $(THEOS_MAKE_PATH)/tweak.mk
88 changes: 88 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// swift-tools-version:5.2

import PackageDescription
import Foundation

let projectDir = URL(fileURLWithPath: #filePath).deletingLastPathComponent()

@dynamicMemberLookup struct TheosConfiguration {
private let dict: [String: String]
init(at path: String) {
let configURL = URL(fileURLWithPath: path, relativeTo: projectDir)
guard let infoString = try? String(contentsOf: configURL) else {
fatalError("""
Could not find Theos SPM config. Have you run `make spm` yet?
""")
}
let pairs = infoString.split(separator: "\n").map {
$0.split(
separator: "=", maxSplits: 1,
omittingEmptySubsequences: false
).map(String.init)
}.map { ($0[0], $0[1]) }
dict = Dictionary(uniqueKeysWithValues: pairs)
}
subscript(
key: String,
or defaultValue: @autoclosure () -> String? = nil
) -> String {
if let value = dict[key] {
return value
} else if let def = defaultValue() {
return def
} else {
fatalError("""
Could not get value of key '\(key)' from Theos SPM config. \
Try running `make spm` again.
""")
}
}
subscript(dynamicMember key: String) -> String { self[key] }
}
let conf = TheosConfiguration(at: ".theos/spm_config")

let theosPath = conf.theos
let sdk = conf.sdk
let resourceDir = conf.swiftResourceDir
let deploymentTarget = conf.deploymentTarget
let triple = "arm64-apple-ios\(deploymentTarget)"

let libFlags: [String] = [
"-F\(theosPath)/vendor/lib", "-F\(theosPath)/lib",
"-I\(theosPath)/vendor/include", "-I\(theosPath)/include"
]

let cFlags: [String] = libFlags + [
"-target", triple, "-isysroot", sdk,
"-Wno-unused-command-line-argument", "-Qunused-arguments",
]

let cxxFlags: [String] = [
]

let swiftFlags: [String] = libFlags + [
"-target", triple, "-sdk", sdk, "-resource-dir", resourceDir,
]

let package = Package(
name: "EeveeSpotify",
platforms: [.iOS(deploymentTarget)],
products: [
.library(
name: "EeveeSpotify",
targets: ["EeveeSpotify"]
),
],
targets: [
.target(
name: "EeveeSpotifyC",
cSettings: [.unsafeFlags(cFlags)],
cxxSettings: [.unsafeFlags(cxxFlags)]
),
.target(
name: "EeveeSpotify",
dependencies: ["EeveeSpotifyC"],
swiftSettings: [.unsafeFlags(swiftFlags)]
),
]
)
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
![Banner](Images/banner.png)

# EeveeSpotify

This tweak makes Spotify think that you have a Premium subscription, granting free listening, just like Spotilife.

## The History

Several months ago, Spotilife, the only tweak to get Spotify Premium, stopped working on new Spotify versions. I decompiled Spotilife, reverse-engineered Spotify, intercepted requests, etc., and created this tweak.

## How It Works

Upon login, Spotify fetches user data, including active subscription, and caches it in the `offline.bnk` file in the `/Library/Application Support/PersistentCache` directory. It uses its proprietary binary format to store data, incorporating a length byte before each value, among other conventions. Certain keys, such as `player-license`, `financial-product`, and `type`, determines the user abilities.

The tweak patches this file while initializing; Spotify loads it and assumes you have Premium. To be honest, it doesn't really patch due to challenges with dynamic length and varied bytes. Ideally, there should be a parser capable of deserializing and serializing such format. However, for now, the tweak simply extracts the username from the current `offline.bnk` file and inserts it into `premiumblank.bnk` (a file containing all premium values preset), replacing `offline.bnk` (`financial-product` is trial because I have no premium `offline.bnk`, but it doesn't matter).

![Hex](Images/hex.png)

Tweak also changes query parameters `trackRows` and `video` to true, so Spotify loads videos and not just track names at the artist page. Sorry if the code seems cringe; the main focus is on the concept. It can stop working just like Spotilife, but so far, it works on the latest Spotify 8.9.## (Spotilife also patches `offline.bnk`, but it changes obscure bytes that do nothing on new versions). Spotify reloads user data from time to time (and on changing network, for example), so if Premium stops working, simply restart the app.

There is no offline or very high quality (similar to Spotilife) because these features are server-sided (i.e., you can't get very high quality tracks from the server without a subscription). In theory, it might be possible to implement offline mode locally, but not in this tweak.

To hide the Premium tab, use [SpotifyHidePremium](https://t.me/SpotilifeIPAs/36).
29 changes: 29 additions & 0 deletions Sources/EeveeSpotify/BundleHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation
import libroot

class BundleHelper {

private let bundleName = "EeveeSpotify"

private let bundle: Bundle
static let shared = BundleHelper()

private init() {
self.bundle = Bundle(
path: Bundle.main.path(
forResource: bundleName,
ofType: "bundle"
)
?? jbRootPath("/Library/Application Support/\(bundleName).bundle")
)!
}

func premiumBlankData() throws -> Data {
return try Data(
contentsOf: self.bundle.url(
forResource: "premiumblank",
withExtension: "bnk"
)!
)
}
}
55 changes: 55 additions & 0 deletions Sources/EeveeSpotify/Tweak.x.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Orion

class URLHook: ClassHook<NSURL> {

func initWithString(_ urlString: String, relativeToURL URL: NSURL) -> NSURL {

var finalString = urlString

if finalString.contains("artistview") {
finalString = finalString.replacingOccurrences(
of: "trackRows=false",
with: "trackRows=true"
)
finalString = finalString.replacingOccurrences(
of: "video=false",
with: "video=true"
)
}

return orig.initWithString(finalString, relativeToURL: URL)
}
}

struct EeveeSpotify: Tweak {

init() {

do {

let filePath = FileManager.default.urls(
for: .applicationSupportDirectory, in: .userDomainMask
)
.first!
.appendingPathComponent("PersistentCache")
.appendingPathComponent("offline.bnk")

let fileData = try Data(contentsOf: filePath)

let usernameLength = Int(fileData[8])
let username = Data(fileData[9..<9 + usernameLength])

var blankData = try BundleHelper.shared.premiumBlankData()

blankData.insert(UInt8(usernameLength), at: 8)
blankData.insert(contentsOf: username, at: 9)

try blankData.write(to: filePath)
NSLog("[EeveeSpotify] Successfully applied")
}

catch {
NSLog("[EeveeSpotify] Unable to apply tweak: \(error)")
}
}
}
8 changes: 8 additions & 0 deletions Sources/EeveeSpotifyC/Tweak.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import <Orion/Orion.h>
#import <Foundation/Foundation.h>

__attribute__((constructor)) static void init() {
// Initialize Orion - do not remove this line.
orion_init();
// Custom initialization code goes here.
}
Empty file.
4 changes: 4 additions & 0 deletions Sources/EeveeSpotifyC/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module EeveeSpotifyC {
umbrella "."
export *
}
9 changes: 9 additions & 0 deletions control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: com.eevee.spotify
Name: EeveeSpotify
Version: 1.0
Architecture: iphoneos-arm
Description: A tweak to get Spotify Premium for free, just like Spotilife
Maintainer: Eevee
Author: Eevee
Section: Tweaks
Depends: ${ORION}, firmware (>= 14.0)
Binary file not shown.

0 comments on commit f787d29

Please sign in to comment.