(site string, path string, customParams *map[string]string)
| 269 | } |
| 270 | |
| 271 | func (p *Phishlet) LoadFromFile(site string, path string, customParams *map[string]string) error { |
| 272 | p.Clear() |
| 273 | |
| 274 | c := viper.New() |
| 275 | c.SetConfigType("yaml") |
| 276 | c.SetConfigFile(path) |
| 277 | |
| 278 | err := c.ReadInConfig() |
| 279 | if err != nil { |
| 280 | return err |
| 281 | } |
| 282 | |
| 283 | p.Name = site |
| 284 | p.Path = path |
| 285 | p.ParentName = "" |
| 286 | p.Author = c.GetString("author") |
| 287 | p.RedirectUrl = c.GetString("redirect_url") |
| 288 | p.Version, err = p.parseVersion(c.GetString("min_ver")) |
| 289 | if err != nil { |
| 290 | return err |
| 291 | } |
| 292 | if !p.isVersionHigherEqual(&p.Version, "2.2.0") { |
| 293 | return fmt.Errorf("this phishlet is incompatible with current version of evilginx.\nplease do the following modifications to update it:\n\n" + |
| 294 | "- in each `sub_filters` item change `hostname` to `triggers_on`\n" + |
| 295 | "- in each `sub_filters` item change `sub` to `orig_sub`\n" + |
| 296 | "- rename section `user_regex` to `username`\n" + |
| 297 | "- rename section `pass_regex` to `password`\n" + |
| 298 | "- rename field `re` in both `username` and `password` to `search`\n" + |
| 299 | "- field `key` in both `username` and `password` must be a regexp by default\n" + |
| 300 | "- move `username` and `password` into new `credentials` section\n" + |
| 301 | "- add `type` field to `username` and `password` with value 'post' or 'json'\n" + |
| 302 | "- change `min_ver` to at least `2.2.0`\n" + |
| 303 | "you can find the phishlet 2.2.0 file format documentation here: https://github.com/kgretzky/evilginx2/wiki/Phishlet-File-Format-(2.2.0)") |
| 304 | } |
| 305 | if !p.isVersionHigherEqual(&p.Version, "2.3.0") { |
| 306 | return fmt.Errorf("this phishlet is incompatible with current version of evilginx.\nplease do the following modifications to update it:\n\n" + |
| 307 | "- replace `landing_path` with `login` section\n" + |
| 308 | "- change `min_ver` to at least `2.3.0`\n" + |
| 309 | "you can find the phishlet 2.3.0 file format documentation here: https://github.com/kgretzky/evilginx2/wiki/Phishlet-File-Format-(2.3.0)") |
| 310 | } |
| 311 | |
| 312 | fp := ConfigPhishlet{} |
| 313 | err = c.Unmarshal(&fp) |
| 314 | if err != nil { |
| 315 | return err |
| 316 | } |
| 317 | |
| 318 | if fp.Params != nil { |
| 319 | if len(*fp.Params) > 0 { |
| 320 | p.isTemplate = true |
| 321 | } |
| 322 | if customParams != nil { |
| 323 | prequired := make(map[string]string) |
| 324 | pall := make(map[string]string) |
| 325 | params := make(map[string]string) |
| 326 | for _, param := range *fp.Params { |
| 327 | val := "" |
| 328 | if param.Default != nil { |
no test coverage detected