wappalyzergo icon indicating copy to clipboard operation
wappalyzergo copied to clipboard

update fingerprints_data.json problem when use wappalyzergo as library

Open LazyMaple opened this issue 2 years ago • 0 comments

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
}

LazyMaple avatar Jul 10 '23 06:07 LazyMaple