Skip to content

Instantly share code, notes, and snippets.

@dmknght
Created November 7, 2021 13:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmknght/1fe4673ef08e9d89160e57ae19cadc53 to your computer and use it in GitHub Desktop.
Save dmknght/1fe4673ef08e9d89160e57ae19cadc53 to your computer and use it in GitHub Desktop.
A short python script (no functions at all) to patch lincense check for sublime_text build 3211 Linux x64
import os
#sublime_binary_path = "/opt/sublime_text/sublime_text_b3211"
sublime_binary_path = "/tmp/sublime_text_3211/sublime_text"
version_magic_string = "/updates/3/stable/updatecheck?version=3211&platform=linux&arch=x64"
sz_magic_string = 66
#version_magic_string_offset = 0x00209ee0 # Offset from disassembler
version_magic_string_offset = 0x00009ee0 # (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 information")
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 3211")
f.close()
first_cmp_offset = 0x0031ea2e
second_cmp_offset = 0x00315564
cmp_size = 0x3
cmp_value = b"\x83\xf8\x01"
cmp_patch = b"\x83\xf8\x02"
f = open(sublime_binary_path, "rb+")
f.seek(first_cmp_offset)
data = f.read(cmp_size)
if data == cmp_value:
print(f"Found unpatched value at 0x{first_cmp_offset:x}")
f.seek(first_cmp_offset)
f.write(cmp_patch)
#print(f"Data at 0x{first_cmp_offset:x}: {str(f.read(cmp_size)):x}")
f.seek(second_cmp_offset)
data = f.read(cmp_size)
if data == cmp_value:
print(f"Found unpatched value at 0x{second_cmp_offset:x}")
f.seek(second_cmp_offset)
f.write(cmp_patch)
#print(f"Data at 0x{second_cmp_offset:x}: {str(f.read(cmp_size)):x}")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment