Skip to content

Commit 43c2872

Browse files
authored
Merge pull request #784 from shelld3v/several-updates
Several updates
2 parents 62a032a + 1912bff commit 43c2872

File tree

12 files changed

+233
-177
lines changed

12 files changed

+233
-177
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Currently working...
88
- Fixed the CSV Injection vulnerability (https://www.exploit-db.com/exploits/49370)
99
- Raw request supported
1010
- Can setup the default URL scheme (will be used when there is no scheme in the URL)
11+
- Option to skip target by specified status codes
12+
- Added max-runtime option
1113

1214
v0.4.1 (2020.12.8)
1315
---------

README.md

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
![dirsearch](https://user-images.githubusercontent.com/59408894/103289759-87a0ce80-4a1a-11eb-89c9-2feb7e6db25f.png) - *Hacking is not a crime*
2-
31
dirsearch - Web path scanner
42
=========
53

@@ -16,13 +14,13 @@ dirsearch - Web path scanner
1614

1715
Overview
1816
--------
19-
- Dirsearch is a mature command-line tool designed to brute force directories and files in webservers.
17+
- "dirsearch" is a mature command-line tool designed to brute force directories and files in webservers.
2018

2119
- With 6 years of growth, dirsearch now has become the top web content scanner.
2220

2321
- As a feature-rich tool, dirsearch gives users the opportunity to perform a complex web content discovering, with many vectors for the wordlist, high accuracy, impressive performance, advanced connection/request settings, modern brute-force techniques and nice output.
2422

25-
- Dirsearch is being actively developed by [@maurosoria](https://twitter.com/_maurosoria) and [@shelld3v](https://github.com/shelld3v)
23+
- "dirsearch" is being actively developed by [@maurosoria](https://twitter.com/_maurosoria) and [@shelld3v](https://github.com/shelld3v)
2624

2725

2826
Installation & Usage
@@ -36,9 +34,9 @@ python3 dirsearch.py -u <URL> -e <EXTENSIONS>
3634

3735
- To can use SOCKS proxy or work with `../` in the wordlist, you need to install pips with `requirements.txt`: `pip3 install -r requirements.txt`
3836

39-
- If you are using Windows and don't have git, you can install the ZIP file [here](https://github.com/maurosoria/dirsearch/archive/master.zip). Dirsearch also supports [Docker](https://github.com/maurosoria/dirsearch#support-docker)
37+
- If you are using Windows and don't have git, you can install the ZIP file [here](https://github.com/maurosoria/dirsearch/archive/master.zip). dirsearch also supports [Docker](https://github.com/maurosoria/dirsearch#support-docker)
4038

41-
*Dirsearch requires python 3 or greater*
39+
*dirsearch requires python 3 or greater*
4240

4341

4442
Features
@@ -84,22 +82,20 @@ Features
8482

8583
About wordlists
8684
---------------
87-
**Summary**: Wordlist must be a text file, each line will be an endpoint. About extensions, unlike other tools, dirsearch won't append extensions to every word, if you don't use the `-f` flag. By default, only the `%EXT%` keyword in the wordlist will be replaced with extensions (`-e <extensions>`).
85+
**Summary**: Wordlist must be a text file, each line will be an endpoint. About extensions, unlike other tools, dirsearch doesn't append extensions to every word, if you don't use the `-f` flag. By default, only the `%EXT%` keyword in the wordlist will be replaced with extensions (`-e <extensions>`).
8886

8987
**Details**:
9088
- Each line in the wordlist will be processed as such, except when the special keyword *%EXT%* is used, it will generate one entry for each extension (-e | --extensions) passed as an argument.
9189

9290
Example:
9391

9492
```
95-
root/
9693
index.%EXT%
9794
```
9895

9996
Passing the extensions "asp" and "aspx" (`-e asp,aspx`) will generate the following dictionary:
10097

10198
```
102-
root/
10399
index
104100
index.asp
105101
index.aspx
@@ -111,7 +107,6 @@ Example:
111107

112108
```
113109
admin
114-
home.%EXT%
115110
api%NOFORCE%
116111
```
117112

@@ -122,9 +117,6 @@ admin
122117
admin.php
123118
admin.html
124119
admin/
125-
home
126-
home.php
127-
home.html
128120
api
129121
```
130122

@@ -169,8 +161,8 @@ Options:
169161
--suffixes=SUFFIXES
170162
Add custom suffixes to all entries, ignore directories
171163
(separated by commas)
172-
--only-selected Only entries with selected extensions or no extension
173-
+ directories
164+
--only-selected Only directories + files with selected extensions (or
165+
no extension)
174166
--remove-extensions
175167
Remove extensions in all wordlist entries (Example:
176168
admin.php -> admin)
@@ -207,10 +199,11 @@ Options:
207199
--exclude-redirects=REGEXPS
208200
Exclude responses by redirect regexps or texts,
209201
separated by commas (Example: 'https://okta.com/*')
210-
--calibration=PATH Path to test for calibration
211-
--random-agent Choose a random User-Agent for each request
202+
--exclude-content=PATH
203+
Exclude responses by response content of this path
212204
--minimal=LENGTH Minimal response length
213205
--maximal=LENGTH Maximal response length
206+
--skip-on-429 Skip target whenever 429 status code is returned
214207
-q, --quiet-mode Quiet mode
215208
--full-url Print full URLs in the output
216209
--no-color No colored output
@@ -226,6 +219,7 @@ Options:
226219
--header-list=FILE File contains HTTP request headers
227220
-F, --follow-redirects
228221
Follow HTTP redirects
222+
--random-agent Choose a random User-Agent for each request
229223
--user-agent=USERAGENT
230224
--cookie=COOKIE
231225
@@ -237,7 +231,7 @@ Options:
237231
--proxy=PROXY Proxy URL, support HTTP and SOCKS proxies (Example:
238232
localhost:8080, socks5://localhost:8088)
239233
--proxy-list=FILE File contains proxy servers
240-
--matches-proxy=PROXY
234+
--replay-proxy=PROXY
241235
Proxy to replay with found paths
242236
--scheme=SCHEME Default scheme (for raw request or if there is no
243237
scheme in the URL)
@@ -257,7 +251,7 @@ Options:
257251
--csv-report=OUTPUTFILE
258252
```
259253

260-
**NOTE**:
254+
**NOTE**:
261255
You can change the dirsearch default configurations (default extensions, timeout, wordlist location, ...) by editing the **default.conf** file.
262256

263257

@@ -306,7 +300,7 @@ python3 dirsearch.py -e php,htm,js,bak,zip,tgz,txt -u https://target -t 30
306300
- **--prefixes**: Adding custom prefixes to all entries
307301

308302
```
309-
python3 dirsearch.py -e php -u https://target --prefixes .,admin,_,~
303+
python3 dirsearch.py -e php -u https://target --prefixes .,admin,_
310304
```
311305
Base wordlist:
312306

@@ -319,7 +313,6 @@ Generated with prefixes:
319313
.tools
320314
admintools
321315
_tools
322-
~tools
323316
```
324317

325318
- **--suffixes**: Adding custom suffixes to all entries
@@ -342,34 +335,48 @@ internal~
342335
internal/
343336
```
344337

345-
### Exclude extensions
346-
Use **-X | --exclude-extensions** with your exclude-extension list to remove all entries in the wordlist that have the given extensions
338+
### Blacklist
339+
Inside the `db` folder, there are several "blacklist files". Paths in those files will be filtered from the scan result if they have the same status as mentioned in the filename.
340+
341+
Example: If you add `admin.php` into `db/403_blacklist.txt`, whenever you do a scan that `admin.php` returns 403, it (`admin.php`) will be excluded.
342+
343+
### Filters
344+
Use **-i | --include-status** and **-x | --exclude-status** to select allowed and not allowed response status codes
347345

348346
```
349-
python3 dirsearch.py -e asp,aspx,htm,js -u https://target -X php,jsp,jspx
347+
python3 dirsearch.py -e php,html,js -u https://target -i 200,204,400,403 -x 500,502,429
350348
```
351349

352-
Base wordlist:
350+
**--exclude-sizes**, **--exclude-texts**, **--exclude-regexps**, **--exclude-redirects** and **--exclude-content** are also supported for a more advanced filter
353351

354352
```
355-
admin
356-
admin.%EXT%
357-
index.html
358-
home.php
359-
test.jsp
353+
python3 dirsearch.py -e php,html,js -u https://target --exclude-sizes 1B,243KB
360354
```
361355

362-
After:
356+
```
357+
python3 dirsearch.py -e php,html,js -u https://target --exclude-texts "403 Forbidden"
358+
```
363359

364360
```
365-
admin
366-
admin.asp
367-
admin.aspx
368-
admin.htm
369-
admin.js
370-
index.html
361+
python3 dirsearch.py -e php,html,js -u https://target --exclude-regexps "^Error$"
362+
```
363+
364+
```
365+
python3 dirsearch.py -e php,html,js -u https://target --exclude-content "admin.php"
366+
```
367+
368+
### Raw requests
369+
dirsearch allows you to import the raw request from a file. The raw file content will be looked something like this:
370+
371+
```
372+
GET /admin HTTP/1.1
373+
Host: admin.example.com
374+
Cache-Control: max-age=0
375+
Accept: */*
371376
```
372377

378+
Since there is no way for dirsearch to know what the URI scheme is (`http` or `https`), you need to set it using the `--scheme` flag. By default, the scheme is `http`, which is not popular in modern web servers now. That means, without setting up the scheme, you may brute-force with the wrong protocol, and will end up with false negatives.
379+
373380
### Wordlist formats
374381
Supported wordlist formats: uppercase, lowercase, capitalization
375382

@@ -378,58 +385,45 @@ Supported wordlist formats: uppercase, lowercase, capitalization
378385
```
379386
admin
380387
index.html
381-
test
382388
```
383389

384390
#### Uppercase:
385391

386392
```
387393
ADMIN
388394
INDEX.HTML
389-
TEST
390395
```
391396

392397
#### Capital:
393398

394399
```
395400
Admin
396401
Index.html
397-
Test
398-
```
399-
400-
### Filters
401-
Use **-i | --include-status** and **-x | --exclude-status** to select allowed and not allowed response status codes
402-
403-
```
404-
python3 dirsearch.py -e php,html,js -u https://target -i 200,204,400,403 -x 500,502,429
405402
```
406403

407-
**--exclude-sizes**, **--exclude-texts**, **--exclude-regexps** and **--exclude-redirects** are also supported for a more advanced filter
404+
### Exclude extensions
405+
Use **-X | --exclude-extensions** with your exclude-extension list to remove all entries in the wordlist that have the given extensions
408406

409407
```
410-
python3 dirsearch.py -e php,html,js -u https://target --exclude-sizes 1B,243KB
408+
python3 dirsearch.py -e asp,aspx -u https://target -X jsp
411409
```
412410

413-
```
414-
python3 dirsearch.py -e php,html,js -u https://target --exclude-texts "403 Forbidden"
415-
```
411+
Base wordlist:
416412

417413
```
418-
python3 dirsearch.py -e php,html,js -u https://target --exclude-regexps "^Error$"
414+
admin
415+
admin.%EXT%
416+
test.jsp
419417
```
420418

421-
### Raw requests
422-
dirsearch allows you to import the raw request from a file. The raw file content will be looked something like this:
419+
After:
423420

424421
```
425-
GET /admin HTTP/1.1
426-
Host: admin.example.com
427-
Cache-Control: max-age=0
428-
Accept: */*
422+
admin
423+
admin.asp
424+
admin.aspx
429425
```
430426

431-
Since there is no way for dirsearch to know what the URI scheme is (`http` or `https`), you need to set it using the `--scheme` flag. By default, the scheme is `http`, which is not popular in modern web servers now. That means, without setting up the scheme, you may brute-force with the wrong protocol, and will end up with false negatives.
432-
433427
### Scan sub-directories
434428
From an URL, you can scan sub-directories with **--subdirs**.
435429

@@ -516,10 +510,11 @@ python3 dirsearch.py -u https://target -w db/dicc.txt --no-extension
516510
Tips
517511
---------------
518512
- To run dirsearch with a rate of requests per second, try `-t <rate> -s 1`
513+
- The server has a request limit? That's bad, but feel free to bypass it, by randomizing proxy with `--proxy-list`
519514
- Want to findout config files or backups? Try out `--suffixes ~` and `--prefixes .`
520515
- For some endpoints that you do not want to force extensions, add `%NOFORCE%` at the end of them
521516
- Want to find only folders/directories? Combine `--no-extension` and `--suffixes /`!
522-
- The combination of `--cidr`, `-F` and `-q` will reduce most of the noise + false negatives when brute-forcing with a CIDR
517+
- The combination of `--cidr`, `-F`, `-q` and a low `--timeout` will reduce most of the noise + false negatives when brute-forcing with a CIDR
523518

524519

525520
Support Docker

db/400_blacklist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
%2e%2e;/test
44
%3f/
55
%C0%AE%C0%AE%C0%AF
6+
..;/
7+

db/500_blacklist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
%ff
22
%3f/
33
%C0%AE%C0%AE%C0%AF
4+
%2e%2e;/test
5+
..;/
6+

default.conf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ recursive = False
1313
recursion-depth = 0
1414
exclude-subdirs = %%ff/
1515
random-user-agents = False
16+
max-time = 0
17+
## 0 means no maximal running time
1618
save-logs-home = False
17-
skip-on-429 = False
1819
full-url = False
1920
quiet-mode = False
2021
color = True
@@ -23,7 +24,8 @@ color = True
2324
# exclude-sizes = 0b,123gb
2425
# exclude-texts = "Not found"
2526
# exclude-regexps = 403 [a-z]{1,25}
26-
# calibration-path = InvalidPath123
27+
# exclude-content = index.html
28+
# skip-on-status = 429,999
2729

2830
[reports]
2931
autosave-report = True

lib/connection/requester.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class Requester(object):
3030
def __init__(
3131
self,
3232
url,
33-
cookie=None,
34-
useragent=None,
3533
maxPool=1,
3634
maxRetries=5,
3735
timeout=20,
@@ -102,13 +100,6 @@ def __init__(
102100
):
103101
self.headers["Host"] += ":{0}".format(self.port)
104102

105-
# Set cookie and user-agent headers
106-
if cookie:
107-
self.setHeader("Cookie", cookie)
108-
109-
if useragent:
110-
self.setHeader("User-agent", useragent)
111-
112103
self.maxRetries = maxRetries
113104
self.maxPool = maxPool
114105
self.timeout = timeout
@@ -164,7 +155,7 @@ def request(self, path, proxy=None):
164155
url = self.url + self.basePath + path
165156

166157
if self.randomAgents:
167-
self.headers["User-agent"] = random.choice(self.randomAgents)
158+
self.headers["User-Agent"] = random.choice(self.randomAgents)
168159

169160
response = self.session.request(
170161
self.httpmethod,

0 commit comments

Comments
 (0)