-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d2a75c6
Showing
6 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
|
||
# Created by https://www.gitignore.io/api/go,linux,macos,windows,visualstudiocode | ||
# Edit at https://www.gitignore.io/?templates=go,linux,macos,windows,visualstudiocode | ||
|
||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
|
||
### Linux ### | ||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
Thumbs.db:encryptable | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msix | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
# Project Output | ||
main | ||
*.exe | ||
client-editor* | ||
|
||
# End of https://www.gitignore.io/api/go,linux,macos,windows,visualstudiocode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
all: | ||
go run main.go | ||
|
||
test: | ||
go build main.go && chmod +x main && ./main ~/Downloads/client.exe https://open.tibia.io/login.php | ||
|
||
build: | ||
GOOS=windows GOARCH=386 go build -o client-editor-x86.exe main.go | ||
GOOS=windows GOARCH=amd64 go build -o client-editor-x64.exe main.go | ||
GOOS=linux GOARCH=386 go build -o client-editor-x86 main.go | ||
GOOS=linux GOARCH=amd64 go build -o client-editor-x64 main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# client-editor | ||
|
||
### Usage | ||
```bash | ||
./client-editor.exe <tibia.exe location> <new custom login webservice> | ||
``` | ||
|
||
### Compiled Releases (Windows/Linux) | ||
https://github.com/opentibiabr/client-editor/releases | ||
|
||
### How to Compile | ||
Requirements: golang 1.8+ | ||
|
||
```bash | ||
$ make build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"time" | ||
) | ||
|
||
const bytePadding = 20 | ||
const propertyLoginWebService = "loginWebService=" | ||
const tibiaLoginWebService1 = "https://www.tibia.com/services/clientservices.php" | ||
const tibiaLoginWebService2 = "https://secure.tibia.com/services/clientservices.php" | ||
const tibiaLoginWebService3 = "https://secure.tibia.com/services/login.php" | ||
|
||
func main() { | ||
var currentExecutable, tibiaExe, customLoginWebService string | ||
var err error | ||
|
||
args := os.Args | ||
if len(args) > 0 { | ||
currentExecutable = args[0] | ||
fmt.Println(currentExecutable) | ||
} | ||
|
||
if len(args) > 1 { | ||
tibiaExe = args[1] | ||
fmt.Println(tibiaExe) | ||
} | ||
|
||
if len(args) > 2 { | ||
customLoginWebService = args[2] | ||
fmt.Println(customLoginWebService) | ||
} | ||
|
||
if currentExecutable == "" || tibiaExe == "" || customLoginWebService == "" { | ||
fmt.Printf("USAGE: %s <Tibia.exe Path> <Address Login Service>\n", currentExecutable) | ||
os.Exit(1) | ||
} | ||
|
||
tibiaPath, tibiaBinary := readFile(tibiaExe) | ||
_, tibiaRsa := readFile("tibia_rsa.key") | ||
_, otservRsa := readFile("otserv_rsa.key") | ||
|
||
tibiaExeFileName := filepath.Base(tibiaPath) | ||
tibiaExeBackupPath := filepath.Join(filepath.Dir(tibiaPath), fmt.Sprintf("BKP%d-%s", time.Now().Unix(), tibiaExeFileName)) | ||
tibiaExeBackupFileName := filepath.Base(tibiaExeBackupPath) | ||
|
||
fmt.Printf("[INFO] Backuping %s to %s\n", tibiaExeFileName, tibiaExeBackupFileName) | ||
err = ioutil.WriteFile(tibiaExeBackupPath, tibiaBinary, 0644) | ||
if err != nil { | ||
fmt.Printf("[ERROR] %s\n", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("[INFO] Searching for Tibia RSA... \n") | ||
if bytes.ContainsAny(tibiaBinary, string(tibiaRsa)) { | ||
fmt.Printf("[INFO] Tibia RSA found!\n") | ||
tibiaBinary = bytes.Replace(tibiaBinary, tibiaRsa, otservRsa, 1) | ||
fmt.Printf("[PATCH] Tibia RSA replaced to OTServ RSA!\n") | ||
} else if bytes.ContainsAny(tibiaBinary, string(otservRsa)) { | ||
fmt.Printf("[WARN] OTServ RSA already patched!\n") | ||
} else { | ||
fmt.Printf("[ERROR] Unable to find Tibia RSA\n") | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("[INFO] Searching for Login WebService... \n") | ||
var replaced bool | ||
for _, tibiaLoginWebService := range []string{tibiaLoginWebService1, tibiaLoginWebService2, tibiaLoginWebService3} { | ||
if propertyIndex := bytes.IndexAny(tibiaBinary, fmt.Sprintf("%s%s", propertyLoginWebService, tibiaLoginWebService)); propertyIndex != -1 { | ||
if len(customLoginWebService) > len(tibiaLoginWebService) { | ||
fmt.Printf("[ERROR] Cannot replace %s to %s, because the new loginWebService length is greater then %d.\n", tibiaLoginWebService, customLoginWebService, len(tibiaLoginWebService)) | ||
os.Exit(1) | ||
} | ||
|
||
tibiaBinary = bytes.Replace(tibiaBinary, append([]byte(propertyLoginWebService+tibiaLoginWebService)), append([]byte(propertyLoginWebService+customLoginWebService)), 1) | ||
fmt.Printf("[INFO] Tibia Login WebService found! %s\n", tibiaLoginWebService) | ||
fmt.Printf("[PATCH] Tibia Login WebService replaced to %s!\n", customLoginWebService) | ||
replaced = true | ||
break | ||
} | ||
} | ||
|
||
if !replaced { | ||
fmt.Printf("[ERROR] Unable to replace Tibia Login WebService\n") | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("[PATCH] Exporting File!\n") | ||
err = ioutil.WriteFile(tibiaPath, tibiaBinary, 0644) | ||
if err != nil { | ||
fmt.Printf("[ERROR] %s\n", err.Error()) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func readFile(path string) (string, []byte) { | ||
fileAbs, err := filepath.Abs(path) | ||
if err != nil { | ||
fmt.Printf("[ERROR] %s\n", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
fileName := filepath.Base(path) | ||
|
||
if _, err := os.Stat(fileAbs); os.IsNotExist(err) { | ||
fmt.Printf("[ERROR] cannot locate %s at %s\n", fileName, path) | ||
os.Exit(1) | ||
} | ||
|
||
raw, err := ioutil.ReadFile(fileAbs) | ||
if err != nil { | ||
fmt.Printf("[ERROR] %s\n", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
return fileAbs, raw | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9B646903B45B07AC956568D87353BD7165139DD7940703B03E6DD079399661B4A837AA60561D7CCB9452FA0080594909882AB5BCA58A1A1B35F8B1059B72B1212611C6152AD3DBB3CFBEE7ADC142A75D3D75971509C321C5C24A5BD51FD460F01B4E15BEB0DE1930528A5D3F15C1E3CBF5C401D6777E10ACAAB33DBE8D5B7FF5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BC27F992A96B8E2A43F4DFBE1CEF8FD51CF43D2803EE34FBBD8634D8B4FA32F7D9D9E159978DD29156D62F4153E9C5914263FC4986797E12245C1A6C4531EFE48A6F7C2EFFFFF18F2C9E1C504031F3E4A2C788EE96618FFFCEC2C3E5BFAFAF743B3FC7A872EE60A52C29AA688BDAF8692305312882F1F66EE9D8AEB7F84B1949 |