forked from MicBrain/Master-Password-Recovery-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm4.cs
98 lines (80 loc) · 3 KB
/
Form4.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace MR_Corporation
{
public partial class Form4 : Form
{
Process InterProc;
public Form4()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((Keys)e.KeyChar == Keys.Enter)
{
string key = textBox1.Text;
if (key.Length != 12)
{
MessageBox.Show("Error. The number of digits must be 12. Please try again!");
return;
}
string s = "";
string temp = Path.GetTempPath() + "2.exe";
using (Stream stream = GetType().Assembly.GetManifestResourceStream("MR_Corporation.2.exe"))
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
File.WriteAllBytes(temp, bytes);
}
InterProc = new Process();
InterProc.StartInfo.UseShellExecute = false;
InterProc.StartInfo.FileName = temp;
InterProc.StartInfo.RedirectStandardOutput = true;
InterProc.StartInfo.RedirectStandardInput = true;
InterProc.StartInfo.RedirectStandardError = true;
InterProc.StartInfo.CreateNoWindow = true;
InterProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
InterProc.EnableRaisingEvents = true;
InterProc.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
bool started = InterProc.Start();
InterProc.StandardInput.WriteLine(key);
InterProc.StandardInput.WriteLine();
for (int i = 0; i < 5; i++)
{
string str = InterProc.StandardOutput.ReadLine();
if (str != null && str.StartsWith("Input:"))
{
str = str.Substring(56);
if (str.StartsWith("password:"))
{
textBox2.Text = str.Substring(10);
InterProc.Dispose();
DeleteFile(temp);
return;
}
}
}
InterProc.Dispose();
DeleteFile(temp);
textBox2.Text = "";
MessageBox.Show("Error. Your code is incorrect.");
}
}
private void DeleteFile(string filename)
{
while (File.Exists(filename))
{
try { File.Delete(filename); }
catch { }
}
}
}
}