Git Product home page Git Product logo

pycraft's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycraft's Issues

ImportError: No module named cryptography.hazmat.backends

The Error:
Traceback (most recent call last):
File "start.py", line 9, in
from minecraft.networking.connection import Connection
File "/Users/FireFolder/Documents/Git /pyCraft-nbt_exploit/minecraft/networking/connection.py", line 11, in
from . import encryption
File "/Users/FireFolder/Documents/Git /pyCraft-nbt_exploit/minecraft/networking/encryption.py", line 3, in
from cryptography.hazmat.backends import default_backend
ImportError: No module named cryptography.hazmat.backends
Ishaans-MacBook-Air:pyCraft-nbt_exploit FireFolder$ python start.py
Traceback (most recent call last):
File "start.py", line 9, in
from minecraft.networking.connection import Connection
File "/Users/FireFolder/Documents/Git /pyCraft-nbt_exploit/minecraft/networking/connection.py", line 11, in
from . import encryption
File "/Users/FireFolder/Documents/Git /pyCraft-nbt_exploit/minecraft/networking/encryption.py", line 3, in
from cryptography.hazmat.backends import default_backend

Failing to connect to server

First time attempting to run this, the latest src gives

Traceback (most recent call last):
  File "D:\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 341, in run
    self.connection._handle_exception(e, sys.exc_info())
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 319, in _handle_exception
    raise_(*exc_info)
  File "D:\Python\Python36\lib\site-packages\future\utils\__init__.py", line 413, in raise_
    raise exc.with_traceback(tb)
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 339, in run
    self._run()
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 371, in _run
    self.connection.file_object)
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 424, in read_packet
    ready_to_read = select.select([stream], [], [], self.TIME_OUT)[0]
TypeError: argument must be an int, or have a fileno() method.

Bye!

I also tried commit 8d1dcec - the 1.12 release

Traceback (most recent call last):
  File "D:\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 341, in run
    self.connection._handle_exception(e, sys.exc_info())
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 319, in _handle_exception
    raise_(*exc_info)
  File "D:\Python\Python36\lib\site-packages\future\utils\__init__.py", line 413, in raise_
    raise exc.with_traceback(tb)
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 339, in run
    self._run()
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 371, in _run
    self.connection.file_object)
  File "D:\Users\Kairus\Downloads\pyCraft-master\minecraft\networking\connection.py", line 439, in read_packet
    decompressed_packet = decompress(packet_data.read())
zlib.error: Error -5 while decompressing data: incomplete or truncated stream

Python -- version
Python 3.6.2
pip install -r requirements.txt

Requirement already satisfied: cryptography>=1.5 in d:\python\python36\lib\site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: requests in d:\python\python36\lib\site-packages(from -r requirements.txt (line 2))
Requirement already satisfied: future in d:\python\python36\lib\site-packages (from -r requirements.txt (line 3))
Requirement already satisfied: idna>=2.1 in d:\python\python36\lib\site-packages (from cryptography>=1.5->-r requirements.txt (line 1))
Requirement already satisfied: cffi>=1.7 in d:\python\python36\lib\site-packages (from cryptography>=1.5->-r requirements.txt (line 1))
Requirement already satisfied: six>=1.4.1 in d:\python\python36\lib\site-packages (from cryptography>=1.5->-r requirements.txt (line 1))
Requirement already satisfied: asn1crypto>=0.21.0 in d:\python\python36\lib\site-packages (from cryptography>=1.5->-r requirements.txt (line 1))
Requirement already satisfied: urllib3<1.22,>=1.21.1 in d:\python\python36\lib\site-packages (from requests->-r requirements.txt (line 2))
Requirement already satisfied: certifi>=2017.4.17 in d:\python\python36\lib\site-packages (from requests->-r requirements.txt (line 2))
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in d:\python\python36\lib\site-packages (from requests->-r requirements.txt (line 2))
Requirement already satisfied: pycparser in d:\python\python36\lib\site-packages (from cffi>=1.7->cryptography>=1.5->-r requirements.txt (line 1))

Any insight? I'm happy to help in working this out.

Send packets in plugins

Make it possible for plugins to send packets (through PacketSenderManager ?). This would make the plugin system way more useful. As far as I can see, it would only require the socket to be accessible by the plugins.
Also, maybe an overkill, but move chat printing and other game management stuff to plugins ?

[question] 1.7.10?

Is there any way I could make this work with 1.7.10? Did this ever support it? Is there simply something I need to change (I tried recompiling init.pyc with minecraft_version=1.7.10 and protocol_version=437)? Thanks in advance!

Movement

I don't understand how to send the packet to move character

Working version/branch for each protocol version

Hello,

First, I would like to thank you for this wonderful application.

I need to connect to different servers with this client. Unfortunately, those servers are running different versions. It would be nice if you could have different branches or version of your code that would work with the different protocol versions while maintaining the same structure around it.

I wanted to try the version that is compatible with 1.2 but it did not seems to work properly with wx or something. I like the simplistic approach of using the command line you used in the latest version.

This is not an issue. I might try to implement it myself or get a simpler and working version that is compatible with 1.2.

Support for Forge servers with arbitrary mod lists

Is it possible to get support for Forge servers so the client can send arbitrary mod lists to allow connections? Currently when connecting, the server gives the error:

Disconnecting Player: This server requires FML/Forge to be installed. Contact your server admin for more details.

Exploit crashes client, not server

So there is this interesting thing that happens when running the exploit.

The server disconnects the exploit user with:
[00:04:27 INFO]: IJoshFTW lost connection: TranslatableComponent{key='disconnect.genericReason', args=[Internal Exception: io.netty.handler.codec.DecoderException: java.lang.OutOfMemoryError: Java heap space], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}

Python gives this:

Exception in thread Networking Thread:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 810, in __bootstrap_inner
    self.run()
  File "C:\Users\Joshua\Desktop\pyCraft-nbt_exploit\minecraft\networking\connection.py", line 184, in run
    self.connection.file_object)
  File "C:\Users\Joshua\Desktop\pyCraft-nbt_exploit\minecraft\networking\connection.py", line 217, in read_packet
    length = VarInt.read_socket(self.connection.socket)
  File "C:\Users\Joshua\Desktop\pyCraft-nbt_exploit\minecraft\networking\types.py", line 88, in read_socket
    raise RuntimeError("Socket disconnected")
RuntimeError: Socket disconnected

The server is running with default RAM, I personally have 16 GB.
Is Python somehow running out of memory?

Python version is 2.7.3
Java version is 1.8_40
Server version: Default fresh 1.8.3 running locally

packet 18 and 21 are broken.

line 234 byte = struct.unpack('!b', FileObject.read(1))[0]
line 264 byte = struct.unpack('!b', FileObject.read(1))[0]
line 399 byte = struct.unpack('!b', FileObject.read(1))[0]
line 420 byte = struct.unpack('!b', FileObject.read(1))[0]

those should be an unsigned byte, !B in the PacketListenerManager.py

Support 1.7.x

Would be supper helpful to support 1.7.x for existing Modded servers.

Cannot run under Python Tools for Visual Studio

I tried running start.py under Python 2.7 on 32-bit Windows 7, via Python Tools for Visual Studio 2010. I received the following error:

exceptions.ImportError occurred
Message: cannot import name __requires__

The exception report is generated in file $/minecraft/__init__.py, line 8 (end of file) The call stack is:

    _build_master in __init__ line 607
    __init__ module line 3020
    __init__ module line 7
    encryption module line 3
    connection module line 11
    start module line 7

Versions:

  • Windows 7 Pro, 64-bit
  • Python 2.7 32-bit for Windows
  • cffi 0.9.2
  • cryptography 0.8.2
  • enum34 1.0.4
  • numpy 1.9.1
    -.PIL 1.1.7
  • pyasn1 0.1.7
  • pycparser 2.10
    -.requests 2.6
  • six 1.9.0

Let me know if I can provide any more info.

Error on executing exploit payload

Getting this a few seconds after typing "exploit".
The server is running Spigot 1.8 (implementing API 1.8-R0.1) with bungeecord (however I dunno if that matters).

exploit
{"extra":["[Proxy] Lost connection to server."],"text":""}
Exception in thread Networking Thread:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/home/max/Downloads/pyCraft-nbt_exploit/minecraft/networking/connection.py", line 195, in run
self.connection.file_object)
File "/home/max/Downloads/pyCraft-nbt_exploit/minecraft/networking/connection.py", line 217, in read_packet
length = VarInt.read_socket(self.connection.socket)
File "/home/max/Downloads/pyCraft-nbt_exploit/minecraft/networking/types.py", line 88, in read_socket
raise RuntimeError("Socket disconnected")
RuntimeError: Socket disconnected

I'm running Python 2.7.8 on Ubuntu 64-bit. No errors in server console.

Invalid NBT data in nbt_exploit

I believe the data used for the exploit (in the nbt_exploit branch) is an invalid NBT:
The write_lists function recursively calls itself, but before the last recursion it writes "list of 10 items" into the datastream, but then fails to write any data for those 10 items in the last recursion.

Authentication times out during Travis tests.

See for example this job: https://travis-ci.org/ammaraskar/pyCraft/jobs/217173485, with relevant output below:

ERROR: test_make_request_url (tests.test_authentication.MakeRequest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/ammaraskar/pyCraft/tests/test_authentication.py", line 216, in test_make_request_url
    res = _make_request(AUTHSERVER, "authenticate", {"Darling": "Diary"})
  File "/home/travis/build/ammaraskar/pyCraft/minecraft/authentication.py", line 272, in _make_request
    headers=HEADERS)
  File "/home/travis/build/ammaraskar/pyCraft/.tox/py34/lib/python3.4/site-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/travis/build/ammaraskar/pyCraft/.tox/py34/lib/python3.4/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/travis/build/ammaraskar/pyCraft/.tox/py34/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/travis/build/ammaraskar/pyCraft/.tox/py34/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/travis/build/ammaraskar/pyCraft/.tox/py34/lib/python3.4/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
nose.proxy.ConnectionError: HTTPSConnectionPool(host='authserver.mojang.com', port=443): Max retries exceeded with url: /authenticate (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87191863c8>: Failed to establish a new connection: [Errno 110] Connection timed out',))
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): authserver.mojang.com
--------------------- >> end captured logging << ---------------------

These timeouts seem to be due to high network load when multiple tests are run in parallel, and happen infrequently and nondeterministically.

One solution might be to increase the timeout, but I'm not sure if this is satisfactory, as this is only a problem in the testing environment. An alternative solution could be to reduce the number of Travis tests that are run in parallel.

Getting this after successful login

Exception in thread Networking Thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in bootstrap_inner
self.run()
File "/Users/aknuck/Desktop/pyCraft-nbt_exploit/minecraft/networking/connection.py", line 188, in run
self.connection.reactor.react(packet)
File "/Users/aknuck/Desktop/pyCraft-nbt_exploit/minecraft/networking/connection.py", line 262, in react
packet.public_key, packet.verify_token, secret)
File "/Users/aknuck/Desktop/pyCraft-nbt_exploit/minecraft/networking/encryption.py", line 28, in encrypt_token_and_secret
pubkey = load_der_public_key(pubkey, default_backend())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/backends/__init
.py", line 40, in default_backend
_default_backend = MultiBackend(_available_backends())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/backends/init.py", line 27, in _available_backends
"cryptography.backends"
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/init.py", line 2345, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/backends/commoncrypto/init.py", line 7, in
from cryptography.hazmat.backends.commoncrypto.backend import backend
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/backends/commoncrypto/backend.py", line 244, in
backend = Backend()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/backends/commoncrypto/backend.py", line 44, in init
self._binding = Binding()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/bindings/commoncrypto/binding.py", line 44, in init
self._ensure_ffi_initialized()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/bindings/commoncrypto/binding.py", line 56, in _ensure_ffi_initialized
modules=cls._modules,
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/hazmat/bindings/utils.py", line 31, in load_library_for_binding
lib = ffi.verifier.load_library()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cffi/verifier.py", line 97, in load_library
return self._load_library()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cffi/verifier.py", line 207, in _load_library
return self._vengine.load_library()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cffi/vengine_cpy.py", line 153, in load_library
raise ffiplatform.VerificationError(error)
VerificationError: importing '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography-0.9.dev1-py2.7-macosx-10.6-intel.egg/cryptography/_Cryptography_cffi_464d07d2xdb61d8fa.so': dynamic module does not define init function (init_Cryptography_cffi_464d07d2xdb61d8fa)

I'm using a MacBook Pro with OSX 10.9.5, and Python 2.7

Error when running on 1.8

Exception in thread Networking Thread:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/home/ryanguy426/Documents/pyCraft-nbt_exploit/minecraft/networking/connection.py", line 195, in run
self.connection.file_object)
File "/home/ryanguy426/Documents/pyCraft-nbt_exploit/minecraft/networking/connection.py", line 232, in read_packet
packet_data.read(compressed_size))
error: Error -5 while decompressing data: incomplete or truncated stream

Script hangs after this.

Update bots branch to protocol version 74

Tried to replace the networking folder and start.py but i stuck with the following error:

Connecting with 25 bots
Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run

Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Connection to server failed
Traceback (most recent call last):
 Connection to server failed
    packetid = self.socket.recv(1)
    packetid = self.socket.recv(1)
Traceback (most recent call last):
error: [Errno 104] Connection reset by peer
error: [Errno 104] Connection reset by peer
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Connection to server failed
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Traceback (most recent call last):
    packetid = self.socket.recv(1)
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
error: [Errno 104] Connection reset by peer
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Connection to server failed
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
Traceback (most recent call last):
 Connection to server failed
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
    packetid = self.socket.recv(1)
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
error: [Errno 104] Connection reset by peer
Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
Connection to server failed
 Connection to server failed
Traceback (most recent call last):
Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Connection to server failed
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
    packetid = self.socket.recv(1)
    packetid = self.socket.recv(1)
Traceback (most recent call last):
error: [Errno 104] Connection reset by peer
error: [Errno 104] Connection reset by peer
    packetid = self.socket.recv(1)
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
Connection to server failedConnection to server failed

error: [Errno 104] Connection reset by peer
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Connection to server failed
    packetid = self.socket.recv(1)
    packetid = self.socket.recv(1)
Traceback (most recent call last):
error: [Errno 104] Connection reset by peer
 Connection to server failed
error: [Errno 104] Connection reset by peer
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
Connection to server failed
Traceback (most recent call last):
    packetid = self.socket.recv(1)
    packetid = self.socket.recv(1)
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 51, in run
error: [Errno 104] Connection reset by peer
error: [Errno 104] Connection reset by peer
    PacketSenderManager.sendHandshake(self.socket, self.username, self.server, self.port)
  File "/tmp/pyCraft-bots/networking/PacketSenderManager.py", line 19, in sendHandshake
    DataUtil.sendString(socket, username)
  File "/tmp/pyCraft-bots/networking/DataUtil.py", line 92, in sendString
    socket.send(struct.pack('>h', len(value) / 2))
Connection to server failed
error: [Errno 104] Connection reset by peer
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 51, in run
Connection to server failed
Traceback (most recent call last):
    PacketSenderManager.sendHandshake(self.socket, self.username, self.server, self.port)
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
  File "/tmp/pyCraft-bots/networking/PacketSenderManager.py", line 22, in sendHandshake
Connection to server failed
    packetid = self.socket.recv(1)
    DataUtil.sendString(socket, host)
Traceback (most recent call last):
error: [Errno 104] Connection reset by peer
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 51, in run
  File "/tmp/pyCraft-bots/networking/DataUtil.py", line 92, in sendString
    PacketSenderManager.sendHandshake(self.socket, self.username, self.server, self.port)
  File "/tmp/pyCraft-bots/networking/PacketSenderManager.py", line 19, in sendHandshake
    socket.send(struct.pack('>h', len(value) / 2))
error: [Errno 104] Connection reset by peer
    DataUtil.sendString(socket, username)
  File "/tmp/pyCraft-bots/networking/DataUtil.py", line 92, in sendString
Connection to server failed
Traceback (most recent call last):
    socket.send(struct.pack('>h', len(value) / 2))
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 51, in run
error: [Errno 104] Connection reset by peer
    PacketSenderManager.sendHandshake(self.socket, self.username, self.server, self.port)
Connection to server failed
  File "/tmp/pyCraft-bots/networking/PacketSenderManager.py", line 19, in sendHandshake
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 54, in run
    DataUtil.sendString(socket, username)
  File "/tmp/pyCraft-bots/networking/DataUtil.py", line 93, in sendString
    packetid = self.socket.recv(1)
error: [Errno 104] Connection reset by peer
    socket.send(value)
error: [Errno 104] Connection reset by peer
Server is in offline mode
Connection to server failed
Traceback (most recent call last):
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 120, in run
    self.pluginLoader.notify("onConnect")
AttributeError: 'NoneType' object has no attribute 'notify'
Exception in thread Thread-26:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 355, in run
    for listener in self.connection.pluginLoader.getPacketListeners():
AttributeError: 'NoneType' object has no attribute 'getPacketListeners'

^C
Traceback (most recent call last):
  File "start.py", line 90, in <module>
    connection.disconnect()
  File "/tmp/pyCraft-bots/networking/NetworkManager.py", line 33, in disconnect
    PacketSenderManager.sendFF(self.socket, reason)
  File "/tmp/pyCraft-bots/networking/PacketSenderManager.py", line 59, in sendFF
    DataUtil.sendString(socket, reason)
  File "/tmp/pyCraft-bots/networking/DataUtil.py", line 92, in sendString
    socket.send(struct.pack('>h', len(value) / 2))
socket.error: [Errno 32] Broken pipe

EOFError on connect()

I have the following worker function:

 def worker(account, server, port=25565):
    token = authentication.AuthenticationToken()
    token.authenticate(*account)
    print "Logged in as {0}:{1}".format(*account)
    time.sleep(1)
    print "Attempting connection"
    connection = Connection(server, port, auth_token=token)
    connection.connect()
    time.sleep(1)
    packet = serverbound.play.ChatPacket()
    packet.message = "test"
    connection.write_packet(packet)
    time.sleep(1)
    connection.disconnect()

Upon calling this from an interpreter:
worker(("email", "password"), "server", port)
I am able to login, but upon attempting connection, I receive this error:

  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/minecraft/networking/connection.py", line 397, in run
    self.connection._handle_exception(e, sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/minecraft/networking/connection.py", line 363, in _handle_exception
    raise_(*exc_info)
  File "/usr/local/lib/python2.7/dist-packages/minecraft/networking/connection.py", line 395, in run
    self._run()
  File "/usr/local/lib/python2.7/dist-packages/minecraft/networking/connection.py", line 426, in _run
    self.connection.file_object, timeout=read_timeout)
  File "/usr/local/lib/python2.7/dist-packages/minecraft/networking/connection.py", line 475, in read_packet
    length = VarInt.read(stream)
  File "/usr/local/lib/python2.7/dist-packages/minecraft/networking/types.py", line 96, in read
    raise EOFError("Unexpected end of message.")
EOFError: Unexpected end of message.

On the server side, I join and then immediately disconnect.
Server is running Spigot on 1.12.2.

Getting this when executing start.py

Exception in thread Networking Thread:
Traceback (most recent call last):
File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
self.run()
File "/root/pyCraft/minecraft/networking/connection.py", line 179, in run
self.connection.file_object)
File "/root/pyCraft/minecraft/networking/connection.py", line 215, in read_packet
packet_data.send(stream.read(length))
File "/usr/lib/python3.2/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 18: invalid start byte

setup.py don't install networking sub-package

After installing pyCraft with:
sudo python -m pip install git+https://github.com/ammaraskar/pyCraft
in Python interactive console:

import minecraft # success
from minecraft.networking.connection import Connection # error
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named networking.connection

cp1250 decoder error

I have tried running start.py under Python 3.4 (64-bit) on Windows 7. I'm getting this on the console:

Logged in as <redacted>
Exception in thread Networking Thread:
Traceback (most recent call last):
  File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
    self.run()
  File "<path>\pyCraft\minecraft\networking\connection.py", line 179, in run
    self.connection.file_object)
  File "<path>\pyCraft\minecraft\networking\connection.py", line 215, in read_packet
    packet_data.send(stream.read(length))
  File "C:\Python34\lib\encodings\cp1250.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 21: character maps to <undefined>

What can I do to help track this down?

My module versions:

  • cryptography 0.8.2
  • pyasn1 0.1.7
  • pycparser 2.10
  • requests 2.6
  • six 1.9
    Running via Python Tools for Visual Studio 2010

zlib.error: Error -3 while decompressing data: incorrect header check

This is what happens when I run start.py:
List count: 0
List count: 20
List count: 40
List count: 60
List count: 80
List count: 100
List count: 120
List count: 140
List count: 160
List count: 180
List count: 200
List count: 220
List count: 240
List count: 260
List count: 280
Exploit length: 26666408
Exploit packet length: 38892
Logged in as *****************
Exception in thread Networking Thread:
Traceback (most recent call last):
File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "C:\Users\Ginna\Downloads\pyCraft-nbt_exploit\minecraft\networking\connec
tion.py", line 195, in run
self.connection.file_object)
File "C:\Users\Ginna\Downloads\pyCraft-nbt_exploit\minecraft\networking\connec
tion.py", line 232, in read_packet
packet_data.read(compressed_size))
zlib.error: Error -3 while decompressing data: incorrect header check

Color coded Chat (instead of JSON) with ANSI Color?

Hi,
I just wanted to check-in if a color coded chat would be something that would fit this scope of this project?
Technically its pretty much at the border of being a python library to provide access to minecraft servers but on the other side there are python classes available that also be used as real client and thus I think it might be worth double checking.
Maybe it would be something a user enables/disables with a switch (so just a side library that would allow to convert the JSON-Text to something colorfull.

Just a side-note:
This might only work on windows 10 most likely out of the box, since it got added to windows 10

Let me know...

High memory usage on server after ~12 hours

Description

After ~ 12 hours with a pycraft account connected to a server (1.12.1), memory usage on server is way more higher than official client or Minecraft Console Client (more than 2ร—): on my Ubuntu server with 16GB RAM, using htop, official client consumes 2.2%, MCC (Minecraft Console Client) consumes 3.0% and Pycraft consumes 7.1%. This seems to happen too with 1.11.2 server.

I'm using the latest version 46e058d, zip-downloaded from GitHub. But I was able to reproduce with an older version, before 1.12.

Steps to reproduce

  1. On a server, create a specific folder for Minecraft Server.
  2. Download official server jar from Mojang: https://minecraft.net/fr-fr/download/server
  3. Start a first time the server to generate eula.txt file.
  4. Accept EULA.
  5. Start again server, then run commands "difficulty 0" and "gamerule doMobSpawning false" to prevent mob generation (and random ram consumption).
  6. Stop server.
  7. (Optionnal) in server.properties, set online-mode to false to make tests easier.
  8. Copy Minecraft Server folder twice: one for Pycraft client, one for MCC, one for official as reference.
  9. In each directory, set a different listening port, and rename jar to readable name (for example, "minecraft_server.1.12.1_pycraft.jar")
  10. Start each server
  11. Connect at the same time one pycraft client, one MCC and one official client to its corresponding server.
  12. Wait ~12 hours
  13. Using any system tool, check memory usage for server: pycraft should use way more RAM than the others.

Expected results

Pycraft server should use almost the same quantity of ram than the other clients.

Using a Proxy

hello, wondered how to connect a bot with a SOCKS5 proxy

Cannot seem to write location packet

Hello,

I am receiving the following stack trace. I am attempting to have the client moves when it receives a certain chat string, and am attempting to write the packet from the packet_listener function call. Any advice.example on how to properly do this?:

    connection.register_packet_listener(process_location_data, PlayerPositionAndLookPacket)
    def print_chat(chat_packet):
            for chatline in chat_payload.get('extra'):
                concatted_chat += chatline.get("text")
                
            if "!magicstring" in concatted_chat: 
                #current_position = PlayerPositionAndLookPacket
            
                packet = PlayerPositionAndLookPacket()
                packet.PositionAndLook(x=-7400, y=1, z=5319, yaw=160, pitch=160, teleport_id=1, flags=0b11111)

                packet.x = 1.0
                packet.z = 1.0
                packet.y = 1.0

                packet.yaw = 150
                packet.pitch = 150
                
                packet.teleport_id = 1
                
                # Now a relative move
                packet.flags = 0b11111

                #packet.apply(current_position)
                connection.write_packet(packet)
                
                print('position change trigger')
                
                
            print concatted_chat
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "C:\Users\mobaction\Desktop\pyCraft-master\minecraft\networking\connection.py",
 line 341, in run
    self.connection._handle_exception(e, sys.exc_info())
  File "C:\Users\mobaction\Desktop\pyCraft-master\minecraft\networking\connection.py",
 line 319, in _handle_exception
    raise_(*exc_info)
  File "C:\Users\mobaction\Desktop\pyCraft-master\minecraft\networking\connection.py",
 line 339, in run
    self._run()
  File "C:\Users\mobaction\Desktop\pyCraft-master\minecraft\networking\connection.py",
 line 371, in _run
    self.connection.file_object)
  File "C:\Users\mobaction\Desktop\pyCraft-master\minecraft\networking\connection.py",
 line 430, in read_packet
    length = VarInt.read(stream)
  File "C:\Users\mobaction\Desktop\pyCraft-master\minecraft\networking\types.py", line
 93, in read
    raise EOFError("Unexpected end of message.")
EOFError: Unexpected end of message.

Thanks much in advance

1.7.2 support

Do you plan to update this for minecraft 1.7 support? I need it and I'm sure others do too. Thank you for the program, by the way. It's impressive!

CLI

I was wondering if you could possibly make the Command-Line interface work if wxwidget is not installed. It should only be a matter of try/catch, shouldn't it ?

pyCraft bots doesnt work on 1.8

Recently (just now) I've tried to run the bots on a server running spigot 1.8.3, and It doesnt work, as it havent been updated since 2 years I want to know if it will be updated or not. I really need it
I am using the command "start.py -x -f -b 5" and I get this error.
...
Connecting with 5 bots
Connection to server failed
Traceback (most recent call last):
File "/home/jaime29010/Workspaces/pycraft/pyCraft-bots/networking/NetworkManager.py", line 69, in run
assert packetid == "\xFD", "Server didn't respond back to handshake with proper packet!"
AssertionError: Server didn't respond back to handshake with proper packet!
(x5)
...

Test suite fails on windows

Haven't been on a windows machine in a while but this is what happens running the test suite on it, I'm assuming it has to do with how getsockname is implemented on windows but I'll look into it.

Traceback (most recent call last):
  File "C:\Users\ammar\workspace\pyCraft\tests\test_connection.py", line 62, in _test_connect
    self._test_connect_client(client, cond)
  File "C:\Users\ammar\workspace\pyCraft\tests\test_connection.py", line 83, in _test_connect_client
    client.connect()
  File "C:\Users\ammar\workspace\pyCraft\minecraft\networking\connection.py", line 245, in connect
    self._connect()
  File "C:\Users\ammar\workspace\pyCraft\minecraft\networking\connection.py", line 275, in _connect
    self.socket.connect((self.options.address, self.options.port))
OSError: [WinError 10049] The requested address is not valid in its context

Failed building wheel for pycraft

here's the error.

pip install pycraft
Collecting pycraft
  Downloading PyCraft-1503040.tar.bz2
Building wheels for collected packages: pycraft
  Running setup.py bdist_wheel for pycraft ... error
  Complete output from command E:\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\TRENTO~1.MCK\\AppData\\Local\\Temp\\pip-build-v0lrago1\\pycraft\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\TRENTO~1.MCK\AppData\Local\Temp\tmpi1oyibdhpip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib
  creating build\lib\pycraft
  copying Src\anvil.py -> build\lib\pycraft
  copying Src\geometry.py -> build\lib\pycraft
  copying Src\low.py -> build\lib\pycraft
  copying Src\nbt.py -> build\lib\pycraft
  copying Src\__init__.py -> build\lib\pycraft
  installing to build\bdist.win-amd64\wheel
  running install
  running install_lib
  creating build\bdist.win-amd64
  creating build\bdist.win-amd64\wheel
  creating build\bdist.win-amd64\wheel\pycraft
  copying build\lib\pycraft\anvil.py -> build\bdist.win-amd64\wheel\.\pycraft
  copying build\lib\pycraft\geometry.py -> build\bdist.win-amd64\wheel\.\pycraft
  copying build\lib\pycraft\low.py -> build\bdist.win-amd64\wheel\.\pycraft
  copying build\lib\pycraft\nbt.py -> build\bdist.win-amd64\wheel\.\pycraft
  copying build\lib\pycraft\__init__.py -> build\bdist.win-amd64\wheel\.\pycraft
  running install_data
  creating build\bdist.win-amd64\wheel\PyCraft-1503040.data
  creating build\bdist.win-amd64\wheel\PyCraft-1503040.data\data
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\TRENTO~1.MCK\AppData\Local\Temp\pip-build-v0lrago1\pycraft\setup.py", line 42, in <module>
      keywords = ["Minecraft"],
    File "E:\Anaconda3\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "E:\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "E:\Anaconda3\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "E:\Anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 215, in run
      self.run_command('install')
    File "E:\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "E:\Anaconda3\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "E:\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\setuptools\command\install.py", line 61, in run
    File "E:\Anaconda3\lib\distutils\command\install.py", line 557, in run
      self.run_command(cmd_name)
    File "E:\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "E:\Anaconda3\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "E:\Anaconda3\lib\distutils\command\install_data.py", line 56, in run
      dir = convert_path(f[0])
    File "E:\Anaconda3\lib\distutils\util.py", line 125, in convert_path
      raise ValueError("path '%s' cannot be absolute" % pathname)
  ValueError: path '/usr/share/doc/pycraft' cannot be absolute

  ----------------------------------------
  Failed building wheel for pycraft
  Running setup.py clean for pycraft
Failed to build pycraft
Installing collected packages: pycraft
  Running setup.py install for pycraft ... error
    Complete output from command E:\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\TRENTO~1.MCK\\AppData\\Local\\Temp\\pip-build-v0lrago1\\pycraft\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\TRENTO~1.MCK\AppData\Local\Temp\pip-qf_nroi1-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\pycraft
    copying Src\anvil.py -> build\lib\pycraft
    copying Src\geometry.py -> build\lib\pycraft
    copying Src\low.py -> build\lib\pycraft
    copying Src\nbt.py -> build\lib\pycraft
    copying Src\__init__.py -> build\lib\pycraft
    running install_lib
    creating E:\Anaconda3\Lib\site-packages\pycraft
    copying build\lib\pycraft\anvil.py -> E:\Anaconda3\Lib\site-packages\pycraft
    copying build\lib\pycraft\geometry.py -> E:\Anaconda3\Lib\site-packages\pycraft
    copying build\lib\pycraft\low.py -> E:\Anaconda3\Lib\site-packages\pycraft
    copying build\lib\pycraft\nbt.py -> E:\Anaconda3\Lib\site-packages\pycraft
    copying build\lib\pycraft\__init__.py -> E:\Anaconda3\Lib\site-packages\pycraft
    byte-compiling E:\Anaconda3\Lib\site-packages\pycraft\anvil.py to anvil.cpython-36.pyc
    byte-compiling E:\Anaconda3\Lib\site-packages\pycraft\geometry.py to geometry.cpython-36.pyc
    byte-compiling E:\Anaconda3\Lib\site-packages\pycraft\low.py to low.cpython-36.pyc
    byte-compiling E:\Anaconda3\Lib\site-packages\pycraft\nbt.py to nbt.cpython-36.pyc
    byte-compiling E:\Anaconda3\Lib\site-packages\pycraft\__init__.py to __init__.cpython-36.pyc
    running install_data
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\TRENTO~1.MCK\AppData\Local\Temp\pip-build-v0lrago1\pycraft\setup.py", line 42, in <module>
        keywords = ["Minecraft"],
      File "E:\Anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "E:\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "E:\Anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "E:\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.6.egg\setuptools\command\install.py", line 61, in run
      File "E:\Anaconda3\lib\distutils\command\install.py", line 557, in run
        self.run_command(cmd_name)
      File "E:\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "E:\Anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "E:\Anaconda3\lib\distutils\command\install_data.py", line 56, in run
        dir = convert_path(f[0])
      File "E:\Anaconda3\lib\distutils\util.py", line 125, in convert_path
        raise ValueError("path '%s' cannot be absolute" % pathname)
    ValueError: path '/usr/share/doc/pycraft' cannot be absolute

    ----------------------------------------
Command "E:\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\TRENTO~1.MCK\\AppData\\Local\\Temp\\pip-build-v0lrago1\\pycraft\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\TRENTO~1.MCK\AppData\Local\Temp\pip-qf_nroi1-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\TRENTO~1.MCK\AppData\Local\Temp\pip-build-v0lrago1\pycraft\

How to send RMB click?

Hello. My task is to press RMB on a sign. Server remembers my position on logout and after login I need only to press RMB because my character is looking at the sign.
So I require only example code to press RMB. I'm very new to this library, help me please.

Not working with 1.5.2

I've tried both master, and the bots branches. Here are the errors messages:

Master:

bot_7 joined the game
Protocol error: 0x78
Exception in thread Thread-31:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/Users/mike/Projects/Misc/pyCraft/networking/NetworkManager.py", line 370, in run
    if (f != None):
UnboundLocalError: local variable 'f' referenced before assignment

Bots:

Connection to server failed
Traceback (most recent call last):
  File "/Users/mike/Projects/Misc/pyCraft/networking/NetworkManager.py", line 65, in run
    assert packetid == "\xFD", "Server didn't respond back to handshake with proper packet!"
AssertionError: Server didn't respond back to handshake with proper packet!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.