Skip to content

Commit

Permalink
Update user details output to boolean flags
Browse files Browse the repository at this point in the history
  • Loading branch information
coj337 committed Aug 22, 2022
1 parent 20d1bb2 commit 00b1bc2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ TheSprayer.exe -p Passwords.txt -f
TheSprayer.exe --Policy
```

##### Write a list of users to users.txt
##### Output a list of users to AdUserList.txt
```
TheSprayer.exe --Users users
TheSprayer.exe --Users
```

##### Write a list of users and all their details from AD to users.csv
##### Write a list of users and all their details from AD to AdUserDetails.csv
```
TheSprayer.exe --UsersCsv users
TheSprayer.exe --UsersCsv
```

## Options
Expand Down
8 changes: 4 additions & 4 deletions TheSprayer/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class CommandLineOptions
[Option('n', "nodb", Required = false, HelpText = "Disable using a DB to store previously sprayed creds.")]
public bool NoDb { get; set; }

[Option("users", Required = false, HelpText = "Outputs a list of all users to the specified file")]
public string OutputUsers { get; set; }
[Option("users", Required = false, Default = null, HelpText = "Outputs a simple list of all users to the txt file")]
public bool OutputUsers { get; set; }

[Option("userscsv", Required = false, HelpText = "Outputs a list of all users along with their domain info to the specified CSV file")]
public string OutputUsersCsv { get; set; }
[Option("userscsv", Required = false, Default = null, HelpText = "Outputs a list of all users along with their domain info to a CSV file")]
public bool OutputUsersCsv { get; set; }

[Option("policy", Required = false, HelpText = "Outputs the password policy(ies) to the terminal")]
public bool OutputPasswordPolicy { get; set; }
Expand Down
15 changes: 8 additions & 7 deletions TheSprayer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,26 @@ public static void Main(string[] args)
return;
}
}
var adService = new ActiveDirectoryService(o.Domain, o.Username, o.Password, o.DomainController);
//Output a list of users to the specified file and exit
if (!string.IsNullOrWhiteSpace(o.OutputUsers))
if (o.OutputUsers)
{
var users = adService.GetAllDomainUsers().Select(u => u.SamAccountName);
File.WriteAllLines(o.OutputUsers + ".txt", users);
Console.WriteLine($"{o.OutputUsers + ".txt"} created.");
File.WriteAllLines("AdUserList.txt", users);
Console.WriteLine("AdUserList.txt created.");
return;
}
if (!string.IsNullOrWhiteSpace(o.OutputUsersCsv))
if (o.OutputUsersCsv)
{
var users = adService.GetAllDomainUsers();
File.WriteAllText(o.OutputUsersCsv + ".csv", users.ToCsv());
Console.WriteLine($"{o.OutputUsersCsv + ".csv"} created.");
File.WriteAllText("AdUserDetails.csv", users.ToCsv());
Console.WriteLine("AdUserDetails.csv created.");
return;
}
else if (o.OutputPasswordPolicy) //Output the password policy to the terminal and exit
{
Console.WriteLine(5);
var defaultPolicy = adService.GetPasswordPolicy();
var fineGrainedPolicies = adService.GetFineGrainedPasswordPolicy();
Expand All @@ -99,6 +99,7 @@ public static void Main(string[] args)
}
else //Otherwise we want to validate remaining parameters and spray
{
Console.WriteLine(6);
IEnumerable<string> passwords, users;
int remainingAttempts;
Expand Down

0 comments on commit 00b1bc2

Please sign in to comment.