|
|
|
|
@ -20,6 +20,7 @@ var symbols = []string{ |
|
|
|
|
func main() { |
|
|
|
|
// Define a command-line flag for the filename
|
|
|
|
|
filenamePtr := flag.String("file", "results.txt", "Name of the file to write results to") |
|
|
|
|
pwdPtr := flag.String("pwd", "", "Enter a password") |
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
|
|
// Open the SQLite3 database file
|
|
|
|
|
@ -62,12 +63,16 @@ func main() { |
|
|
|
|
defer rows.Close() |
|
|
|
|
if rows.Next() {
|
|
|
|
|
// Process the results
|
|
|
|
|
fmt.Println("Results for case-insensitive LIKE:") |
|
|
|
|
//fmt.Println("Results for case-insensitive LIKE:")
|
|
|
|
|
writeResultsToFile(*filenamePtr, rows) |
|
|
|
|
} else {
|
|
|
|
|
if strings.Contains(searchTerm, "*") { |
|
|
|
|
result := strings.Replace(searchTerm, "*", "", -1) |
|
|
|
|
writeDataToFile(*filenamePtr, xorBy13(compressRLE(result))) |
|
|
|
|
if (*pwdPtr != "") { |
|
|
|
|
writeDataToFile(*filenamePtr, xorStringWithPassword(compressRLE(result), *pwdPtr)) |
|
|
|
|
} else { |
|
|
|
|
writeDataToFile(*filenamePtr, xorBy13(compressRLE(result))) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
fmt.Println("Not found! Please retype and add an * at the end to save") |
|
|
|
|
} |
|
|
|
|
@ -75,7 +80,7 @@ func main() { |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Process the results
|
|
|
|
|
fmt.Println("Results for case-sensitive LIKE:") |
|
|
|
|
//fmt.Println("Results for case-sensitive LIKE:")
|
|
|
|
|
writeResultsToFile(*filenamePtr, rows) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -94,7 +99,7 @@ func writeDataToFile(filename string, data string) { |
|
|
|
|
log.Fatal(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fmt.Printf("Added to %s\n", filename) |
|
|
|
|
//fmt.Printf("Added to %s\n", filename)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func writeResultsToFile(filename string, rows *sql.Rows) { |
|
|
|
|
@ -109,7 +114,7 @@ func writeResultsToFile(filename string, rows *sql.Rows) { |
|
|
|
|
if err != nil { |
|
|
|
|
log.Fatal(err) |
|
|
|
|
} |
|
|
|
|
fmt.Printf("ID=%d\n", id) |
|
|
|
|
fmt.Printf("Added ID %d\n", id) |
|
|
|
|
|
|
|
|
|
result := fmt.Sprintf("%d ", id) |
|
|
|
|
_, err = file.WriteString(result) |
|
|
|
|
@ -120,7 +125,7 @@ func writeResultsToFile(filename string, rows *sql.Rows) { |
|
|
|
|
if err := rows.Err(); err != nil { |
|
|
|
|
log.Fatal(err) |
|
|
|
|
} |
|
|
|
|
fmt.Printf("Results written to %s\n", filename) |
|
|
|
|
//fmt.Printf("Results written to %s\n", filename)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func xorBy13(input string) string { |
|
|
|
|
@ -134,6 +139,17 @@ func xorBy13(input string) string { |
|
|
|
|
return result.String() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func xorStringWithPassword(input string, password string) string { |
|
|
|
|
inputBytes := []byte(input) |
|
|
|
|
passwordBytes := []byte(password) |
|
|
|
|
|
|
|
|
|
for i := 0; i < len(inputBytes); i++ { |
|
|
|
|
inputBytes[i] ^= passwordBytes[i%len(passwordBytes)] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return string(inputBytes) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// compressRLE compresses a string using Run-Length Encoding
|
|
|
|
|
func compressRLE(input string) string { |
|
|
|
|
result := "" |
|
|
|
|
|