diff --git a/src/config/VafConfigStructure.nim b/src/config/VafConfigStructure.nim new file mode 100644 index 0000000..a6bd24b --- /dev/null +++ b/src/config/VafConfigStructure.nim @@ -0,0 +1,6 @@ +import VafWordlist + +type + VafConfigStructure* = object + DefaultWordlist*: int + Wordlists*: seq[VafWordlist] \ No newline at end of file diff --git a/src/config/VafWordlist.nim b/src/config/VafWordlist.nim new file mode 100644 index 0000000..6c15704 --- /dev/null +++ b/src/config/VafWordlist.nim @@ -0,0 +1,5 @@ + +type + VafWordlist* = object + Id*: int + Path*: string \ No newline at end of file diff --git a/src/config/importVafConfig.nim b/src/config/importVafConfig.nim new file mode 100644 index 0000000..1873c7d --- /dev/null +++ b/src/config/importVafConfig.nim @@ -0,0 +1,24 @@ +import json +import os +import strutils + +import initVafConfig +import parseVafConfig + +import VafConfigStructure + +var homeDir: string = os.getHomeDir() + +proc importVafConfig*(): VafConfigStructure = + var configExists: bool = fileExists(homedir & "/.vaf.json") + var configContents = readFile(homedir & "/.vaf.json") + var jsonData: JsonNode + + + if configExists: + jsonData = parseJson(configContents) + # else: + # jsonData = initVafConfig() + + return parseVafConfig(jsonData) + \ No newline at end of file diff --git a/src/config/initVafConfig.nim b/src/config/initVafConfig.nim new file mode 100644 index 0000000..63877d9 --- /dev/null +++ b/src/config/initVafConfig.nim @@ -0,0 +1,17 @@ +import os +import strutils + +var homeDir: string = os.getHomeDir() +var defaultJson: string = """{}""" + +proc initVafConfig*(): int = + var configExists: bool = fileExists(homedir & "/.vaf.json") + var configFile = open(homedir & "/.vaf.json", fmWrite) + + defer: configFile.close() + + if configExists: + return 1 + else: + for i in defaultJson.split("\n"): + configFile.writeLine(i) \ No newline at end of file diff --git a/src/config/parseVafConfig.nim b/src/config/parseVafConfig.nim new file mode 100644 index 0000000..c9cf348 --- /dev/null +++ b/src/config/parseVafConfig.nim @@ -0,0 +1,36 @@ +import json +import os +import strutils + +import VafWordlist +import VafConfigStructure + +proc parseWordlist(data: JsonNode): VafWordlist = + var wordlistObject: VafWordlist = VafWordlist() + + if data{"Id"} != nil: + wordlistObject.Id = data{"Id"}.getInt() + + if data{"Path"} != nil: + wordlistObject.Path = data{"Path"}.getStr() + + return wordlistObject + +proc parseVafConfig*(data: JsonNode): VafConfigStructure = + var configObject: VafConfigStructure = VafConfigStructure() + + echo data + + if data{"DefaultWordlist"} == nil: + configObject.DefaultWordlist = -1 + else: + configObject.DefaultWordlist = data{"DefaultWordlist"}.getInt() + + if data{"Wordlists"} != nil: + for wordlist in data{"Wordlists"}: + configObject.Wordlists.add( parseWordlist( wordlist )) + + + echo configObject + + return configObject \ No newline at end of file diff --git a/src/config/readVafConfig.nim b/src/config/readVafConfig.nim new file mode 100644 index 0000000..30c54c7 --- /dev/null +++ b/src/config/readVafConfig.nim @@ -0,0 +1,18 @@ +import json +import os +import strutils +import initVafConfig + +var homeDir: string = os.getHomeDir() + +proc readVafConfig*(): int = + var configExists: bool = fileExists(homedir & "/.vaf.json") + var configContents = readFile(homedir & "/.vaf.json") + var jsonNode = parseJson(configContents) + + discard initVafConfig() + + if configExists: + return 0 + else: + echo jsonNode \ No newline at end of file diff --git a/src/utils/VafHttpClient.nim b/src/utils/VafHttpClient.nim index b5bdd40..0ac5f25 100644 --- a/src/utils/VafHttpClient.nim +++ b/src/utils/VafHttpClient.nim @@ -1,6 +1,5 @@ import httpclient import VafResponse -import json var client = newHttpClient() diff --git a/src/vaf.nim b/src/vaf.nim index e65c358..f778fca 100644 --- a/src/vaf.nim +++ b/src/vaf.nim @@ -8,6 +8,7 @@ import os import argparse import utils/VafFuzzResult import utils/VafColors +import config/initVafConfig let p = newParser("vaf - very advanced fuzzer"): option("-u", "--url", help="choose url, replace area to fuzz with []") @@ -23,6 +24,9 @@ let p = newParser("vaf - very advanced fuzzer"): flag("-pu", "--printurl", help="prints the url that has been requested") try: + + # discard initVafConfig() + var parsedArgs = p.parse(commandLineParams()) var url: string = parsedArgs.url diff --git a/vaf.exe b/vaf.exe new file mode 100644 index 0000000..949f9ef Binary files /dev/null and b/vaf.exe differ