static string filetype = "singlefile";
static string filepath = "D:\\sc\\MD5\\md5_numeric#1-12_0_10000x67108864_distrrtgen[p][i]_0.rti";
static string password = "25d55ad283aa400af464c76d713c07ad";
public static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
string strOutput = null;
try
{
p.Start();
string filestr = "";
string menustr = "";
if (filetype == "singlefile")
{
filestr = filepath.ToString();
menustr = filestr.Substring(0, filestr.LastIndexOf(@"\"));
}
else
{
filestr = filepath.ToString() + @"\*.rti";
menustr = filepath.ToString();
}
string rootpath = filestr.Substring(0, filestr.IndexOf(@"\"));
string crackcommad = "rcracki_mt -h " + password + " " + filestr;
p.StandardInput.WriteLine(rootpath);
p.StandardInput.WriteLine("cd " + menustr);
p.StandardInput.Write(crackcommad);
strOutput = p.StandardOutput.ReadToEnd();
//Thread.Sleep(5000);
p.Close();
}
catch (Exception)
{
}
}
p.StartInfo.CreateNoWindow = false;这个应该是会显示DOS界面的。
找这个代码DOS界面应该会显示
>D:
D:\> cd sc\md5
D:\sc\MD5>rcraki_mt -h 25d55ad283aa400af464c76d713c07ad D:\sc\MD5\md5_numeric#1-12_0_10000x67108864_distrrtgen[p][i]_0.rti和最后一条命令的知性结果吧。但是我调试的时候却什么都没有出现,不知道是哪里有问题呢c#dos
System.IO.StreamReader reader = p.StandardOutput;//截取输出流 string line = reader.ReadLine();//每次读取一行 while (!reader.EndOfStream)
{
strOutput += line + "\r\n";
line = reader.ReadLine();
}
p.Close();
reader.close();
但是,现在用窗体界面输入password,定义了一个string类型的result保存结果,在界面上用textbox显示result,也就是DOS命令的最后一行输出,却没有反应strOutput = p.StandardOutput;
string s = "";
while (!strOutput.EndOfStream)
{
s = strOutput.ReadLine();
}
result = s;