Skip to content

Commit

Permalink
source code
Browse files Browse the repository at this point in the history
  • Loading branch information
jewdev committed Mar 17, 2022
1 parent dac1973 commit c63b49d
Show file tree
Hide file tree
Showing 14 changed files with 754 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# jewEditor
Advanced combolist editor
I made this tool 2 years ago when I was learning C# so there is a lot of duplicate code

# EVERYTHING IN THIS REPOSITORY IS FOR EDUCATIONAL PURPOSES ONLY!
25 changes: 25 additions & 0 deletions src/jewEditor.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29009.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jewEditor", "jewEditor\jewEditor.csproj", "{F4EE0432-9E74-48CC-8248-AB1F2FC9F972}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F4EE0432-9E74-48CC-8248-AB1F2FC9F972}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4EE0432-9E74-48CC-8248-AB1F2FC9F972}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4EE0432-9E74-48CC-8248-AB1F2FC9F972}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4EE0432-9E74-48CC-8248-AB1F2FC9F972}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0F19C752-D6C2-41DE-855B-41026B59A73F}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions src/jewEditor/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
206 changes: 206 additions & 0 deletions src/jewEditor/Edit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Timers;
using System.Windows.Forms;
using Timer = System.Timers.Timer;

namespace jewEditor
{
internal class Edit
{
public static void Start()
{
Console.Clear();
Console.Title = $"jewEditor | v{Globals.Version} | Edit";
Messages.Logo();
Messages.PrintWithPrefix("Input", "Please choose a file.", "Crimson");
OpenFileDialog file = new OpenFileDialog();
file.Title = "Choose a text file!";
file.Filter = "Text Files|*.txt";
file.FilterIndex = 2;
file.RestoreDirectory = true;
if (file.ShowDialog() == DialogResult.OK)
{
string path = file.FileName;
Globals.Lines = File.ReadLines(path).ToList();
}
else
{
Program.Menu();
}
ProcessInfo();
}

private static void ProcessInfo()
{
Console.Clear();
Messages.Logo();
Messages.PrintWithPrefix("Warning", "Don't edit the combolist before fixing it, it could CRASH the program!", "Yellow");
Console.WriteLine();
Messages.PrintWithPrefix("Info", $"Loaded {Globals.Lines.Count} lines from the file!", "Crimson");
Messages.PrintWithPrefix("Continue", "Press any key to continue.", "Crimson");
Console.ReadKey();
Process();
}

//TODO: Optimize the code, set splits to 2 variables instead of 2 EACH function.
private static void Process()
{
Console.Clear();
//Messages.PrintWithPrefix("Process", "I'm working on it! (If the file's size is BIG it will take more time)", "Crimson");
Messages.Logo();
Messages.PrintWithPrefix("Editing", $"[{Globals.NewLines.Count} / {Globals.Lines.Count * 9}]", "Crimson");

Timer aTimer = new Timer();
aTimer.Interval = 750;
aTimer.Elapsed += TimerHandle;
aTimer.AutoReset = true;
aTimer.Enabled = true;

foreach (string line in Globals.Lines)
{
string[] splitLine = line.Split(':');

// email:Pass
string result1 = Regex.Replace(splitLine[1], "^[a-z]", m => m.Value.ToUpper());
Globals.NewLines.Add(splitLine[0] + ":" + result1);

// email:pass!
string result2 = splitLine[1] + "!";
Globals.NewLines.Add(splitLine[0] + ":" + result2);

// email:Pass!
string result3Regex = Regex.Replace(splitLine[1], "^[a-z]", m => m.Value.ToUpper());
string result3 = result3Regex + "!";
Globals.NewLines.Add(splitLine[0] + ":" + result3);

// email:pass1
string result4 = splitLine[1] + "1";
Globals.NewLines.Add(splitLine[0] + ":" + result4);

// email:Pass1
string result5Regex = Regex.Replace(splitLine[1], "^[a-z]", m => m.Value.ToUpper());
string result5 = result5Regex + "1";
Globals.NewLines.Add(splitLine[0] + ":" + result5);

// email:pass123
string result6 = splitLine[1] + "123";
Globals.NewLines.Add(splitLine[0] + ":" + result6);

// email:Pass123
string result7Regex = Regex.Replace(splitLine[1], "^[a-z]", m => m.Value.ToUpper());
string result7 = result7Regex + "123";
Globals.NewLines.Add(splitLine[0] + ":" + result7);

// email(passnum):pass(num)
string takeNumbersFromPw = Regex.Replace(splitLine[1], @"[^\d]", "");
string[] splitEmailLine1 = splitLine[0].Split('@');
string emailResult = splitEmailLine1[0] + takeNumbersFromPw;
Globals.NewLines.Add(emailResult + "@" + splitEmailLine1[1] + ":" + splitLine[1]);

// email(num):pass(emailnum)
string[] splitEmailLine2 = splitLine[0].Split('@');
string takeNumbersFromEmail = Regex.Replace(splitEmailLine2[0], @"[^\d]", "");
string passResult = splitLine[1] + takeNumbersFromEmail;

Globals.NewLines.Add(splitLine[0] + ":" + passResult);
}

aTimer.Enabled = false;

Globals.Lines.Clear();
RemovedDuplicates();
}

private static void TimerHandle(Object source, ElapsedEventArgs e)
{
Console.Clear();
Messages.PrintWithPrefix("Editing", $"[{Globals.NewLines.Count} / {Globals.Lines.Count * 9}]", "Crimson");
}

private static void RemovedDuplicates()
{
Console.Clear();
Messages.PrintWithPrefix("Question", "Would you like to remove duplicates in the combolist? (y / n)", "Crimson");

string removeAnswer = Console.ReadLine();

if (removeAnswer != null && removeAnswer.StartsWith("Y".ToLower()))
{
Console.Clear();
Messages.PrintWithPrefix("Process", "Removing duplicates...", "Crimson");

var removedLines = Globals.NewLines.Distinct().ToList();
Globals.NewLines.Clear();
foreach (string line in removedLines)
{
Globals.NewLines.Add(line);
}
Randomize();
}
else
{
Randomize();
}
}

private static void Randomize()
{
Console.Clear();
Messages.PrintWithPrefix("Question", "Would you like to randomize the combolist? (y / n)", "Crimson");
string randomizeAnswer = Console.ReadLine();

if (randomizeAnswer != null && randomizeAnswer.StartsWith("Y".ToLower()))
{
Console.Clear();
Messages.PrintWithPrefix("Process", "Randomizing Lines...", "Crimson");
var randomizedList = Globals.NewLines.OrderBy(a => Guid.NewGuid()).ToList();
Globals.NewLines.Clear();
foreach (string line in randomizedList)
{
Globals.NewLines.Add(line);
}
SaveToFile();
}
else
{
SaveToFile();
}
}

private static void SaveToFile()
{
Console.Clear();
SaveFileDialog saveFile = new SaveFileDialog
{
FileName = $"jewEditor - Edit - {Globals.NewLines.Count} Lines.txt",
Filter = "Text Files|*.txt"
};

if (saveFile.ShowDialog() == DialogResult.OK)
{
using (StreamWriter sw = new StreamWriter(saveFile.FileName))
{
foreach (string line in Globals.NewLines)
{
sw.WriteLine(line);
}
}

Globals.NewLines.Clear();
}
else
{
Program.Menu();
}

Console.Clear();
Messages.PrintWithPrefix("Info", $"Saved the file! File location: {saveFile.FileName}", "Crimson");
Messages.PrintWithPrefix("Done", "Press any key to go back to the menu.", "Crimson");
Console.ReadKey();
Program.Menu();
}
}
}
104 changes: 104 additions & 0 deletions src/jewEditor/Fix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace jewEditor
{
internal class Fix
{
public static void Start()
{
Console.Clear();
Console.Title = string.Format("jewEditor | v{0} | Fix", Globals.Version);
Messages.Logo();
Messages.PrintWithPrefix("Input", "Please choose a file.", "Crimson");
OpenFileDialog file = new OpenFileDialog();
file.Title = "Choose a text file!";
file.Filter = "Text Files|*.txt";
file.FilterIndex = 2;
file.RestoreDirectory = true;
if (file.ShowDialog() == DialogResult.OK)
{
string path = file.FileName;
Globals.Lines = File.ReadLines(path).ToList();
}
else
{
Program.Menu();
}
ProcessInfo();
}

private static void ProcessInfo()
{
Console.Clear();
Messages.Logo();
Messages.PrintWithPrefix("Info", $"Loaded {Globals.Lines.Count} lines from the file!", "Crimson");
Messages.PrintWithPrefix("Continue", "Press any key to continue.", "Crimson");
Console.ReadKey();
Process();
}

private static void Process()
{
Console.Clear();
Messages.Logo();
Messages.PrintWithPrefix("Process", "I'm working on it! (If the file's size is BIG it will take more time)", "Crimson");

Messages.PrintWithPrefix("Process", "Fixing Lines...", "Crimson");
foreach (string line in Globals.Lines)
{
if (!line.Contains(" ") && line.Contains("@") && line.Contains(":"))
{
string[] splitLine = line.Split(':');
if (splitLine[0].Contains("@"))
{
_fixedLines.Add(line);
}
}
}

Messages.PrintWithPrefix("Process", "Removing Duplicates...", "Crimson");
_fixedLines = _fixedLines.Distinct().ToList();

Globals.Lines.Clear();
SaveToFile();
}

private static void SaveToFile()
{
Console.Clear();
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.FileName = $"jewEditor - Fix - {_fixedLines.Count} Lines.txt";
saveFile.Filter = "Text Files|*.txt";

if (saveFile.ShowDialog() == DialogResult.OK)
{
using (StreamWriter sw = new StreamWriter(saveFile.FileName))
{
foreach (string line in _fixedLines)
{
sw.WriteLine(line);
}
}

_fixedLines.Clear();
}
else
{
Program.Menu();
}

Console.Clear();
Messages.Logo();
Messages.PrintWithPrefix("Info", $"Saved the file! File location: {saveFile.FileName}", "Crimson");
Messages.PrintWithPrefix("Done", "Press any key to go back to the menu.", "Crimson");
Console.ReadKey();
Program.Menu();
}

private static List<string> _fixedLines = new List<string>();
}
}
3 changes: 3 additions & 0 deletions src/jewEditor/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
13 changes: 13 additions & 0 deletions src/jewEditor/Globals.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;

namespace jewEditor
{
internal class Globals
{
public static string Version = "1.0";

public static List<string> Lines = new List<string>();

public static List<string> NewLines = new List<string>();
}
}
Loading

0 comments on commit c63b49d

Please sign in to comment.