github.com/chainreactors/fingers@v1.2.1/wappalyzer/wappalyzergo_test.go (about) 1 package wappalyzer 2 3 import ( 4 "testing" 5 6 "github.com/chainreactors/fingers/resources" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestCookiesDetect(t *testing.T) { 11 wappalyzer, err := NewWappalyzeEngine(resources.WappalyzerData) 12 require.Nil(t, err, "could not create wappalyzer") 13 14 matches := wappalyzer.Fingerprint(map[string][]string{ 15 "Set-Cookie": {"_uetsid=ABCDEF"}, 16 }, []byte("")) 17 18 require.Contains(t, matches, "microsoft advertising", "Could not get correct match") 19 20 t.Run("position", func(t *testing.T) { 21 wappalyzerClient, _ := NewWappalyzeEngine(resources.WappalyzerData) 22 23 fingerprints := wappalyzerClient.Fingerprint(map[string][]string{ 24 "Set-Cookie": {"path=/; jsessionid=111; path=/, jsessionid=111;"}, 25 }, []byte("")) 26 fingerprints1 := wappalyzerClient.Fingerprint(map[string][]string{ 27 "Set-Cookie": {"jsessionid=111; path=/, XSRF-TOKEN=; expires=test, path=/ laravel_session=eyJ*"}, 28 }, []byte("")) 29 30 require.Contains(t, fingerprints, "java", "could not get correct fingerprints") 31 require.Contains(t, fingerprints1, "java", "could not get correct fingerprints") 32 require.Contains(t, fingerprints1, "laravel", "could not get correct fingerprints") 33 }) 34 } 35 36 func TestHeadersDetect(t *testing.T) { 37 wappalyzer, err := NewWappalyzeEngine(resources.WappalyzerData) 38 require.Nil(t, err, "could not create wappalyzer") 39 40 matches := wappalyzer.Fingerprint(map[string][]string{ 41 "Server": {"now"}, 42 }, []byte("")) 43 44 require.Contains(t, matches, "vercel", "Could not get correct match") 45 } 46 47 func TestBodyDetect(t *testing.T) { 48 wappalyzer, err := NewWappalyzeEngine(resources.WappalyzerData) 49 require.Nil(t, err, "could not create wappalyzer") 50 51 t.Run("meta", func(t *testing.T) { 52 matches := wappalyzer.Fingerprint(map[string][]string{}, []byte(`<html> 53 <head> 54 <meta name="generator" content="mura cms 1"> 55 </head> 56 </html>`)) 57 require.Contains(t, matches, "mura cms", "Could not get correct match") 58 }) 59 60 t.Run("html-implied", func(t *testing.T) { 61 matches := wappalyzer.Fingerprint(map[string][]string{}, []byte(`<html data-ng-app="rbschangeapp"> 62 <head> 63 </head> 64 <body> 65 </body> 66 </html>`)) 67 require.Contains(t, matches, "angularjs", "Could not get correct implied match") 68 require.Contains(t, matches, "proximis unified commerce", "Could not get correct match") 69 }) 70 }