Created
February 19, 2010 16:54
-
-
Save gdude2002/308892 to your computer and use it in GitHub Desktop.
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
import sys | |
import os | |
import datetime | |
import struct | |
import urllib | |
import urllib2 | |
import re | |
import socket | |
import cookielib | |
import threading | |
class bot (threading.Thread): | |
def __init__(self, sock=None): | |
threading.Thread.__init__(self) | |
self.username = "gdudebot" | |
self.passw = "gdudeismyname" | |
if sock is None: | |
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
else: | |
self.sock = sock | |
def run(self): | |
self.rip(sys.argv[1], self.username, self.passw) | |
def rip(self, key, username, password): | |
login_url = 'http://minecraft.net/login.jsp' | |
play_url = 'http://minecraft.net/play.jsp?server=%s' | |
cj = cookielib.CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | |
login_data = urllib.urlencode({'username': username, 'password': password}) | |
print "Logging in..." | |
opener.open(login_url, login_data) | |
print "Fetching server info..." | |
html = opener.open(play_url % key).read() | |
ip = re.search(r'param name\="server" value="([0-9.]+)"', html).groups()[0] | |
port = int(re.search(r'param name\="port" value="([0-9]+)"', html).groups()[0]) | |
mppass = re.search(r'param name\="mppass" value="([0-9a-zA-Z]+)"', html).groups()[0] | |
print "Details:" | |
print ip | |
print port | |
print mppass | |
self.login(ip, port, mppass) | |
def login(self, ip, port, mppass): | |
packet = "0x0 0x7 "+self.username+" "+mppass | |
# packed = packet + struct.pack('%dx' % (64-len(packet))) | |
packed = packet + " "*(64-len(packet)) | |
print len(packed) | |
self.sock.connect((ip, port)) | |
self.sock.send(packed) | |
bot().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment