Compare commits

..
5 Commits
Author SHA1 Message Date
Majd Alfhaily 8619332e52 Align version (1.0.2) 2021-05-24 12:36:33 +02:00
Majd Alfhaily 6db68b6bd2 Handle invalid license errors 2021-05-23 19:01:23 +02:00
Majd Alfhaily 3c90c45dab Add Makefile 2021-05-23 11:38:54 +02:00
Majd Alfhaily 94fc3a6d47 Align version (1.0.1) 2021-05-23 11:06:59 +02:00
Majd Alfhaily 0f517f43f6 Update readme 2021-05-23 11:00:44 +02:00
6 changed files with 80 additions and 143 deletions

No files matched your search

+5 -20
View File
@@ -1,7 +1,7 @@
# IPATool
[![Release](https://img.shields.io/github/release/majd/ipatool.svg)](https://GitHub.com/majd/ipatool/releases/)
![Swift](https://img.shields.io/badge/Swift-5.4-green.svg)
![macOS](https://img.shields.io/badge/macOS-10.15%2B-green.svg)
![Swift](https://img.shields.io/badge/Swift-5.x-green.svg)
![macOS](https://img.shields.io/badge/macOS-10.11%2B-green.svg)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/majd/ipatool/blob/main/LICENSE)
`ipatool` is a command line tool that allows you to search for iOS apps on the [App Store](https://apps.apple.com) and download a copy of the app package, known as an _ipa_ file.
@@ -9,24 +9,9 @@
![Demo](./demo.gif)
## Requirements
* macOS 10.15 or later.
* macOS 10.11 or later.
* Apple ID set up to use the App Store.
## Installation
### Manual Install
You can grab the latest version of `ipatool` from [GitHub releases](https://github.com/majd/ipatool/releases).
### Homebrew
You can install `ipatool` using [Homebrew](https://brew.sh).
```
$ brew tap majd/repo
$ brew install ipatool
```
## Usage
To search for apps on the App Store, use the `search` command.
@@ -74,11 +59,11 @@ The tool does not store your credentials anywhere and it only communicates with
**Will my Apple ID get flagged for using this tool?**
Maybe, but probably not. While this tool communicates with iTunes and the App Store directly, mimicking the behavior of iTunes running on macOS, I cannot guarantee its safety. I recommend using a throwaway Apple ID. **Use this tool at your own risk**.
Maybe, but probably not. While this tool communicates with iTunes and the App Store directly, mimicking the behavior of iTunes running on macOS, I cannot guarrantee its safety. I recommend using a throwaway Apple ID. **Use this tool your own risk**.
**Can I use this tool to download paid apps without paying for them?**
**No**. This is is not a piracy tool; you can only download apps that you have previously installed on your iOS device. This limitation applies to free apps as well. Essentially, your account must already have a license for the app you are trying to download.
**No**. This is is not a piracy tool; you can only download apps that you have previously install on your iOS device. This limitation applies to free apps as well. Essentially, your account must already have a license for the app you are trying to download.
**Can I use this tool to sideload unuspported iOS apps on Apple Silicon Macs?**
+60 -100
View File
@@ -16,29 +16,37 @@ struct Download: ParsableCommand {
@Option(name: [.short, .long], help: "The bundle identifier of the target iOS app.")
private var bundleIdentifier: String
@Option(name: [.short, .customLong("email")], help: "The email address for the Apple ID.")
private var emailArgument: String?
@Option(name: [.short, .long], help: "The email address for the Apple ID.")
private var email: String?
@Option(name: [.short, .customLong("password")], help: "The password for the Apple ID.")
private var passwordArgument: String?
@Option(name: [.short, .long], help: "The password for the Apple ID.")
private var password: String?
@Option
private var logLevel: LogLevel = .info
lazy var logger = ConsoleLogger(level: logLevel)
}
extension Download {
mutating func app(with bundleIdentifier: String) -> iTunesResponse.Result {
func run() throws {
let logger = ConsoleLogger(level: logLevel)
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
logger.log("Creating iTunes client...", level: .debug)
let itunesClient = iTunesClient(httpClient: httpClient)
logger.log("Creating App Store client...", level: .debug)
let storeClient = StoreClient(httpClient: httpClient)
logger.log("Creating download client...", level: .debug)
let downloadClient = HTTPDownloadClient()
logger.log("Querying the iTunes store for '\(bundleIdentifier)'...", level: .info)
let app: iTunesResponse.Result
do {
logger.log("Querying the iTunes Store for '\(bundleIdentifier)'...", level: .info)
return try itunesClient.lookup(bundleIdentifier: bundleIdentifier)
app = try itunesClient.lookup(bundleIdentifier: bundleIdentifier)
} catch {
logger.log("\(error)", level: .debug)
@@ -51,51 +59,45 @@ extension Download {
_exit(1)
}
}
mutating func email() -> String {
if let email = emailArgument {
return email
} else if let email = ProcessInfo.processInfo.environment["IPATOOL_EMAIL"] {
return email
} else if let email = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter Apple ID email: ", level: .warning)))) {
return email
logger.log("Found app: \(app.name) (\(app.version)).", level: .debug)
let email: String
let password: String
if let cliEmail = self.email {
email = cliEmail
} else if let envEmail = ProcessInfo.processInfo.environment["IPATOOL_EMAIL"] {
email = envEmail
} else if let inputEmail = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter Apple ID email: ", level: .warning)))) {
email = inputEmail
} else {
logger.log("An Apple ID email address is required.", level: .error)
_exit(1)
}
}
mutating func password() -> String {
if let password = passwordArgument {
return password
} else if let password = ProcessInfo.processInfo.environment["IPATOOL_PASSWORD"] {
return password
} else if let password = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter Apple ID password: ", level: .warning)))) {
return password
if let cliPassword = self.password {
password = cliPassword
} else if let envPassword = ProcessInfo.processInfo.environment["IPATOOL_PASSWORD"] {
password = envPassword
} else if let inputPassword = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter Apple ID password: ", level: .warning)))) {
password = inputPassword
} else {
logger.log("An Apple ID password is required.", level: .error)
_exit(1)
}
}
mutating func authenticate(email: String, password: String) -> StoreResponse.Account {
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
logger.log("Creating App Store client...", level: .debug)
let storeClient = StoreClient(httpClient: httpClient)
let account: StoreResponse.Account
do {
logger.log("Authenticating with the App Store...", level: .info)
return try storeClient.authenticate(email: email, password: password)
account = try storeClient.authenticate(email: email, password: password)
} catch {
switch error {
case StoreResponse.Error.codeRequired:
let code = String(validatingUTF8: UnsafePointer<CChar>(getpass(logger.compile("Enter 2FA code: ", level: .warning))))
do {
return try storeClient.authenticate(email: email, password: password, code: code)
account = try storeClient.authenticate(email: email, password: password, code: code)
} catch {
logger.log("\(error)", level: .debug)
@@ -133,19 +135,13 @@ extension Download {
_exit(1)
}
}
logger.log("Authenticated as '\(account.firstName) \(account.lastName)'.", level: .info)
}
mutating func item(from app: iTunesResponse.Result, account: StoreResponse.Account) -> StoreResponse.Item {
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
logger.log("Creating App Store client...", level: .debug)
let storeClient = StoreClient(httpClient: httpClient)
logger.log("Requesting a signed copy of '\(app.identifier)' from the App Store...", level: .info)
let item: StoreResponse.Item
do {
logger.log("Requesting a signed copy of '\(app.identifier)' from the App Store...", level: .info)
return try storeClient.item(identifier: "\(app.identifier)", directoryServicesIdentifier: account.directoryServicesIdentifier)
item = try storeClient.item(identifier: "\(app.identifier)", directoryServicesIdentifier: account.directoryServicesIdentifier)
} catch {
logger.log("\(error)", level: .debug)
@@ -162,32 +158,28 @@ extension Download {
_exit(1)
}
}
mutating func download(item: StoreResponse.Item, to targetURL: URL) {
logger.log("Creating download client...", level: .debug)
let downloadClient = HTTPDownloadClient()
do {
logger.log("Downloading app package...", level: .info)
try downloadClient.download(from: item.url, to: targetURL) { [logger] progress in
logger.log("Downloading app package... [\(Int((progress * 100).rounded()))%]",
prefix: "\u{1B}[1A\u{1B}[K",
level: .info)
}
} catch {
logger.log("\(error)", level: .debug)
logger.log("An error has occurred while downloading the app package.", level: .error)
_exit(1)
}
}
mutating func applyPatches(item: StoreResponse.Item, email: String, path: String) {
logger.log("Received a response of the signed copy: \(item.md5).", level: .debug)
logger.log("Creating signature client...", level: .debug)
let path = FileManager.default.currentDirectoryPath
.appending("/\(bundleIdentifier)_\(app.identifier)_v\(app.version)_\(Int.random(in: 100...999))")
.appending(".ipa")
logger.log("Output path: \(path).", level: .debug)
let signatureClient = SignatureClient(fileManager: .default, filePath: path)
logger.log("Downloading app package...", level: .info)
try downloadClient.download(from: item.url, to: URL(fileURLWithPath: path)) { progress in
logger.log("Downloading app package... [\(Int((progress * 100).rounded()))%]",
prefix: "\u{1B}[1A\u{1B}[K",
level: .info)
}
logger.log("Saved app package to \(URL(fileURLWithPath: path).lastPathComponent).", level: .info)
logger.log("Applying patches...", level: .info)
do {
logger.log("Applying patches...", level: .info)
try signatureClient.appendMetadata(item: item, email: email)
try signatureClient.appendSignature(item: item)
} catch {
@@ -195,39 +187,7 @@ extension Download {
logger.log("Failed to apply patches. The ipa file will be left incomplete.", level: .error)
_exit(1)
}
}
mutating func run() throws {
// Query for app
let app: iTunesResponse.Result = app(with: bundleIdentifier)
logger.log("Found app: \(app.name) (\(app.version)).", level: .debug)
// Get Apple ID email
let email: String = email()
// Get Apple ID password
let password: String = password()
// Authenticate with the App Store
let account: StoreResponse.Account = authenticate(email: email, password: password)
logger.log("Authenticated as '\(account.firstName) \(account.lastName)'.", level: .info)
// Query for store item
let item: StoreResponse.Item = item(from: app, account: account)
logger.log("Received a response of the signed copy: \(item.md5).", level: .debug)
// Generate file name
let path = FileManager.default.currentDirectoryPath
.appending("/\(bundleIdentifier)_\(app.identifier)_v\(app.version)_\(Int.random(in: 100...999))")
.appending(".ipa")
logger.log("Output path: \(path).", level: .debug)
// Download app package
download(item: item, to: URL(fileURLWithPath: path))
logger.log("Saved app package to \(URL(fileURLWithPath: path).lastPathComponent).", level: .info)
// Apply patches
applyPatches(item: item, email: email, path: path)
logger.log("Done.", level: .info)
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ struct IPATool: ParsableCommand {
static var configuration: CommandConfiguration {
return .init(commandName: "ipatool",
abstract: "A cli tool for interacting with Apple's ipa files.",
version: "1.0.3",
version: "1.0.2",
subcommands: [Download.self, Search.self])
}
}
+9 -17
View File
@@ -21,12 +21,12 @@ struct Search: ParsableCommand {
@Option
private var logLevel: LogLevel = .info
lazy var logger = ConsoleLogger(level: logLevel)
}
extension Search {
mutating func results(with term: String) -> [iTunesResponse.Result] {
func run() throws {
let logger = ConsoleLogger(level: logLevel)
logger.log("Creating HTTP client...", level: .debug)
let httpClient = HTTPClient(urlSession: URLSession.shared)
@@ -41,25 +41,17 @@ extension Search {
logger.log("No results found.", level: .error)
_exit(1)
}
let output = results
.enumerated()
.map({ "\($0 + 1). \($1.name): \($1.bundleIdentifier) (\($1.version))." })
.joined(separator: "\n")
return results
logger.log("Found \(results.count) \(results.count == 1 ? "result" : "results"):\n\(output)", level: .info)
} catch {
logger.log("\(error)", level: .debug)
logger.log("An unknown error has occurred.", level: .error)
_exit(1)
}
}
mutating func run() throws {
// Search the iTunes store
let results = results(with: term)
// Compile output
let output = results
.enumerated()
.map({ "\($0 + 1). \($1.name): \($1.bundleIdentifier) (\($1.version))." })
.joined(separator: "\n")
logger.log("Found \(results.count) \(results.count == 1 ? "result" : "results"):\n\(output)", level: .info)
}
}
+2 -2
View File
@@ -397,7 +397,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_NAME = ipatool;
SWIFT_VERSION = 5.0;
};
@@ -407,7 +407,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_NAME = ipatool;
SWIFT_VERSION = 5.0;
};
@@ -57,15 +57,15 @@
</CommandLineArgument>
<CommandLineArgument
argument = "download -b com.apple.TestFlight"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "search --help"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "search TestFlight --limit 5"
isEnabled = "YES">
argument = "search TestFlight --limit 1"
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>