Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dirbnim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nong Hoang Tu
dirbnim
Commits
05195dc9
Commit
05195dc9
authored
Aug 30, 2020
by
dmknght
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve color and exception in connection
parent
017a1ba8
Pipeline
#1135
canceled with stages
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
42 deletions
+41
-42
.vscode/tasks.json
.vscode/tasks.json
+5
-0
src/dirbnim.nim
src/dirbnim.nim
+3
-0
src/modules/cli/help.nim
src/modules/cli/help.nim
+1
-0
src/modules/cli/options.nim
src/modules/cli/options.nim
+3
-1
src/modules/cli/utils.nim
src/modules/cli/utils.nim
+15
-3
src/modules/cores/connection.nim
src/modules/cores/connection.nim
+10
-5
src/modules/cores/paramHandler.nim
src/modules/cores/paramHandler.nim
+1
-1
src/test/test.nim
src/test/test.nim
+3
-32
No files found.
.vscode/tasks.json
View file @
05195dc9
...
...
@@ -13,5 +13,10 @@
"type"
:
"shell"
,
"command"
:
"nim c -r src/test/testargs.nim a.b -w x"
}
{
"label"
:
"[Test]Test run connection"
,
"type"
:
"shell"
,
"command"
:
"nim c -r src/test/test.nim"
}
]
}
\ No newline at end of file
src/dirbnim.nim
View file @
05195dc9
# This is just an example to get you started. A typical binary package
# uses this file as the main entry point of the application.
# TODO handle `/` at end of branch
# TODO handle end session
# TODO handle time
# TODO threadpool.setMaxPoolSize
when
isMainModule
:
echo
(
"Hello, World!"
)
src/modules/cli/help.nim
View file @
05195dc9
...
...
@@ -3,6 +3,7 @@ import utils
proc
fastHelp
*
()
=
# TODO read data from .nimble for dynamic information
echo
"DirbNim - A modern URL bruteforcing tool"
echo
"Author: Nong Hoang
\"
dmknght
\"
Tu <dmknght@parrotsec.org>"
echo
"URL: https://nest.parrotsec.org/dmknght/dirbnim"
...
...
src/modules/cli/options.nim
View file @
05195dc9
...
...
@@ -10,6 +10,7 @@ type
cookie
*
:
string
agent
*
:
string
paramError
*
:
bool
maxThreads
*
:
int
proc
getOptions
*
():
DirbOptions
=
...
...
@@ -17,7 +18,8 @@ proc getOptions*(): DirbOptions =
allOptions
=
DirbOptions
(
wordlist
:
"/usr/share/wordlists/common.txt"
,
paramError
:
false
paramError
:
false
,
maxThreads
:
32
)
let
...
...
src/modules/cli/utils.nim
View file @
05195dc9
import
terminal
import
strutils
proc
showHelpCmd
*
(
app
=
"dirbnim"
,
keyword
=
"help"
,
value
=
""
,
descr
=
""
)
=
...
...
@@ -29,7 +30,7 @@ proc progressBar*(subPath: string) =
proc
prntErr
*
(
reason
:
string
,
descr
=
""
)
=
var
msg
=
"[
\e
[
31mE
\e
[0m] "
# R
ed
var
msg
=
"[
\e
[
91mE
\e
[0m] "
# Bright r
ed
if
descr
!=
""
:
msg
&=
"[
\e
[36m"
&
descr
&
"
\e
[0m] "
# cyan
msg
&=
"
\e
[35m"
&
reason
&
"
\e
[0m"
...
...
@@ -37,7 +38,7 @@ proc prntErr*(reason: string, descr = "") =
proc
prntWarn
*
(
reason
:
string
,
descr
=
""
)
=
var
msg
=
"[
\e
[
33mW
\e
[0m] "
#
Yellow
var
msg
=
"[
\e
[
93mW
\e
[0m] "
# Bright
Yellow
if
descr
!=
""
:
msg
&=
"[
\e
[36m"
&
descr
&
"
\e
[0m] "
# cyan
msg
&=
reason
...
...
@@ -48,4 +49,15 @@ proc prntFound*(status, url: string) =
# TODO color here
stdout
.
eraseLine
()
stdout
.
flushFile
()
echo
"["
&
status
&
"] ["
&
url
&
"]"
var
msg
=
" [
\e
[95m"
&
url
&
"
\e
[0m]"
# Bright Magenta
if
status
.
startsWith
(
"2"
):
msg
=
"[
\e
[92m"
&
status
&
"
\e
[0m]"
&
msg
# Bright green
elif
status
.
startsWith
(
"3"
):
msg
=
"[
\e
[33m"
&
status
&
"
\e
[0m]"
&
msg
# Yellow (orange alike)
elif
status
.
startsWith
(
"4"
):
msg
=
"[
\e
[31m"
&
status
&
"
\e
[0m]"
&
msg
# Red (a little dark)
elif
status
.
startsWith
(
"5"
):
msg
=
"[
\e
[96m"
&
status
&
"
\e
[0m]"
&
msg
# Bright Cyan
echo
msg
src/modules/cores/connection.nim
View file @
05195dc9
...
...
@@ -7,8 +7,13 @@ proc checkBranch*(client: HttpClient, subPath, fullURL: string) =
if
not
isEmptyOrWhitespace
(
subPath
):
progressBar
(
subPath
)
# TODO use a callback function instead of cli
let
resp
=
client
.
get
(
fullURL
)
if
resp
.
status
!=
"404 Not Found"
:
# TODO use a callback function instead of cli
prntFound
(
resp
.
status
,
fullURL
)
# TODO do a sub branch append for later scan
try
:
let
resp
=
client
.
get
(
fullURL
)
if
resp
.
status
!=
"404 Not Found"
:
# TODO use a callback function instead of cli
prntFound
(
resp
.
status
,
fullURL
)
# TODO do a sub branch append for later scan
except
ProtocolError
:
prntErr
(
fullURL
,
"ProtocolError"
)
except
:
prntErr
(
fullURL
,
"Unknown"
)
src/modules/cores/paramHandler.nim
View file @
05195dc9
...
...
@@ -37,5 +37,5 @@ proc validWordlist*(path: string): string =
result = ""
except:
prntErr(path, "Unknown error")
prntErr(path, getCurrentExceptionMsg())
#
prntErr(path, getCurrentExceptionMsg())
result = ""
src/test/test.nim
View file @
05195dc9
import
httpclient
import
terminal
import
strutils
#
import strutils
import
bench
import
threadpool
import
..
/
modules
/
cores
/
connection
const
url
=
"http://testphp.vulnweb.com/"
dict
=
"/usr/share/dirb/wordlists/common.txt"
# dict = "list.txt"
# TODO handle url format
{.
experimental
:
"parallel"
.}
proc
simProgressBar
(
subPath
:
string
)
=
stdout
.
eraseLine
()
stdout
.
write
(
subPath
)
stdout
.
flushFile
()
proc
checkPath
(
client
:
HttpClient
,
subPath
,
fullURL
:
string
)
=
if
not
isEmptyOrWhitespace
(
subPath
):
simProgressBar
(
subPath
)
let
fullURL
=
url
&
subPath
let
resp
=
client
.
get
(
fullURL
)
if
resp
.
status
!=
"404 Not Found"
:
stdout
.
eraseLine
()
echo
fullURL
&
" "
&
resp
.
status
proc
createTest
()
=
var
client
=
newHttpClient
()
# benchmark "Normal loop":
# for subPath in lines(dict):
# if isEmptyOrWhitespace(subPath):
# continue
# simProgressBar(subPath)
# let fullURL = url & subPath
# let resp = client.get(fullURL)
# if resp.status != "404 Not Found":
# stdout.eraseLine()
# echo fullURL & " " & resp.status
benchmark
"ThreadPool loop"
:
for
subPath
in
lines
(
dict
):
let
fullURL
=
url
&
subPath
spawn
check
Pat
h
(
client
,
subPath
,
fullURL
)
spawn
check
Branc
h
(
client
,
subPath
,
fullURL
)
client
.
close
()
stdout
.
eraseLine
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment