Skip to content

Commit

Permalink
a bit of security
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jun 21, 2016
1 parent a523e00 commit ad64ce4
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 362 deletions.
Binary file modified python2-scripts.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions python2-scripts/mcpipy/mcpi/security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AUTHENTICATION_USERNAME=None
AUTHENTICATION_PASSWORD=None
Binary file modified python3-scripts.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions python3-scripts/mcpipy/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def inputLine(prompt):
return 'quit()'
elif c.message == ' ':
return ''
elif "__" in c.message:
sys.exit();
else:
return c.message
time.sleep(0.2)
Expand Down
10 changes: 10 additions & 0 deletions python3-scripts/mcpipy/mcpi/connection.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@

import socket
import select
import sys
import atexit
import os
import platform
import base64
from hashlib import md5
from .util import flatten_parameters_to_string

""" @author: Aron Nieminen, Mojang AB"""
Expand Down Expand Up @@ -53,6 +56,13 @@ def close(self):
self.socket.close()
except:
pass

def authenticate(self, username, password):
challenge = self.sendReceive("world.getBlock",0,0,0)
if challenge.startswith("challenge "):
salt = challenge[10:].rstrip()
auth = base64.b64encode(md5(salt+":"+username+":"+password).digest())
self.send("security.authenticate", auth)

def drain(self):
"""Drains the socket of incoming data"""
Expand Down
Loading

0 comments on commit ad64ce4

Please sign in to comment.