metin2_login.py
Login-Key Capture & Scripted Login Client
Python · Standard Library · Metin2 Authentication Protocol
Overview
metin2_login.py is a single-file Python module (stdlib only, no external dependencies) implementing the classic Metin2 authentication protocol found in The Old Metin2 Project-style server builds, including nightly and Anka2-era implementations.
The module provides authentication-handshake functionality, login-exchange capture through a transparent local TCP proxy, and scripted session functionality from Python.
Features
- fetch_login_key()
Performs the authentication handshake (0xFF) and LOGIN3 exchange, retrieving the dwLoginKey issued by the authentication server. - capture_login_key()
A transparent TCP proxy that relays traffic while recording the LOGIN3 / AUTH_SUCCESS exchange to a local JSON file. - login_with_key()
Provides scripted login functionality for channel cores, including handshake and subsequent session stages. - In-client mode
Designed to support clients embedding Python, with functionality for hooking net.ConnectToAccountServer for automated login workflows. See the module docstring for details.
Requirements
[]Python 3.8+ for external usage.
[]An authentication core implementing the plain LOGIN3 protocol (TOMP nightly-style).- Network access to the relevant authentication endpoint.
Quick Start — CLI
Bash:
python metin2_login.py key --host 127.0.0.1 --auth-port 11002 --user myaccount
python metin2_login.py login --host 127.0.0.1 --game-port 13001 --char 0
python metin2_login.py capture --target-host 127.0.0.1 --target-port 11002
Usage from Python
Python:
import metin2_login as m2
key = m2.fetch_login_key(
"127.0.0.1",
"myaccount",
"mypassword",
auth_port=11002
)
sess = m2.login_with_key(
"127.0.0.1",
key["login"],
key["login_key"],
game_port=13001,
char_index=0,
enter_game=True
)
print(sess.main_character["name"], "is in game")
Protocol Overview
- Handshake: 0xFF — 13 bytes.
[]Client response: dwTime + 2lDelta.
[]LOGIN3: Header 111, 65 bytes plus one sequence byte.
[]Sequence handling: packet_info sequence table embedded from sequence.cpp.
[]AUTH_SUCCESS: Header 150, carrying the dwLoginKey.
[]LOGIN2: Header 109, used by the channel core.
[]Session progression: PHASE → SELECT → LOADING → GAME. - Structure format: #pragma pack#pragmaian.
Important Notes
[]The capture proxy writes captured credentials to a local JSON file in plain text.
[]Login keys are session-bound and may expire server-side after logout.- Logging in twice on the same account may disconnect the previous session, depending on the server's DisconnectOfSameLogin implementation.
Tested Environments
[]TOMP nightly client — x64, embedded Python 3.14 — with nightly server sources.
[]Metin2 style web/gateway deployments.
Unknown packet headers raise a PacketError identifying the offending header byte. Porting to other server builds may require adjusting GC_SIZES to account for differences in packet definitions.
Feedback and test reports from other TOMP-based builds are welcome.
Additional Testing & References
This implementation was also tested against deployments using
Linkleri görebilmek için Turkmmo Forumuna ÜYE olmanız gerekmektedir.
, including
Linkleri görebilmek için Turkmmo Forumuna ÜYE olmanız gerekmektedir.
.Technical feedback, compatibility reports and discussion are welcome.
Son düzenleme:
Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)
Benzer konular
- Cevaplar
- 41
- Görüntüleme
- 3K
- Cevaplar
- 1
- Görüntüleme
- 204
- Cevaplar
- 2
- Görüntüleme
- 40
- Cevaplar
- 2
- Görüntüleme
- 26
- Cevaplar
- 3
- Görüntüleme
- 55