Illegal Characters in Path

Open
#66 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
cli

Research direction

Start at the ResolveFileName method shown in the issue and reproduce the failure using an existing output directory. Trace how the filename, extension, timestamp, and OutputPrefix are combined before Path.Combine is called. Done means the same output-directory scenario completes without an Illegal Characters in Path error and preserves the intended output naming.

Written by the indexing model from the issue text.

Description

I ran into an issue where I specified an output directory (it exists), but for some reason when sharphound ran, it gave an "Illegal Characters in Path" error and died. Rohan said to file a bug and thinks it relates to the following code:

`public string ResolveFileName(string filename, string extension, bool addTimestamp)
{
var finalFilename = filename;
if (!filename.EndsWith(extension))
finalFilename = $"{filename}.{extension}";

        if (extension is "json" or "zip" && Flags.RandomizeFilenames)
            finalFilename = $"{Path.GetRandomFileName()}";

        if (addTimestamp) finalFilename = $"{CurrentLoopTime}_{finalFilename}";

        if (OutputPrefix != null) finalFilename = $"{OutputPrefix}_{finalFilename}";

        var finalPath = Path.Combine(OutputDirectory, finalFilename);

        return finalPath;
    }`
Dominant language
C#
Stars
1.3k
Forks
266
Avg merge
2d 7h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SpecterOps/SharpHound

All issues in SpecterOps/SharpHound

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.