Skip to content

Instantly share code, notes, and snippets.

@jwrb
Forked from mipek/cwportchanger.py
Created July 15, 2013 17:31
Show Gist options
  • Save jwrb/6001782 to your computer and use it in GitHub Desktop.
Save jwrb/6001782 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
'''
CubeWorld Server Port Changer
By island219
Version 1.0
'''
import os
if not os.path.isfile("Server.exe"):
raise Exception("Couldn't find server binary!")
if os.path.isfile("Server_MITD.exe"):
raise Exception("Server_MITD.exe already exists, you have to remove it first.")
print 'Creating patched server binary..'
original = open('Server.exe', 'rb')
if original:
custom = open('Server_MITD.exe', 'wb')
edit = str(original.read())
loc = edit.find('\x68\x39\x30\x00\x00')
if not loc:
raise Exception("Server_MITD.exe seems to be already modified.")
custom.write(edit.replace('\x68\x39\x30\x00\x00', '\x68\x3A\x30\x00\x00', 1))
custom.close()
original.close()
print 'Port has been changed!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment