-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathHash.cs
153 lines (128 loc) · 5.81 KB
/
Hash.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//Avilla Forensics - Copyright (C) 2023 – Daniel Hubscher Avilla
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace Avilla_Forensics
{
public partial class Hash : Form
{
public Hash()
{
InitializeComponent();
}
public class tipoHASH //Variável Pública
{
public static string THash = "SHA256";
}
private void button3_Click(object sender, EventArgs e)
{
backgroundWorker3.RunWorkerAsync();
pictureBox2.Visible = true;
panel3.Enabled = false;
}
private void button10_Click(object sender, EventArgs e)
{
FolderBrowserDialog backupfolderIPEDArquivo = new FolderBrowserDialog();
backupfolderIPEDArquivo.Description = "Choose source folder";
if (backupfolderIPEDArquivo.ShowDialog() == DialogResult.OK)
{
txtOrigem.Text = backupfolderIPEDArquivo.SelectedPath;
//button4.Enabled = true;
}
}
private void button4_Click(object sender, EventArgs e)
{
FolderBrowserDialog backupfolderIPEDArquivo = new FolderBrowserDialog();
backupfolderIPEDArquivo.Description = "Choose source folder";
if (backupfolderIPEDArquivo.ShowDialog() == DialogResult.OK)
{
txtDestino.Text = backupfolderIPEDArquivo.SelectedPath;
webBrowser2.Navigate(backupfolderIPEDArquivo.SelectedPath);
button3.Enabled = true;
}
}
private void backgroundWorker3_DoWork(object sender, DoWorkEventArgs e)
{
string fullPathOrigem;
fullPathOrigem = txtOrigem.Text;
string fullPathDestino;
fullPathDestino = txtDestino.Text;
ProcessStartInfo processStartInfoAPPT = new ProcessStartInfo("powershell.exe");
processStartInfoAPPT.RedirectStandardInput = true;
processStartInfoAPPT.RedirectStandardOutput = true;
processStartInfoAPPT.UseShellExecute = false;
processStartInfoAPPT.CreateNoWindow = true;
Process processAPPT = Process.Start(processStartInfoAPPT);
if (processAPPT != null)
{
processAPPT.StandardInput.WriteLine("Get-ChildItem -Path \"" + txtOrigem.Text + "*\" -Recurse -Filter *.* | Get-FileHash -Algorithm " + tipoHASH.THash + " | Format-List > \"" + txtDestino.Text + "/" + tipoHASH.THash + "Hash.txt" + "\"");
processAPPT.StandardInput.Close();
processAPPT.StandardOutput.ReadToEnd();
webBrowser1.Navigate(fullPathDestino + "\\" + tipoHASH.THash + "Hash.txt");
}
//string pathFind = @"find";
//string fullPathFind;
//fullPathFind = Path.GetFullPath(pathFind);
//StreamWriter EscreverTXT = new StreamWriter(@fullPathFind + "\\Hash.ps1");
//EscreverTXT.WriteLine($"Get-ChildItem -Path '{fullPathOrigem}*' -Recurse -Filter *.* | Get-FileHash -Algorithm MD5 | Format-List > '{fullPathDestino}\\Hash.txt'");
//EscreverTXT.Close();
//webBrowser1.Navigate(fullPathDestino + "\\Hash.txt");
//Process process1 = new Process();
//ProcessStartInfo startInfo1 = new ProcessStartInfo();
//startInfo1.WindowStyle = ProcessWindowStyle.Hidden;
//startInfo1.CreateNoWindow = true;
//startInfo1.UseShellExecute = false;
//startInfo1.RedirectStandardOutput = true;
//startInfo1.FileName = fullPathFind + "\\Hash.ps1";
//process1.StartInfo = startInfo1;
//process1.Start();
//process1.StandardOutput.ReadToEnd();
}
private void backgroundWorker3_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
pictureBox2.Visible = false;
panel3.Enabled = true;
}
private void radioSHA1_CheckedChanged(object sender, EventArgs e)
{
tipoHASH.THash = "SHA1";
}
private void radioSHA256_CheckedChanged(object sender, EventArgs e)
{
tipoHASH.THash = "SHA256";
}
private void radioSHA384_CheckedChanged(object sender, EventArgs e)
{
tipoHASH.THash = "SHA384";
}
private void radioSHA512_CheckedChanged(object sender, EventArgs e)
{
tipoHASH.THash = "SHA512";
}
private void radioMD5_CheckedChanged(object sender, EventArgs e)
{
tipoHASH.THash = "MD5";
}
private void Hash_Load(object sender, EventArgs e)
{
string pathTEMP = @"temp";
string fullPathTEMP;
fullPathTEMP = Path.GetFullPath(pathTEMP);
System.IO.StreamReader file = new System.IO.StreamReader(fullPathTEMP + "\\PathAcquisition.txt");
txtOrigem.Text = file.ReadLine();
file.Close();
}
}
}