Skip to content

Commit aa6734b

Browse files
made it a single function
1 parent 173d8df commit aa6734b

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

config/config.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,7 @@ func NewRemoteExploit(implemented ImplementedFeatures, extype ExploitType, suppo
168168
product []string, cpe []string, cve string, protocol string, defaultPort int,
169169
) *Config {
170170
newConf := new(Config)
171-
172-
joinedProducts := strings.Join(product, "/")
173-
if joinedProducts == vendor {
174-
newConf.Product = vendor // prevents awkward duplicate word output such as "Validating Product Product"
175-
} else {
176-
newConf.Product = fmt.Sprintf("%s %s", vendor, joinedProducts)
177-
}
178-
171+
newConf.Product = deDupeProductName(product, vendor)
179172
newConf.InitFlagsStructs()
180173
newConf.Impl = implemented
181174
newConf.ExType = extype
@@ -191,19 +184,21 @@ func NewRemoteExploit(implemented ImplementedFeatures, extype ExploitType, suppo
191184
return newConf
192185
}
193186

194-
// Defines a new remote exploit and associates with CVE/Product/Protocol metadata. Usage example:.
195-
func NewLocalExploit(implemented ImplementedFeatures, extype ExploitType, supportedC2 []c2.Impl, vendor string,
196-
product []string, cpe []string, cve string,
197-
) *Config {
198-
newConf := new(Config)
199-
187+
func deDupeProductName(product []string, vendor string) string {
200188
joinedProducts := strings.Join(product, "/")
201189
if joinedProducts == vendor {
202-
newConf.Product = vendor // prevents awkward duplicate word output such as "Validating Product Product"
190+
return vendor
203191
} else {
204-
newConf.Product = fmt.Sprintf("%s %s", vendor, joinedProducts)
192+
return fmt.Sprintf("%s %s", vendor, joinedProducts)
205193
}
194+
}
206195

196+
// Defines a new remote exploit and associates with CVE/Product/Protocol metadata. Usage example:.
197+
func NewLocalExploit(implemented ImplementedFeatures, extype ExploitType, supportedC2 []c2.Impl, vendor string,
198+
product []string, cpe []string, cve string,
199+
) *Config {
200+
newConf := new(Config)
201+
newConf.Product = deDupeProductName(product, vendor)
207202
newConf.InitFlagsStructs()
208203
newConf.Impl = implemented
209204
newConf.ExType = extype

0 commit comments

Comments
 (0)