Skip to content

Instantly share code, notes, and snippets.

@rufoa
Last active Oct 21, 2021
Embed
What would you like to do?
sublime merge 2 build 2059 linux
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
target="${1:-/opt/sublime_merge/sublime_merge}"
check_sha() {
local sha_valid
sha_valid=("$@")
local hash
hash="$(sha256sum "$target" | cut -d' ' -f1)"
for s in "${sha_valid[@]}"; do
if [ "$hash" = "$s" ]; then
return 0
fi
done
return 1
}
patch_offset() {
printf "$3" | dd of="$target" bs=1 seek=$(($1)) count="$2" conv=notrunc status=none
}
if [ ! -w "$target" ]; then
echo "$target does not exist or is not writable. Ensure the path is correct and that you have write permission." >&2
exit 1
fi
if check_sha "c0a53b097742ada4b148f31d27f782e290739dadeb83de9f8147a4c4a81a1ac3" "95720e680665819c9f42ea2f1d4626e4da473d177fc871efc694af96d8e057a4"; then
echo "Checksum matches" >&2
else
echo "Checksum does not match. Ensure $target is the correct, unmodified version of Sublime Merge." >&2
exit 1
fi
backup="$target.bak"
cp "$target" "$backup"
revert() {
err=$?
trap - TERM INT EXIT
mv "$backup" "$target"
echo "Reverted modifications to $target" >&2
exit $err
}
trap revert TERM INT EXIT
echo "Patching $target" >&2
# Swap public key
patch_offset 0x55BF0 160 '\x30\x81\x9d\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8b\x00\x30\x81\x87\x02\x81\x81\x00\xc9\xda\x03\xe0\xc6\x33\xce\x4e\x55\xf5\xbf\x60\xf9\xb1\xb0\xda\xd6\x64\xc0\x5d\x03\xca\x7e\x21\xa6\x57\xd2\x17\xa9\x58\x9d\x51\x73\x30\x0d\xb5\x34\x13\x08\xab\x55\x5c\x22\x26\x6c\x03\x0d\xbe\x3c\x80\xb4\x59\xe9\xee\xad\x45\x8f\xa1\x38\x37\x69\xcd\x51\xa2\x19\xa4\x41\x4b\x8c\x0a\x1e\x51\x7f\x58\xc8\x33\xa5\x3c\x15\xc8\x24\xcd\xcc\x94\xb8\x5a\xfe\x44\x12\xa0\x18\x34\x63\x87\x72\x11\x11\x0b\x0c\x12\x44\x76\xec\x60\x13\xc0\x0d\x7e\xf1\x48\xbf\x8a\xce\x10\x02\x79\x45\x31\xf5\x3a\x34\xf2\x56\x6e\x71\xc7\xf4\x45\x02\x01\x11'
# Swap xor key
patch_offset 0x3A5436 1 '\x00'
# Fix sha-2 check
patch_offset 0x3A5C96 1 '\xf9'
patch_offset 0x3A5C99 1 '\x0e'
# Disable online licence check
patch_offset 0x3A67FE 1 '\xc3'
# Disable phone home
patch_offset 0x3A514E 1 '\xc3'
if check_sha "0a4a2bf9087c4b2a60b96a5746f4ffbe10f33986be6955e2a4c2ed694adf5e49" "28aab83c5f20b8e6d551116574e0ee2cbf2b30d0dba48cb46bc223b4d90c2491"; then
echo "Patch applied successfully" >&2
else
echo "Patch appears unsuccessful" >&2
exit 1
fi
trap - TERM INT EXIT
----- BEGIN LICENSE -----
TEAM RUFIO
Unlimited User License
E52D-666666
487EE6F0309908F702DDD52AFCD99A6A
6EE14CF8A2D42271B4FC0991BBF93ADC
FAA9075C436B3796669194A2F36CAAEF
B251155329EC2E434FD28B4A21BE68CC
955D306EE9ED843C5E98B1577D02DEAA
1F4E872AE6495CD5E3B1DA55D5ACD2B2
2EA4110FB800F21AA3EC2E3902589BCF
7281A19C2DFF0CEE4AEA5DDD1E6DF893
----- END LICENSE -----
@rufoa

This comment has been minimized.

Copy link
Owner Author

@rufoa rufoa commented May 18, 2021

updated for build 2056

@tukusejssirs

This comment has been minimized.

Copy link

@tukusejssirs tukusejssirs commented May 18, 2021

Thanks, @rufoa, for this awesome work and for the latest update!

I have created a script using the code in this gist. It checks the SHA 256 and only then proceeds with patching the binary. It also inserts the licence automatically (from variable defined at the beginning of the script.

smerge_patch.sh
#!/bin/bash

# Patch Sublime Merge Build 2056 on Linux


# Variables
sha_valid=('44c6587efd8dd8faf84a47504dccf4ab36d00ca47e90f60879f749669fbdc897' '296872fe3bcb5c35908918c59fc78f35b8325547824dc773b1a52cc8cfd17061')
sha_current="$(sha256sum /opt/sublime_merge/sublime_merge | grep -o '^[^ ]\+')"
sha_matches='false'
licence='----- BEGIN LICENSE -----
TEAM RUFIO
Unlimited User License
E52D-666666
487EE6F0309908F702DDD52AFCD99A6A
6EE14CF8A2D42271B4FC0991BBF93ADC
FAA9075C436B3796669194A2F36CAAEF
B251155329EC2E434FD28B4A21BE68CC
955D306EE9ED843C5E98B1577D02DEAA
1F4E872AE6495CD5E3B1DA55D5ACD2B2
2EA4110FB800F21AA3EC2E3902589BCF
7281A19C2DFF0CEE4AEA5DDD1E6DF893
----- END LICENSE -----'

# Check if the SHA 256 checksum matches
for s in "${sha_valid[@]}"; do
	echo "s : $s"
	if [ "$sha_current" = "$s" ]; then
		echo '[INFO] SHA 256 checksum matches.' 1>&2
		sha_matches='true'
		break
	fi
done

if [ "$sha_matches" = 'true' ]; then
	# Backup the original file
	cp /opt/sublime_merge/sublime_merge{,.bak}

	# Swap public key
	printf '\x30\x81\x9d\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8b\x00\x30\x81\x87\x02\x81\x81\x00\xc9\xda\x03\xe0\xc6\x33\xce\x4e\x55\xf5\xbf\x60\xf9\xb1\xb0\xda\xd6\x64\xc0\x5d\x03\xca\x7e\x21\xa6\x57\xd2\x17\xa9\x58\x9d\x51\x73\x30\x0d\xb5\x34\x13\x08\xab\x55\x5c\x22\x26\x6c\x03\x0d\xbe\x3c\x80\xb4\x59\xe9\xee\xad\x45\x8f\xa1\x38\x37\x69\xcd\x51\xa2\x19\xa4\x41\x4b\x8c\x0a\x1e\x51\x7f\x58\xc8\x33\xa5\x3c\x15\xc8\x24\xcd\xcc\x94\xb8\x5a\xfe\x44\x12\xa0\x18\x34\x63\x87\x72\x11\x11\x0b\x0c\x12\x44\x76\xec\x60\x13\xc0\x0d\x7e\xf1\x48\xbf\x8a\xce\x10\x02\x79\x45\x31\xf5\x3a\x34\xf2\x56\x6e\x71\xc7\xf4\x45\x02\x01\x11' | dd of=/opt/sublime_merge/sublime_merge bs=1 seek=345216 count=160 conv=notrunc

	# Swap xor key
	printf '\x00' | dd of=/opt/sublime_merge/sublime_merge bs=1 seek=3804370 count=1 conv=notrunc

	# Fix SHA-2 check
	printf '\xf9' | dd of=/opt/sublime_merge/sublime_merge bs=1 seek=3806511 count=1 conv=notrunc
	printf '\x0e' | dd of=/opt/sublime_merge/sublime_merge bs=1 seek=3806514 count=1 conv=notrunc

	# Disable online licence check
	printf '\xc3' | dd of=/opt/sublime_merge/sublime_merge bs=1 seek=3809430 count=1 conv=notrunc

	# Insert licence
	rm -rf "$HOME/.config/sublime-merge/Local/License.sublime_license"
	echo "$licence" > "$HOME/.config/sublime-merge/Local/License.sublime_license"
else
	echo '[ERROR] SHA 256 checksum does not match, quitting.' 1>&2
	exit 1
fi
@tuannm93

This comment has been minimized.

Copy link

@tuannm93 tuannm93 commented May 20, 2021

Thanks, @rufoa, for this awesome work and for the latest update!

I have created a script using the code in this gist. It checks the SHA 256 and only then proceeds with patching the binary. It also inserts the licence automatically (from variable defined at the beginning of the script.

smerge_patch.sh

@tukusejssirs, It's great that you created the .sh file above.
I am using MacOS. Can you create a file for MacOS?
That would be great for me.
Thank you.

@rufoa

This comment has been minimized.

Copy link
Owner Author

@rufoa rufoa commented May 20, 2021

@tukusejssirs thanks for this! I will incorporate your work into the script soon

@tuannm93 it isn't that simple, sorry. The changes needed for MacOS are quite different

@tukusejssirs

This comment has been minimized.

Copy link

@tukusejssirs tukusejssirs commented May 20, 2021

@tukusejssirs thanks for this! I will incorporate your work into the script soon

Anytimes. 😉

The script could still be improved, e.g. patch other versions (checksums + hex offsets / replacement values). If necessary, we could check the version number.

And we could also support Sublime Text (3+).

I wish I’d how you find the hex offsets and replacement values. 😉

[@tuannm93]

Can you create a file for MacOS?

I am not a cracker. If you provide me the information as @rufoa provided me/us for Linux, I could create a script for you.

@tuannm93

This comment has been minimized.

Copy link

@tuannm93 tuannm93 commented May 20, 2021

@tukusejssirs thanks for this! I will incorporate your work into the script soon

@tuannm93 it isn't that simple, sorry. The changes needed for MacOS are quite different

Thank you very much. No problem, I'll find out more.

@tuannm93

This comment has been minimized.

Copy link

@tuannm93 tuannm93 commented May 20, 2021

@tukusejssirs thanks for this! I will incorporate your work into the script soon

Anytimes. 😉

The script could still be improved, e.g. patch other versions (checksums + hex offsets / replacement values). If necessary, we could check the version number.

And we could also support Sublime Text (3+).

I wish I’d how you find the hex offsets and replacement values. 😉

[@tuannm93]
Can you create a file for MacOS?

I am not a cracker. If you provide me the information as @rufoa provided me/us for Linux, I could create a script for you.

Thank you very much. I will recheck it.

@tukusejssirs

This comment has been minimized.

Copy link

@tukusejssirs tukusejssirs commented May 21, 2021

@rufoa, you definitely did not incorpporate my script, you reworked and improved it! 😉 I still think though that the licence should be inserted via command (echo "$licence" > "$HOME/.config/sublime-merge/Local/License.sublime_license"). If needed, we could place it under a command-line option (getopt; also see also this comment of mine. It might a good idea to backup the previous licence.

Also I think that INFO | WARN | ERROR prefixes are nice to have; they provide some additional information to the user what is the log level of a particular message.

Also I think that the exit codes could be different for every different error type. We should then list them in the help message.


Do tell me what you think about a repo with patching script for both ST and SM. 😉

@Sunny-2772

This comment has been minimized.

Copy link

@Sunny-2772 Sunny-2772 commented Jun 6, 2021

how to use this on windows

@bitsper2nd

This comment has been minimized.

Copy link

@bitsper2nd bitsper2nd commented Jun 7, 2021

how to use this on windows

I think you would need to use bash. If you have git for windows installed, then you could run the script with a slight modification.

@theol0403

This comment has been minimized.

Copy link

@theol0403 theol0403 commented Jun 7, 2021

Even if you could run, the offsets won't be the same with windows - this is Linux only.

Try
https://gist.github.com/maboloshi/feaa63c35f4c2baab24c9aaf9b3f4e47#how-to-crack-sublime-merge-2056-with-hex-editor--win64--with-license-

@ardyfeb

This comment has been minimized.

Copy link

@ardyfeb ardyfeb commented Aug 27, 2021

Any update for 2059 ?

@rufoa

This comment has been minimized.

Copy link
Owner Author

@rufoa rufoa commented Aug 27, 2021

@ardyfeb updated for build 2059

@ahmubashshir

This comment has been minimized.

Copy link

@ahmubashshir ahmubashshir commented Aug 28, 2021

Checksum of 2059 is 3d36ad7cf10e87b83e2443070366e69093c32b16dad820bffe4a46f66245ab70 on my machine, installed from AUR.

@rufoa

This comment has been minimized.

Copy link
Owner Author

@rufoa rufoa commented Aug 28, 2021

@ahmubashshir I can't reproduce that. Please confirm my steps:

This also works correctly with the official repo https://www.sublimemerge.com/docs/linux_repositories#pacman

@ahmubashshir

This comment has been minimized.

Copy link

@ahmubashshir ahmubashshir commented Aug 28, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment