diff --git a/docs/template.json b/docs/template.json index 093aec3..089e0af 100644 --- a/docs/template.json +++ b/docs/template.json @@ -5,7 +5,8 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "mask" + "TransformationMode": "mask", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -13,6 +14,7 @@ "Verbose": false, "ReplacementMask": "dsb", "Bypass": false, - "TransformationMode": "mask" + "TransformationMode": "mask", + "PassphraseWords": 0 } ] diff --git a/main.go b/main.go index cdf53e4..679110d 100644 --- a/main.go +++ b/main.go @@ -150,9 +150,9 @@ func main() { // Apply transformations from template files for i, template := range transformationTemplateArray { if i == 0 { - temporaryMap = transform.TransformationController(primaryMap, template.TransformationMode, template.StartIndex, template.EndIndex, template.Verbose, template.ReplacementMask, transformationFilesMap, template.Bypass, *debugMode, *passPhraseWords) + temporaryMap = transform.TransformationController(primaryMap, template.TransformationMode, template.StartIndex, template.EndIndex, template.Verbose, template.ReplacementMask, transformationFilesMap, template.Bypass, *debugMode, template.PassphraseWords) } else { - temporaryMap = utils.CombineMaps(temporaryMap, transform.TransformationController(primaryMap, template.TransformationMode, template.StartIndex, template.EndIndex, template.Verbose, template.ReplacementMask, transformationFilesMap, template.Bypass, *debugMode, *passPhraseWords)) + temporaryMap = utils.CombineMaps(temporaryMap, transform.TransformationController(primaryMap, template.TransformationMode, template.StartIndex, template.EndIndex, template.Verbose, template.ReplacementMask, transformationFilesMap, template.Bypass, *debugMode, template.PassphraseWords)) } } primaryMap = temporaryMap diff --git a/pkg/models/models.go b/pkg/models/models.go index 9d87410..03d176f 100644 --- a/pkg/models/models.go +++ b/pkg/models/models.go @@ -62,6 +62,7 @@ type TemplateFileOperation struct { ReplacementMask string Bypass bool TransformationMode string + PassphraseWords int } // ---------------------------------------------------------------------------- diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index 49c2084..0bc787e 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -32,12 +32,12 @@ import ( // use for modes like retain-mask // bypass (bool): If true, the map is not used for output or filtering // debug (int): Different debug levels to use for debugging [0-2] -// passphraseWord (int): The number of words to use for passphrase generation +// passphraseWords (int): The number of words to use for passphrase generation // // Returns: // // (map[string]int): A map of transformed values -func TransformationController(input map[string]int, mode string, startingIndex int, endingIndex int, verbose bool, replacementMask string, transformationFilesMap map[string]int, bypass bool, debug int, passphraseWord int) (output map[string]int) { +func TransformationController(input map[string]int, mode string, startingIndex int, endingIndex int, verbose bool, replacementMask string, transformationFilesMap map[string]int, bypass bool, debug int, passphraseWords int) (output map[string]int) { functionDebug := false if debug > 1 { @@ -116,11 +116,11 @@ func TransformationController(input map[string]int, mode string, startingIndex i } output = mask.ShuffleMap(input, replacementMask, transformationFilesMap, bypass, functionDebug) case "passphrase", "phrase", "pp": - if passphraseWord == 0 { + if passphraseWords == 0 { fmt.Fprintf(os.Stderr, "[!] Passphrase operations require use of the -w flag to specify the number of words to use\n") os.Exit(1) } - output = MakePassphraseMap(input, transformationFilesMap, bypass, functionDebug, passphraseWord) + output = MakePassphraseMap(input, transformationFilesMap, bypass, functionDebug, passphraseWords) default: output = input } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 5047008..01991b5 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -330,6 +330,11 @@ func ReadJSONToArray(fs models.FileSystem, filenames []string) []models.Template fmt.Fprintf(os.Stderr, "[!] Error: TransformationMode must be a string\n") os.Exit(1) } + + if !numRe.MatchString(fmt.Sprintf("%v", template.PassphraseWords)) { + fmt.Fprintf(os.Stderr, "[!] Error: PassphraseWords must be an integer\n") + os.Exit(1) + } } } diff --git a/templates/append.json b/templates/append.json index 19298ef..964c598 100644 --- a/templates/append.json +++ b/templates/append.json @@ -5,7 +5,8 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "append" + "TransformationMode": "append", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -13,7 +14,8 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "append-remove" + "TransformationMode": "append-remove", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -21,6 +23,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "append-shift" + "TransformationMode": "append-shift", + "PassphraseWords": 0 } ] diff --git a/templates/inov1-6.json b/templates/inov1-6.json index 89f937d..d6860f2 100644 --- a/templates/inov1-6.json +++ b/templates/inov1-6.json @@ -5,7 +5,8 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "insert" + "TransformationMode": "insert", + "PassphraseWords": 0 }, { "StartIndex": 1, @@ -13,6 +14,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "overwrite" + "TransformationMode": "overwrite", + "PassphraseWords": 0 } ] diff --git a/templates/mask.json b/templates/mask.json index 694ed97..d108b06 100644 --- a/templates/mask.json +++ b/templates/mask.json @@ -5,7 +5,8 @@ "Verbose": false, "ReplacementMask": "ul", "Bypass": false, - "TransformationMode": "mask" + "TransformationMode": "mask", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -13,7 +14,8 @@ "Verbose": false, "ReplacementMask": "dsb", "Bypass": false, - "TransformationMode": "mask" + "TransformationMode": "mask", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -21,6 +23,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "mask" + "TransformationMode": "mask", + "PassphraseWords": 0 } ] diff --git a/templates/prepend.json b/templates/prepend.json index d5f628a..fca7a00 100644 --- a/templates/prepend.json +++ b/templates/prepend.json @@ -5,7 +5,8 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "prepend" + "TransformationMode": "prepend", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -13,7 +14,8 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "prepend-remove" + "TransformationMode": "prepend-remove", + "PassphraseWords": 0 }, { "StartIndex": 0, @@ -21,6 +23,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "prepend-shift" + "TransformationMode": "prepend-shift", + "PassphraseWords": 0 } ]