forked from projectdiscovery/wappalyzergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwappalyzergo_test.go
91 lines (72 loc) · 3.12 KB
/
wappalyzergo_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package wappalyzer
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCookiesDetect(t *testing.T) {
wappalyzer, err := New()
require.Nil(t, err, "could not create wappalyzer")
matches := wappalyzer.Fingerprint(map[string][]string{
"Set-Cookie": {"_uetsid=ABCDEF"},
}, []byte(""))
require.Contains(t, matches, "Microsoft Advertising", "Could not get correct match")
t.Run("position", func(t *testing.T) {
wappalyzerClient, _ := New()
fingerprints := wappalyzerClient.Fingerprint(map[string][]string{
"Set-Cookie": {"path=/; jsessionid=111; path=/, jsessionid=111;"},
}, []byte(""))
fingerprints1 := wappalyzerClient.Fingerprint(map[string][]string{
"Set-Cookie": {"jsessionid=111; path=/, XSRF-TOKEN=; expires=test, path=/ laravel_session=eyJ*"},
}, []byte(""))
require.Equal(t, map[string]struct{}{"Java": {}}, fingerprints, "could not get correct fingerprints")
require.Equal(t, map[string]struct{}{"Java": {}, "Laravel": {}, "PHP": {}}, fingerprints1, "could not get correct fingerprints")
})
}
func TestHeadersDetect(t *testing.T) {
wappalyzer, err := New()
require.Nil(t, err, "could not create wappalyzer")
matches := wappalyzer.Fingerprint(map[string][]string{
"Server": {"now"},
}, []byte(""))
require.Contains(t, matches, "Vercel", "Could not get correct match")
}
func TestBodyDetect(t *testing.T) {
wappalyzer, err := New()
require.Nil(t, err, "could not create wappalyzer")
t.Run("meta", func(t *testing.T) {
matches := wappalyzer.Fingerprint(map[string][]string{}, []byte(`<html>
<head>
<meta name="generator" content="mura cms 1">
</head>
</html>`))
require.Contains(t, matches, "Mura CMS:1", "Could not get correct match")
})
t.Run("html-implied", func(t *testing.T) {
matches := wappalyzer.Fingerprint(map[string][]string{}, []byte(`<html data-ng-app="rbschangeapp">
<head>
</head>
<body>
</body>
</html>`))
require.Contains(t, matches, "AngularJS", "Could not get correct implied match")
require.Contains(t, matches, "PHP", "Could not get correct implied match")
require.Contains(t, matches, "Proximis Unified Commerce", "Could not get correct match")
})
}
func TestUniqueFingerprints(t *testing.T) {
fingerprints := newUniqueFingerprints()
fingerprints.setIfNotExists("test")
require.Equal(t, map[string]struct{}{"test": {}}, fingerprints.getValues(), "could not get correct values")
t.Run("linear", func(t *testing.T) {
fingerprints.setIfNotExists("new:2.3.5")
require.Equal(t, map[string]struct{}{"test": {}, "new:2.3.5": {}}, fingerprints.getValues(), "could not get correct values")
fingerprints.setIfNotExists("new")
require.Equal(t, map[string]struct{}{"test": {}, "new:2.3.5": {}}, fingerprints.getValues(), "could not get correct values")
})
t.Run("opposite", func(t *testing.T) {
fingerprints.setIfNotExists("another")
require.Equal(t, map[string]struct{}{"test": {}, "new:2.3.5": {}, "another": {}}, fingerprints.getValues(), "could not get correct values")
fingerprints.setIfNotExists("another:2.3.5")
require.Equal(t, map[string]struct{}{"test": {}, "new:2.3.5": {}, "another:2.3.5": {}}, fingerprints.getValues(), "could not get correct values")
})
}