Commit 5b647852 authored by dmknght's avatar dmknght

Fix URL bug

parent 1afc5e63
......@@ -17,6 +17,11 @@
"label": "[Test]Test run connection",
"type": "shell",
"command": "nim c -r src/test/test.nim"
},
{
"label": "[Test]Test start program from scratch",
"type": "shell",
"command": "nim c --threads:on --define:ssl -r src/test/testmain.nim"
}
]
}
\ No newline at end of file
......@@ -58,8 +58,9 @@ proc getOptions*(): DirbOptions =
allOptions.paramError = true
else:
prntErr("Unknown option " & paramStr(i))
allOptions.paramError = true
else:
allOptions.url = urlFormat(paramStr(1))
allOptions.url = urlFormat(paramStr(i))
if allOptions.url == "":
allOptions.paramError = true
i -= 1
......
import httpclient
import strutils
# import strutils
import .. / cli / utils
proc checkBranch*(client: HttpClient, subPath, fullURL: string) =
if not isEmptyOrWhitespace(subPath):
progressBar(subPath)
# TODO use a callback function instead of cli
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")
progressBar(fullURL)
# TODO use a callback function instead of cli
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")
......@@ -9,12 +9,13 @@ proc urlFormat*(url: string): string =
Input: URL: string
Outpt: URL: string
]#
if url == "":
result = url
if result == "":
prntErr("URL is missing")
return ""
if not url.startsWith("http://") and not url.startsWith("https://"):
prntWarn("Added http to url", "Missing protocol in URL")
result = "http://" & url
result = "http://" & result
if not result.endsWith("/"):
result &= "/"
......
......@@ -8,10 +8,15 @@ import strutils
let allOptions = getOptions()
if not allOptions.paramError:
var client = newHttpClient()
for line in lines(allOptions.wordlist):
let fullURL = allOptions.url & line
# TODO handle / at end of line here
spawn checkBranch(client, line, fullURL)
if not line.endsWith("/"): # and option
spawn checkBranch(client, line & "/", fullURL)
client.close()
try:
for line in lines(allOptions.wordlist):
if not isEmptyOrWhitespace(line):
let fullURL = allOptions.url & line
# TODO handle / at end of line here
spawn checkBranch(client, line, fullURL)
if not line.endsWith("/"): # and option
spawn checkBranch(client, line & "/", fullURL & "/")
except:
discard
finally:
client.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment