Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
- Completed and published
  • Loading branch information
Jewels committed Apr 13, 2024
1 parent f9efd8e commit a2aa3de
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 49 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Tourmaline-Directory Enumerator
![90%](https://progress-bar.dev/90)
# Tourmaline-Directory Enumerator (v1.0)
## ![100%](https://progress-bar.dev/100)

A directory enumeration tool with many modes.
26 changes: 16 additions & 10 deletions Tourmaline/Scripts/BruteAgent.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tourmaline.Scripts
namespace Tourmaline.Scripts
{
public class BruteAgent
{
public string URL { get; set; }
public string WordlistPath { get; set; }
public string? OutfilePath { get; set; }
public bool DevMode { get; set; } = false;
public bool BareOutfile { get; set; } = false;

internal BruteAgent(string wordlistPath, string url)
{
Expand Down Expand Up @@ -66,11 +61,22 @@ internal async Task<List<Path>> Start(Action<Path>? next = null)
string[] realArray = new string[array.Length];

int i = 0;
foreach (var path in array)
if (!BareOutfile)
{
foreach (var path in array)
{
realArray[i] = path.ToString();
i++;
}
} else
{
realArray[i] = path.ToString();
i++;
foreach (var path in array)
{
realArray[i] = path.URL;
i++;
}
}


File.WriteAllLines(OutfilePath, realArray);
}
Expand Down
29 changes: 17 additions & 12 deletions Tourmaline/Scripts/BruteCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spectre.Console.Cli;
using Spectre.Console.Cli;
using Spectre.Console;

namespace Tourmaline.Scripts
Expand All @@ -19,9 +14,12 @@ public sealed class Settings : CommandSettings

[CommandOption("-d")]
public bool? DevMode { get; init; }
[CommandOption("-o")]
[CommandOption("-o|--outfile-path")]
public string? OutfilePath { get; init; }

[CommandOption("--outfile-bare")]
public bool? OutfileBare { get; init; }
[CommandOption("--output-bare")]
public bool? OutputBare { get; init; }
}

public async override Task<int> ExecuteAsync(CommandContext context, Settings settings)
Expand All @@ -48,8 +46,9 @@ await status.StartAsync("Starting...", async ctx =>
await Task.Delay(200);

ctx.Status = "Configuring agent...";
if (settings.DevMode != null && settings.DevMode == true) agent.DevMode = (bool)settings.DevMode;
if (settings.DevMode != null && settings.DevMode == true) agent.DevMode = true;
if (settings.OutfilePath != null) agent.OutfilePath = settings.OutfilePath;
if (settings.OutfileBare != null && settings.OutfileBare == true) agent.BareOutfile = true;
await Task.Delay(1000);

ctx.Status = "Finished";
Expand All @@ -63,9 +62,15 @@ await status.StartAsync("Starting...", async ctx =>
);

if (start == "No") return -1;

gui.Start();
await agent.Start((path) => gui.AddRow(path.URL, path.Type, path.Status.ToString()));
if (settings.OutputBare != null && settings.OutputBare == true)
{
await agent.Start((path) => Console.WriteLine(path.URL));
} else
{
gui.Start();
await agent.Start((path) => gui.AddRow(path.URL, path.Type, path.Status.ToString()));
}


gui.TaskCompletionSource.TrySetResult();

Expand Down
12 changes: 4 additions & 8 deletions Tourmaline/Scripts/BuilderCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spectre.Console;
using Spectre.Console.Cli;
using Tourmaline;

namespace Tourmaline.Scripts
{
Expand All @@ -25,7 +19,6 @@ public override Task<int> ExecuteAsync(CommandContext context)
AnsiConsole.MarkupLine("Welcome to the [Blue]Tourmaline[/] command builder!");
AnsiConsole.MarkupLine("This is meant to help you create [Blue]Tourmaline[/] commands (CTRL + C to quit)");
AnsiConsole.MarkupLine("We are going to ask you a couple of questions to help us generate the command.");
AnsiConsole.MarkupLine("If you are new to directory enumeration, run this again with '-n'.");

string url = AnsiConsole.Prompt(new TextPrompt<string>("Target URL:"));

Expand All @@ -45,7 +38,10 @@ public override Task<int> ExecuteAsync(CommandContext context)
} else
{
strBuilder.Append("tourmaline brute ");
strBuilder.Append(url);
strBuilder.Append(url + " ");

string wordlistPath = AnsiConsole.Prompt(new TextPrompt<string>("Wordlist Path?"));
strBuilder.Append(wordlistPath + " ");
}

AnsiConsole.MarkupLine("Here's your command: \n");
Expand Down
26 changes: 18 additions & 8 deletions Tourmaline/Scripts/SpiderAgent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Net.Http;
using System.Runtime.Loader;
using System.Windows.Markup;
using HtmlAgilityPack;

namespace Tourmaline.Scripts
Expand All @@ -13,6 +9,7 @@ public class SpiderAgent
public int MaxPaths { get; set; }
public bool DevMode { get; set; } = false;
public string? OutfilePath { get; set; }
public bool BareOutfile { get; set; } = false;

public SpiderAgent(string url, int rateLimit = 60, int maxPaths = int.MaxValue)
{
Expand Down Expand Up @@ -67,16 +64,18 @@ public async Task<List<Path>> Start(Action<Path>? next = null)

HtmlDocument doc = new();
doc.LoadHtml(html);
IEnumerable<HtmlNode> nodes = doc.DocumentNode.SelectNodes("//img | //script | //link | //a");
IEnumerable<HtmlNode> nodes = doc.DocumentNode.SelectNodes("//img | //script | //link | //a | //form");
if (nodes != null)
{
foreach (HtmlNode node in nodes)
{
string src = node.GetAttributeValue("src", "");
string href = node.GetAttributeValue("href", "");
string action = node.GetAttributeValue("action", "");

if (!string.IsNullOrEmpty(src)) queue.Enqueue(src);
if (!string.IsNullOrEmpty(href)) queue.Enqueue(href);
if (!string.IsNullOrEmpty(action)) queue.Enqueue(action);
}
}
}
Expand All @@ -99,11 +98,22 @@ public async Task<List<Path>> Start(Action<Path>? next = null)
string[] realArray = [];

int k = 0;
foreach (var path in array)
if (!BareOutfile)
{
realArray[k] = path.ToString();
k++;
foreach (var path in array)
{
realArray[k] = path.ToString();
k++;
}
} else
{
foreach (var path in array)
{
realArray[k] = path.URL;
k++;
}
}


File.WriteAllLines(OutfilePath, realArray);
}
Expand Down
25 changes: 16 additions & 9 deletions Tourmaline/Scripts/SpiderCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Spectre.Console;
using Spectre.Console.Cli;
using Tourmaline;

namespace Tourmaline.Scripts
{
Expand All @@ -25,6 +19,11 @@ public sealed class Settings : CommandSettings
[Description("Initates dev mode")]
[CommandOption("-d|--dev-mode")]
public bool? DevMode { get; init; }

[CommandOption("--outfile-bare")]
public bool? OutfileBare { get; init; }
[CommandOption("--output-bare")]
public bool? OutputBare { get; init; }
}

public async override Task<int> ExecuteAsync(CommandContext context, Settings settings)
Expand Down Expand Up @@ -52,6 +51,7 @@ await status.StartAsync("Starting...", async ctx =>
ctx.Status = "Configuring agent...";
if (settings.MaxPaths != null) agent.MaxPaths = (int)settings.MaxPaths;
if (settings.DevMode != null && settings.DevMode == true) agent.DevMode = (bool)settings.DevMode;
if (settings.OutfileBare != null && settings.OutfileBare == true) agent.BareOutfile = (bool)settings.OutfileBare;
await Task.Delay(1000);

ctx.Status = "Finished";
Expand All @@ -66,8 +66,15 @@ await status.StartAsync("Starting...", async ctx =>

if (start == "No") return -1;

gui.Start();
await agent.Start((path) => gui.AddRow(path.URL, path.Type, path.Status.ToString()));
if (settings.OutputBare != null && settings.OutputBare == true)
{
await agent.Start((path) => Console.WriteLine(path.URL));
}
else
{
gui.Start();
await agent.Start((path) => gui.AddRow(path.URL, path.Type, path.Status.ToString()));
}

gui.TaskCompletionSource.TrySetResult();

Expand Down

0 comments on commit a2aa3de

Please sign in to comment.