Пример #1
0
class TDS_Prelogin_Request(Packet):
    name = "TDS Prelogin Request"
    tds_type = TDS_TYPES_PRE_LOGIN
    fields_desc = [
        PacketField("VersionToken", TDS_Value(), TDS_Value),
        PacketField("EncryptionToken", TDS_Value(), TDS_Value),
        PacketField("InstanceToken", TDS_Value(), TDS_Value),
        PacketField("ThreadIDToken", TDS_Value(), TDS_Value),

        # Multiple Active Result Sets (MARS) has introduced in MSSQL Server 2005
        # To determine the existence of MARS TokenType
        # 0x04 is MARSToken
        # 0xFF is Terminator
        XByteField("MARSTokenOrTerminator", 0),
        ConditionalField(ShortField("MARSOffset", 0),
                         lambda x: x.MARSTokenOrTerminator == 0x04),
        ConditionalField(ShortField("MARSLen", 0),
                         lambda x: x.MARSTokenOrTerminator == 0x04),
        ConditionalField(XByteField("Terminator", 0),
                         lambda x: x.MARSTokenOrTerminator == 0x04),
        LEIntField("Version", 0),
        LEShortField("SubBuild", 0x0),
        ByteField("Encryption", 0),
        StrFixedLenField("InstanceOpt",
                         b'',
                         length_from=lambda x: x.InstanceToken.Len),
        LEIntField("ThreadID", 0),
        ConditionalField(ByteField("MARS", 0),
                         lambda x: x.MARSTokenOrTerminator == 0x04),
    ]
Пример #2
0
class MsgReply(Packet):
    name = " Wire Protocol OP_REPLY"
    fields_desc = [
        LEIntField("responseFlags", 0),
        LELongField("cursorID", 0),
        LEIntField("startingFrom", 0),
        LEIntField("numberReturned", 0)
    ]
Пример #3
0
class MsgQuery(Packet):
    name = "Wire Protocol OP_QUERY"
    fields_desc = [
        LEIntField("flags", 0),
        StrNullField("fullCollectionName", ""),
        LEIntField("numberToSkip", 0),
        LEIntField("numberToReturn", 0)
    ]
Пример #4
0
class MsgHeader(Packet):
    name = "Wire Protocol Message Header"
    fields_desc = [
        LEIntField("messageLength", 0),
        LEIntField("requestID", 0),
        LEIntField("responseTo", 0),
        LEIntField("opCode", 0)
    ]

    def post_build(self, p, pay):
        self.messageLength = len(pay) + 16
        p = self.do_build()
        return p + pay
Пример #5
0
class TDS_Token_AllHeader(Packet):
    name = "TDS Token ALLHEADER"
    fields_desc = [
        LEIntField("TotalLength", 0),
        LEIntField("HeaderLength", 0),

        # Two HeaderType
        # 1. Query Notification Header
        # 2. Transaction Descriptor Header, apply to [MSDN-MARS]
        LEShortField("HeaderType", 0),

        # Only support for Transaction Descriptor Header for the moment
        LELongField("TransactionDescription", 0),
        LEIntField("OutstandingRequestCount", 0),
    ]
Пример #6
0
class TDS_Prelogin_Response(Packet):
    name = "TDS Prelogin Response"
    tds_type = TDS_TYPES_TABULAR_RESULT
    fields_desc = [
        PacketField("VersionToken", TDS_Value(), TDS_Value),
        PacketField("EncryptionToken", TDS_Value(), TDS_Value),
        PacketField("InstanceToken", TDS_Value(), TDS_Value),
        PacketField("ThreadIDToken", TDS_Value(), TDS_Value),
        PacketField("MARSToken", TDS_Value(), TDS_Value),
        XByteField("Terminator", 0xFF),

        # From the observation, the value for Version field
        # MS SQLServer 2005:	1996816393
        # MS SQLServer 2000:	268566536
        LEIntField("Version", 268566536),
        LEShortField("SubBuild", 0x0),

        # For Encryption field, value 0x02 mean ENCRPYT_NOT_SUP
        # value 0x02 is needed as we may skip the SSL authentication
        # support
        ByteField("Encryption", 0x02),
        ByteField("InstanceOpt", 0),
        #LEIntField("ThreadID",0),
        ByteField("MARS", 0),
    ]
Пример #7
0
class TDS_Token_DoneProc(Packet):
    name = "TDS Token DONEPROC"
    fields_desc = [
        #		ByteField("TokenType",0xfe),
        FlagsField("Status", 0, -16, TDS_Token_Status),
        LEShortField("CurCmd", 0xE0),
        LEIntField("DoneRowCount", 0),
    ]
Пример #8
0
class MySQL_Client_Authentication(Packet):
    name = "MySQL Client Authentication"
    fields_desc = [
        FlagsField("ClientCapabilities", 0, -16, MySQL_Capabilities),
        FlagsField("ClientExCapabilities", 0, -16,
                   MySQL_Extended_Capabilities),
        LEIntField("MaxPacketSize", 0),
        ByteField("CharSetNumber", 0),
        StrFixedLenField("Filler", b"", 23),
        StrNullField("User", "bob"),
        LengthCodedBinaryField("ScrambleBuffer", b""),
        StrNullField("DatabaseName", b"")
    ]
Пример #9
0
class TDS_Login7_Request(Packet):
    name = "TDS Login7 Request"
    fields_desc = [
        LEIntField("Length", 0),
        LEIntField("TDSVersion", 0),
        LEIntField("PacketSize", 0),
        LEIntField("ClientProgVer", 0),
        LEIntField("ClientPID", 0),
        LEIntField("PID", 0),
        FlagsField("OptionFlags1", 0, -8, TDS_OptionFlags1),
        FlagsField("OptionFlags2", 0, -8, TDS_OptionFlags2),
        FlagsField("TypesFlags", 0, -8, TDS_TypesFlags),
        FlagsField("OptionFlags3", 0, -8, TDS_OptionFlags3),
        LEIntField("ClientTimeZone", 0),

        # start of ClientLCID field
        LEShortField("LCID", 0x0),
        FlagsField("ColFlags", 0, -8, TDS_ColFlags),
        ByteField("Version", 0x0),
        # end of ClientLCID field

        # start of OffsetLength field
        LEShortField("ibHostName", 0),
        LEShortField("cchHostName", 0),
        LEShortField("ibUserName", 0),
        LEShortField("cchUserName", 0),
        LEShortField("ibPassword", 0),
        LEShortField("cchPassword", 0),
        LEShortField("ibAppName", 0),
        LEShortField("cchAppName", 0),
        LEShortField("ibServerName", 0),
        LEShortField("cchServerName", 0),
        LEShortField("ibUnused", 0),
        LEShortField("cbUnused", 0),
        LEShortField("ibCltIntName", 0),
        LEShortField("cchCltIntName", 0),
        LEShortField("ibLanguage", 0),
        LEShortField("cchLanguage", 0),
        LEShortField("ibDatabase", 0),
        LEShortField("cchDatabase", 0),
        StrFixedLenField("ClientID", "012345", 6),
        LEShortField("ibSSPI", 0),
        LEShortField("cbSSPI", 0),
        LEShortField("ibAtchDBFile", 0),
        LEShortField("cchAtchDBFile", 0),
        #LEShortField("ibChangePassword",0),	# introduce in TDS 7.2
        #LEShortField("ibChangePassword",0),	# introduce in TDS 7.2
        #LEIntField("cbSSPILong",0),		# introduce in TDS 7.2
        # end of OffsetLength field
        StrField("Payload", ""),
    ]
Пример #10
0
class MySQL_Result_Field(Packet):
    name = "MySQL Result Field"
    fields_desc = [
        LengthCodedBinaryField("Catalog", None),
        LengthCodedBinaryField("Database", None),
        LengthCodedBinaryField("Table", None),
        LengthCodedBinaryField("ORGTable", None),
        LengthCodedBinaryField("Name", None),
        LengthCodedBinaryField("ORGName", None),
        ByteField("Filler", 0xc),
        LEShortField("CharSet", 0),
        LEIntField("Length", 0),
        XByteEnumField("Type", 0, MySQL_Field_Types),
        FlagsField("Flags", 0, -16, MySQL_Field_Flags),
        ByteField("Decimals", 0),
        LEShortField("Filler2", 0),
        LengthCodedBinaryField("Default", None),
    ]
Пример #11
0
class TDS_Token_Info(Packet):
    name = "TDS Token INFO"
    fields_desc = [
        #		ByteField("TokenType",0xAB),
        LEShortField("Length", 118),  #FIXME: make a dynamic count?
        LEIntField("Number", 5701),
        ByteField("State", 2),
        ByteField("Class", 1),
        FieldLenField("MessageTextLen", 37, fmt='<H', length_of="MessageText"),
        StrLenField(
            "MessageText",
            "Changed database context to 'master'.".encode('utf16')[2:],
            length_from=lambda x: x.MessageTextLen),
        FieldLenField("ServerNameLen", 15, fmt='B', length_of="ServerName"),
        StrLenField("ServerName",
                    "HOMEUSER-3AF6FE".encode('utf16')[2:],
                    length_from=lambda x: x.ServerNameLen),
        FieldLenField("ProcNameLen", 0, fmt='B', length_of="ProcName"),

        #StrLenField("ProName", "", length_from=lambda x:x.ProcName),
        #LEIntField("LineNumber",1),
    ]
Пример #12
0
class TDS_Token_ReturnStatus(Packet):
    name = "TDS Token RETURNSTATUS"
    fields_desc = [
        #		ByteField("TokenType",0x79),
        LEIntField("Value", 0),
    ]