Ejemplo n.º 1
0
        // Sign for all binary files (series mode)
        public static void SignAllBinaryFilesSerial()
        {
            string[] files = Directory.GetFiles(Paths.BinDirName, "*", SearchOption.AllDirectories);

            foreach (string file in files)
            {
                if (IsFileSignable(file))
                {
                    bool isDriver = file.EndsWith(".sys", StringComparison.InvariantCultureIgnoreCase);

                    // Check whether this file is signed
                    bool isSigned = ExeSignChecker.CheckFileDigitalSignature(file);
                    if (isSigned && isDriver)
                    {
                        isSigned = ExeSignChecker.IsKernelModeSignedFile(file);
                    }

                    Con.WriteLine("The file '{0}': {1}.", file, isSigned ? "Already signed" : "Not yet signed");

                    if (isSigned == false)
                    {
                        Con.WriteLine("Signing...");

                        CodeSign.SignFile(file, file, "VPN Software", isDriver);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static int SignCode(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[filename]", ConsoleService.Prompt, "Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("DEST"),
                new ConsoleParam("COMMENT",    ConsoleService.Prompt, "Comment: ",  ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("KERNEL"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string destFileName = vl["DEST"].StrValue;
            string srcFileName  = vl.DefaultParam.StrValue;

            if (Str.IsEmptyStr(destFileName))
            {
                destFileName = srcFileName;
            }
            string comment = vl["COMMENT"].StrValue;
            bool   kernel  = vl["KERNEL"].BoolValue;

            CodeSign.SignFile(destFileName, srcFileName, comment, kernel);

            return(0);
        }
Ejemplo n.º 3
0
        // Binary file signature thread
        static void sign_thread(object param)
        {
            string filename = (string)param;
            bool   isDriver = filename.EndsWith(".sys", StringComparison.InvariantCultureIgnoreCase);

            Con.WriteLine("Signing...");

            CodeSign.SignFile(filename, filename, "VPN Software", isDriver);
        }
Ejemplo n.º 4
0
        // Build the installer
        void buildInstaller()
        {
            string outFileName = Path.Combine(Paths.ReleaseDir, this.OutputFileName);

            string vpnsetup_exe = Path.Combine(Paths.BinDirName, "vpnsetup.exe");

            try
            {
                File.Delete(outFileName);
            }
            catch
            {
            }

            Win32BuildUtil.ExecCommand(vpnsetup_exe, string.Format("/SFXMODE:{1} /SFXOUT:\"{0}\"",
                                                                   outFileName, Software.ToString()));

            CodeSign.SignFile(outFileName, outFileName, "VPN Software", false);
        }
Ejemplo n.º 5
0
        // Generate vpnweb.ocx
        public static void GenerateVpnWebOcxCab(string dstFileName, string ocxFileName)
        {
            int      build, version;
            string   name;
            DateTime date;

            ReadBuildInfoFromTextFile(out build, out version, out name, out date);

            string cabVer      = string.Format("{0},{1},0,{2}", version / 100, version % 100, build);
            string cabFileName = IO.CreateTempFileNameByExt(".cab");
            Mutex  m           = new Mutex(false, "cabtmp_mutex");

            m.WaitOne();

            try
            {
                // Building the cab
                string cabTmpDir = Path.Combine(Paths.TmpDirName, "cabtmp");

                IO.MakeDir(cabTmpDir);
                IO.DeleteFilesAndSubDirsInDir(cabTmpDir);

                File.Copy(Path.Combine(Paths.BinDirName, ocxFileName), Path.Combine(cabTmpDir, "vpnweb.ocx"));

                string infText = File.ReadAllText(Path.Combine(Path.Combine(Paths.BaseDirName, @"BuildFiles\OcxCabInf"), "vpnweb.inf"));
                infText = Str.ReplaceStr(infText, "$CAB_VERSION$", cabVer);
                File.WriteAllText(Path.Combine(cabTmpDir, "vpnweb.inf"), infText);

                Win32BuildUtil.ExecCommand(Path.Combine(Paths.BaseDirName, @"BuildFiles\Utility\cabarc.exe"),
                                           string.Format(@"-s 6144 n {0}\vpnweb.cab {0}\vpnweb.ocx {0}\vpnweb.inf", cabTmpDir));

                File.Copy(Path.Combine(cabTmpDir, "vpnweb.cab"), cabFileName, true);
            }
            finally
            {
                m.ReleaseMutex();
            }

            CodeSign.SignFile(cabFileName, cabFileName, "VPN Software", false);

            File.Copy(cabFileName, dstFileName, true);
        }
Ejemplo n.º 6
0
        static void generateINFFilesForPlatform(string inf, string sys, string sys6, string dstDir, int ver, int build, DateTime date, bool selow)
        {
            string       cdfFileName = Path.Combine(dstDir, "inf.cdf");
            string       catFileName = Path.Combine(dstDir, "inf.cat");
            StringWriter sw          = new StringWriter();

            string txt = File.ReadAllText(inf, Str.ShiftJisEncoding);

            IO.DeleteFilesAndSubDirsInDir(dstDir);
            IO.MakeDirIfNotExists(dstDir);

            string dst_sys_name = Path.Combine(dstDir, Path.GetFileName(sys));

            File.Copy(sys, dst_sys_name, true);

            string dst_sys6_name = null;

            if (sys6 != null)
            {
                dst_sys6_name = Path.Combine(dstDir, Path.GetFileName(sys6));
                File.Copy(sys6, dst_sys6_name, true);
            }

            sw.WriteLine("[CatalogHeader]");
            sw.WriteLine("name=inf.cat");
            sw.WriteLine();
            sw.WriteLine("[CatalogFiles]");
            sw.WriteLine("<hash>{0}={0}", Path.GetFileName(dst_sys_name));

            if (sys6 != null)
            {
                sw.WriteLine("<hash>{0}={0}", Path.GetFileName(dst_sys6_name));
            }

            int i;

            for (i = 1; i < 128; i++)
            {
                string name = "VPN";
                if (i >= 2)
                {
                    name += i.ToString();
                }

                if (selow)
                {
                    name = "selow";
                }

                //string mac = "00AC0011" + i.ToString("X2") + "01";
                string mac      = "000001000001";
                string sys_name = "Neo_" + name + ".sys";

                string body = txt;
                body = Str.ReplaceStr(body, "$TAG_SYS_NAME$", sys_name);
                body = Str.ReplaceStr(body, "$TAG_INSTANCE_NAME$", name);
                body = Str.ReplaceStr(body, "$TAG_MAC_ADDRESS$", mac);
                body = Str.ReplaceStr(body, "$YEAR$", date.Year.ToString("D4"));
                body = Str.ReplaceStr(body, "$MONTH$", date.Month.ToString("D2"));
                body = Str.ReplaceStr(body, "$DAY$", date.Day.ToString("D2"));
                body = Str.ReplaceStr(body, "$VER_MAJOR$", (ver / 100).ToString());
                body = Str.ReplaceStr(body, "$VER_MINOR$", (ver % 100).ToString());
                body = Str.ReplaceStr(body, "$VER_BUILD$", build.ToString());
                body = Str.ReplaceStr(body, "[Manufacturer]", "CatalogFile.NT\t\t\t\t= inf_" + name + ".cat\r\n\r\n[Manufacturer]");

                string dst_inf_name = Path.Combine(dstDir, "INF_" + name + ".inf");

                if (selow)
                {
                    dst_inf_name = Path.Combine(dstDir, Path.GetFileName(inf));
                }

                if (selow)
                {
                    body += "\r\n; Auto Generated " + Str.DateTimeToStrShortWithMilliSecs(DateTime.Now) + "\r\n\r\n";
                }

                File.WriteAllText(dst_inf_name, body, Str.ShiftJisEncoding);

                sw.WriteLine("<hash>{0}={0}", Path.GetFileName(dst_inf_name));

                if (selow)
                {
                    break;
                }
            }
            sw.WriteLine();

            File.WriteAllText(cdfFileName, sw.ToString());

            // generate catalog file
            Directory.SetCurrentDirectory(dstDir);
            ExecCommand(Paths.MakeCatFilename, string.Format("\"{0}\"", cdfFileName));

            // sign catalog file
            CodeSign.SignFile(catFileName, catFileName, "Catalog File", false);

            // delete cdf file
            File.Delete(cdfFileName);

            // delete sys file
            File.Delete(dst_sys_name);

            if (sys6 != null)
            {
                File.Delete(dst_sys6_name);
            }
        }