From 6b01f3d7a1d894ee2443cbfd54a7a2255981d14b Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Fri, 8 Nov 2024 17:14:51 -0500 Subject: [PATCH 01/12] add verbose to mask-retain added verbose information to the mask-retain mode --- README.md | 4 ++-- docs/USAGE.md | 8 +++---- main.go | 48 +++++++++++++++++++------------------- pkg/mask/mask.go | 7 +++++- pkg/mask/mask_test.go | 2 +- pkg/transform/transform.go | 2 +- 6 files changed, 38 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index e7b49c9..01e561d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ git clone https://github.com/JakeWnuk/ptt && cd ptt && docker build -t ptt . && --- ### Usage: ``` -Usage of Password Transformation Tool (ptt) version (0.3.8): +Usage of Password Transformation Tool (ptt) version (0.4.0): ptt [options] [...] Accepts standard input and/or additonal arguments. @@ -124,7 +124,7 @@ These create or alter based on the selected mode. Transforms input by 'popping' tokens from character boundaries using the provided mask. -t mask-remove -rm [uldsb] Transforms input by removing characters with provided mask. - -t mask-retain -rm [uldsb] -tf [file] + -t mask-retain -rm [uldsb] -tf [file] -v Transforms input by creating masks that still retain strings from file. -t mask-swap -tf [file] Transforms input by swapping tokens from a mask/partial mask input and a transformation file of tokens. diff --git a/docs/USAGE.md b/docs/USAGE.md index a5135a8..404504c 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -1,5 +1,5 @@ # Password Transformation Tool (PTT) Usage Guide -> Version 0.3.8 +> Version 0.4.0 ## Table of Contents - [Introduction](#introduction) - [Installation](#installation) @@ -256,7 +256,7 @@ Where `` can be any of the following: - `b`: Byte characters - Multiple characters can be combined to create a mask. -The default value is `uldsb` for all characters. The `-v` flag is optional and, if provided, will print the length of the original string and its character complexity. The format will be `:length:complexity:mask-keyspace` appended to the end of the output. The mask keyspace is the number of possible combinations for the masked portion of the string. +The default value is `uldsb` for all characters. The `-v` flag is optional and, if provided, will print the length of the original string, the length, the complexity, and the remaining mask keyspace. The format will be `:length:complexity:mask-keyspace` appended to the end of the output. The mask keyspace is the number of possible combinations for the masked portion of the string. ``` $ echo 'HelloWorld!I<3ThePasswordTransformationToolPr0j3ct' | go run . -t mask -rm ds -v [*] All input loaded. @@ -276,9 +276,9 @@ ptt -f -t mask-remove -rm ``` Where `` is the mask to remove from the string. The output will be the string with the characters removed. ### Creating Retain/Partial Masks -Retain masks or partial masks can be created to retain only certain keywords in a string. The syntax to create a retain mask is as follows: +Retain masks or partial masks can be created to retain only certain keywords in a string. The `-v` flag is optional and, if provided, will print the length of the original string, the length, the complexity, and the remaining mask keyspace. The syntax to create a retain mask is as follows: ``` -ptt -f -t mask-retain -rm -tf +ptt -f -t mask-retain -rm -tf -v ``` Where `` is the mask to retain and `` is the file containing the keywords to retain. The output will be the mask with only the keywords retained. diff --git a/main.go b/main.go index f073b40..e3f5767 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( "github.com/jakewnuk/ptt/pkg/utils" ) -var version = "0.3.8" +var version = "0.4.0" var wg sync.WaitGroup var mutex = &sync.Mutex{} var retain models.FileArgumentFlag @@ -44,29 +44,29 @@ func main() { fmt.Fprintf(os.Stderr, "Transformation Modes:\n") fmt.Fprintf(os.Stderr, "These create or alter based on the selected mode.\n\n") modes := map[string]string{ - "rule-append": "Transforms input by creating append rules.", - "rule-append-remove": "Transforms input by creating append-remove rules.", - "rule-prepend": "Transforms input by creating prepend rules.", - "rule-prepend-remove": "Transforms input by creating prepend-remove rules.", - "rule-prepend-toggle": "Transforms input by creating prepend-toggle rules.", - "rule-insert -i [index]": "Transforms input by creating insert rules starting at index.", - "rule-overwrite -i [index]": "Transforms input by creating overwrite rules starting at index.", - "rule-toggle -i [index]": "Transforms input by creating toggle rules starting at index.", - "encode": "Transforms input by HTML and Unicode escape encoding.", - "decode": "Transforms input by HTML and Unicode escape decoding.", - "hex": "Transforms input by encoding strings into $HEX[...] format.", - "dehex": "Transforms input by decoding $HEX[...] formatted strings.", - "mask -rm [uldsb] -v": "Transforms input by masking characters with provided mask.", - "mask-remove -rm [uldsb]": "Transforms input by removing characters with provided mask.", - "mask-retain -rm [uldsb] -tf [file]": "Transforms input by creating masks that still retain strings from file.", - "mask-pop -rm [uldsbt]": "Transforms input by 'popping' tokens from character boundaries using the provided mask.", - "mask-match -tf [file]": "Transforms input by keeping only strings with matching masks from a mask file.", - "swap-single -tf [file]": "Transforms input by swapping tokens once per string per replacement with exact matches from a ':' separated file.", - "mask-swap -tf [file]": "Transforms input by swapping tokens from a mask/partial mask input and a transformation file of tokens.", - "passphrase -w [words]": "Transforms input by generating passphrases from sentences with a given number of words.", - "substring -i [index]": "Transforms input by extracting substrings starting at index and ending at index.", - "replace-all -tf [file]": "Transforms input by replacing all strings with all matches from a ':' separated file.", - "regram -w [words]": "Transforms input by 'regramming' sentences into new n-grams with a given number of words.", + "rule-append": "Transforms input by creating append rules.", + "rule-append-remove": "Transforms input by creating append-remove rules.", + "rule-prepend": "Transforms input by creating prepend rules.", + "rule-prepend-remove": "Transforms input by creating prepend-remove rules.", + "rule-prepend-toggle": "Transforms input by creating prepend-toggle rules.", + "rule-insert -i [index]": "Transforms input by creating insert rules starting at index.", + "rule-overwrite -i [index]": "Transforms input by creating overwrite rules starting at index.", + "rule-toggle -i [index]": "Transforms input by creating toggle rules starting at index.", + "encode": "Transforms input by HTML and Unicode escape encoding.", + "decode": "Transforms input by HTML and Unicode escape decoding.", + "hex": "Transforms input by encoding strings into $HEX[...] format.", + "dehex": "Transforms input by decoding $HEX[...] formatted strings.", + "mask -rm [uldsb] -v": "Transforms input by masking characters with provided mask.", + "mask-remove -rm [uldsb]": "Transforms input by removing characters with provided mask.", + "mask-retain -rm [uldsb] -tf [file] -v": "Transforms input by creating masks that still retain strings from file.", + "mask-pop -rm [uldsbt]": "Transforms input by 'popping' tokens from character boundaries using the provided mask.", + "mask-match -tf [file]": "Transforms input by keeping only strings with matching masks from a mask file.", + "swap-single -tf [file]": "Transforms input by swapping tokens once per string per replacement with exact matches from a ':' separated file.", + "mask-swap -tf [file]": "Transforms input by swapping tokens from a mask/partial mask input and a transformation file of tokens.", + "passphrase -w [words]": "Transforms input by generating passphrases from sentences with a given number of words.", + "substring -i [index]": "Transforms input by extracting substrings starting at index and ending at index.", + "replace-all -tf [file]": "Transforms input by replacing all strings with all matches from a ':' separated file.", + "regram -w [words]": "Transforms input by 'regramming' sentences into new n-grams with a given number of words.", } // Sort and print transformation modes diff --git a/pkg/mask/mask.go b/pkg/mask/mask.go index 6f5da9f..a34b80f 100644 --- a/pkg/mask/mask.go +++ b/pkg/mask/mask.go @@ -130,11 +130,12 @@ func MakeMaskedMap(input map[string]int, replacementMask string, verbose bool, b // retain (map[string]int): Map of keywords to retain // bypass (bool): If true, the map is not used for output or filtering // debug (bool): If true, print additional debug information to stderr +// verbose (bool): Verbose information if true // // Returns: // // maskedMap (map[string]int): Masked retain map -func MakeRetainMaskedMap(input map[string]int, replacementMask string, retain map[string]int, bypass bool, debug bool) map[string]int { +func MakeRetainMaskedMap(input map[string]int, replacementMask string, retain map[string]int, bypass bool, debug bool, verbose bool) map[string]int { maskedMap := make(map[string]int) replacements := ConstructReplacements(replacementMask) replacer := strings.NewReplacer(replacements...) @@ -163,6 +164,10 @@ func MakeRetainMaskedMap(input map[string]int, replacementMask string, retain ma continue } + if verbose { + newKey = fmt.Sprintf("%s:%d:%d:%d", newKey, len(key), TestMaskComplexity(newKey), CalculateMaskKeyspace(newKey)) + } + if debug { fmt.Fprintf(os.Stderr, "[?] MakeRetainMaskedMap:\n") fmt.Fprintf(os.Stderr, "Key: %s\n", key) diff --git a/pkg/mask/mask_test.go b/pkg/mask/mask_test.go index 7dd0d3e..24b4a90 100644 --- a/pkg/mask/mask_test.go +++ b/pkg/mask/mask_test.go @@ -115,7 +115,7 @@ func TestMakeRetainMaskedMap(t *testing.T) { // Run test cases for _, test := range tests { - output := MakeRetainMaskedMap(test.input, test.replacements, test.retain, false, false) + output := MakeRetainMaskedMap(test.input, test.replacements, test.retain, false, false, false) if !reflect.DeepEqual(output, test.output) { t.Errorf("Test failed: %v inputted, %v expected, %v returned", test.input, test.output, output) } diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index 1a0b1b9..5d71ae9 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -93,7 +93,7 @@ func TransformationController(input map[string]int, mode string, startingIndex i fmt.Fprintf(os.Stderr, "[!] Retain masks require use of one or more -tf flags to specify one or more files.\n") os.Exit(1) } - output = mask.MakeRetainMaskedMap(input, replacementMask, transformationFilesMap, bypass, functionDebug) + output = mask.MakeRetainMaskedMap(input, replacementMask, transformationFilesMap, bypass, functionDebug, verbose) case "mask-match", "match": if len(transformationFilesMap) == 0 { fmt.Fprintf(os.Stderr, "[!] Match masks require use of one or more -tf flags to specify one or more files.\n") From 4adaa8c3b166195f97ffcb951e71530b009fe9f9 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Fri, 8 Nov 2024 17:48:28 -0500 Subject: [PATCH 02/12] Add status timer add 5 minute status timer to the transformation controller to print updates --- pkg/transform/transform.go | 2 ++ pkg/utils/utils.go | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index 5d71ae9..babacba 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -40,6 +40,8 @@ import ( // (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, wordRangeStart int, wordRangeEnd int) (output map[string]int) { + utils.TrackElapsedTime(mode, len(input), len(transformationFilesMap), bypass) + functionDebug := false if debug > 1 { functionDebug = true diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7d60f92..c69cace 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -30,6 +30,19 @@ import ( // Loading and Processing Functions // ---------------------------------------------------------------------------- +func TrackElapsedTime(mode string, inputLength int, transformationFileLength int, bypass bool) { + start := time.Now() + ticker := time.NewTicker(5 * time.Minute) + defer ticker.Stop() + + go func() { + for range ticker.C { + elapsed := time.Since(start) + fmt.Fprintf(os.Stderr, "[-] Processing. Processing Mode: %s. Input Length: %d. Transformation File Length: %d. Elapsed Time: %v.\n", mode, inputLength, transformationFileLength, elapsed) + } + }() +} + // ReadFilesToMap reads the contents of the multiple files and returns a map of words // // Args: From 0e435a9d446bed518b4b0f604b50d9890e726852 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Fri, 8 Nov 2024 18:50:28 -0500 Subject: [PATCH 03/12] Update templates update templates and swap lists --- .../swap-encode.json => append-rule.json} | 4 +- ...sert1-6.json => insert-overwrite-1-9.json} | 8 +- .../{masks/mask.json => mask-analysis.json} | 0 .../{rules/append.json => prepend-rule.json} | 14 +- templates/swap-lists/emojis.txt | 332 ++++++++++++++++++ templates/swap-lists/love.txt | 30 +- templates/swap-lists/script.txt | 86 +++++ templates/swap-lists/spellit.txt | 108 ++++++ .../{rules/prepend.json => tokenize.json} | 22 +- 9 files changed, 574 insertions(+), 30 deletions(-) rename templates/{misc/swap-encode.json => append-rule.json} (80%) rename templates/{rules/insert1-6.json => insert-overwrite-1-9.json} (72%) rename templates/{masks/mask.json => mask-analysis.json} (100%) rename templates/{rules/append.json => prepend-rule.json} (54%) create mode 100644 templates/swap-lists/emojis.txt create mode 100644 templates/swap-lists/script.txt create mode 100644 templates/swap-lists/spellit.txt rename templates/{rules/prepend.json => tokenize.json} (51%) diff --git a/templates/misc/swap-encode.json b/templates/append-rule.json similarity index 80% rename from templates/misc/swap-encode.json rename to templates/append-rule.json index 8abba0a..3947388 100644 --- a/templates/misc/swap-encode.json +++ b/templates/append-rule.json @@ -5,7 +5,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "swap", + "TransformationMode": "rule-append", "WordRangeStart": 0, "WordRangeEnd": 0 }, @@ -15,7 +15,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "encode", + "TransformationMode": "rule-append-remove", "WordRangeStart": 0, "WordRangeEnd": 0 } diff --git a/templates/rules/insert1-6.json b/templates/insert-overwrite-1-9.json similarity index 72% rename from templates/rules/insert1-6.json rename to templates/insert-overwrite-1-9.json index f850d93..4fd7b2e 100644 --- a/templates/rules/insert1-6.json +++ b/templates/insert-overwrite-1-9.json @@ -1,21 +1,21 @@ [ { "StartIndex": 1, - "EndIndex": 6, + "EndIndex": 9, "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "insert", + "TransformationMode": "rule-insert", "WordRangeStart": 0, "WordRangeEnd": 0 }, { "StartIndex": 1, - "EndIndex": 6, + "EndIndex": 9, "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "overwrite", + "TransformationMode": "rule-overwrite", "WordRangeStart": 0, "WordRangeEnd": 0 } diff --git a/templates/masks/mask.json b/templates/mask-analysis.json similarity index 100% rename from templates/masks/mask.json rename to templates/mask-analysis.json diff --git a/templates/rules/append.json b/templates/prepend-rule.json similarity index 54% rename from templates/rules/append.json rename to templates/prepend-rule.json index c7124a2..94b6d51 100644 --- a/templates/rules/append.json +++ b/templates/prepend-rule.json @@ -5,7 +5,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "append", + "TransformationMode": "rule-prepend", "WordRangeStart": 0, "WordRangeEnd": 0 }, @@ -15,17 +15,7 @@ "Verbose": false, "ReplacementMask": "uldsb", "Bypass": false, - "TransformationMode": "append-remove", - "WordRangeStart": 0, - "WordRangeEnd": 0 - }, - { - "StartIndex": 0, - "EndIndex": 0, - "Verbose": false, - "ReplacementMask": "uldsb", - "Bypass": false, - "TransformationMode": "append-shift", + "TransformationMode": "rule-prepend-remove", "WordRangeStart": 0, "WordRangeEnd": 0 } diff --git a/templates/swap-lists/emojis.txt b/templates/swap-lists/emojis.txt new file mode 100644 index 0000000..4a2a25b --- /dev/null +++ b/templates/swap-lists/emojis.txt @@ -0,0 +1,332 @@ +alien:๐Ÿ‘ฝ +alienmonster:๐Ÿ‘พ +ant:๐Ÿœ +apple:๐ŸŽ +atm:๐Ÿง +babybottle:๐Ÿผ +babychick:๐Ÿค +banana:๐ŸŒ +bank:๐Ÿฆ +barchart:๐Ÿ“Š +bear:๐Ÿป +bee:๐Ÿ +beer:๐Ÿบ +beers:๐Ÿป +bikini:๐Ÿ‘™ +bird:๐Ÿฆ +blouse:๐Ÿ‘š +blowfish:๐Ÿก +blush:๐Ÿ˜‰ +book:๐Ÿ“š +boot:๐Ÿ‘ข +bread:๐Ÿž +bug:๐Ÿ› +bus:๐ŸšŒ +butterfly:๐Ÿฆ‹ +calendar:๐Ÿ“… +car:๐Ÿš— +cat:๐Ÿฑ +chart:๐Ÿ“ˆ +chartdown:๐Ÿ“‰ +check:โœ… +checkered:๐Ÿ +cherries:๐Ÿ’ +chicken:๐Ÿ” +chickenleg:๐Ÿ— +clap:๐Ÿ‘ +clipboard:๐Ÿ“‹ +cocktail:๐Ÿธ +cow:๐Ÿฎ +creditcard:๐Ÿ’ณ +crown:๐Ÿ‘‘ +curry:๐Ÿ› +dango:๐Ÿก +dislike:๐Ÿ‘Ž +dog:๐Ÿถ +dollar:๐Ÿ’ต +dolphin:๐Ÿฌ +dress:๐Ÿ‘— +drum:๐Ÿฅ +euro:๐Ÿ’ถ +eyes:๐Ÿ‘€ +fire:๐Ÿ”ฅ +fish:๐ŸŸ +fishcake:๐Ÿฅ +flashlight:๐Ÿ”ฆ +friedshrimp:๐Ÿค +fries:๐ŸŸ +frog:๐Ÿธ +ghost:๐Ÿ‘ป +grapes:๐Ÿ‡ +greenapple:๐Ÿ +guitar:๐ŸŽธ +hamburger:๐Ÿ” +hammer:๐Ÿ”จ +hamster:๐Ÿน +handbag:๐Ÿ‘œ +headphones:๐ŸŽง +hearteyes:๐Ÿ˜ +heavydollar:๐Ÿ’ฒ +highheel:๐Ÿ‘  +hotel:๐Ÿจ +house:๐Ÿ  +icecream:๐Ÿฆ +innocent:๐Ÿ˜‡ +jeans:๐Ÿ‘– +joy:๐Ÿ˜‚ +key:๐Ÿ”‘ +kiss:๐Ÿ˜˜ +koala:๐Ÿจ +ladybug:๐Ÿž +lemon:๐Ÿ‹ +like:๐Ÿ‘ +link:๐Ÿ”— +location:๐Ÿ“ +lock:๐Ÿ”’ +love:โค๏ธ +lovehotel:๐Ÿฉ +magnifying:๐Ÿ” +meat:๐Ÿ– +melon:๐Ÿˆ +microphone:๐ŸŽค +money:๐Ÿ’ฐ +moneyface:๐Ÿค‘ +moneywings:๐Ÿ’ธ +monkey:๐Ÿต +mouse:๐Ÿญ +music:๐ŸŽต +note:๐Ÿ“ +nut:๐Ÿ”ฉ +octopus:๐Ÿ™ +oden:๐Ÿข +package:๐Ÿ“ฆ +palette:๐ŸŽจ +panda:๐Ÿผ +paperclip:๐Ÿ“Ž +party:๐ŸŽ‰ +peach:๐Ÿ‘ +pear:๐Ÿ +penguin:๐Ÿง +piano:๐ŸŽน +pig:๐Ÿท +pin:๐Ÿ“Œ +pineapple:๐Ÿ +pizza:๐Ÿ• +pouch:๐Ÿ‘ +pound:๐Ÿ’ท +pray:๐Ÿ™ +purse:๐Ÿ‘› +rabbit:๐Ÿฐ +raise:๐Ÿ™Œ +ramen:๐Ÿœ +rice:๐Ÿš +riceball:๐Ÿ™ +ricecracker:๐Ÿ˜ +robot:๐Ÿค– +rocket:๐Ÿš€ +ruler:๐Ÿ“ +salute:๐Ÿซก +saxophone:๐ŸŽท +shavedice:๐Ÿง +shirt:๐Ÿ‘• +shoe:๐Ÿ‘Ÿ +shoppingcart:๐Ÿ›’ +skull:๐Ÿ’€ +smile:๐Ÿ˜Š +snail:๐ŸŒ +snake:๐Ÿ +spaghetti:๐Ÿ +sparkles:โœจ +star2:๐ŸŒŸ +star:โญ +strawberry:๐Ÿ“ +stuckouttongue:๐Ÿ˜› +sunglasses:๐Ÿ˜Ž +sushi:๐Ÿฃ +suv:๐Ÿš™ +sweetpotato:๐Ÿ  +tangerine:๐ŸŠ +target:๐ŸŽฏ +taxi:๐Ÿš• +tiger:๐Ÿฏ +trolleybus:๐ŸšŽ +trophy:๐Ÿ† +tropicaldrink:๐Ÿน +tropicalfish:๐Ÿ  +trumpet:๐ŸŽบ +turtle:๐Ÿข +unlock:๐Ÿ”“ +violin:๐ŸŽป +watermelon:๐Ÿ‰ +whale:๐Ÿณ +wine:๐Ÿท +wink:๐Ÿ˜œ +wrench:๐Ÿ”ง +yen:๐Ÿ’ด +zzz:๐Ÿ’ค +โœ…:check +โœจ:sparkles +โค๏ธ:love +โญ:star +๐ŸŒŸ:star2 +๐Ÿ‡:grapes +๐Ÿˆ:melon +๐Ÿ‰:watermelon +๐ŸŠ:tangerine +๐Ÿ‹:lemon +๐ŸŒ:banana +๐Ÿ:pineapple +๐ŸŽ:apple +๐Ÿ:greenapple +๐Ÿ:pear +๐Ÿ‘:peach +๐Ÿ’:cherries +๐Ÿ“:strawberry +๐Ÿ”:hamburger +๐Ÿ•:pizza +๐Ÿ–:meat +๐Ÿ—:chickenleg +๐Ÿ˜:ricecracker +๐Ÿ™:riceball +๐Ÿš:rice +๐Ÿ›:curry +๐Ÿœ:ramen +๐Ÿ:spaghetti +๐Ÿž:bread +๐ŸŸ:fries +๐Ÿ :sweetpotato +๐Ÿก:dango +๐Ÿข:oden +๐Ÿฃ:sushi +๐Ÿค:friedshrimp +๐Ÿฅ:fishcake +๐Ÿฆ:icecream +๐Ÿง:shavedice +๐Ÿท:wine +๐Ÿธ:cocktail +๐Ÿน:tropicaldrink +๐Ÿบ:beer +๐Ÿป:beers +๐Ÿผ:babybottle +๐ŸŽ‰:party +๐ŸŽค:microphone +๐ŸŽง:headphones +๐ŸŽจ:palette +๐ŸŽฏ:target +๐ŸŽต:music +๐ŸŽท:saxophone +๐ŸŽธ:guitar +๐ŸŽน:piano +๐ŸŽบ:trumpet +๐ŸŽป:violin +๐Ÿ:checkered +๐Ÿ†:trophy +๐Ÿ :house +๐Ÿฆ:bank +๐Ÿง:atm +๐Ÿจ:hotel +๐Ÿฉ:lovehotel +๐ŸŒ:snail +๐Ÿ:snake +๐Ÿ”:chicken +๐Ÿ™:octopus +๐Ÿ›:bug +๐Ÿœ:ant +๐Ÿ:bee +๐Ÿž:ladybug +๐ŸŸ:fish +๐Ÿ :tropicalfish +๐Ÿก:blowfish +๐Ÿข:turtle +๐Ÿค:babychick +๐Ÿฆ:bird +๐Ÿง:penguin +๐Ÿจ:koala +๐Ÿฌ:dolphin +๐Ÿญ:mouse +๐Ÿฎ:cow +๐Ÿฏ:tiger +๐Ÿฐ:rabbit +๐Ÿฑ:cat +๐Ÿณ:whale +๐Ÿต:monkey +๐Ÿถ:dog +๐Ÿท:pig +๐Ÿธ:frog +๐Ÿน:hamster +๐Ÿป:bear +๐Ÿผ:panda +๐Ÿ‘€:eyes +๐Ÿ‘:like +๐Ÿ‘Ž:dislike +๐Ÿ‘:clap +๐Ÿ‘‘:crown +๐Ÿ‘•:shirt +๐Ÿ‘–:jeans +๐Ÿ‘—:dress +๐Ÿ‘™:bikini +๐Ÿ‘š:blouse +๐Ÿ‘›:purse +๐Ÿ‘œ:handbag +๐Ÿ‘:pouch +๐Ÿ‘Ÿ:shoe +๐Ÿ‘ :highheel +๐Ÿ‘ข:boot +๐Ÿ‘ป:ghost +๐Ÿ‘ฝ:alien +๐Ÿ‘พ:alienmonster +๐Ÿ’€:skull +๐Ÿ’ค:zzz +๐Ÿ’ฐ:money +๐Ÿ’ฒ:heavydollar +๐Ÿ’ณ:creditcard +๐Ÿ’ด:yen +๐Ÿ’ต:dollar +๐Ÿ’ถ:euro +๐Ÿ’ท:pound +๐Ÿ’ธ:moneywings +๐Ÿ“…:calendar +๐Ÿ“ˆ:chart +๐Ÿ“‰:chartdown +๐Ÿ“Š:barchart +๐Ÿ“‹:clipboard +๐Ÿ“Œ:pin +๐Ÿ“:location +๐Ÿ“Ž:paperclip +๐Ÿ“:ruler +๐Ÿ“š:book +๐Ÿ“:note +๐Ÿ“ฆ:package +๐Ÿ”:magnifying +๐Ÿ”‘:key +๐Ÿ”’:lock +๐Ÿ”“:unlock +๐Ÿ”—:link +๐Ÿ”ฅ:fire +๐Ÿ”ฆ:flashlight +๐Ÿ”ง:wrench +๐Ÿ”จ:hammer +๐Ÿ”ฉ:nut +๐Ÿ˜‚:joy +๐Ÿ˜‡:innocent +๐Ÿ˜‰:blush +๐Ÿ˜Š:smile +๐Ÿ˜:hearteyes +๐Ÿ˜Ž:sunglasses +๐Ÿ˜˜:kiss +๐Ÿ˜›:stuckouttongue +๐Ÿ˜œ:wink +๐Ÿ™Œ:raise +๐Ÿ™:pray +๐Ÿš€:rocket +๐ŸšŒ:bus +๐ŸšŽ:trolleybus +๐Ÿš•:taxi +๐Ÿš—:car +๐Ÿš™:suv +๐Ÿ›’:shoppingcart +๐Ÿค‘:moneyface +๐Ÿค–:robot +๐Ÿฅ:drum +๐Ÿฆ‹:butterfly +๐Ÿซก:salute diff --git a/templates/swap-lists/love.txt b/templates/swap-lists/love.txt index 70fc49d..cae6611 100644 --- a/templates/swap-lists/love.txt +++ b/templates/swap-lists/love.txt @@ -1,12 +1,30 @@ -love:<3 +heart:<3 heart:<3 -love:โ™ฅ +heart:\u2665 +heart:\u2764 heart:โ™ฅ -love:โค heart:โค +love:<3 +love:<3 +love:\u1f60d +love:\u1f618 +love:\u1f970 +love:\u2665 +love:\u2764 +love:i<3u +love:i<3you +love:i<3u +love:i<3you +love:ilove +love:iloveu +love:iloveyou +love:ilu +love:ily +love:ily2 +love:teamo +love:tequiero +love:โ™ฅ +love:โค love:๐Ÿ˜ -heart:๐Ÿ˜ love:๐Ÿ˜˜ -heart:๐Ÿ˜˜ love:๐Ÿฅฐ -heart:๐Ÿฅฐ diff --git a/templates/swap-lists/script.txt b/templates/swap-lists/script.txt new file mode 100644 index 0000000..db8f640 --- /dev/null +++ b/templates/swap-lists/script.txt @@ -0,0 +1,86 @@ +0:โฐ +0:โ‚€ +1:ยน +1:โ‚ +2:ยฒ +2:โ‚‚ +3:ยณ +3:โ‚ƒ +4:โด +4:โ‚„ +5:โต +5:โ‚… +6:โถ +6:โ‚† +7:โท +7:โ‚‡ +8:โธ +8:โ‚ˆ +9:โน +9:โ‚‰ +a:ร  +a:รก +a:รข +a:รฃ +a:รค +a:รฅ +a:รฆ +a:ฤ +a:ฤƒ +a:ฤ… +a:วŽ +a:วŸ +a:วก +a:วฃ +a:วป +e:รจ +e:รฉ +e:รช +e:รซ +e:ฤ“ +e:ฤ— +e:ฤ™ +e:ฤ› +e:ว +e:วŸ +e:วก +e:วฃ +e:วป +i:รฌ +i:รญ +i:รฎ +i:รฏ +i:ฤซ +i:ฤฏ +i:ว +n:รฑ +n:ล„ +n:ลˆ +n:ล‹ +n:วน +o:รฒ +o:รณ +o:รด +o:รต +o:รถ +o:รธ +o:ล +o:ล‘ +o:ล“ +o:ว’ +o:วซ +o:วญ +o:วฟ +u:รน +u:รบ +u:รป +u:รผ +u:ลซ +u:ลฏ +u:ลฑ +u:ลณ +u:ว” +u:ว– +u:ว˜ +u:วš +u:วœ diff --git a/templates/swap-lists/spellit.txt b/templates/swap-lists/spellit.txt new file mode 100644 index 0000000..94d59ba --- /dev/null +++ b/templates/swap-lists/spellit.txt @@ -0,0 +1,108 @@ +10:ten +11:eleven +12:twelve +13:thirteen +14:fourteen +15:fifteen +16:sixteen +17:seventeen +18:eighteen +19:nineteen +1:one +20:twenty +21:twenty-one +22:twenty-two +23:twenty-three +24:twenty-four +25:twenty-five +26:twenty-six +27:twenty-seven +28:twenty-eight +29:twenty-nine +2:two +30:thirty +31:thirty-one +32:thirty-two +33:thirty-three +34:thirty-four +35:thirty-five +36:thirty-six +37:thirty-seven +38:thirty-eight +39:thirty-nine +3:three +40:forty +41:forty-one +42:forty-two +43:forty-three +44:forty-four +45:forty-five +46:forty-six +47:forty-seven +48:forty-eight +49:forty-nine +4:for +4:four +50:fifty +5:five +6:six +7:seven +8:eight +9:nine +@:at +at:@ +eight:8 +eighteen:18 +eleven:11 +fifteen:15 +fifty:50 +five:5 +for:4 +forty-eight:48 +forty-five:45 +forty-four:44 +forty-nine:49 +forty-one:41 +forty-seven:47 +forty-six:46 +forty-three:43 +forty-two:42 +forty:40 +four:4 +fourteen:14 +haha:lol +lol:haha +nine:9 +nineteen:19 +one:1 +seven:7 +seventeen:17 +six:6 +sixteen:16 +ten:10 +thirteen:13 +thirty-eight:38 +thirty-five:35 +thirty-four:34 +thirty-nine:39 +thirty-one:31 +thirty-seven:37 +thirty-six:36 +thirty-three:33 +thirty-two:32 +thirty:30 +three:3 +twelve:12 +twenty-eight:28 +twenty-five:25 +twenty-four:24 +twenty-nine:29 +twenty-one:21 +twenty-seven:27 +twenty-six:26 +twenty-three:23 +twenty-two:22 +twenty:20 +two:2 +ur:your +your:ur diff --git a/templates/rules/prepend.json b/templates/tokenize.json similarity index 51% rename from templates/rules/prepend.json rename to templates/tokenize.json index 83b0faa..6934d97 100644 --- a/templates/rules/prepend.json +++ b/templates/tokenize.json @@ -3,9 +3,9 @@ "StartIndex": 0, "EndIndex": 0, "Verbose": false, - "ReplacementMask": "uldsb", + "ReplacementMask": "ult", "Bypass": false, - "TransformationMode": "prepend", + "TransformationMode": "mask-pop", "WordRangeStart": 0, "WordRangeEnd": 0 }, @@ -13,9 +13,9 @@ "StartIndex": 0, "EndIndex": 0, "Verbose": false, - "ReplacementMask": "uldsb", + "ReplacementMask": "dsb", "Bypass": false, - "TransformationMode": "prepend-remove", + "TransformationMode": "mask-pop", "WordRangeStart": 0, "WordRangeEnd": 0 }, @@ -23,9 +23,19 @@ "StartIndex": 0, "EndIndex": 0, "Verbose": false, - "ReplacementMask": "uldsb", + "ReplacementMask": "ul", "Bypass": false, - "TransformationMode": "prepend-shift", + "TransformationMode": "mask-remove", + "WordRangeStart": 0, + "WordRangeEnd": 0 + }, + { + "StartIndex": 0, + "EndIndex": 0, + "Verbose": false, + "ReplacementMask": "dsb", + "Bypass": false, + "TransformationMode": "mask-remove", "WordRangeStart": 0, "WordRangeEnd": 0 } From 1f852b97ecae1b9d9f95936fdacbcfb941fadbd0 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Fri, 8 Nov 2024 18:59:14 -0500 Subject: [PATCH 04/12] Update SECURITY.md --- docs/SECURITY.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 8e40115..ec689a4 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -5,4 +5,5 @@ ## Notes: - `pkg/utils/utils.go:9` use of `crypto/rand` over `math/rand` is not needed in this module. ## Last SAST Scan: -- `10/16/2024` - `v0.3.7` \ No newline at end of file +- `11/08/2024` - `v0.4.0` +- `10/16/2024` - `v0.3.7` From 2e70b0f2cbbf0f968d9ae69046e6ccc7c81ec1c5 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 10:37:47 -0500 Subject: [PATCH 05/12] Add load timer --- main.go | 1 + pkg/utils/utils.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/main.go b/main.go index e3f5767..f7d05a5 100644 --- a/main.go +++ b/main.go @@ -128,6 +128,7 @@ func main() { // Read files if provided if retain != nil || remove != nil || readFiles != nil || transformationFiles != nil { fmt.Fprintf(os.Stderr, "[*] Reading files for input.\n") + utils.TrackLoadTime() } if retain != nil { diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index c69cace..a60138d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -30,6 +30,40 @@ import ( // Loading and Processing Functions // ---------------------------------------------------------------------------- +// TrackLoadTime tracks the time it takes to load the input and prints the time +// to stderr every 5 minutes +// +// Args: +// None +// +// Returns: +// None +func TrackLoadTime() { + start := time.Now() + ticker := time.NewTicker(5 * time.Minute) + defer ticker.Stop() + + go func() { + for range ticker.C { + elapsed := time.Since(start) + fmt.Fprintf(os.Stderr, "[-] Loading. Elapsed Time: %v.\n", elapsed) + } + }() +} + +// TrackElapsedTime tracks the elapsed time for processing and prints the time +// to stderr every 5 minutes +// +// Args: +// +// mode (string): The processing mode +// inputLength (int): The length of the input +// transformationFileLength (int): The length of the transformation file +// bypass (bool): A flag to bypass tracking the elapsed time +// +// Returns: +// +// None func TrackElapsedTime(mode string, inputLength int, transformationFileLength int, bypass bool) { start := time.Now() ticker := time.NewTicker(5 * time.Minute) From 0ca18ad986564fc2e6fd97be7f303f69bc01f558 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 10:45:23 -0500 Subject: [PATCH 06/12] async add --- main.go | 2 +- pkg/transform/transform.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index f7d05a5..eeedd2d 100644 --- a/main.go +++ b/main.go @@ -128,7 +128,7 @@ func main() { // Read files if provided if retain != nil || remove != nil || readFiles != nil || transformationFiles != nil { fmt.Fprintf(os.Stderr, "[*] Reading files for input.\n") - utils.TrackLoadTime() + go utils.TrackLoadTime() } if retain != nil { diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index babacba..98f5303 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -40,7 +40,7 @@ import ( // (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, wordRangeStart int, wordRangeEnd int) (output map[string]int) { - utils.TrackElapsedTime(mode, len(input), len(transformationFilesMap), bypass) + go utils.TrackElapsedTime(mode, len(input), len(transformationFilesMap), bypass) functionDebug := false if debug > 1 { From b6228670198a4735d04d251de1eef7440491c345 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 11:52:34 -0500 Subject: [PATCH 07/12] test timer --- main.go | 5 ++++- pkg/utils/utils.go | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index eeedd2d..78b2e4f 100644 --- a/main.go +++ b/main.go @@ -124,11 +124,12 @@ func main() { var removeMap map[string]int var readFilesMap map[string]int var transformationFilesMap map[string]int + done := make(chan bool) + go utils.TrackLoadTime(done) // Read files if provided if retain != nil || remove != nil || readFiles != nil || transformationFiles != nil { fmt.Fprintf(os.Stderr, "[*] Reading files for input.\n") - go utils.TrackLoadTime() } if retain != nil { @@ -171,6 +172,8 @@ func main() { primaryMap = utils.CombineMaps(primaryMap, readFilesMap, readURLsMap) } + done <- true + close(done) fmt.Fprintf(os.Stderr, "[*] All input loaded.\n") // Apply transformation if provided diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index a60138d..7f62c55 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -38,15 +38,22 @@ import ( // // Returns: // None -func TrackLoadTime() { +func TrackLoadTime(done chan bool) { + fmt.Fprintln(os.Stderr, "[*] TrackLoadTime started") start := time.Now() - ticker := time.NewTicker(5 * time.Minute) + ticker := time.NewTicker(1 * time.Second) defer ticker.Stop() go func() { - for range ticker.C { - elapsed := time.Since(start) - fmt.Fprintf(os.Stderr, "[-] Loading. Elapsed Time: %v.\n", elapsed) + for { + select { + case <-ticker.C: + elapsed := time.Since(start) + fmt.Fprintf(os.Stderr, "[-] Loading. Elapsed Time: %v.\n", elapsed) + case <-done: + fmt.Fprintln(os.Stderr, "[*] TrackLoadTime stopped") + return + } } }() } From 334eda7917a2523f12087c32263c2680c2c3d40e Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 13:27:48 -0500 Subject: [PATCH 08/12] clean timer implementation --- main.go | 15 ++++++++--- pkg/transform/transform.go | 2 -- pkg/utils/utils.go | 54 ++++++++------------------------------ 3 files changed, 22 insertions(+), 49 deletions(-) diff --git a/main.go b/main.go index 78b2e4f..90f0008 100644 --- a/main.go +++ b/main.go @@ -124,8 +124,8 @@ func main() { var removeMap map[string]int var readFilesMap map[string]int var transformationFilesMap map[string]int - done := make(chan bool) - go utils.TrackLoadTime(done) + doneLoad := make(chan bool) + go utils.TrackLoadTime(doneLoad, "Load") // Read files if provided if retain != nil || remove != nil || readFiles != nil || transformationFiles != nil { @@ -172,9 +172,13 @@ func main() { primaryMap = utils.CombineMaps(primaryMap, readFilesMap, readURLsMap) } - done <- true - close(done) + doneLoad <- true + close(doneLoad) fmt.Fprintf(os.Stderr, "[*] All input loaded.\n") + fmt.Fprintf(os.Stderr, "[*] Starting Processing.\n") + + doneProcess := make(chan bool) + go utils.TrackLoadTime(doneProcess, "Processing") // Apply transformation if provided if *transformation != "" && templateFiles == nil { @@ -203,6 +207,9 @@ func main() { return } + doneProcess <- true + close(doneProcess) + // Print ignore case if provided if *ignoreCase { fmt.Fprintf(os.Stderr, "[*] Ignoring case when processing output.\n") diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index 98f5303..5d71ae9 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -40,8 +40,6 @@ import ( // (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, wordRangeStart int, wordRangeEnd int) (output map[string]int) { - go utils.TrackElapsedTime(mode, len(input), len(transformationFilesMap), bypass) - functionDebug := false if debug > 1 { functionDebug = true diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7f62c55..eb3eef8 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -31,57 +31,25 @@ import ( // ---------------------------------------------------------------------------- // TrackLoadTime tracks the time it takes to load the input and prints the time -// to stderr every 5 minutes // // Args: // None // // Returns: // None -func TrackLoadTime(done chan bool) { - fmt.Fprintln(os.Stderr, "[*] TrackLoadTime started") +func TrackLoadTime(done <-chan bool, work string) { start := time.Now() - ticker := time.NewTicker(1 * time.Second) - defer ticker.Stop() - - go func() { - for { - select { - case <-ticker.C: - elapsed := time.Since(start) - fmt.Fprintf(os.Stderr, "[-] Loading. Elapsed Time: %v.\n", elapsed) - case <-done: - fmt.Fprintln(os.Stderr, "[*] TrackLoadTime stopped") - return - } - } - }() -} - -// TrackElapsedTime tracks the elapsed time for processing and prints the time -// to stderr every 5 minutes -// -// Args: -// -// mode (string): The processing mode -// inputLength (int): The length of the input -// transformationFileLength (int): The length of the transformation file -// bypass (bool): A flag to bypass tracking the elapsed time -// -// Returns: -// -// None -func TrackElapsedTime(mode string, inputLength int, transformationFileLength int, bypass bool) { - start := time.Now() - ticker := time.NewTicker(5 * time.Minute) - defer ticker.Stop() - - go func() { - for range ticker.C { - elapsed := time.Since(start) - fmt.Fprintf(os.Stderr, "[-] Processing. Processing Mode: %s. Input Length: %d. Transformation File Length: %d. Elapsed Time: %v.\n", mode, inputLength, transformationFileLength, elapsed) + ticker := time.NewTicker(30 * time.Second) + for { + select { + case <-done: + ticker.Stop() + fmt.Fprintf(os.Stderr, "[-] Total %s Time: %s\n", work, time.Since(start)) + return + case t := <-ticker.C: + fmt.Fprintf(os.Stderr, "[-] Please wait... %s\n", t.Sub(start)) } - }() + } } // ReadFilesToMap reads the contents of the multiple files and returns a map of words From 851c76820f13adec89464253d3e1918119b0be50 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 13:39:00 -0500 Subject: [PATCH 09/12] Update utils.go --- pkg/utils/utils.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index eb3eef8..918740b 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -33,7 +33,8 @@ import ( // TrackLoadTime tracks the time it takes to load the input and prints the time // // Args: -// None +// done (chan bool): channel to use to track tasks +// work (string): string used in status printing // // Returns: // None @@ -44,10 +45,10 @@ func TrackLoadTime(done <-chan bool, work string) { select { case <-done: ticker.Stop() - fmt.Fprintf(os.Stderr, "[-] Total %s Time: %s\n", work, time.Since(start)) + fmt.Fprintf(os.Stderr, "[-] Total %s Time: %02d:%02d:%02d.\n", work, int(time.Since(start).Hours()), int(time.Since(start).Minutes())%60, int(time.Since(start).Seconds())%60) return case t := <-ticker.C: - fmt.Fprintf(os.Stderr, "[-] Please wait... %s\n", t.Sub(start)) + fmt.Fprintf(os.Stderr, "[-] Please wait. Elapsed: %02d:%02d:%02d.\n", int(t.Sub(start).Hours()), int(t.Sub(start).Minutes())%60, int(t.Sub(start).Seconds())%60) } } } From 5ac9e53c3aa4a6a21ea593a49273f91caa3c1cba Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 13:44:28 -0500 Subject: [PATCH 10/12] Complete timer --- pkg/utils/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 918740b..3e3ceb8 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -48,7 +48,8 @@ func TrackLoadTime(done <-chan bool, work string) { fmt.Fprintf(os.Stderr, "[-] Total %s Time: %02d:%02d:%02d.\n", work, int(time.Since(start).Hours()), int(time.Since(start).Minutes())%60, int(time.Since(start).Seconds())%60) return case t := <-ticker.C: - fmt.Fprintf(os.Stderr, "[-] Please wait. Elapsed: %02d:%02d:%02d.\n", int(t.Sub(start).Hours()), int(t.Sub(start).Minutes())%60, int(t.Sub(start).Seconds())%60) + elapsed := t.Sub(start) + fmt.Fprintf(os.Stderr, "[-] Please wait. Elapsed: %02d:%02d:%02d.%03d.\n", int(t.Sub(start).Hours()), int(t.Sub(start).Minutes())%60, int(t.Sub(start).Seconds())%60, elapsed.Milliseconds()%1000) } } } From 9f59a6aa4b4358795f3d5e407a0939105bde179e Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 13:58:20 -0500 Subject: [PATCH 11/12] Add memory usage --- main.go | 2 +- pkg/utils/utils.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 90f0008..608f0f3 100644 --- a/main.go +++ b/main.go @@ -110,7 +110,7 @@ func main() { // Bypass map creation if requested if *bypassMap { - fmt.Fprintf(os.Stderr, "[*] Bypassing map creation and using standard output as primary output. Options are disabled.\n") + fmt.Fprintf(os.Stderr, "[*] Bypassing map creation and using standard output as primary output. Options are disabled. This does not bypass the initial input memory usage.\n") } // Print debug information if requested diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 3e3ceb8..113cbf3 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -12,6 +12,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "sort" "strconv" "strings" @@ -45,15 +46,24 @@ func TrackLoadTime(done <-chan bool, work string) { select { case <-done: ticker.Stop() - fmt.Fprintf(os.Stderr, "[-] Total %s Time: %02d:%02d:%02d.\n", work, int(time.Since(start).Hours()), int(time.Since(start).Minutes())%60, int(time.Since(start).Seconds())%60) + memUsage := GetMemoryUsage() + fmt.Fprintf(os.Stderr, "[-] Total %s Time: %02d:%02d:%02d. Memory Usage: %.2f MB.\n", work, int(time.Since(start).Hours()), int(time.Since(start).Minutes())%60, int(time.Since(start).Seconds())%60, memUsage) return case t := <-ticker.C: elapsed := t.Sub(start) - fmt.Fprintf(os.Stderr, "[-] Please wait. Elapsed: %02d:%02d:%02d.%03d.\n", int(t.Sub(start).Hours()), int(t.Sub(start).Minutes())%60, int(t.Sub(start).Seconds())%60, elapsed.Milliseconds()%1000) + memUsage := GetMemoryUsage() + fmt.Fprintf(os.Stderr, "[-] Please wait. Elapsed: %02d:%02d:%02d.%03d. Memory Usage: %.2f MB.\n", int(t.Sub(start).Hours()), int(t.Sub(start).Minutes())%60, int(t.Sub(start).Seconds())%60, elapsed.Milliseconds()%1000, memUsage) } } } +// GetMemoryUsage returns the current memory usage in megabytes +func GetMemoryUsage() float64 { + var m runtime.MemStats + runtime.ReadMemStats(&m) + return float64(m.Alloc) / 1024 / 1024 +} + // ReadFilesToMap reads the contents of the multiple files and returns a map of words // // Args: From 6b6ebefbcae9868bdcc56bfb767205be283be848 Mon Sep 17 00:00:00 2001 From: Jake Wnuk Date: Sat, 9 Nov 2024 14:17:35 -0500 Subject: [PATCH 12/12] Update utils.go --- pkg/utils/utils.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 113cbf3..b22c266 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -46,8 +46,7 @@ func TrackLoadTime(done <-chan bool, work string) { select { case <-done: ticker.Stop() - memUsage := GetMemoryUsage() - fmt.Fprintf(os.Stderr, "[-] Total %s Time: %02d:%02d:%02d. Memory Usage: %.2f MB.\n", work, int(time.Since(start).Hours()), int(time.Since(start).Minutes())%60, int(time.Since(start).Seconds())%60, memUsage) + fmt.Fprintf(os.Stderr, "[-] Total %s Time: %02d:%02d:%02d.\n", work, int(time.Since(start).Hours()), int(time.Since(start).Minutes())%60, int(time.Since(start).Seconds())%60) return case t := <-ticker.C: elapsed := t.Sub(start)