Skip to content

Instantly share code, notes, and snippets.

@heinrich5991 heinrich5991/ Secret
Created Oct 31, 2015

What would you like to do?
import argparse
import os
SERVERBROWSE_FWERROR = b'\xff\xff\xff\xfffwer'
def make_executable(path):
Taken from
Has obvious race conditions, but whatever...
old_mode = os.stat(path).st_mode
new_mode = old_mode | ((old_mode & 0o444) >> 2) # copy R bits to X
if new_mode != old_mode:
os.chmod(path, new_mode)
def main():
parser = argparse.ArgumentParser(description="Patch a Teeworlds server executable to work around a bug in the registering code.")
parser.add_argument('file', metavar="FILE", help="Filename of the executable to patch")
filename = parser.parse_args().file
file = open(filename, 'rb')
contents =
fixed = contents.replace(SERVERBROWSE_FWERROR, os.urandom(len(SERVERBROWSE_FWERROR)))
fixed_filename = filename + "_fixed.exe"
open(fixed_filename, 'wb').write(fixed)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.