-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.go
More file actions
728 lines (678 loc) · 20.3 KB
/
rules.go
File metadata and controls
728 lines (678 loc) · 20.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
package main
import (
"errors"
"fmt"
"sort"
"strings"
"unicode"
"github.com/cespare/xxhash/v2"
)
/*
Modifications by cyclone:
v0.0.1-2025-05-10-dev
removed all C, CUDA (GPU) logic and converted to Pure Go using CPU
refactored ParameterCountRule() switch case
*/
// Rule contains the core data structure
// Process is a function that applies the rule to a string
type Rule struct {
Function string
Parameter1 string
NumericParameter1 int
Parameter2 string
NumericParameter2 int
Parameter3 string
NumericParameter3 int
Process func(string) string // A lambda function for improved processing
}
// Helper function to reverse a string.
func reverseString(s string) string {
runes := []rune(s)
sort.SliceStable(runes, func(i, j int) bool { return i > j })
return string(runes)
}
// CreateTestWords generates an array of words used to validate and verify if Rules are unique with UniqueID
//
// testWords := rule.CreateTestWords()
// Rules, _ := rule.ConvertFromHashcat(1, "$1 ]")
// id := rule.UniqueID(testWords, Rules)
// Rules2, _ := rule.ConvertFromHashcat(1, ": $2 ]")
// id2 := rule.UniqueID(testWords, Rules2)
func CreateTestWords() []string {
var testWords []string
// Create 256 strings, each containing 37 characters of the same value (0x0 to 0xff)
for i := 0x0; i <= 0xff; i++ {
testWords = append(testWords, strings.Repeat(string(rune(i)), 37))
}
// Create a string with all possible hex values repeated 37 times with an appended 'a'
var allChars strings.Builder
for i := 0x0; i <= 0xff; i++ {
for j := 0; j < 37; j++ {
allChars.WriteRune(rune(i))
allChars.WriteRune('a')
}
}
testWords = append(testWords, allChars.String())
// Reverse the string created above
allCharsReversed := reverseString(allChars.String())
testWords = append(testWords, allCharsReversed)
// Create alphanumeric strings of different lengths
alphabet := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i := 0; i < 37; i++ {
// Reverse every other alphabet
currentAlphabet := alphabet
if i%2 == 0 {
currentAlphabet = reverseString(currentAlphabet)
}
// Erase characters from the start to keep only the last (i + 1) characters
if len(currentAlphabet) > i+1 {
currentAlphabet = currentAlphabet[len(currentAlphabet)-i-1:]
}
testWords = append(testWords, currentAlphabet)
}
return testWords
}
// UniqueID Generates an ID unique to the set of rules allowing you to compare two lines to each-other
func UniqueID(testWords *[]string, rules []Rule) uint64 {
result := xxhash.New()
for _, w := range *testWords {
for _, rule := range rules {
w = rule.Process(w)
}
_, err := result.WriteString(w)
if err != nil {
return 0
}
}
return result.Sum64()
}
// ParameterCountRule displays the amount of required parameters
// refactored ParameterCountRule() switch case
func ParameterCountRule(rule string) (int, error) {
if len(rule) == 0 {
return -1, errors.New("Empty String")
}
switch rule[0] {
// zero-parameter
case ':', 'l', 'u', 'c', 'C', 't', 'r', 'd', 'f', '{', '}', '[', ']', 'k', 'K', 'q', 'E':
return 0, nil
// one-parameter
case '@', 'T', 'p', 'D', 'Z', 'z', '$', '^', '<', '>', '_', '\'', '!', '/', 'y', 'Y', '-', '+', 'e', '.', ',', 'L', 'R':
return 1, nil
// two-parameter
case 's', 'x', 'O', 'o', 'i', '3', '*':
return 2, nil
// three-parameter
case 'S':
return 3, nil
}
return -1, errors.New("Unknown Function")
}
// ParseTSVRules Takes TSV input and converts it to an array of Rules
func ParseTSVRules(lineCounter uint64, line string) ([]Rule, error) {
rulesRaw := strings.Split(line, "\t")
var parsedRules []Rule
for _, rule := range rulesRaw {
parsedRule, err := ParseSingleRule(rule)
if err != nil {
if err.Error() != "Empty String" {
return nil, fmt.Errorf("Invalid rule '%s' on line %d: %v", rule, lineCounter, err)
}
continue
}
parsedRules = append(parsedRules, parsedRule)
}
return parsedRules, nil
}
// ParseSingleRule Parses a single rule such as : or s31 or $b
func ParseSingleRule(originalRule string) (Rule, error) {
parameterCount, err := ParameterCountRule(originalRule)
if parameterCount == -1 {
return Rule{}, err
}
if len([]rune(originalRule))-1 < parameterCount {
return Rule{}, errors.New("Missing parameters")
}
myRule := Rule{}
if parameterCount >= 0 {
myRule.Function = originalRule[0:1]
}
if parameterCount >= 1 {
myRule.Parameter1 = originalRule[1:2]
}
if parameterCount >= 2 {
myRule.Parameter2 = originalRule[2:3]
}
if parameterCount >= 3 {
myRule.Parameter3 = originalRule[3:4]
}
alphabet := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if strings.Contains(alphabet, myRule.Parameter1) && len(myRule.Parameter1) > 0 {
myRule.NumericParameter1 = strings.IndexRune(alphabet, rune(myRule.Parameter1[0]))
}
if strings.Contains(alphabet, myRule.Parameter2) && len(myRule.Parameter2) > 0 {
myRule.NumericParameter2 = strings.IndexRune(alphabet, rune(myRule.Parameter2[0]))
}
if strings.Contains(alphabet, myRule.Parameter3) && len(myRule.Parameter3) > 0 {
myRule.NumericParameter3 = strings.IndexRune(alphabet, rune(myRule.Parameter3[0]))
}
switch myRule.Function {
case ":":
myRule.Process = func(input string) string {
return input
}
case "l":
myRule.Process = func(input string) string {
return strings.ToLower(input)
}
case "u":
myRule.Process = func(input string) string {
return strings.ToUpper(input)
}
case "c":
myRule.Process = func(input string) string {
if len(input) <= 1 {
return strings.ToUpper(input)
}
lower := strings.ToLower(input)
return strings.ToUpper(string(lower[0])) + lower[1:]
}
case "C":
myRule.Process = func(input string) string {
if len(input) <= 1 {
return strings.ToLower(input)
}
upper := strings.ToUpper(input)
return strings.ToLower(string(upper[0])) + upper[1:]
}
case "t":
myRule.Process = func(input string) string {
var result []rune
for _, r := range input {
if unicode.IsLower(r) {
result = append(result, unicode.ToUpper(r))
} else if unicode.IsUpper(r) {
result = append(result, unicode.ToLower(r))
} else {
result = append(result, r)
}
}
return string(result)
}
case "q":
myRule.Process = func(input string) string {
var result strings.Builder
for _, r := range input {
result.WriteRune(r)
result.WriteRune(r)
}
return result.String()
}
case "r":
myRule.Process = func(input string) string {
runes := []rune(input)
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
return string(runes)
}
case "k":
myRule.Process = func(input string) string {
if len([]rune(input)) < 2 {
return input
}
runes := []rune(input)
runes[0], runes[1] = runes[1], runes[0]
return string(runes)
}
case "K":
myRule.Process = func(input string) string {
if len([]rune(input)) < 2 {
return input
}
runes := []rune(input)
runes[len(runes)-1], runes[len(runes)-2] = runes[len(runes)-2], runes[len(runes)-1]
return string(runes)
}
case "d":
myRule.Process = func(input string) string {
return input + input
}
case "f":
myRule.Process = func(input string) string {
runes := []rune(input)
// Reverse the string
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
return input + string(runes)
}
case "{":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
return input[1:] + string(input[0])
}
case "}":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
return string(input[len(input)-1]) + input[:len(input)-1]
}
case "[":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
return input[1:]
}
case "]":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
return input[:len(input)-1]
}
case "E":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
input = strings.ToLower(input)
runes := []rune(input)
runes[0] = unicode.ToUpper(runes[0])
for i := 1; i < len(runes); i++ {
if runes[i-1] == ' ' {
runes[i] = unicode.ToUpper(runes[i])
}
}
return string(runes)
}
case "T":
myRule.Process = func(input string) string {
if len(input) == 0 || myRule.NumericParameter1 >= len([]rune(input)) {
return input
}
runes := []rune(input)
if unicode.IsLower(runes[myRule.NumericParameter1]) {
runes[myRule.NumericParameter1] = unicode.ToUpper(runes[myRule.NumericParameter1])
} else if unicode.IsUpper(runes[myRule.NumericParameter1]) {
runes[myRule.NumericParameter1] = unicode.ToLower(runes[myRule.NumericParameter1])
}
return string(runes)
}
case "p":
myRule.Process = func(input string) string {
var result strings.Builder
for i := 0; i <= myRule.NumericParameter1; i++ {
result.WriteString(input)
}
return result.String()
}
case "D":
myRule.Process = func(input string) string {
if len(input) == 0 || myRule.NumericParameter1 > len(input)-1 {
return input
}
return input[:myRule.NumericParameter1] + input[myRule.NumericParameter1+1:]
}
case "z":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
return strings.Repeat(string(input[0]), myRule.NumericParameter1) + input
}
case "Z":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
return input + strings.Repeat(string(input[len(input)-1]), myRule.NumericParameter1)
}
case "'":
myRule.Process = func(input string) string {
if len(input) == 0 || myRule.NumericParameter1 > len(input) {
return input
}
return input[:myRule.NumericParameter1]
}
case "s":
myRule.Process = func(input string) string {
return strings.ReplaceAll(input, myRule.Parameter1, myRule.Parameter2)
}
case "S": // Replace nth occurrence of character. S0ab replace the first 'a' with 'b'. SAs$ replace the 10th s with $
myRule.Process = func(input string) string {
if n := myRule.NumericParameter1; n >= 0 && myRule.Parameter2 != "" && myRule.Parameter3 != "" {
var pos, count int
for {
if idx := strings.Index(input[pos:], myRule.Parameter2); idx >= 0 {
if count == n {
pos += idx
return input[:pos] + myRule.Parameter3 + input[pos+len(myRule.Parameter2):]
}
count++
pos += idx + len(myRule.Parameter2)
} else {
break
}
}
}
return input
}
case "$":
myRule.Process = func(input string) string {
return input + myRule.Parameter1
}
case "^":
myRule.Process = func(input string) string {
return myRule.Parameter1 + input
}
case "y":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 == 0 {
return input
}
if myRule.NumericParameter1 > len(input) {
return input
}
return input[:myRule.NumericParameter1] + input
}
case "Y":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 == 0 {
return input
}
if myRule.NumericParameter1 > len(input) {
return input + input
}
return input + input[len(input)-myRule.NumericParameter1:]
}
case "L":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len(input) {
return input
}
char := input[myRule.NumericParameter1]
modifiedChar := char << 1
return input[:myRule.NumericParameter1] + string(modifiedChar) + input[myRule.NumericParameter1+1:]
}
case "R":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len(input) {
return input
}
char := input[myRule.NumericParameter1]
modifiedChar := char >> 1
return input[:myRule.NumericParameter1] + string(modifiedChar) + input[myRule.NumericParameter1+1:]
}
case "-":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len(input) {
return input
}
char := input[myRule.NumericParameter1]
modifiedChar := char - 1
return input[:myRule.NumericParameter1] + string(modifiedChar) + input[myRule.NumericParameter1+1:]
}
case "+":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len(input) {
return input
}
char := input[myRule.NumericParameter1]
modifiedChar := char + 1
return input[:myRule.NumericParameter1] + string(modifiedChar) + input[myRule.NumericParameter1+1:]
}
case "@":
myRule.Process = func(input string) string {
return strings.ReplaceAll(input, string(myRule.Parameter1[0]), "")
}
case ".":
myRule.Process = func(input string) string {
if myRule.NumericParameter1+1 >= len(input) {
return input
}
modified := input[:myRule.NumericParameter1] + string(input[myRule.NumericParameter1+1]) + input[myRule.NumericParameter1+1:]
return modified[:len(modified)-1]
}
case ",":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len(input) || myRule.NumericParameter1 <= 0 {
return input
}
modified := input[:myRule.NumericParameter1] + string(input[myRule.NumericParameter1-1]) + input[myRule.NumericParameter1+1:]
return modified
}
case "e":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
lower := strings.ToLower(input)
result := strings.ToUpper(string(lower[0])) + lower[1:]
for i := 1; i < len(result); i++ {
if i+1 < len(result) && result[i] == myRule.Parameter1[0] {
result = result[:i+1] + strings.ToUpper(string(result[i+1])) + result[i+2:]
}
}
return result
}
case "i":
myRule.Process = func(input string) string {
if len(input) == 0 || myRule.NumericParameter1 > len(input) {
return input
}
return input[:myRule.NumericParameter1] + myRule.Parameter2 + input[myRule.NumericParameter1:]
}
case "O":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len(input) || len(input) == 0 {
return input
}
if myRule.NumericParameter1+myRule.NumericParameter2 < len(input) {
return input[:myRule.NumericParameter1] + input[myRule.NumericParameter1+myRule.NumericParameter2:]
}
return input
}
case "o":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 < 0 || len(input) == 0 || myRule.NumericParameter1+len(myRule.Parameter2)-1 >= len(input) {
return input
}
modified := input[:myRule.NumericParameter1] + myRule.Parameter2
if myRule.NumericParameter1+len(myRule.Parameter2) < len(input) {
modified += input[myRule.NumericParameter1+len(myRule.Parameter2):]
}
return modified
}
case "*":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 >= len([]rune(input)) || myRule.NumericParameter2 >= len([]rune(input)) || len(input) == 0 {
return input
}
runes := []rune(input)
runes[myRule.NumericParameter1], runes[myRule.NumericParameter2] = runes[myRule.NumericParameter2], runes[myRule.NumericParameter1]
return string(runes)
}
case "x":
myRule.Process = func(input string) string {
if len(input) == 0 || myRule.NumericParameter1 >= len(input) {
return input
}
if myRule.NumericParameter1+myRule.NumericParameter2 <= len(input) {
input = input[myRule.NumericParameter1 : myRule.NumericParameter1+myRule.NumericParameter2]
}
return input
}
case "<":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 < len(input) {
return input
}
return ""
}
case ">":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 > len(input) {
return input
}
return ""
}
case "_":
myRule.Process = func(input string) string {
if myRule.NumericParameter1 == len(input) {
return ""
}
return input
}
case "!":
myRule.Process = func(input string) string {
if strings.Contains(input, myRule.Parameter1) {
return ""
}
return input
}
case "/":
myRule.Process = func(input string) string {
if !strings.Contains(input, myRule.Parameter1) {
return ""
}
return input
}
case "3":
myRule.Process = func(input string) string {
if len(input) == 0 {
return input
}
instance := -1
runes := []rune(input)
for i, char := range runes {
if instance == myRule.NumericParameter1 {
if unicode.IsLower(char) {
runes[i] = unicode.ToUpper(char)
} else if unicode.IsUpper(char) {
runes[i] = unicode.ToLower(char)
}
break
}
if char == rune(myRule.Parameter2[0]) {
instance++
}
}
return string(runes)
}
}
return myRule, nil
}
// PrintFormat renders a rule back to hashcat syntax
func (r *Rule) PrintFormat() string {
s1 := strings.ReplaceAll(r.Parameter1, "\t", "\\x09")
s2 := strings.ReplaceAll(r.Parameter2, "\t", "\\x09")
s3 := strings.ReplaceAll(r.Parameter3, "\t", "\\x09")
pc, _ := ParameterCountRule(r.Function)
switch pc {
case 0:
return r.Function
case 1:
return r.Function + s1
case 2:
if len(r.Parameter1) > 1 || len(r.Parameter2) > 1 {
return fmt.Sprintf("%s/%s/%s", r.Function, s1, s2)
}
return r.Function + s1 + s2
case 3:
if len(r.Parameter1) > 1 || len(r.Parameter2) > 1 || len(r.Parameter3) > 1 {
return fmt.Sprintf("%s/%s/%s/%s", r.Function, s1, s2, s3)
}
return r.Function + s1 + s2 + s3
}
return ""
}
// FormatAllRules joins multiple rules with delimiter
func FormatAllRules(all []Rule, delim ...string) string {
d := "\t"
if len(delim) > 0 {
d = delim[0]
}
var b strings.Builder
for i, r := range all {
b.WriteString(r.PrintFormat())
if i < len(all)-1 {
b.WriteString(d)
}
}
return b.String()
}
// ConvertFromHashcat converts a line of hashcat compatible rules to an array of Rule objects.
// Done by first converting to TSV and then using ParseTSVRules to convert to Rule objects.
func ConvertFromHashcat(lineCounter uint64, rawLine string) ([]Rule, error) {
if len(rawLine) == 0 {
return nil, fmt.Errorf("empty rule on line [%d]", lineCounter)
}
// Sets of each rawLine width
singleWide := ":lucCtrdf{}[]kKqE"
doubleWide := "TpDZz$^<>_'!/@-+yYLR.,e"
tripleWide := "sxOoi*3"
quadrupleWide := "S"
var formattedRule strings.Builder
offset := 0
for offset < len(rawLine) {
baseRule := rawLine[offset]
switch {
case baseRule == ' ':
offset++
case strings.Contains(singleWide, string(baseRule)):
formattedRule.WriteString(rawLine[offset:offset+1] + "\t")
offset++
case strings.Contains(doubleWide, string(baseRule)):
if offset+3 < len(rawLine) && rawLine[offset+1:offset+3] == "\\x" {
if offset+5 > len(rawLine) {
return nil, fmt.Errorf("missing hex parameters on line [%d]: \"%s\"", lineCounter, rawLine)
}
formattedRule.WriteString(rawLine[offset:offset+5] + "\t")
offset += 5
} else {
if offset+2 > len(rawLine) {
return nil, fmt.Errorf("missing rule parameters on line [%d]: \"%s\"", lineCounter, rawLine)
}
formattedRule.WriteString(rawLine[offset:offset+2] + "\t")
offset += 2
}
case strings.Contains(tripleWide, string(baseRule)):
if offset+9 <= len(rawLine) && rawLine[offset+1:offset+3] == "\\x" && rawLine[offset+5:offset+7] == "\\x" {
formattedRule.WriteString(rawLine[offset:offset+9] + "\t")
offset += 9
} else if offset+6 <= len(rawLine) && (rawLine[offset+1:offset+3] == "\\x" || rawLine[offset+2:offset+4] == "\\x") {
formattedRule.WriteString(rawLine[offset:offset+6] + "\t")
offset += 6
} else {
if offset+3 > len(rawLine) {
return nil, fmt.Errorf("missing rule parameters on line [%d]: \"%s\"", lineCounter, rawLine)
}
formattedRule.WriteString(rawLine[offset:offset+3] + "\t")
offset += 3
}
case strings.Contains(quadrupleWide, string(baseRule)):
if offset+12 <= len(rawLine) && rawLine[offset+1:offset+3] == "\\x" && rawLine[offset+5:offset+7] == "\\x" && rawLine[offset+9:offset+11] == "\\x" {
formattedRule.WriteString(rawLine[offset:offset+12] + "\t")
offset += 12
} else {
if offset+4 > len(rawLine) {
return nil, fmt.Errorf("missing rule parameters on line [%d]: \"%s\"", lineCounter, rawLine)
}
formattedRule.WriteString(rawLine[offset:offset+4] + "\t")
offset += 4
}
case baseRule == '#':
return nil, nil // Exit loop on comments
default:
return nil, fmt.Errorf("unknown rule function \"%c\" on line [%d]", baseRule, lineCounter)
}
}
// Remove last tab if exists
TSVResult := strings.TrimSuffix(formattedRule.String(), "\t")
return ParseTSVRules(lineCounter, TSVResult)
}