def getLoginPacket(self): self.dbname = self.password packet = '\x02\x00\x02\x00\x00\x00\x00\x00' # Packet header packet += self.hostname + "\x00" * ( MAX_HOST_SIZE - len(self.hostname)) + int2hex(len(self.hostname)) packet += self.username + "\x00" * ( MAX_USER_SIZE - len(self.username)) + int2hex(len(self.username)) packet += self.dbname + "\x00" * ( MAX_USER_SIZE - len(self.dbname)) + int2hex(len(self.dbname)) packet += magicNumber + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex( len(magicNumber)) packet += "\x03\x01\x06\n\t\x01\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00" packet += self.appName + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex( len(self.appName)) packet += self.ip_address + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex( len(self.ip_address)) packet += self.password + "\x00" * ( MAX_PASS_SIZE - len(self.password)) + int2hex(len(self.password)) packet += "\x04\x02\x00\x00DB-Library\n\x00\x00\x00\x00\x00\r\x11" packet += self.language + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x01\x00" packet += "L\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" packet += self.encoding + "\x00" * (MAX_ENCODING_SIZE - len( self.encoding)) + int2hex(len(self.encoding)) + "\x01" packet += magicNumber2 + "\x00\x00\x00" + int2hex( len(magicNumber2)) + "\x00\x00\x00\x00\x00\x00\x00\x00" return packet
def makeSqlServerPacket(hostname="", username="******", password="******", encoding="iso_1", appName="example1", ip_address="192.168.1.14", language="english", dbname="master"): packet = '\x02\x00\x02\x00\x00\x00\x00\x00' # Packet header packet += hostname + "\x00" * (MAX_HOST_SIZE - len(hostname)) + int2hex( len(hostname)) packet += username + "\x00" * (MAX_USER_SIZE - len(username)) + int2hex( len(username)) packet += dbname + "\x00" * (MAX_USER_SIZE - len(dbname)) + int2hex( len(password)) packet += magicNumber + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex( len(magicNumber)) packet += "\x03\x01\x06\n\t\x01\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00" packet += appName + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex( len(appName)) packet += ip_address + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex( len(ip_address)) packet += password + "\x00" * (MAX_PASS_SIZE - len(password)) + int2hex( len(password)) packet += "\x04\x02\x00\x00DB-Library\n\x00\x00\x00\x00\x00\r\x11" packet += language + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x01\x00" packet += "L\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" packet += encoding + "\x00" * ( MAX_ENCODING_SIZE - len(encoding)) + int2hex(len(encoding)) + "\x01" packet += magicNumber2 + "\x00\x00\x00" + int2hex( len(magicNumber2)) + "\x00\x00\x00\x00\x00\x00\x00\x00" return packet
def getLoginPacket(self): self.dbname = self.password packet = '\x02\x00\x02\x00\x00\x00\x00\x00' # Packet header packet += self.hostname + "\x00"*(MAX_HOST_SIZE - len(self.hostname)) + int2hex(len(self.hostname)) packet += self.username + "\x00"*(MAX_USER_SIZE - len(self.username)) + int2hex(len(self.username)) packet += self.dbname + "\x00"*(MAX_USER_SIZE - len(self.dbname)) + int2hex(len(self.dbname)) packet += magicNumber + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex(len(magicNumber)) packet += "\x03\x01\x06\n\t\x01\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00" packet += self.appName + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex(len(self.appName)) packet += self.ip_address + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex(len(self.ip_address)) packet += self.password + "\x00"*(MAX_PASS_SIZE - len(self.password)) + int2hex(len(self.password)) packet += "\x04\x02\x00\x00DB-Library\n\x00\x00\x00\x00\x00\r\x11" packet += self.language + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x01\x00" packet += "L\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" packet += self.encoding + "\x00"*(MAX_ENCODING_SIZE - len(self.encoding)) + int2hex(len(self.encoding)) + "\x01" packet += magicNumber2 + "\x00\x00\x00" + int2hex(len(magicNumber2)) + "\x00\x00\x00\x00\x00\x00\x00\x00" return packet
def makeSqlServerPacket(hostname = "", username = "******", password = "******", encoding = "iso_1", appName = "example1", ip_address = "192.168.1.14", language = "english", dbname = "master"): packet = '\x02\x00\x02\x00\x00\x00\x00\x00' # Packet header packet += hostname + "\x00"*(MAX_HOST_SIZE - len(hostname)) + int2hex(len(hostname)) packet += username + "\x00"*(MAX_USER_SIZE - len(username)) + int2hex(len(username)) packet += dbname + "\x00"*(MAX_USER_SIZE - len(dbname)) + int2hex(len(password)) packet += magicNumber + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex(len(magicNumber)) packet += "\x03\x01\x06\n\t\x01\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00" packet += appName + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex(len(appName)) packet += ip_address + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + int2hex(len(ip_address)) packet += password + "\x00"*(MAX_PASS_SIZE - len(password)) + int2hex(len(password)) packet += "\x04\x02\x00\x00DB-Library\n\x00\x00\x00\x00\x00\r\x11" packet += language + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x01\x00" packet += "L\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" packet += encoding + "\x00"*(MAX_ENCODING_SIZE - len(encoding)) + int2hex(len(encoding)) + "\x01" packet += magicNumber2 + "\x00\x00\x00" + int2hex(len(magicNumber2)) + "\x00\x00\x00\x00\x00\x00\x00\x00" return packet