-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathFiles.cs
More file actions
48 lines (47 loc) · 1.31 KB
/
Files.cs
File metadata and controls
48 lines (47 loc) · 1.31 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace WinDump
{
internal class Files
{
internal static string DumpFile(string file,out bool ok)
{
try
{
var data = File.ReadAllText(Environment.ExpandEnvironmentVariables(file));
ok = true;
return data;
}
catch (Exception e)
{
ok = false;
return e.Message;
}
}
internal static string Hosts()
{
return DumpFile(@"%windir%\system32\drivers\etc\hosts", out var _);
}
internal static string IIS()
{
// >=IIS7
var iis7 = DumpFile(@"%windir%\system32\inetsrv\config\ApplicationHost.config", out var ok);
if (ok) return iis7;
// IIS6
var iis6 = DumpFile(@"%windir%\system32\inetsrv\MetaBase.xml", out ok);
if (ok)
{
return iis6;
}
else
{
return iis7 + "\n" + iis6;
}
}
internal static string Powershell() {
return DumpFile(@"%appdata%\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt", out var _);
}
}
}