projectdiscovery / wappalyzergo

A high performance go implementation of Wappalyzer Technology Detection Library
MIT License
723 stars 110 forks source link

update fingerprints_data.json problem when use wappalyzergo as library #52

Open LazyMaple opened 1 year ago

LazyMaple commented 1 year ago

hi, i use wappalyzergo as library,the fingerprints_data.json file is bound to the repo code. When I update the json file, I need to update the whole golang project, I think it would be nice to have a function on the Wappalyze object to define fingerprints, In this way, when used as a function library, it avoids constantly updating the entire project code in order to update the data file

image
// now I use some tricks to solve this problem
// the wappalyzerFileBytes define from outter resource, such as cloud object storage service

//go:linkname compileFingerprint github.com/projectdiscovery/wappalyzergo.compileFingerprint
func compileFingerprint(fingerprint *wappalyzer.Fingerprint) *wappalyzer.CompiledFingerprint

type WappalyzeWithUnsafe struct {
    fingerprints unsafe.Pointer
}

func NewWappalyzerClient() *wappalyzer.Wappalyze {
    EnsureWappalyzerFile()

    wappalyzerClient := new(wappalyzer.Wappalyze)
    wappalyzerClientCompiledFingerprints := &wappalyzer.CompiledFingerprints{
        Apps: make(map[string]*wappalyzer.CompiledFingerprint),
    }
    var fingerprintsStruct wappalyzer.Fingerprints
    json.Unmarshal([]byte(wappalyzerFileBytes), &fingerprintsStruct)

    for i, fingerprint := range fingerprintsStruct.Apps {
        wappalyzerClientCompiledFingerprints.Apps[i] = compileFingerprint(fingerprint)
    }

    wappalyzeUnsafe := (*WappalyzeWithUnsafe)(unsafe.Pointer(wappalyzerClient))
    wappalyzeUnsafe.fingerprints = unsafe.Pointer(wappalyzerClientCompiledFingerprints)

    return wappalyzerClient
}