forked from vulsio/go-exploitdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
exploit.go
120 lines (106 loc) · 4.24 KB
/
exploit.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package models
import (
"time"
)
var offensiveSecurityDateFormat = "2006-01-02"
// ExploitType :
type ExploitType string
var (
// OffensiveSecurityType : https://www.exploit-db.com/
OffensiveSecurityType ExploitType = "OffensiveSecurity"
)
// Exploit :
type Exploit struct {
ID int64 `json:",omitempty"`
ExploitType ExploitType `json:"exploit_type"`
ExploitUniqueID string `json:"exploit_unique_id"`
URL string `json:"url"`
Description string `json:"description"`
CveID string `json:"cve_id"`
OffensiveSecurity *OffensiveSecurity `json:"offensive_security"`
}
// OffensiveSecurity : https://www.exploit-db.com/
type OffensiveSecurity struct {
ID int64 `json:",omitempty"`
ExploitID int64 `sql:"type:bigint REFERENCES exploits(id)" json:",omitempty"`
ExploitUniqueID string `json:"exploit_unique_id"`
Document *Document `json:"document"`
ShellCode *ShellCode `json:"shell_code"`
Paper *Paper `json:"paper"`
}
// Document :
// https://github.com/offensive-security/exploitdb/tree/master/exploits
type Document struct {
OffensiveSecurityID int64 `sql:"type:bigint REFERENCES offensive_securities(id)" json:",omitempty"`
ExploitUniqueID string `csv:"id" json:"exploit_unique_id"`
DocumentURL string `csv:"file" json:"document_url"`
Description string `csv:"description" json:"description"`
Date OffensiveSecurityTime `csv:"date" json:"date"`
Author string `csv:"author" json:"author"`
// docs local remote webapps
Type string `csv:"type" json:"type"`
Platform string `csv:"platform" json:"palatform"`
Port string `csv:"port" json:"port"`
}
// ShellCode :
// https://github.com/offensive-security/exploitdb/tree/master/shellcodes
type ShellCode struct {
OffensiveSecurityID int64 `sql:"type:bigint REFERENCES offensive_securities(id)" json:",omitempty"`
ExploitUniqueID string `csv:"id" json:"exploit_unique_id"`
ShellCodeURL string `csv:"file" json:"shell_code_url"`
Description string `csv:"description" json:"description"`
Date OffensiveSecurityTime `csv:"date" json:"date"`
Author string `csv:"author" json:"author"`
Platform string `csv:"platform" json:"platform"`
}
// Paper :
// https://github.com/offensive-security/exploitdb-papers
type Paper struct {
OffensiveSecurityID int64 `sql:"type:bigint REFERENCES offensive_securities(id)" json:",omitempty"`
ExploitUniqueID string `csv:"id" json:"exploit_unique_id"`
PaperURL string `csv:"file" json:"paper_url"`
Description string `csv:"description" json:"description"`
Date OffensiveSecurityTime `csv:"date" json:"date"`
Author string `csv:"author" json:"author"`
Platform string `csv:"platform" json:"platform"`
Language string `csv:"language" json:"language"`
}
// MitreXML :
// http://cve.mitre.org/cve/cvrf.html
type MitreXML struct {
Vulnerability []struct {
CVE string `xml:"CVE"`
References []struct {
// External, Self
AttrType string `xml:"Type,attr"`
URL string `xml:"URL"`
Description string `xml:"Description"`
} `xml:"References>Reference"`
} `xml:"Vulnerability"`
}
// GithubJSON :
type GithubJSON struct {
TotalCount int `json:"total_count"`
Items []struct {
Name string `json:"name"`
Path string `json:"path"`
} `json:"items"`
}
// OffensiveSecurityTime :
type OffensiveSecurityTime struct {
time.Time
}
// String :
// You could also use the standard Stringer interface
func (date *OffensiveSecurityTime) String() string {
return date.String() // Redundant, just for example
}
// UnmarshalCSV :
// Convert the CSV string as internal date
func (date *OffensiveSecurityTime) UnmarshalCSV(csv string) (err error) {
date.Time, err = time.Parse(offensiveSecurityDateFormat, csv)
if err != nil {
return err
}
return nil
}