Finalize C# script

This commit is contained in:
Taevas 2021-06-29 15:16:53 +02:00
parent 67842f8686
commit 972af03a56
3 changed files with 34 additions and 12 deletions

View file

@ -3,7 +3,12 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>C_</RootNamespace>
<RootNamespace>C_</RootNamespace>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
</Project>

View file

@ -9,15 +9,21 @@ using System.Linq;
class WebRequests
{
public static void Main()
public static void Main(string[] args)
{
int times = 3000;
string[] domains = new string[]{".co", ".com", ".net", ".edu", ".gov", ".cn", ".org", ".cc", ".us", ".mil", ".ac", ".it", ".de"};
string[] mode = new string[]{"http", "https"};
bool log = true;
int mini = 2;
int maxi = 50;
int second = 1;
int times = Array.IndexOf(args, "-t") > -1 ? int.Parse(args[Array.IndexOf(args, "-t") + 1]) : 3000;
string[] domains = Array.IndexOf(args, "-d") > -1 ? args[Array.IndexOf(args, "-d") + 1].Split(",") : new string[]{".co", ".com", ".net", ".edu", ".gov", ".cn", ".org", ".cc", ".us", ".mil", ".ac", ".it", ".de"};
string[] mode = Array.IndexOf(args, "-m") > -1 ? args[Array.IndexOf(args, "-m") + 1].Split(",") : new string[]{"http"};
bool log = Array.IndexOf(args, "-l") > -1;
int mini = Array.IndexOf(args, "-MIN") > -1 ? int.Parse(args[Array.IndexOf(args, "-MIN") + 1]) : 2;
int maxi = Array.IndexOf(args, "-MAX") > -1 ? int.Parse(args[Array.IndexOf(args, "-MAX") + 1]) : 50;
int second = Array.IndexOf(args, "-s") > -1 ? int.Parse(args[Array.IndexOf(args, "-s") + 1]) : 1;
DateTime time = DateTime.Now;
Console.WriteLine($"\nI am going to look for websites through {times} random URLs (min length {mini} and max length {maxi}) with the following domains: {String.Join(", ", domains)}");
Console.WriteLine($"These URLs will use the protocols {String.Join(", ", mode)} and each of them have {second} in a 100 chance to have a second level domain.");
Console.WriteLine($"Started at {time.Hour}h{time.Minute}m\n");
List<data> _data = new List<data>();
@ -65,8 +71,9 @@ class WebRequests
}
}
string json_file_name = $"C#_report_{time.Day}{time.Hour}{time.Minute}.json";
string json = JsonSerializer.Serialize(_data);
File.WriteAllText("C#_report.json", json);
File.WriteAllText(json_file_name, json);
}
public class data

View file

@ -12,17 +12,24 @@ Each script has its own requirements.
* index.js, the Node.js script, requires [Node.js](https://nodejs.org/en/download/)
* index.rb, the Ruby script, requires [Ruby](https://rubyinstaller.org/downloads/)
* index.html, which runs a Javascript script within a HTML webpage, only requires a web browser supporting [JS](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript)
* Program.cs, the C# script, requires [.NET SDK](https://dotnet.microsoft.com/download) **to be built**
An already built C# script for Windows (x64) that doesn't have any requirement is available in this repository's releases. (C#.exe in win-x64)
## HOW TO RUN
You can run the Python or Ruby script by simply double clicking on it or going into the command-line, moving into the right directory and entering the file name.
You can run the Python, the (built) C# script or the Ruby script by simply double clicking on it or going into the command-line, moving into the right directory and entering the file name.
To run the Node.js script, you will have to use the command-line.
To run the Node.js script or the (unbuilt) C# script, you will have to use the command-line.
```sh
$ cd Website-Finder/Node.js
$ node index.js
```
```sh
$ cd Website-Finder/C#
$ dotnet run
```
For the Javascript script, you can:
@ -62,6 +69,9 @@ $ index.rb -MAX 7 -t 500 -MIN 5 -m http,https -l -s 30 -d .com,.fr
# To make the Node.js script go through 3000 URLs in HTTPS with various top-level domains with logging:
$ node index.js -m https -l
# To make the (built) C# script go through 100 URLs with the .com top-level domains with a 0% chance for each URL to feature a second level domain without logging:
$ C#.exe -d .com -s 0
```
## REPORTS