Example #1
0
        // Token: 0x06000549 RID: 1353 RVA: 0x00032678 File Offset: 0x00030878
        private static void createProfile(string IPforward, string Portforward, string fileLocation)
        {
            sshcommand.profile profile      = default(sshcommand.profile);
            System.IO.Stream   stream       = File.Open(AppDomain.CurrentDomain.BaseDirectory + "1.bscp", FileMode.Open);
            BinaryReader       binaryReader = new BinaryReader(stream);
            long length = stream.Length;

            profile.header  = binaryReader.ReadBytes(21);
            profile.length  = binaryReader.ReadByte();
            profile.body    = binaryReader.ReadBytes((int)length - 189);
            profile.iplen   = binaryReader.ReadByte();
            profile.ip      = binaryReader.ReadBytes((int)profile.iplen);
            profile.s1      = binaryReader.ReadBytes(3);
            profile.portlen = binaryReader.ReadByte();
            profile.port    = binaryReader.ReadBytes((int)profile.portlen);
            profile.end     = binaryReader.ReadBytes(149);
            profile.ip      = Encoding.UTF8.GetBytes(IPforward);
            profile.length  = (byte)((int)profile.length + (IPforward.Length + Portforward.Length - (int)profile.iplen - (int)profile.portlen));
            profile.iplen   = (byte)IPforward.Length;
            profile.port    = Encoding.UTF8.GetBytes(Portforward);
            profile.portlen = (byte)Portforward.Length;
            stream.Close();
            using (System.IO.Stream stream2 = new FileStream(fileLocation, FileMode.Create, System.IO.FileAccess.Write, FileShare.ReadWrite))
            {
                using (BinaryWriter binaryWriter = new BinaryWriter(stream2, Encoding.Default))
                {
                    binaryWriter.Write(profile.header);
                    binaryWriter.Write(profile.length);
                    binaryWriter.Write(profile.body);
                    binaryWriter.Write(profile.iplen);
                    binaryWriter.Write(profile.ip);
                    binaryWriter.Write(profile.s1);
                    binaryWriter.Write(profile.portlen);
                    binaryWriter.Write(profile.port);
                    binaryWriter.Write(profile.end);
                }
                stream2.Close();
            }
        }
Example #2
0
        private static void createProfile(string IPforward, string Portforward, string fileLocation)
        {
            sshcommand.profile bytes        = new sshcommand.profile();
            Stream             stream       = File.Open(string.Concat(AppDomain.CurrentDomain.BaseDirectory, "1.bscp"), FileMode.Open);
            BinaryReader       binaryReader = new BinaryReader(stream);
            long length = stream.Length;

            bytes.header  = binaryReader.ReadBytes(21);
            bytes.length  = binaryReader.ReadByte();
            bytes.body    = binaryReader.ReadBytes((int)length - 189);
            bytes.iplen   = binaryReader.ReadByte();
            bytes.ip      = binaryReader.ReadBytes((int)bytes.iplen);
            bytes.s1      = binaryReader.ReadBytes(3);
            bytes.portlen = binaryReader.ReadByte();
            bytes.port    = binaryReader.ReadBytes((int)bytes.portlen);
            bytes.end     = binaryReader.ReadBytes(149);
            bytes.ip      = Encoding.UTF8.GetBytes(IPforward);
            bytes.length  = (byte)(bytes.length + (IPforward.Length + Portforward.Length - bytes.iplen - bytes.portlen));
            bytes.iplen   = (byte)IPforward.Length;
            bytes.port    = Encoding.UTF8.GetBytes(Portforward);
            bytes.portlen = (byte)Portforward.Length;
            stream.Close();
            using (Stream fileStream = new FileStream(fileLocation, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
            {
                using (BinaryWriter binaryWriter = new BinaryWriter(fileStream, Encoding.Default))
                {
                    binaryWriter.Write(bytes.header);
                    binaryWriter.Write(bytes.length);
                    binaryWriter.Write(bytes.body);
                    binaryWriter.Write(bytes.iplen);
                    binaryWriter.Write(bytes.ip);
                    binaryWriter.Write(bytes.s1);
                    binaryWriter.Write(bytes.portlen);
                    binaryWriter.Write(bytes.port);
                    binaryWriter.Write(bytes.end);
                }
                fileStream.Close();
            }
        }