forked from gaulliath/operative-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_cookies.go
79 lines (67 loc) · 1.69 KB
/
get_cookies.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
package cookies
import (
"github.com/Oni-kuki/operative-framework/session"
)
type GetCookiesModule struct {
session.SessionModule
sess *session.Session `json:"-"`
Stream *session.Stream `json:"-"`
}
func PushGetCookiesModule(s *session.Session) *GetCookiesModule {
mod := GetCookiesModule{
sess: s,
Stream: &s.Stream,
}
mod.CreateNewParam("TARGET", "e.g: 127.0.0.1", "", true, session.BOOL)
return &mod
}
func (module *GetCookiesModule) Name() string {
return "get.cookies"
}
func (module *GetCookiesModule) Description() string {
return "Get cookie from http header"
}
func (module *GetCookiesModule) Author() string {
return "Tristan Granier"
}
func (module *GetCookiesModule) GetType() []string {
return []string{
session.T_TARGET_URL,
session.T_TARGET_HEADER,
}
}
func (module *GetCookiesModule) GetInformation() session.ModuleInformation {
information := session.ModuleInformation{
Name: module.Name(),
Description: module.Description(),
Author: module.Author(),
Type: module.GetType(),
Parameters: module.Parameters,
}
return information
}
func (module *GetCookiesModule) Start() {
trg, err := module.GetParameter("TARGET")
if err != nil {
module.sess.Stream.Error(err.Error())
return
}
target, err := module.sess.GetTarget(trg.Value)
if err != nil {
module.sess.Stream.Error(err.Error())
return
}
client := module.sess.Client
res, err := client.Perform("GET", target.GetName())
if err != nil {
module.sess.NewEvent(session.ERROR_MODULE, err.Error())
return
}
cookies := res.Header.Get("Set-Cookie")
if cookies != "" {
result := target.NewResult()
result.Set("cookie", cookies)
result.Save(module, target)
}
return
}