破解压缩密码的程序

来源:互联网 发布:翻墙软件 自由 编辑:程序博客网 时间:2024/05/21 07:53
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Diagnostics;using System.Collections;namespace _7ZipEx{    class CUnZip    {        //private string[] NumStrArr = {"0","1","2","3","4","5","6","7","8","9"};        private string[] NumStrArr =null;        private string fileName;        /// <summary>        /// ファイル名        /// </summary>        public string FileName        {            get { return fileName; }            set { fileName = value; }        }        private string unZipPath;        /// <summary>        /// unzipPath        /// </summary>        public string UnZipPath        {            get { return unZipPath; }            set { unZipPath = value; }        }        private string cmdName;        /// <summary>        /// コマンド名        /// </summary>        public string CmdName        {            get { return cmdName; }            set { cmdName = value; }        }        private int flag;        /// <summary>        /// 1:7z 2:winrar        /// </summary>        public int Flag        {            get { return flag; }            set { flag = value; }        }        private int stopFlag;        public int StopFlag        {            get { return stopFlag; }            set { stopFlag = value; }        }        /// <summary>        /// 検索用配列初期化        /// </summary>        ///  string[] NumStrArr = { "0", "1", "2", "3", "4", "5", "6","7","8","9" };        ///   string[] NumStrArr2 = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j","k","l","m",        ///                          "n","o","p","q","r","s","t","u","v","w","x","y","z"};        /// <param name="_NumStrArr">検索用配列</param>        public CUnZip(string[] _NumStrArr)        {            NumStrArr = _NumStrArr;        }        private int numbers;        //最大長さ        public int Numbers        {            get { return numbers; }            set { numbers = value; }        }        ProcessStartInfo the_StartInfo = new ProcessStartInfo();        System.IO.StreamWriter fw = null;          /// <summary>        ///         /// </summary>        /// <param name="baseData"></param>        /// <param name="dataNum"></param>        /// <param name="serchArr"></param>        /// <returns></returns>        public string  ZipProcess()        {            string retPss = null;            the_StartInfo.FileName = CmdName;            the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;            the_StartInfo.RedirectStandardOutput = false;            using (fw = new System.IO.StreamWriter("d:\\temp.txt", true))            {                retPss = PassTest();            }            return retPss;        }          /// <summary>        /// pass のテスト開始        /// </summary>        /// <returns></returns>        private string PassTest()        {            string strBase = "";            string retPass = null ;            //从第一个字符向后a[0]->a[n]            for (int i = 0; i < NumStrArr.Length; i++)            {                if (StopFlag == 1)                {                    break;                }                //第一个字符向后a[0]->a[n]作为基准                strBase = NumStrArr[i];               // fw.WriteLine(strBase);                //fw.Write(strBase + ",");                //基准字符出力                int ret = TryUnZip(CmdName, fileName, unZipPath, strBase);                if (ret == 0)                {                    return strBase;                }                //递归第一个字符的所有匹配                if ((retPass = ProcessPassTest(strBase)) != null)                {                    return retPass;                }            }            return null;        }        /// <summary>        ///         /// </summary>        /// <param name="baseData">"0","1","2","3"...</param>        /// <param name="baseBack">元</param>        /// <returns></returns>        private string ProcessPassTest(string baseData)        {            string strBase = "";            string retStr = null;                        for (int i = 0; i < NumStrArr.Length; i++)            {                if (StopFlag == 1)                {                    break;                }                //00 -> 09                strBase = baseData + NumStrArr[i];                if (strBase.Length > Numbers)                {                    break; ;                }                //fw.Write(strBase+",");                //fw.WriteLine(strBase);                int ret = TryUnZip(CmdName, fileName, unZipPath, strBase);                if (ret == 0)                {                    return strBase;                }                //"00"-> "09"                if ((retStr = ProcessPassTest(strBase)) != null)                {                    return retStr;                }            }                        return null;        }                /// <summary>        /// unzip        /// </summary>        /// <param name="CmdName">执行命令名(winrar,7z)</param>        /// <param name="zipPath"></param>        /// <param name="unZipPath"></param>        /// <param name="password"></param>        /// <param name="Flag">1:7z 2:winrar</param>        private int TryUnZip(string CmdName, string zipPath, string unZipPath, string password)        {            int ret = -1;                       // the_StartInfo.Arguments = " x " + zipPath + " -p150 -o" + unZipPath;            string argument = "";            //7z            if (flag == 1)            {                argument = String.Format(" x {0} -p{1} -aoa -o{2}", zipPath, password, unZipPath);            }            //winrar            else            {            }            the_StartInfo.Arguments = argument;                       using (Process the_Process = new Process())            {                the_Process.StartInfo = the_StartInfo;                the_Process.Start();                the_Process.WaitForExit();                ret = the_Process.ExitCode;                the_Process.Close();            }                        return ret;        }    }}


 

原创粉丝点击