Skip to content

BNLS Client

David edited this page Oct 5, 2018 · 1 revision

BNLS Client

A client implementation of the BNLS protocol.

Constructor

  • BnlsClient() - creates a new instance of a BNLS client

Methods

  • connect(host, [port]) - connects to a BNLS server (default port is 9367)
  • disconnect() - disconnects from the server
  • send_packet(id, [payload]) - sends a BNLS packet with the given ID and payload
  • receive_packet() - reads the next packet in the data stream
  • authorize(bot id, password) - authenticates with the server
    • This is not required by all servers, but can be used by them for statistics tracking
    • Returns TRUE if the authorization was accepted.
  • request_version_byte(product) - returns the version byte for the specified product
    • 'product' can be anything supported by the get_product_info function.
    • Returns False on error, or -1 if the server does not support the specified product.
  • hash_data(data, [flags], [client], [server], [cookie]) - returns the Broken-SHA1 (XSha) hash of the given data
    • Flags are binary - supported flags:
      • 0x02 - double hash (must specify 'client' and 'server') values
      • 0x04 - use cookie (must specify 'cookie' value
    • If using a double hash the 'client' and 'server' values are their respective tokens.
    • Returns the hash as a bytes object, or False on error.
  • encrypt_key_basic(key, server token) - decodes and encrypts a CD key
    • FOR SECURITY REASONS IT IS NOT RECOMMENDED TO USE THIS FUNCTION! Your key will be transmitted in plain-text to the server. An untrusted server could be recording these values and stealing your keys. Consider using the local key decoder instead.
    • Returns True/False and a tuple containing the decoded key values:
      1. Client token
      2. Key length
      3. Product value
      4. Public value
      5. Unknown value (0)
      6. 20-byte key hash
    • On failure, the tuple will be None.
  • set_nls_version(version) - instructs the server to use the specified NLS version
    • For whatever reason, servers use version 1 as the default even though it's only used by the WarCraft 3 DEMO.
    • This must be sent with version = 2 before any NLS operations are performed.
  • verify_server_signature(ip, signature) - verifies the 128-byte signature that is sometimes provided by servers
    • Returns TRUE if the server was verified
  • check_version(product, archive filetime, archive filename, formula, [cookie], [flags]) - performs a version check for the given product and returns the results
    • 'product' can be anything supported by the get_product_info function.
    • The archive filetime, filename, and formula are provided by the server.
    • If making multiple requests, an optional cookie can be specified.
    • No flags are currently supported, but they are in the server specification just in case.
    • Returns True/False, a tuple containing the returned data, and the latest version byte
      • The returned data tuple contains: version, checksum, exe info
  • get_logon_challenge(username, password) - initializes NLS and returns the client key (A) to use in SID_AUTH_ACCOUNTLOGON.
    • FOR SECURITY REASONS IT IS NOT RECOMMENDED TO USE THIS FUNCTION! Your password will be transmitted to the server in plain text. Consider using the local NLS Client instead.
  • get_logon_proof(salt, server key) - processes the logon challenge and returns the proof (M1) needed for SID_AUTH_ACCOUNTLOGONPROOF.
    • get_logon_challenge() must be used before this.
    • 'salt' and 'server key' are values returned in SID_AUTH_ACCOUNTLOGON and should be bytes objects.
  • get_create_account(username, password) - returns the values needed to create an account with SID_AUTH_ACCOUNTCREATE.
    • FOR SECURITY REASONS IT IS NOT RECOMMENDED TO USE THIS FUNCTION! Your password will be transmitted to the server in plain text. Consider using the local NLS Client instead.

Properties

  • connected() - returns TRUE if the client is connected to a server
  • authorized() - returns TRUE if the client has authenticated with the server
  • external_ip - the public IP address of the client, as optionally returned by the server when authenticating
Clone this wiki locally