Skip to content

Commit

Permalink
Validate cookie string to stop 403 error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sim0n00ps committed Sep 29, 2024
1 parent 5107f31 commit b244286
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions OF DL/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public async static Task Main(string[] args)
Environment.Exit(2);
}

//Added to stop cookie being filled with un-needed headers
ValidateCookieString();

if (File.Exists("rules.json"))
{
AnsiConsole.Markup("[green]rules.json located successfully!\n[/]");
Expand Down Expand Up @@ -2562,4 +2565,24 @@ static ProgressColumn[] GetProgressColumns(bool showScrapeSize)
}
return null;
}

public static void ValidateCookieString()
{
string pattern = @"(auth_id=\d+)|(sess=[^;]+)";
var matches = Regex.Matches(auth.COOKIE, pattern);

string output = string.Join("; ", matches);

if (!output.EndsWith(";"))
{
output += ";";
}

if(auth.COOKIE.Trim() != output.Trim())
{
auth.COOKIE = output;
string newAuthString = JsonConvert.SerializeObject(auth, Formatting.Indented);
File.WriteAllText("auth.json", newAuthString);
}
}
}

0 comments on commit b244286

Please sign in to comment.