- Added datawells subcommand
- Altered the request format to match the new api request structure - Altered max results per page to reflect updated Dehashed API max (10000)
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -31,6 +31,13 @@ func WriteCredsToFile(creds []sqlite.User, outputFile string, fileType files.Fil
|
||||
outStrings = append(outStrings, c.ToString()+"\n")
|
||||
}
|
||||
data = []byte(strings.Join(outStrings, ""))
|
||||
case files.GREPPABLE:
|
||||
var outStrings []string
|
||||
for _, c := range creds {
|
||||
outStrings = append(outStrings, fmt.Sprintf("email=%s\tusername=%s\tpassword=%s\n",
|
||||
greppableValue(c.Email), greppableValue(c.Username), greppableValue(c.Password)))
|
||||
}
|
||||
data = []byte(strings.Join(outStrings, ""))
|
||||
default:
|
||||
return errors.New("unsupported file type")
|
||||
}
|
||||
@@ -65,6 +72,12 @@ func WriteToFile(results sqlite.DehashedResults, outputFile string, fileType fil
|
||||
outStrings = append(outStrings, out)
|
||||
}
|
||||
data = []byte(strings.Join(outStrings, ""))
|
||||
case files.GREPPABLE:
|
||||
var outStrings []string
|
||||
for _, r := range result {
|
||||
outStrings = append(outStrings, dehashedResultGreppable(r)+"\n")
|
||||
}
|
||||
data = []byte(strings.Join(outStrings, ""))
|
||||
default:
|
||||
return errors.New("unsupported file type")
|
||||
}
|
||||
@@ -73,8 +86,8 @@ func WriteToFile(results sqlite.DehashedResults, outputFile string, fileType fil
|
||||
return err
|
||||
}
|
||||
|
||||
filePath := fmt.Sprintf("%s.%s", outputFile, fileType)
|
||||
return ioutil.WriteFile(filePath, data, 0644)
|
||||
filePath := fmt.Sprintf("%s.%s", outputFile, fileType.String())
|
||||
return os.WriteFile(filePath, data, 0644)
|
||||
}
|
||||
|
||||
// WriteQueryResultsToFile writes query results to a file in the specified format
|
||||
@@ -121,6 +134,22 @@ func WriteQueryResultsToFile(results []map[string]interface{}, outputFile string
|
||||
outStrings = append(outStrings, strings.Join(rowStrings, "\n")+"\n\n")
|
||||
}
|
||||
data = []byte(strings.Join(outStrings, ""))
|
||||
case files.GREPPABLE:
|
||||
var outStrings []string
|
||||
for _, r := range results {
|
||||
keys := make([]string, 0, len(r))
|
||||
for k := range r {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
rowStrings := make([]string, 0, len(keys))
|
||||
for _, k := range keys {
|
||||
rowStrings = append(rowStrings, fmt.Sprintf("%s=%s", k, greppableAnyValue(r[k])))
|
||||
}
|
||||
outStrings = append(outStrings, strings.Join(rowStrings, "\t")+"\n")
|
||||
}
|
||||
data = []byte(strings.Join(outStrings, ""))
|
||||
default:
|
||||
return errors.New("unsupported file type")
|
||||
}
|
||||
@@ -133,6 +162,55 @@ func WriteQueryResultsToFile(results []map[string]interface{}, outputFile string
|
||||
return os.WriteFile(filePath, data, 0644)
|
||||
}
|
||||
|
||||
func dehashedResultGreppable(r sqlite.Result) string {
|
||||
fields := []string{
|
||||
"id=" + greppableValue(r.DehashedId),
|
||||
"email=" + greppableValue(strings.Join(r.Email, ",")),
|
||||
"ip_address=" + greppableValue(strings.Join(r.IpAddress, ",")),
|
||||
"username=" + greppableValue(strings.Join(r.Username, ",")),
|
||||
"password=" + greppableValue(strings.Join(r.Password, ",")),
|
||||
"hashed_password=" + greppableValue(strings.Join(r.HashedPassword, ",")),
|
||||
"hash_type=" + greppableValue(r.HashType),
|
||||
"name=" + greppableValue(strings.Join(r.Name, ",")),
|
||||
"vin=" + greppableValue(strings.Join(r.Vin, ",")),
|
||||
"license_plate=" + greppableValue(strings.Join(r.LicensePlate, ",")),
|
||||
"url=" + greppableValue(strings.Join(r.Url, ",")),
|
||||
"social=" + greppableValue(strings.Join(r.Social, ",")),
|
||||
"cryptocurrency_address=" + greppableValue(strings.Join(r.CryptoCurrencyAddress, ",")),
|
||||
"address=" + greppableValue(strings.Join(r.Address, ",")),
|
||||
"phone=" + greppableValue(strings.Join(r.Phone, ",")),
|
||||
"company=" + greppableValue(strings.Join(r.Company, ",")),
|
||||
"database_name=" + greppableValue(r.DatabaseName),
|
||||
}
|
||||
return strings.Join(fields, "\t")
|
||||
}
|
||||
|
||||
func greppableAnyValue(value interface{}) string {
|
||||
switch v := value.(type) {
|
||||
case nil:
|
||||
return ""
|
||||
case []string:
|
||||
return greppableValue(strings.Join(v, ","))
|
||||
case []interface{}:
|
||||
values := make([]string, 0, len(v))
|
||||
for _, item := range v {
|
||||
values = append(values, fmt.Sprintf("%v", item))
|
||||
}
|
||||
return greppableValue(strings.Join(values, ","))
|
||||
case []byte:
|
||||
return greppableValue(string(v))
|
||||
default:
|
||||
return greppableValue(fmt.Sprintf("%v", v))
|
||||
}
|
||||
}
|
||||
|
||||
func greppableValue(value string) string {
|
||||
value = strings.ReplaceAll(value, "\r", " ")
|
||||
value = strings.ReplaceAll(value, "\n", " ")
|
||||
value = strings.ReplaceAll(value, "\t", " ")
|
||||
return strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
func WriteWhoIsHistoryToFile(results []sqlite.HistoryRecord, outputFile string, fileType files.FileType) error {
|
||||
var data []byte
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user