Skip to content

Commit

Permalink
Add some code in the codesign part.
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahtsai committed Feb 11, 2021
1 parent 256ea2c commit dd365a1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 27 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Usage:
./sketchcrapp [-h] [-a] <applicationPath> [-m]
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
[+] SketchCrapp last published date: 2021-02-05 serial 001
[+] SketchCrapp last published date: 2021-02-12 serial 005
```

```
Expand All @@ -67,6 +67,7 @@ crackb0x:SketchCrapp duraki$ ./sketchcrapp.sh -m
Dload Upload Total Spent Left Speed
100 58.5M 100 58.5M 0 0 1805k 0 0:00:33 0:00:33 --:--:-- 2328k
Checking if Sketch.app exist in /tmp ... Not exist. Continuous.
[+] Checking if Sketch.app exist in /tmp ... Not exist. Continuous.
[+] Checking if Sketch.app exist in /Applications ... Exist. Removing.
[+] Moving Sketch.app to /Applications directory ... Successfully.
[+] Analysing application bundle ... Starting
Expand All @@ -79,51 +80,52 @@ Checking if Sketch.app exist in /tmp ... Not exist. Continuous.
[+] Patching address at offset: 0x58606f with value: \00
1+0 records in
1+0 records out
1 bytes transferred in 0.000026 secs (38480 bytes/sec)
1 bytes transferred in 0.000023 secs (43240 bytes/sec)
[+] Patching address at offset: 0x586072 with value: \00
1+0 records in
1+0 records out
1 bytes transferred in 0.000020 secs (49932 bytes/sec)
1 bytes transferred in 0.000018 secs (55188 bytes/sec)
[+] Patching address at offset: 0x584cbe with value: \00\00
2+0 records in
2+0 records out
2 bytes transferred in 0.000023 secs (86480 bytes/sec)
2 bytes transferred in 0.000025 secs (79892 bytes/sec)
[+] Patching address at offset: 0x584dee with value: \165
1+0 records in
1+0 records out
1 bytes transferred in 0.000018 secs (55924 bytes/sec)
1 bytes transferred in 0.000018 secs (55188 bytes/sec)
[+] Patching address at offset: 0x66cffb with value: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00
15+0 records in
15+0 records out
15 bytes transferred in 0.000062 secs (241979 bytes/sec)
[+] Patching address at offset: 0x66d00b with value: \40\123\153\145\164\143\150\103\162\141\160\160\40
13+0 records in
13+0 records out
13 bytes transferred in 0.000059 secs (220753 bytes/sec)
13 bytes transferred in 0.000058 secs (224387 bytes/sec)
[+] Patching address at offset: 0xdcd484 with value: \01
1+0 records in
1+0 records out
1 bytes transferred in 0.000017 secs (58254 bytes/sec)
1 bytes transferred in 0.000018 secs (55924 bytes/sec)
[+] Patching address at offset: 0xdcd488 with value: \24
1+0 records in
1+0 records out
1 bytes transferred in 0.000016 secs (62602 bytes/sec)
1 bytes transferred in 0.000017 secs (59075 bytes/sec)
[+] Patching address at offset: 0xdcc0fc with value: \165\00
2+0 records in
2+0 records out
2 bytes transferred in 0.000020 secs (99864 bytes/sec)
2 bytes transferred in 0.000021 secs (95325 bytes/sec)
[+] Patching address at offset: 0xdcc21f with value: \64
1+0 records in
1+0 records out
1 bytes transferred in 0.000017 secs (59075 bytes/sec)
1 bytes transferred in 0.000018 secs (55924 bytes/sec)
[+] Patching address at offset: 0xed0fa5 with value: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00
15+0 records in
15+0 records out
15 bytes transferred in 0.000066 secs (227128 bytes/sec)
15 bytes transferred in 0.000110 secs (136179 bytes/sec)
[+] Patching address at offset: 0xed0fb5 with value: \40\123\153\145\164\143\150\103\162\141\160\160\40
13+0 records in
13+0 records out
13 bytes transferred in 0.000059 secs (220753 bytes/sec)
13 bytes transferred in 0.000055 secs (236043 bytes/sec)
[+] Checking user default keychain ... Exist.
[+] SketchCrapp certificate already exists.
[+] Skipping certificate creation ... OK
[+] Signing the patched *.app bundle. This may require root privilege.
Expand All @@ -142,7 +144,7 @@ Checking if Sketch.app exist in /tmp ... Not exist. Continuous.
[+] SketchCrapp (A Sketch.app cracking tool)
[+] https://github.com/duraki/SketchCrapp [by @duraki & @elijahtsai]
[+] SketchCrapp last published date: 2021-02-05 serial 001
[+] SketchCrapp last published date: 2021-02-12 serial 005
```

## Issues
Expand Down Expand Up @@ -194,4 +196,3 @@ If you really need specific version you can contact the team via GitHub Issues,

##### Stargazers over time
[![Stargazers over time](https://starchart.cc/duraki/SketchCrapp.svg)](https://starchart.cc/duraki/SketchCrapp)

49 changes: 36 additions & 13 deletions sketchcrapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ EOF
# Last function to run before exit.
finally() {
local status="$1"
echo "[+] SketchCrapp last published date: 2021-02-05 serial 001"
echo "[+] SketchCrapp last published date: 2021-02-12 serial 005"
exit $status
}

Expand Down Expand Up @@ -257,33 +257,38 @@ genSelfSignCert() {

# Import code-signature certificate to keychain. Must be included and trusted
# by the OS internals.
# - First: The default keychain that under the user profile.
importSelfSignCert() {
# Get the path of user default keychain.
userKeyChain="$(security default-keychain -d user | sed -e 's/^[ ]*//g' -e 's/\"//g')"

if ! [ -f "$userKeyChain" ]; then
echo "[-] User default Keychain does not exist: $userKeyChain"
finally 1
fi
local userDefaultKeychain="$1"

echo "[+] Importing private key and self-signed certificate"
security import pkcs.p12 -k "$userKeyChain" -f pkcs12 -P 1234
security import pkcs.p12 -k "$userDefaultKeychain" -f pkcs12 -P 1234
}

# Equivalent to code-signature application in Sketch.
# Sign Sketch with generated certificate.
# - Parameters:
# - First: The application bundle path.
# - Second: The default keychain that under the user profile.
signApplication() {

appPath="$1"

local userDefaultKeychain="$2"

echo "[+] Signing the patched *.app bundle. This may require root privilege."
echo "[+] If asked, enter your login password. Choose \"Always Allow\" to \
not be asked again."
codesign --deep --force -s "sketchcrapp" "$appPath"
codesign --deep --force -s "sketchcrapp" "$appPath" --keychain "$userDefaultKeychain"
if ! [ "$?" -eq "0" ]; then
echo "[-] Failed to Signing Sketch bundle."
clean
finally 1
fi
}

#Get binary hash from CFBundleShortVersionString
# Get binary hash from CFBundleShortVersionString
# - Parameters:
# - First: The application bundle CFBundleShortVersionString.
getHashFromVersionString() {
Expand Down Expand Up @@ -696,19 +701,37 @@ https://github.com/duraki/SketchCrapp"
esac
# Install name tag
nameTag "$appPath"

# Get the path of user default keychain.
userKeyChain="$(security default-keychain -d user | sed -e 's/^[ ]*//g' -e 's/\"//g')"

echo -n "[+] Checking user default keychain ... "

if ! [ -f "$userKeyChain" ]; then
echo "Not exist."
echo "[-] User default Keychain does not exist: $userKeyChain"
clean
finally 1
fi

echo "Exist."

# CodeSigning area.
# Check if sketchcrapp certificate already exist.
if ! security find-certificate -c "sketchcrapp" 2>&1 >/dev/null; then
# Certificate does not exist, generate one.
genSelfSignCert

# Import the certificate.
importSelfSignCert
importSelfSignCert "$userKeyChain"
else
echo "[+] SketchCrapp certificate already exists."
echo "[+] Skipping certificate creation ... OK"
fi

# Sign the application.
signApplication "$appPath"
signApplication "$appPath" "$userKeyChain"

# Call cleaner to do some housekeeping.
clean
echo "[+] SketchCrapp process completed. Sketch.app has been patched :)"
Expand Down Expand Up @@ -771,7 +794,7 @@ magicFunction() {
finally 1
fi

echo -n "Checking if Sketch.app exist in /tmp ... "
echo -n "[+] Checking if Sketch.app exist in /tmp ... "
if [ -d "/tmp/Sketch.app" ]; then
echo "Exist. Removing."
rm -rf "/tmp/Sketch.app"
Expand Down

0 comments on commit dd365a1

Please sign in to comment.