Beispiel #1
0
        /// <summary>
        /// Sends an AIM invitation to a receipient -- SNAC(06,02)
        /// </summary>
        /// <param name="sess">A <see cref="ISession"/> object</param>
        /// <param name="email">The email address of the person to invite</param>
        /// <param name="text">The text of the invitation</param>
        public static void SendInvitiationRequest(ISession sess, string email, string text)
        {
            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = (ushort) SNACFamily.PrivacyManagementService;
            sh.FamilySubtypeID = (ushort) PrivacyManagementService.ServiceParametersRequest;
            sh.Flags = 0x0000;
            sh.RequestID = Session.GetNextRequestID();

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0011, email, Encoding.ASCII);
                tlvs.WriteString(0x0015, text, Encoding.ASCII);
                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #2
0
        /// <summary>
        /// Performs a directory search by interest -- SNAC(0F,02)
        /// </summary>
        /// <param name="sess">A <see cref="Session"/> object</param>
        /// <param name="interest">The interest to search for</param>
        public static void SearchByInterest(Session sess, string interest)
        {
            SNACHeader sh = new SNACHeader();

            sh.FamilyServiceID = (ushort)SNACFamily.DirectoryUserSearch;
            sh.FamilySubtypeID = (ushort)DirectorySearch.SearchUserRequest;


            ByteStream stream = new ByteStream();

            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII);
                tlvs.WriteUshort(0x000A, 0x0001);
                tlvs.WriteString(0x0001, interest, Encoding.ASCII);
                stream.WriteTlvBlock(tlvs);
            }
            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #3
0
        /// <summary>
        /// Sends an AIM invitation to a receipient -- SNAC(06,02)
        /// </summary>
        /// <param name="sess">A <see cref="ISession"/> object</param>
        /// <param name="email">The email address of the person to invite</param>
        /// <param name="text">The text of the invitation</param>
        public static void SendInvitiationRequest(ISession sess, string email, string text)
        {
            SNACHeader sh = new SNACHeader();

            sh.FamilyServiceID = (ushort)SNACFamily.PrivacyManagementService;
            sh.FamilySubtypeID = (ushort)PrivacyManagementService.ServiceParametersRequest;
            sh.Flags           = 0x0000;
            sh.RequestID       = Session.GetNextRequestID();

            ByteStream stream = new ByteStream();

            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0011, email, Encoding.ASCII);
                tlvs.WriteString(0x0015, text, Encoding.ASCII);
                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #4
0
            public byte[] GetBytes()
            {
                ByteStream buffer = new ByteStream();

                buffer.WriteUshort((ushort)Encoding.UTF8.GetByteCount(item.Name));
                buffer.WriteString(item.Name, Encoding.UTF8);
                buffer.WriteUshort(item.GroupID);
                buffer.WriteUshort(item.ItemID);
                buffer.WriteUshort(item.ItemType);
                if (item.Tlvs == null)
                {
                    buffer.WriteUshort(0x000);
                }
                else
                {
                    buffer.WriteUshort((ushort)item.Tlvs.GetByteCount());
                    buffer.WriteTlvBlock(item.Tlvs);
                }

                return(buffer.GetBytes());
            }
Beispiel #5
0
        /// <summary>
        /// Sends authorization request -- SNAC(17,02)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param>
        public static void SendAuthorizationRequest(DataPacket dp)
        {
            // Pull apart SNAC(17,07)
            byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort());

            // Construct SNAC(17,02)
            SNACHeader header = new SNACHeader();

            header.FamilyServiceID = (ushort)SNACFamily.AuthorizationRegistrationService;
            header.FamilySubtypeID = (ushort)AuthorizationRegistrationService.LoginRequest;
            header.Flags           = 0;
            header.RequestID       = Session.GetNextRequestID();

            OSCARIdentification id = dp.ParentSession.ClientIdentification;

            ByteStream stream = new ByteStream();

            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0001, dp.ParentSession.ScreenName, Encoding.ASCII);
                tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII);
                tlvs.WriteString(0x000F, "en", Encoding.ASCII);
                tlvs.WriteString(0x000E, "us", Encoding.ASCII);
                tlvs.WriteUint(0x0014, id.ClientDistribution);
                tlvs.WriteUshort(0x0016, id.ClientId);
                tlvs.WriteUshort(0x0017, id.ClientMajor);
                tlvs.WriteUshort(0x0018, id.ClientMinor);
                tlvs.WriteUshort(0x0019, id.ClientLesser);
                tlvs.WriteUshort(0x001A, id.ClientBuild);
                tlvs.WriteByteArray(0x0025, dp.ParentSession.HashPassword(key));
                tlvs.WriteByte(0x004A, 0x01);
                tlvs.WriteEmpty(0x004C);
                stream.WriteTlvBlock(tlvs);
            }

            DataPacket newPacket = Marshal.BuildDataPacket(dp.ParentSession, header, stream);

            newPacket.ParentConnection = dp.ParentConnection;
            SNACFunctions.BuildFLAP(newPacket);
        }
Beispiel #6
0
        /// <summary>
        /// Send MD5 key request -- SNAC(17,06)
        /// </summary>
        /// <param name="sess">A <see cref="ISession"/> object</param>
        public static void SendMD5Request(ISession sess)
        {
            /*** Send SNAC(17,06) to get the auth key ***/
            SNACHeader sh = new SNACHeader();

            sh.FamilyServiceID = (ushort)SNACFamily.AuthorizationRegistrationService;
            sh.FamilySubtypeID = (ushort)AuthorizationRegistrationService.MD5AuthkeyRequest;
            sh.Flags           = 0x0000;
            sh.RequestID       = Session.GetNextRequestID();

            ByteStream stream = new ByteStream();

            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0001, sess.ScreenName, Encoding.ASCII);
                tlvs.WriteEmpty(0x004B);
                tlvs.WriteEmpty(0x005A);
                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #7
0
        /// <summary>
        /// Performs a directory search by personal information -- SNAC(0F,02)
        /// </summary>
        /// <param name="sess">A <see cref="Session"/> object</param>
        /// <param name="items">The number of non-null search terms</param>
        /// <param name="firstname">A first name</param>
        /// <param name="middlename">A middle name</param>
        /// <param name="lastname">A last name</param>
        /// <param name="maidenname">A maiden name</param>
        /// <param name="nickname">A nickname</param>
        /// <param name="city">A city</param>
        /// <param name="state">A state</param>
        /// <param name="country">A country (two letter code)</param>
        /// <param name="zip">A ZIP code</param>
        /// <param name="address">An address</param>
        /// <remarks>
        /// <para>If a search term is to be ignored, it must be set to <c>null</c>.</para>
        /// <para>There must be at least one non-null search term.</para></remarks>
        public static void SearchByInfo(
            Session sess, int items,
            string firstname, string middlename, string lastname, string maidenname, string nickname,
            string city, string state, string country, string zip, string address)
        {
            SNACHeader sh = new SNACHeader();

            sh.FamilyServiceID = (ushort)SNACFamily.DirectoryUserSearch;
            sh.FamilySubtypeID = (ushort)DirectorySearch.SearchUserRequest;



            ByteStream stream = new ByteStream();

            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII);
                tlvs.WriteUshort(0x000A, 0x0000);

                if (firstname != null)
                {
                    tlvs.WriteString(0x0001, firstname, Encoding.ASCII);
                }
                if (middlename != null)
                {
                    tlvs.WriteString(0x0002, middlename, Encoding.ASCII);
                }
                if (lastname != null)
                {
                    tlvs.WriteString(0x0003, lastname, Encoding.ASCII);
                }
                if (maidenname != null)
                {
                    tlvs.WriteString(0x0004, maidenname, Encoding.ASCII);
                }
                if (country != null)
                {
                    tlvs.WriteString(0x0006, country, Encoding.ASCII);
                }
                if (state != null)
                {
                    tlvs.WriteString(0x0007, state, Encoding.ASCII);
                }
                if (city != null)
                {
                    tlvs.WriteString(0x0008, city, Encoding.ASCII);
                }
                if (nickname != null)
                {
                    tlvs.WriteString(0x000C, nickname, Encoding.ASCII);
                }
                if (zip != null)
                {
                    tlvs.WriteString(0x000D, zip, Encoding.ASCII);
                }
                if (address != null)
                {
                    tlvs.WriteString(0x0021, address, Encoding.ASCII);
                }

                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #8
0
        /// <summary>
        /// Sends authorization request -- SNAC(17,02)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param>
        void SendAuthorizationRequest(DataPacket dp)
        {
            // Pull apart SNAC(17,07)
            byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort());

            // Construct SNAC(17,02)
            SNACHeader header = new SNACHeader();
            header.FamilyServiceID = SNAC_AUTH_FAMILY;
            header.FamilySubtypeID = AUTH_LOGIN_REQUEST;

            OSCARIdentification id = parent.ClientIdentification;

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0001, parent.ScreenName, Encoding.ASCII);
                tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII);
                tlvs.WriteString(0x000F, "en", Encoding.ASCII);
                tlvs.WriteString(0x000E, "us", Encoding.ASCII);
                tlvs.WriteUint(0x0014, id.ClientDistribution);
                tlvs.WriteUshort(0x0016, id.ClientId);
                tlvs.WriteUshort(0x0017, id.ClientMajor);
                tlvs.WriteUshort(0x0018, id.ClientMinor);
                tlvs.WriteUshort(0x0019, id.ClientLesser);
                tlvs.WriteUshort(0x001A, id.ClientBuild);
                tlvs.WriteByteArray(0x0025, parent.HashPassword(key));
                tlvs.WriteByte(0x004A, 0x01);
                tlvs.WriteEmpty(0x004C);
                stream.WriteTlvBlock(tlvs);
            }

            DataPacket newPacket = Marshal.BuildDataPacket(parent, header, stream);
            newPacket.ParentConnection = dp.ParentConnection;
            SNACFunctions.BuildFLAP(newPacket);
        }
Beispiel #9
0
        /// <summary>
        /// Kicks off the authorization hash request when the initial connection is complete
        /// </summary>
        void loginConnection_ServerConnectionCompleted(Connection conn)
        {
            conn.ReadyForData = true;

            /*** Send SNAC(17,06) to get the auth key ***/
            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = SNAC_AUTH_FAMILY;
            sh.FamilySubtypeID = AUTH_KEY_REQUEST;

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0001, parent.ScreenName, Encoding.ASCII);
                tlvs.WriteEmpty(0x004B);
                tlvs.WriteEmpty(0x005A);
                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream));

            conn.ReadHeader();
        }
Beispiel #10
0
            public byte[] GetBytes()
            {
                ByteStream buffer = new ByteStream();

                buffer.WriteUshort((ushort)Encoding.UTF8.GetByteCount(item.Name));
                buffer.WriteString(item.Name, Encoding.UTF8);
                buffer.WriteUshort(item.GroupID);
                buffer.WriteUshort(item.ItemID);
                buffer.WriteUshort(item.ItemType);
                if (item.Tlvs == null)
                    buffer.WriteUshort(0x000);
                else
                {
                    buffer.WriteUshort((ushort)item.Tlvs.GetByteCount());
                    buffer.WriteTlvBlock(item.Tlvs);
                }

                return buffer.GetBytes();
            }
Beispiel #11
0
        /// <summary>
        /// Sends authorization request -- SNAC(17,02)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param>
        public static void SendAuthorizationRequest(DataPacket dp)
        {
            // Pull apart SNAC(17,07)
            byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort());

            // Construct SNAC(17,02)
            SNACHeader header = new SNACHeader();
            header.FamilyServiceID = (ushort) SNACFamily.AuthorizationRegistrationService;
            header.FamilySubtypeID = (ushort) AuthorizationRegistrationService.LoginRequest;
            header.Flags = 0;
            header.RequestID = Session.GetNextRequestID();

            OSCARIdentification id = dp.ParentSession.ClientIdentification;

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0001, dp.ParentSession.ScreenName, Encoding.ASCII);
                tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII);
                tlvs.WriteString(0x000F, "en", Encoding.ASCII);
                tlvs.WriteString(0x000E, "us", Encoding.ASCII);
                tlvs.WriteUint(0x0014, id.ClientDistribution);
                tlvs.WriteUshort(0x0016, id.ClientId);
                tlvs.WriteUshort(0x0017, id.ClientMajor);
                tlvs.WriteUshort(0x0018, id.ClientMinor);
                tlvs.WriteUshort(0x0019, id.ClientLesser);
                tlvs.WriteUshort(0x001A, id.ClientBuild);
                tlvs.WriteByteArray(0x0025, dp.ParentSession.HashPassword(key));
                tlvs.WriteByte(0x004A, 0x01);
                tlvs.WriteEmpty(0x004C);
                stream.WriteTlvBlock(tlvs);
            }

            DataPacket newPacket = Marshal.BuildDataPacket(dp.ParentSession, header, stream);
            newPacket.ParentConnection = dp.ParentConnection;
            SNACFunctions.BuildFLAP(newPacket);
        }
Beispiel #12
0
        /// <summary>
        /// Send MD5 key request -- SNAC(17,06)
        /// </summary>
        /// <param name="sess">A <see cref="ISession"/> object</param>
        public static void SendMD5Request(ISession sess)
        {
            /*** Send SNAC(17,06) to get the auth key ***/
            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = (ushort) SNACFamily.AuthorizationRegistrationService;
            sh.FamilySubtypeID = (ushort) AuthorizationRegistrationService.MD5AuthkeyRequest;
            sh.Flags = 0x0000;
            sh.RequestID = Session.GetNextRequestID();

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x0001, sess.ScreenName, Encoding.ASCII);
                tlvs.WriteEmpty(0x004B);
                tlvs.WriteEmpty(0x005A);
                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #13
0
        /// <summary>
        /// Sends a status report to the OSCAR server -- SNAC(0B,03)
        /// </summary>
        /// <param name="sess">A <see cref="ISession"/> object</param>
        /// <remarks>libfaim does not send this report</remarks>
        public static void SendStatusReport(ISession sess)
        {
            SNACHeader sh = new SNACHeader();

            sh.FamilyServiceID = (ushort)SNACFamily.UsageStatsService;
            sh.FamilySubtypeID = (ushort)UsageStatsService.UsageReport;
            sh.Flags           = 0;
            sh.RequestID       = Session.GetNextRequestID();

            // Get the necessary strings together
            string sn = sess.ScreenName;
            // Here we start lying until I can figure out how to get *all* the values in .NET
            string osversion   = Environment.OSVersion.ToString();
            string osname      = "Windows 98";    //osversion.Substring(0, osversion.LastIndexOf(" ") - 1);
            string osver       = "4.10.67766446"; //osversion.Substring(osversion.LastIndexOf(" ") + 1);
            string procname    = "Intel Pentium";
            string winsockname = "Microsoft Corporation BSD Socket API for Windows";
            string winsockver  = "4.1.1998";

            Encoding enc               = Encoding.ASCII;
            byte     snlength          = (byte)enc.GetByteCount(sn);
            ushort   osversionlength   = (ushort)enc.GetByteCount(osversion);
            ushort   osnamelength      = (ushort)enc.GetByteCount(osname);
            ushort   osverlength       = (ushort)enc.GetByteCount(osver);
            ushort   procnamelength    = (ushort)enc.GetByteCount(procname);
            ushort   winsocknamelength = (ushort)enc.GetByteCount(winsockname);
            ushort   winsockverlength  = (ushort)enc.GetByteCount(winsockver);

            ByteStream mainStream = new ByteStream();

            using (ByteStream stream = new ByteStream())
            {
                TimeSpan t = (DateTime.Now - new DateTime(1970, 1, 1));
                stream.WriteUint((uint)t.Seconds);
                t = (DateTime.UtcNow - new DateTime(1970, 1, 1).ToUniversalTime());
                stream.WriteUint((uint)t.Seconds);
                stream.WriteUint(0x00000000);
                stream.WriteUint(0x00000000);
                stream.WriteUint(0x00000000);
                stream.WriteUint(0x00000000);
                stream.WriteByte(snlength);
                stream.WriteString(sn, Encoding.ASCII);
                stream.WriteUshort(osnamelength);
                stream.WriteString(osname, Encoding.ASCII);
                stream.WriteUshort(osverlength);
                stream.WriteString(osver, Encoding.ASCII);
                stream.WriteUshort(procnamelength);
                stream.WriteString(procname, Encoding.ASCII);
                stream.WriteUshort(winsocknamelength);
                stream.WriteString(winsockname, Encoding.ASCII);
                stream.WriteUshort(winsockverlength);
                stream.WriteString(winsockver, Encoding.ASCII);
                stream.WriteUint(0x00000002);
                stream.WriteUint(0x00010001);
                stream.WriteUint(0x00020002);

                using (TlvBlock tlv = new TlvBlock())
                {
                    tlv.WriteByteArray(0x0009, stream.GetBytes());
                    mainStream.WriteTlvBlock(tlv);
                }
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, mainStream));
        }
Beispiel #14
0
        /// <summary>
        /// Performs a directory search by interest -- SNAC(0F,02)
        /// </summary>
        /// <param name="sess">A <see cref="Session"/> object</param>
        /// <param name="interest">The interest to search for</param>
        public static void SearchByInterest(Session sess, string interest)
        {
            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = (ushort) SNACFamily.DirectoryUserSearch;
            sh.FamilySubtypeID = (ushort) DirectorySearch.SearchUserRequest;

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII);
                tlvs.WriteUshort(0x000A, 0x0001);
                tlvs.WriteString(0x0001, interest, Encoding.ASCII);
                stream.WriteTlvBlock(tlvs);
            }
            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Beispiel #15
0
        /// <summary>
        /// Performs a directory search by personal information -- SNAC(0F,02)
        /// </summary>
        /// <param name="sess">A <see cref="Session"/> object</param>
        /// <param name="items">The number of non-null search terms</param>
        /// <param name="firstname">A first name</param>
        /// <param name="middlename">A middle name</param>
        /// <param name="lastname">A last name</param>
        /// <param name="maidenname">A maiden name</param>
        /// <param name="nickname">A nickname</param>
        /// <param name="city">A city</param>
        /// <param name="state">A state</param>
        /// <param name="country">A country (two letter code)</param>
        /// <param name="zip">A ZIP code</param>
        /// <param name="address">An address</param>
        /// <remarks>
        /// <para>If a search term is to be ignored, it must be set to <c>null</c>.</para>
        /// <para>There must be at least one non-null search term.</para></remarks>
        public static void SearchByInfo(
            Session sess, int items,
            string firstname, string middlename, string lastname, string maidenname, string nickname,
            string city, string state, string country, string zip, string address)
        {
            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = (ushort) SNACFamily.DirectoryUserSearch;
            sh.FamilySubtypeID = (ushort) DirectorySearch.SearchUserRequest;

            ByteStream stream = new ByteStream();
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII);
                tlvs.WriteUshort(0x000A, 0x0000);

                if (firstname != null)
                    tlvs.WriteString(0x0001, firstname, Encoding.ASCII);
                if (middlename != null)
                    tlvs.WriteString(0x0002, middlename, Encoding.ASCII);
                if (lastname != null)
                    tlvs.WriteString(0x0003, lastname, Encoding.ASCII);
                if (maidenname != null)
                    tlvs.WriteString(0x0004, maidenname, Encoding.ASCII);
                if (country != null)
                    tlvs.WriteString(0x0006, country, Encoding.ASCII);
                if (state != null)
                    tlvs.WriteString(0x0007, state, Encoding.ASCII);
                if (city != null)
                    tlvs.WriteString(0x0008, city, Encoding.ASCII);
                if (nickname != null)
                    tlvs.WriteString(0x000C, nickname, Encoding.ASCII);
                if (zip != null)
                    tlvs.WriteString(0x000D, zip, Encoding.ASCII);
                if (address != null)
                    tlvs.WriteString(0x0021, address, Encoding.ASCII);

                stream.WriteTlvBlock(tlvs);
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }