Browse Source
fuzzfuzzPatternSearch) Changes to be committed: modified: README.md deleted: clearextralines.desktop new file: fuzzPattern/fuzzPatternCreate new file: fuzzPattern/fuzzPatternCreate.go new file: fuzzPattern/fuzzPatternSearch new file: fuzzPattern/fuzzPatternSearch.go modified: install.sh modified: uninstall.shmaster
8 changed files with 166 additions and 8 deletions
@ -1,7 +0,0 @@ |
|||||
[Desktop Entry] |
|
||||
Name=ClearExtraLines |
|
||||
Encoding=UTF-8 |
|
||||
Exec=/usr/bin/clearExtraLines.py |
|
||||
StartupNotify=false |
|
||||
Terminal=false |
|
||||
Type=Application |
|
Binary file not shown.
@ -0,0 +1,50 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"gopkg.in/alecthomas/kingpin.v2" |
||||
|
"bytes" |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
charCountPointer:= kingpin.Arg("char-count", "Number of characters to generate").Required().Int() |
||||
|
kingpin.Parse() |
||||
|
|
||||
|
var charCount int=*charCountPointer |
||||
|
var ans bytes.Buffer |
||||
|
var tempCombi string |
||||
|
var combiArr [4]int |
||||
|
charsetCaps := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
||||
|
charsetSmall := "abcdefgjijklmnopqrustuvwxyz" |
||||
|
charsetNum := "0123456789" |
||||
|
|
||||
|
for ans.Len()<charCount { |
||||
|
tempCombi=string(charsetCaps[combiArr[0]]) + string(charsetSmall[combiArr[1]]) + string(charsetSmall[combiArr[2]]) + string(charsetNum[combiArr[3]]) |
||||
|
if ans.Len()+len(tempCombi) < charCount { |
||||
|
ans.WriteString(tempCombi) |
||||
|
} else { |
||||
|
ans.WriteString(tempCombi[:charCount-ans.Len()]) |
||||
|
} |
||||
|
|
||||
|
addCombi(combiArr[:]) |
||||
|
} |
||||
|
|
||||
|
fmt.Println(ans.String()) |
||||
|
} |
||||
|
|
||||
|
func addCombi(combiArr []int) { |
||||
|
combiMax := [4]int{26, 26, 26, 10} |
||||
|
|
||||
|
combiArr[len(combiArr)-1]+=1 |
||||
|
|
||||
|
for i:= len(combiArr)-1; i>0; i-- { |
||||
|
if combiArr[i] >= combiMax[i] { |
||||
|
combiArr[i] = 0 |
||||
|
combiArr[i-1] += 1 |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if combiArr[0] >= combiMax[0] { |
||||
|
combiArr[0] = 0 |
||||
|
} |
||||
|
} |
Binary file not shown.
@ -0,0 +1,100 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"gopkg.in/alecthomas/kingpin.v2" |
||||
|
"encoding/hex" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
patternPointer:= kingpin.Arg("search", "Hex(eg '0x42424242') or String to be search").Required().String() |
||||
|
pattLengthPointer:= kingpin.Flag("length", "Pattern length").Short(rune('l')).Int() |
||||
|
kingpin.Parse() |
||||
|
|
||||
|
var fullPattern string |
||||
|
var pattern string |
||||
|
var combiArr []int = []int{0,0,0,0} |
||||
|
combiMax := []int{26, 26, 26, 10} |
||||
|
var fullCombi int |
||||
|
charsetCaps := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
||||
|
charsetSmall := "abcdefgjijklmnopqrustuvwxyz" |
||||
|
charsetNum := "0123456789" |
||||
|
pattLength := *pattLengthPointer |
||||
|
finalPos := 0 |
||||
|
var startPos int |
||||
|
|
||||
|
if len(*patternPointer)<4 { |
||||
|
fmt.Println("Input must have at least 4 bytes") |
||||
|
} |
||||
|
|
||||
|
if (*patternPointer)[:2] == "0x" { |
||||
|
fmt.Println("Hex detected") |
||||
|
fullBytes, _ := hex.DecodeString((*patternPointer)[2:]) |
||||
|
fullPattern = string(fullBytes) |
||||
|
} else { |
||||
|
fullPattern = *patternPointer |
||||
|
} |
||||
|
|
||||
|
if len(fullPattern)<4 { |
||||
|
fmt.Println("Input must have at least 4 bytes") |
||||
|
} |
||||
|
|
||||
|
pattern = fullPattern[:4] |
||||
|
|
||||
|
for i:=0; i<len(pattern); i++ { |
||||
|
if strings.Contains(charsetCaps, string(pattern[i])) { |
||||
|
startPos = i |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//find combi
|
||||
|
combiArr[0]=strings.IndexByte(charsetCaps, pattern[(startPos+0)%4]) |
||||
|
combiArr[1]=strings.IndexByte(charsetSmall, pattern[(startPos+1)%4]) |
||||
|
combiArr[2]=strings.IndexByte(charsetSmall, pattern[(startPos+2)%4]) |
||||
|
combiArr[3]=strings.IndexByte(charsetNum, pattern[(startPos+3)%4]) |
||||
|
|
||||
|
finalPos = findPos(combiArr, startPos) |
||||
|
|
||||
|
if pattLength == 0 { |
||||
|
fmt.Println("Pattern found:",finalPos) |
||||
|
} else { |
||||
|
fullCombi = combiMax[0] * combiMax[1] * combiMax[2] * combiMax[3] |
||||
|
fmt.Println("Full cycle:", fullCombi) |
||||
|
fmt.Println("") |
||||
|
|
||||
|
for finalPos < pattLength { |
||||
|
fmt.Println("Pattern found:",finalPos) |
||||
|
finalPos+=fullCombi |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func findPos(combiArr []int, startPos int) int { |
||||
|
combiMax := []int{26, 26, 26, 10} |
||||
|
permuteCombi := []int{10*26*26, 26*10, 10, 1} |
||||
|
|
||||
|
var answerLength int |
||||
|
|
||||
|
if startPos > 0 { |
||||
|
combiArr[len(combiArr)-1]+=1 |
||||
|
|
||||
|
for i:= len(combiArr)-1; i>0; i-- { |
||||
|
if (combiArr[i] >= combiMax[i]) && (i >= (len(combiArr)-startPos)) { |
||||
|
combiArr[i] = 0 |
||||
|
if (i-1 >= (len(combiArr)-startPos)) { |
||||
|
combiArr[i-1] += 1 |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for i:=0; i<len(combiArr); i++ { |
||||
|
answerLength += combiArr[i] * permuteCombi[i] |
||||
|
} |
||||
|
|
||||
|
answerLength = answerLength * len(combiArr) |
||||
|
answerLength -= startPos |
||||
|
|
||||
|
return answerLength |
||||
|
} |
Loading…
Reference in new issue