Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Simple Dork Scanner

Dork Scanner

[Image: obSSgLS.png]
(No offence if you're the owner of that website, just picked a random one from the Website sub-forum.)

Wrote this in my free time.
Nothing special, just a simple program that scans a URL against a given list of dorks.

It's pretty fast and hasn't given me any issues.

Put the dorks in the executable directory with the name 'dorks.txt' or set your own path in the program.

Source: https://github.com/arcanecfg/Dork-Scanner/

//Someone should probably move this to the C# section, posted it here by accident.

Enjoy.

For the glory of humanity
Nice work Arcane. Love how simple this is and gives anyone the ability to add there own dorks or paths. Not only that you are even presenting a nice report at the end gj!
Some small suggestions:

-.Length is faster than .Count() and should be used when possable
Though the performance difference dosent realy matter here, its good practice.

-Use the Console.WriteLine formatting
This:
Code
Console.WriteLine("Successfully loaded " + dorkList.Count() + " dorks.");
Can be
Code
Console.WriteLine("Successfully loaded {0} dorks.", dorkList.Length);
//or
Console.WriteLine($"Successfully loaded {dorkList.Length} dorks.");

-Initial variable values
Spoiler (Click to View)

Why not
Code
string dorkPath = "dorks.txt";

Personal prefrence, this deceleration is a bit odd
Code
string[] dorkList = { string.Empty };
If you want to initialize an empty array
Code
string[] dorkList = new string[];
//or even just null
string[] dorkList = null;

-No checking before string modifications
Spoiler (Click to View)
There are no checks to verify that the string is not empty. If there is a blank line in the file, this will throw an error.

-Not disposing of objects
Good praceice, dispose your objects when you are finished with them.
in the startScan function, this
Spoiler (Click to View)
Can be
Code
using (StreamReader sReader = new StreamReader(newRes.GetResponseStream()))
{
    myResp = sReader.ReadToEnd();
}
Or, if you want to dispose of them manualy
Code
StreamReader sReader = new StreamReader(newRes.GetResponseStream());
myResp = sReader.ReadToEnd();
sReader.Dispose();
They do the same thing.

-Personal prefrence, dont check againsed true/false in IF statements
Code
if (myResp.Contains("404") == false)
Can be
Code
if (!myResp.Contains("404"))
Lotta blood to let, peace to make, give a fuk about a check
Thank you for sharing the source code, it will help people like me understand this kind of programs better.
(May 5, 2016 12:18 PM)2344lkn Wrote:  Nice work Arcane. Love how simple this is and gives anyone the ability to add there own dorks or paths. Not only that you are even presenting a nice report at the end gj!
Glad you liked it mate.

(May 6, 2016 01:58 AM)BahNahNah Wrote:  Some small suggestions:

-.Length is faster than .Count() and should be used when possable
Though the performance difference dosent realy matter here, its good practice.

-Use the Console.WriteLine formatting
This:
Code
Console.WriteLine("Successfully loaded " + dorkList.Count() + " dorks.");
Can be
Code
Console.WriteLine("Successfully loaded {0} dorks.", dorkList.Length);
//or
Console.WriteLine($"Successfully loaded {dorkList.Length} dorks.");

-Initial variable values
Spoiler (Click to View)

Why not
Code
string dorkPath = "dorks.txt";

Personal prefrence, this deceleration is a bit odd
Code
string[] dorkList = { string.Empty };
If you want to initialize an empty array
Code
string[] dorkList = new string[];
//or even just null
string[] dorkList = null;

-No checking before string modifications
Spoiler (Click to View)
There are no checks to verify that the string is not empty. If there is a blank line in the file, this will throw an error.

-Not disposing of objects
Good praceice, dispose your objects when you are finished with them.
in the startScan function, this
Spoiler (Click to View)
Can be
Code
using (StreamReader sReader = new StreamReader(newRes.GetResponseStream()))
{
    myResp = sReader.ReadToEnd();
}
Or, if you want to dispose of them manualy
Code
StreamReader sReader = new StreamReader(newRes.GetResponseStream());
myResp = sReader.ReadToEnd();
sReader.Dispose();
They do the same thing.

-Personal prefrence, dont check againsed true/false in IF statements
Code
if (myResp.Contains("404") == false)
Can be
Code
if (!myResp.Contains("404"))
I really appreciate you taking the time to go through the code thoroughly and giving me suggestions.
Some of the stuff, the pointless initialisation and forgetting to close the StreamReader for example, was the result of my careless debugging.
The consoleline formatting is just a bad habit that stuck with me, I'll try my best to fight it in the future.

Never knew .Length was faster than Count(), I'll keep that in mind as well.

Thanks again.

(May 6, 2016 01:59 AM)Aveling Wrote:  Thank you for sharing the source code, it will help people like me understand this kind of programs better.
Happy to hear that.

For the glory of humanity

Thanks BahNahNah for the optimizations and better practices. I've been messing around with C# for around a year I'm no expert but I picked up on a few things thanks again.
(May 6, 2016 04:46 AM)Decim Wrote:  Glad you liked it mate.

I really appreciate you taking the time to go through the code thoroughly and giving me suggestions.
Some of the stuff, the pointless initialisation and forgetting to close the StreamReader for example, was the result of my careless debugging.
The consoleline formatting is just a bad habit that stuck with me, I'll try my best to fight it in the future.

Never knew .Length was faster than Count(), I'll keep that in mind as well.

Thanks again.

Happy to hear that.

Adding on to his post a little.

You're doing a lot of string manipulation when you don't have to.

Code
targetURL = Console.ReadLine();
//... firewall didn't like this line

You never check to see if the address is valid until later when it'll throw an exception.
If you use Uri.TryCreate here, you can make sure their input is valid. From there, use the Host property.

Read through the methods (GetLeftPart, specifically) and properties. You'll find some stuff that'll make your life easier.

Using a WebClient will make your code easier to read.

Code
if (myResp.Contains("404") == false)

You're more likely to get a 404 exception than a site giving a 200 and displaying a 404 page. If any of the pages you request contain "404," it'll put it in the "bad" list when it's valid.
Catch as a WebException. From there, Google how to get the status code and determine which errors you want to determine as "bad." For example, a "timeout" might not be something you want to determine as bad.
(May 6, 2016 02:02 PM)SL x TnT Wrote:  Adding on to his post a little.

You're doing a lot of string manipulation when you don't have to.

Code
targetURL = Console.ReadLine();
//... firewall didn't like this line

You never check to see if the address is valid until later when it'll throw an exception.
If you use Uri.TryCreate here, you can make sure their input is valid. From there, use the Host property.

Read through the methods (GetLeftPart, specifically) and properties. You'll find some stuff that'll make your life easier.

Using a WebClient will make your code easier to read.

Code
if (myResp.Contains("404") == false)

You're more likely to get a 404 exception than a site giving a 200 and displaying a 404 page. If any of the pages you request contain "404," it'll put it in the "bad" list when it's valid.
Catch as a WebException. From there, Google how to get the status code and determine which errors you want to determine as "bad." For example, a "timeout" might not be something you want to determine as bad.

I probably should be checking the URL first, thanks.

As for the 404, some websites have custom error pages set up and they won't return an exception when the URL is invalid.

For the glory of humanity
(May 6, 2016 07:55 PM)Decim Wrote:  I probably should be checking the URL first, thanks.

As for the 404, some websites have custom error pages set up and they won't return an exception when the URL is invalid.

Then they should fix their site.

If they have a custom 404 page that doesn't have a 404 status, it's impossible to reliably check it.
posting here to remind myself later
nice these post can be usefull thanks for sharing
(May 6, 2016 01:58 AM)BahNahNah Wrote:  Some small suggestions:

-.Length is faster than .Count() and should be used when possable
Though the performance difference dosent realy matter here, its good practice.

-Use the Console.WriteLine formatting
This:
Code
Console.WriteLine("Successfully loaded " + dorkList.Count() + " dorks.");
Can be
Code
Console.WriteLine("Successfully loaded {0} dorks.", dorkList.Length);
//or
Console.WriteLine($"Successfully loaded {dorkList.Length} dorks.");

-Initial variable values
Spoiler (Click to View)

Why not
Code
string dorkPath = "dorks.txt";

Personal prefrence, this deceleration is a bit odd
Code
string[] dorkList = { string.Empty };
If you want to initialize an empty array
Code
string[] dorkList = new string[];
//or even just null
string[] dorkList = null;

-No checking before string modifications
Spoiler (Click to View)
There are no checks to verify that the string is not empty. If there is a blank line in the file, this will throw an error.

-Not disposing of objects
Good praceice, dispose your objects when you are finished with them.
in the startScan function, this
Spoiler (Click to View)
Can be
Code
using (StreamReader sReader = new StreamReader(newRes.GetResponseStream()))
{
   myResp = sReader.ReadToEnd();
}
Or, if you want to dispose of them manualy
Code
StreamReader sReader = new StreamReader(newRes.GetResponseStream());
myResp = sReader.ReadToEnd();
sReader.Dispose();
They do the same thing.

-Personal prefrence, dont check againsed true/false in IF statements
Code
if (myResp.Contains("404") == false)
Can be
Code
if (!myResp.Contains("404"))
Very informative post, thanks heaps.
I believe this is called a admin panel scanner and you may be able to achieve faster results with queue and socket combination

Thanks for the contribution keep it up champ
[Image: Syr3DlV.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by basisJun 1, 2018 05:59 AM 9 789 Jun 1, 2018 05:59 AM
Last Post: Dalvik
[Python] by THC77Oct 2, 2017 07:13 AM 2 245 Oct 2, 2017 07:13 AM
Last Post: TheMarkMan
[Python] by SIM-2339042Jun 25, 2016 06:56 AM 10 677 Jun 25, 2016 06:56 AM
Last Post: kabir68