Skip to content

Commit

Permalink
Add version input method.
Browse files Browse the repository at this point in the history
See description at #72
  • Loading branch information
elijahtsai committed Apr 12, 2021
1 parent 977b474 commit a395c81
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 27 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For the people who would like to try the new version, we got you covered. You ca

One-liner script to install latest Sketch version and automatically patch it:<br />`bash -c "$(curl -s https://raw.githubusercontent.com/duraki/SketchCrapp/master/sketchcrapp.sh -o -)" -O -m`
<br /><br />
![magictrickimage](https://i.imgur.com/e6JRxB5.png)
![magictrickimage](https://i.imgur.com/gGr8bHi.png)

<p align="center">Successful screenshot of using magic trick</p>

Expand All @@ -45,11 +45,11 @@ crackb0x:SketchCrapp duraki$ ./sketchcrapp.sh -h
by @duraki & @elijahtsai
Usage:
./sketchcrapp [-h] [-a] <applicationPath> [-m]
./sketchcrapp [-h] [-a] <applicationPath> [-m] [-g] <version>
Supported versions: v58, v63.1, v64.0, v65.1, v66.1, v67, v67.1, v67.2,
v68, v68.1, v68.2, v69, v69.1, v69.2, v70.2, v70.3, v70.4, v70.5, v70.6
v71.1, v71.2
[+] SketchCrapp last published date: 2021-04-09 serial 001
[+] SketchCrapp last published date: 2021-04-12 serial 023
```

```
Expand All @@ -62,8 +62,17 @@ crackb0x:SketchCrapp duraki$ ./sketchcrapp.sh -m
Sketch.App Patch Tool (https://github.com/duraki/SketchCrapp)
by @duraki & @elijahtsai
[+] Hello, The magic show is about to start! Are you ready?
[+] Checking if version 71.2 is supported ...Yes
[+] Fetching https://download.sketchapp.com/sketch-versions.xml ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 85817 100 85817 0 0 53435 0 0:00:01 0:00:01 --:--:-- 355k
[+] Generating swift script ...
[+] Zip file download path: https://download.sketch.com/sketch-71.2-115329.zip
[+] Checking directory tmp existence ... OK
[+] Fetching https://download.sketch.com/sketch-71.2-115329.zip ...
[+] Fetching https://download.sketch.com/sketch-71.2-115329.zip ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 58.5M 100 58.5M 0 0 1805k 0 0:00:33 0:00:33 --:--:-- 2328k
Expand Down Expand Up @@ -145,7 +154,7 @@ crackb0x:SketchCrapp duraki$ ./sketchcrapp.sh -m
[+] SketchCrapp (A Sketch.app cracking tool)
[+] https://github.com/duraki/SketchCrapp [by @duraki & @elijahtsai]
[+] SketchCrapp last published date: 2021-04-09 serial 001
[+] SketchCrapp last published date: 2021-04-12 serial 023
```

## Issues
Expand Down Expand Up @@ -196,5 +205,5 @@ If you really need specific version you can contact the team via GitHub Issues,
|200|2021-03-04|
|250|soon 🙉|

##### Stargazers over time
### Stargazers over time
[![Stargazers over time](https://starchart.cc/duraki/SketchCrapp.svg)](https://starchart.cc/duraki/SketchCrapp)
190 changes: 169 additions & 21 deletions sketchcrapp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
# RUP Review every time when new verison update part.
#latest supported version
latestVersion="71.2"

# Support version list.
declare -a version_list

Expand Down Expand Up @@ -228,6 +232,8 @@ subjectKeyIdentifier = hash
basicConstraints = critical,CA:false
"

downloadURLString=""

# Banner block
banner() {
cat <<"EOF"
Expand All @@ -246,15 +252,15 @@ EOF
# Last function to run before exit.
finally() {
local status="$1"
echo "[+] SketchCrapp last published date: 2021-04-09 serial 001"
echo "[+] SketchCrapp last published date: 2021-04-12 serial 023"
exit $status
}

# RUP Review every time when new verison update part.
# Help messages block.
usage() {
echo "Usage:"
echo "./sketchcrapp [-h] [-a] <applicationPath> [-m]"
echo "./sketchcrapp [-h] [-a] <applicationPath> [-m] [-g] <version>"
echo "Supported versions: v58, v63.1, v64.0, v65.1, v66.1, v67, v67.1, v67.2,"
echo "v68, v68.1, v68.2, v69, v69.1, v69.2, v70.2, v70.3, v70.4, v70.5, v70.6"
echo "v71.1, v71.2"
Expand All @@ -273,8 +279,8 @@ clean() {
if [ -f pkcs.p12 ]; then
rm -f pkcs.p12
fi
if [ -f "/tmp/latest.zip" ]; then
rm -f "/tmp/latest.zip"
if [ -f "/tmp/app.zip" ]; then
rm -f "/tmp/app.zip"
if ! [ "$?" -eq "0" ]; then
echo "Error"
echo "[-] Fail to remove zip file of latest application. remove by yourself."
Expand All @@ -289,6 +295,22 @@ clean() {
finally 1
fi
fi
if [ -f "/tmp/select.swift" ]; then
rm -f "/tmp/select.swift"
if ! [ "$?" -eq "0" ]; then
echo "Error"
echo "[-] Fail to remove swift script file. remove by yourself."
finally 1
fi
fi
if [ -f "/tmp/list.xml" ]; then
rm -f "/tmp/list.xml"
if ! [ "$?" -eq "0" ]; then
echo "Error"
echo "[-] Fail to remove list xml file. remove by yourself."
finally 1
fi
fi
echo "Cleaned"
}

Expand Down Expand Up @@ -363,6 +385,128 @@ repository: https://github.com/duraki/SketchCrapp"
fi
}

checkVersionSupported() {

local testVersionString="$1"

local ticket=0

for versionElement in "${version_list[@]}"
do
if [ "$testVersionString" = "$versionElement" ]; then
ticket=1
fi
done
echo $ticket
}

generateSwiftScript(){
echo "[+] Generating swift script ..."
cat <<'EOF' > /tmp/select.swift
import Foundation
var testString = ""
while let line = readLine() {
testString += "\(line)\n"
}
let pattern = #".*<enclosure url[^"]"(.*)" len.*\/>.*"#
let regex = try! NSRegularExpression(pattern: pattern)
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let matches = regex.matches(in: testString, range: stringRange)
var urls: [String] = []
for match in matches {
var groups: String = ""
for rangeIndex in 1 ..< match.numberOfRanges {
if match.range(at: rangeIndex).location > testString.utf16.count {
continue
}
groups = (testString as NSString).substring(with: match.range(at: rangeIndex))
}
urls.append(groups)
}
for u in urls {
print(u)
}
EOF
}

getURLFromVersionString() {

local versionString="$1"

echo -n "[+] Checking if version $versionString is supported ..."
local isVersionSupported=$(checkVersionSupported "$versionString")

if [ "$isVersionSupported" -eq 0 ]; then
echo "No"
echo "[ERR] Version $versionString is not supported, \
please carefully review README file again."
echo "[INFO] Copy the details below and open a new issue on GitHub \
repository: https://github.com/duraki/SketchCrapp"
echo "+==================================================================="
echo "+ Issue details ‹s:sketchcrapp:VersionUserEnter›"
echo "+ Passed version : $versionString"
echo "+ Error : Version $versionString is not supported."
echo "+==================================================================="
clean
finally 1
else
echo "Yes"
fi

local versionListXMLURL="https://download.sketchapp.com/sketch-versions.xml"

echo "[+] Fetching $versionListXMLURL ... "
curl -L "$versionListXMLURL" --output "/tmp/list.xml"

if ! [ "$?" -eq "0" ]; then
echo "[-] Failed while downloading version list xml file!"
echo "[-] Are you connected to the internet? Check your network connection."
clean
finally 1
fi

generateSwiftScript

if ! [ -f "/tmp/select.swift" ]; then
echo "[-] Swift script does not exists under the /tmp folder."
echo "[ERR] Couldn't find select.swift at /tmp/select.swift"
echo "[INFO] We don't know what's going on, try to use -m to get latest patch."
clean
finally 1
fi

LANG=en_GB.UTF-8
OIFS=$IFS
IFS=$'\n'
testURL=$(cat /tmp/list.xml | \
sed -e 's/^[[:space:]]*//g' | \
sed -e 's/[[:space:]]*$//g'| \
tr -d '\n' | \
sed -e $'s/<enclos/\\\n<enclos/g' | \
swift "/tmp/select.swift" | \
grep "\-$versionString\-")
IFS=$OIFS

downloadURLString="$testURL"

if [ -z "$downloadURLString" ]; then
echo "[ERR] Version $versionString is not supported, \
please carefully review README file again."
echo "[INFO] Copy the details below and open a new issue on GitHub \
repository: https://github.com/duraki/SketchCrapp"
echo "+==================================================================="
echo "+ Issue details ‹s:sketchcrapp:UnknowDownloadURLString"
echo "+ Passed version : $versionString"
echo "+ Error : Version $versionString is not supported."
echo "+==================================================================="
clean
finally 1
fi

echo "[+] Download URL set to: $downloadURLString"
}


# Get binary hash from CFBundleShortVersionString
# - Parameters:
# - First: The application bundle CFBundleShortVersionString.
Expand Down Expand Up @@ -493,16 +637,9 @@ analysisApplication() {
# Get the hash of application executable
local appSHA1="$(shasum -a 1 "$execPath" | cut -f 1 -d ' ')"

local ticket=0

for versionElement in "${version_list[@]}"
do
if [ "$bundleVersionString" = "$versionElement" ]; then
ticket=1
fi
done
local isVersionSupported=$(checkVersionSupported "$bundleVersionString")

if [ "$ticket" -eq 0 ]; then
if [ "$isVersionSupported" -eq 0 ]; then
echo "[ERR] Version $bundleVersionString is not supported, \
please carefully review README file again."
echo "[INFO] Copy the details below and open a new issue on GitHub \
Expand Down Expand Up @@ -864,10 +1001,16 @@ https://github.com/duraki/SketchCrapp"
}

# An auto function to patch latest app.
magicFunction() {
magic() {

# RUP Review every time when new verison update part.
local latestBundleURLPath="https://download.sketch.com/sketch-71.2-115329.zip"
local testVersionString="$1"

if [ -z "$testVersionString" ]; then
testVersionString="$latestVersion"
fi
echo "[+] Hello, The magic show is about to start! Are you ready?"

getURLFromVersionString "$testVersionString"

# Check if missing cURL
if ! command -v curl &> /dev/null; then
Expand Down Expand Up @@ -898,9 +1041,10 @@ magicFunction() {
fi

echo "OK"
echo "[+] Fetching $latestBundleURLPath ... "

curl "$latestBundleURLPath" --output "/tmp/latest.zip"
echo "[+] Fetching $downloadURLString ... "

curl "$downloadURLString" --output "/tmp/app.zip"

if ! [ "$?" -eq "0" ]; then
echo "[-] Failed while downloading latest application version!"
Expand All @@ -922,7 +1066,7 @@ magicFunction() {
echo "Not exist. Continuous."
fi

unzip -q "/tmp/latest.zip" -d "/tmp"
unzip -q "/tmp/app.zip" -d "/tmp"

if ! [ "$?" -eq "0" ]; then
echo "[-] Can't unzip downloaded archived file of the latest application version."
Expand Down Expand Up @@ -1005,7 +1149,7 @@ if [ $# -eq 0 ]; then
fi

# Option filter (Command-Line Interface parser).
while getopts "ha:m" argv; do
while getopts "ha:mg:" argv; do
case "${argv}" in
h)
usage
Expand All @@ -1020,7 +1164,11 @@ while getopts "ha:m" argv; do
fi
;;
m)
magicFunction
magic
;;
g)
version="${OPTARG}"
magic "$version"
;;
*)
echo "Use -h for more information."
Expand Down

0 comments on commit a395c81

Please sign in to comment.