-
Notifications
You must be signed in to change notification settings - Fork 59
/
Program.cs
152 lines (132 loc) · 6.36 KB
/
Program.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
using EDD.Models;
using Mono.Options;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace EDD
{
class Program
{
private static readonly List<EDDFunction> _functions = new List<EDDFunction>();
static void Main(string[] args)
{
try
{
ParsedArgs parsedArgs = new ParsedArgs();
string functionName = null;
string fileSavePath = null;
bool show_help = false;
bool list_functions = false;
bool functionInfo = false;
var p = new OptionSet()
{
{"f|function=", "the function you want to use", (v) => functionName = v},
{"o|output=", "the path to the file to save", (v) => fileSavePath = v},
{"c|computername=", "the computer you are targeting", (v) => parsedArgs.ComputerName = v},
{"n|canonicalname=", "canonical name for domain user", (v) => parsedArgs.CanonicalName = v},
{"d|domainname=", "the computer you are targeting", (v) => parsedArgs.DomainName = v},
{"g|groupname=", "the domain group you are targeting", (v) => parsedArgs.GroupName = v},
{"p|processname=", "the process you are targeting", (v) => parsedArgs.ProcessName = v},
{"w|password=", "the password to authenticate with or what you are setting it to", (v) => parsedArgs.Password = v},
{"u|username=", "the domain account you are targeting", (v) => parsedArgs.UserName = v},
{"t|threads=", "the number of threads to run (default: 5)", (int t) => parsedArgs.Threads = t},
{"q|query=", "custom LDAP filter to search", (v) => parsedArgs.ldapQuery = v},
{"fd|filedata=", "path to file containing data for the function", (v) => parsedArgs.FileData = v},
{"a|adright=", "Active Directory Rights to return, separated by commas", (v) => parsedArgs.ADRights = v},
{"s|search=", "the search term(s) for FindInterestingDomainShareFile separated by a comma (,), accepts wildcards",
(string s) => parsedArgs.SearchTerms = s?.Split(',')},
{"sharepath=", "the specific share to search for interesting files", (v) => parsedArgs.SharePath = v},
{"i|info", "Returns information on specified function", (v) => functionInfo =v != null},
{"l|listfunctions", "list EDD functions available", (v) => list_functions = v != null},
{"h|help", "show this message and exit", (v) => show_help = v != null}
};
p.Parse(args);
if (show_help)
{
ShowHelp(p);
return;
}
InitFunctions();
if (list_functions) { FunctionReturn(); return; }
EDDFunction function = _functions.FirstOrDefault(f =>
f.FunctionName.Equals(functionName, StringComparison.InvariantCultureIgnoreCase));
if (functionInfo) { functionDetails(function); return; }
if (function is null)
{
Console.WriteLine($"Function {functionName} does not exist");
return;
}
if (parsedArgs.Threads <= 0)
parsedArgs.Threads = 5;
string[] results = function.Execute(parsedArgs);
if (results is null || results.Length < 1)
{
Console.WriteLine("No results");
return;
}
Console.WriteLine();
foreach (string result in results)
Console.WriteLine(result);
if (!string.IsNullOrEmpty(fileSavePath))
{
File.AppendAllText(fileSavePath, $"{functionName}:{Environment.NewLine}");
File.AppendAllLines(fileSavePath, results);
File.AppendAllText(fileSavePath, Environment.NewLine);
}
}
catch (OptionException e)
{
Console.Write("EDD.exe: ");
Console.WriteLine(e.Message);
Console.WriteLine("Try `EDD.exe --help' for more information.");
}
catch (EDDException e)
{
Console.WriteLine(e.Message);
}
catch (NotImplementedException)
{
Console.WriteLine("\n[-] That command is not implemented, please try a different one.");
}
finally
{
Console.WriteLine("\n[!] EDD is done running!\n");
}
}
static void ShowHelp(OptionSet p)
{
Console.WriteLine("Usage: EDD.exe -f <function name> -<extra options>");
Console.WriteLine("Provide the function you want to run to enumerate that data from the domain");
Console.WriteLine("Also provide any other extra options that you need for the specific function");
Console.WriteLine();
Console.WriteLine("Arguments:");
p.WriteOptionDescriptions(Console.Out);
}
static void FunctionReturn()
{
Console.WriteLine("EDD functions:");
foreach (EDDFunction function in _functions) { Console.WriteLine($"{function.FunctionName}"); }
}
static void functionDetails(EDDFunction function)
{
Console.WriteLine(
$"Name: {function.FunctionName}\n" +
$"Desc: {function.FunctionDesc}\n" +
$"Usage: {function.FunctionUsage}"
);
}
static void InitFunctions()
{
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
if (type.IsSubclassOf(typeof(EDDFunction)))
{
EDDFunction function = Activator.CreateInstance(type) as EDDFunction;
_functions.Add(function);
}
}
}
}
}