Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit b698fe2

Browse files
authored
Update to v0.2.3 (#25)
* Bug fix: Remove move improper byte handling - remove mode failed to display multibyte characters back to the user due the user supplied mask not reaching the removal function. * Feature: Add title case to pop - Added the ability to include "t" into the replacement mask for the pop mode which will pop title case words instead of skipping them - changed the default replacement mask to include "t" - fix unit tests * Add templates directory to docker image - adding templates to docker image * add swap templates - added a swap-encode template - added a swap lists directory for examples
1 parent 9653304 commit b698fe2

File tree

8 files changed

+45
-8
lines changed

8 files changed

+45
-8
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ADD ./main.go .
55
ADD ./go.mod .
66
ADD ./go.sum .
77
ADD ./pkg ./pkg
8+
ADD ./templates/ ./templates
89
RUN go build .
910

1011
FROM alpine

docs/WORDLISTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ Where `<mask_characters>` can be any of the following:
4848
- `d`: Digits
4949
- `s`: Special characters
5050
- `b`: Byte characters
51+
- `t`: Title case words (requires `u` and `l`)
5152
- Multiple characters can be combined to create a mask.
5253

53-
The default value is `uldsb` for all characters. This mode will create tokens
54+
The default value is `uldsbt` for all characters. This mode will create tokens
5455
by popping characters from the input string then aggregating the results.
5556

5657
### Token Swapping

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555
"mask -rm [uldsb] -v": "Transforms input by masking characters with provided mask.",
5656
"remove -rm [uldsb]": "Transforms input by removing characters with provided mask characters.",
5757
"mask-retain -rm [uldsb] -tf [file]": "Transforms input by creating masks that still retain strings from file.",
58-
"pop -rm [uldsb]": "Transforms input by generating tokens from popping strings at character boundaries.",
58+
"pop -rm [uldsbt]": "Transforms input by generating tokens from popping strings at character boundaries.",
5959
"mask-match -tf [file]": "Transforms input by keeping only strings with matching masks from a mask file.",
6060
"swap -tf [file]": "Transforms input by swapping tokens with exact matches from a ':' separated file.",
6161
"mask-swap -tf [file]": "Transforms input by swapping tokens from a partial mask file and a input file.",
@@ -83,7 +83,7 @@ func main() {
8383
minimum := flag.Int("m", 0, "Minimum numerical frequency to include in output.")
8484
verboseStatsMax := flag.Int("n", 25, "Maximum number of items to display in verbose statistics output.")
8585
transformation := flag.String("t", "", "Transformation to apply to input.")
86-
replacementMask := flag.String("rm", "uldsb", "Replacement mask for transformations if applicable.")
86+
replacementMask := flag.String("rm", "uldsbt", "Replacement mask for transformations if applicable.")
8787
jsonOutput := flag.String("o", "", "Output to JSON file in addition to stdout.")
8888
bypassMap := flag.Bool("b", false, "Bypass map creation and use stdout as primary output.")
8989
debugMode := flag.Int("d", 0, "Enable debug mode with verbosity levels [0-2].")

pkg/mask/mask.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,21 @@ func TestMaskComplexity(str string) int {
267267
// Args:
268268
//
269269
// input (map[string]int): Input map
270+
// replacementMask (string): Mask characters to apply
270271
// bypass (bool): If true, the map is not used for output or filtering
271272
// debug (bool): If true, print additional debug information to stderr
272273
//
273274
// Returns:
274275
//
275276
// (map[string]int): Masked map
276-
func RemoveMaskedCharacters(input map[string]int, bypass bool, debug bool) map[string]int {
277+
func RemoveMaskedCharacters(input map[string]int, replacementMask string, bypass bool, debug bool) map[string]int {
277278
maskedMap := make(map[string]int)
278279
replacer := strings.NewReplacer("?u", "", "?l", "", "?d", "", "?b", "", "?s", "")
279280

280281
for key, value := range input {
281282
newKey := replacer.Replace(key)
282283

283-
if !utils.CheckASCIIString(newKey) {
284+
if !utils.CheckASCIIString(newKey) && strings.Contains(replacementMask, "b") {
284285
newKey = ConvertMultiByteMask(newKey)
285286
}
286287

@@ -393,7 +394,9 @@ func BoundarySplitPopMap(input map[string]int, replacementMask string, bypass bo
393394
}
394395

395396
if (lastRuneType != 0 && lastRuneType != runeType) || !strings.ContainsRune(replacementMask, runeType) {
396-
if token != "" {
397+
if strings.ContainsRune(replacementMask, 't') && lastRuneType == 'u' && runeType == 'l' {
398+
// do nothing so the token continues
399+
} else if token != "" {
397400
result[token]++
398401
token = ""
399402
}

pkg/mask/mask_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestRemoveMaskedCharacters(t *testing.T) {
225225

226226
// Run test cases
227227
for _, test := range tests {
228-
output := RemoveMaskedCharacters(test.input, false, false)
228+
output := RemoveMaskedCharacters(test.input, "ulsbd", false, false)
229229
if !reflect.DeepEqual(output, test.output) {
230230
t.Errorf("Test failed: %v inputted, %v expected, %v returned", test.input, test.output, output)
231231
}

pkg/transform/transform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TransformationController(input map[string]int, mode string, startingIndex i
8686
output = format.HexEncodeMap(input, bypass, functionDebug)
8787
case "remove", "remove-all", "delete", "delete-all", "rm":
8888
input = mask.MakeMaskedMap(input, replacementMask, false, false, false)
89-
output = mask.RemoveMaskedCharacters(input, bypass, functionDebug)
89+
output = mask.RemoveMaskedCharacters(input, replacementMask, bypass, functionDebug)
9090
case "retain-mask", "retain", "r", "mask-retain":
9191
if len(transformationFilesMap) == 0 {
9292
fmt.Fprintf(os.Stderr, "[!] Retain masks require use of one or more -tf flags to specify one or more files\n")

templates/swap-encode.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"StartIndex": 0,
4+
"EndIndex": 0,
5+
"Verbose": false,
6+
"ReplacementMask": "uldsb",
7+
"Bypass": false,
8+
"TransformationMode": "swap",
9+
"PassphraseWords": 0
10+
},
11+
{
12+
"StartIndex": 0,
13+
"EndIndex": 0,
14+
"Verbose": false,
15+
"ReplacementMask": "uldsb",
16+
"Bypass": false,
17+
"TransformationMode": "encode",
18+
"PassphraseWords": 0
19+
}
20+
]

templates/swap-lists/love.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
love:<3
2+
heart:<3
3+
love:♥
4+
heart:♥
5+
love:❤
6+
heart:❤
7+
love:😍
8+
heart:😍
9+
love:😘
10+
heart:😘
11+
love:🥰
12+
heart:🥰

0 commit comments

Comments
 (0)