Skip to content

Instantly share code, notes, and snippets.

@dmknght
Last active August 26, 2022 00:28
Show Gist options
  • Save dmknght/bfd8d25a8b4c804889f8eeaf026efbe8 to your computer and use it in GitHub Desktop.
Save dmknght/bfd8d25a8b4c804889f8eeaf026efbe8 to your computer and use it in GitHub Desktop.
import os
sublime_binary_path = "/tmp/sublime_text" # FIXME: this is the absolute path to writable sublime_text binary.
version_magic_string = "4126"
sz_magic_string = 4
version_magic_string_offset = 0x0002d78a # (Real offset from xxd)
is_file_read = os.access(sublime_binary_path, os.R_OK)
if not is_file_read:
print(f"File {sublime_binary_path} is not readable. Exit!")
exit(1)
is_file_write = os.access(sublime_binary_path, os.W_OK)
if not is_file_write:
print(f"File {sublime_binary_path} is not writable. Only check for patch.")
f = open(sublime_binary_path, "rb")
f.seek(version_magic_string_offset)
data = f.read(sz_magic_string)
if data.decode() == version_magic_string:
print("File matched sublime_text build 4126")
else:
print("File doesn't have build 4126 magic string")
f.close()
offset_1 = 0x00385797 # data = 0f 84; patched = 0f 85
offset_2 = 0x0038583d # data = 74 1f; patched = 75 1f
if is_file_write:
f = open(sublime_binary_path, "rb+")
f.seek(offset_1)
if f.read(2) == b"\x0f\x84":
print("Patching first jump")
f.seek(offset_1)
f.write(b"\x0f\x85")
f.seek(offset_2)
if f.read(2) == b"\x74\x1f":
print("Patching second jump")
f.seek(offset_2)
f.write(b"\x75")
f.close()
else:
f = open(sublime_binary_path, "rb")
f.seek(offset_1)
if f.read(2) == b"\x84\x8c":
print("First jump is not patched")
f.seek(offset_2)
if f.read(2) == b"\x74\x09":
print("Second jump is not patched")
f.close()
print("Done")
@dmknght
Copy link
Author

dmknght commented Jun 21, 2022

I still get a pop up all the time! "thanks for trying sublime, would you like to buy?"

Because it has an other thread that do check license from internet. This script patches the license key check only.

@gamesguru
Copy link

i have this in my hosts file.

first two lines were NOT commented when i installed your patch. But i still got the pop-up, why?

# Sublime Text 3
#0.0.0.0 www.sublimetext.com
#0.0.0.0 sublimetext.com
0.0.0.0 sublimehq.com
0.0.0.0 license.sublimehq.com
0.0.0.0 45.55.255.55
0.0.0.0 45.55.41.223

# Sublime Text 3
#127.0.0.1 license.sublimehq.com
#127.0.0.1 www.sublimetext.com
##0.0.0.0 license.sublimehq.com
##0.0.0.0 45.55.255.55
##0.0.0.0 45.55.41.223

@ccambra
Copy link

ccambra commented Aug 7, 2022

i cant understand i need copy paste the serial key

@jn0
Copy link

jn0 commented Aug 24, 2022

Folks, I DO NOT USE the sublime. Just wanted to take a look. I did. Just making a found patch (see ref) a bit more clean to my mind.

The patch was ok at the time of post. It's not maintained or otherwise supported.

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