|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "crypto/tls" |
| 5 | + "encoding/json" |
| 6 | + "flag" |
| 7 | + "fmt" |
| 8 | + "io/ioutil" |
| 9 | + "net/http" |
| 10 | + "net/http/cookiejar" |
| 11 | + "os" |
| 12 | + "strconv" |
| 13 | + "strings" |
| 14 | +) |
| 15 | + |
| 16 | +var justsuccess bool = false |
| 17 | +var successlist []string |
| 18 | +var httpcc http.Client |
| 19 | + |
| 20 | +func main() { |
| 21 | + |
| 22 | + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} |
| 23 | + |
| 24 | + address := flag.String("url", "", "url address https://google.com") |
| 25 | + gitfile := flag.Bool("git", false, "try git lists") |
| 26 | + Sensfile := flag.Bool("sens", false, "try sens lists") |
| 27 | + Envfile := flag.Bool("env", false, "try env lists") |
| 28 | + Shellfile := flag.Bool("shell", false, "try shellfile lists") |
| 29 | + Allfile := flag.Bool("all", false, "try all lists") |
| 30 | + success := flag.Bool("v", false, "show success result only") |
| 31 | + flag.Parse() |
| 32 | + if !*gitfile && !*Sensfile && !*Envfile && !*Shellfile { |
| 33 | + |
| 34 | + *Allfile = true |
| 35 | + } |
| 36 | + if *Allfile { |
| 37 | + *gitfile = true |
| 38 | + *Sensfile = true |
| 39 | + *gitfile = true |
| 40 | + *Envfile = true |
| 41 | + } |
| 42 | + if *success { |
| 43 | + justsuccess = true |
| 44 | + } |
| 45 | + if *address == "" { |
| 46 | + println("please set url with --url or -h for help") |
| 47 | + } |
| 48 | + path, err := os.Getwd() |
| 49 | + if err != nil { |
| 50 | + println(err.Error()) |
| 51 | + return |
| 52 | + } |
| 53 | + |
| 54 | + jsonFile, err := os.Open(path + "/SensitiveList.json") |
| 55 | + if err != nil { |
| 56 | + fmt.Printf("%s", "Can not read json file") |
| 57 | + } |
| 58 | + byteValue, _ := ioutil.ReadAll(jsonFile) |
| 59 | + |
| 60 | + // we initialize our Users array |
| 61 | + paths := SensitiveList{} |
| 62 | + |
| 63 | + // we unmarshal our byteArray which contains our |
| 64 | + // jsonFile's content into 'users' which we defined above |
| 65 | + json.Unmarshal(byteValue, &paths) |
| 66 | + defer jsonFile.Close() |
| 67 | + jar, err := cookiejar.New(nil) |
| 68 | + if err != nil { |
| 69 | + println(err.Error()) |
| 70 | + } |
| 71 | + |
| 72 | + httpcc = http.Client{Jar: jar} |
| 73 | + if *gitfile { |
| 74 | + for i := 0; i < len(paths.Git); i++ { |
| 75 | + checkurl(*address+paths.Git[i].Path, paths.Git[i].Content, paths.Git[i].Lentgh) |
| 76 | + } |
| 77 | + } |
| 78 | + if *Sensfile { |
| 79 | + for i := 0; i < len(paths.Sensitive); i++ { |
| 80 | + checkurl(*address+paths.Sensitive[i].Path, paths.Sensitive[i].Content, paths.Sensitive[i].Lentgh) |
| 81 | + } |
| 82 | + } |
| 83 | + if *Envfile { |
| 84 | + for i := 0; i < len(paths.Env); i++ { |
| 85 | + checkurl(*address+paths.Env[i].Path, paths.Env[i].Content, paths.Env[i].Lentgh) |
| 86 | + } |
| 87 | + } |
| 88 | + if *Shellfile { |
| 89 | + for i := 0; i < len(paths.Shell); i++ { |
| 90 | + checkurl(*address+paths.Shell[i].Path, paths.Shell[i].Content, paths.Shell[i].Lentgh) |
| 91 | + } |
| 92 | + } |
| 93 | + fmt.Printf("%d %s", len(successlist), " Found") |
| 94 | + |
| 95 | + if len(successlist) > 0 { |
| 96 | + |
| 97 | + for _, v := range successlist { |
| 98 | + println(v) |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | +} |
| 103 | + |
| 104 | +func checkurl(url string, content string, len string) { |
| 105 | + |
| 106 | + resp, err := httpcc.Head(url) |
| 107 | + |
| 108 | + if err != nil { |
| 109 | + println(err.Error()) |
| 110 | + resp, err = httpcc.Get(url) |
| 111 | + |
| 112 | + } |
| 113 | + if err == nil { |
| 114 | + if !justsuccess { |
| 115 | + |
| 116 | + fmt.Printf("Checking '%s', '%s',\n", url, resp.Status) |
| 117 | + } |
| 118 | + if resp.StatusCode == 200 { |
| 119 | + if resp.Header.Get("Content-Type") != "" { |
| 120 | + respcontetnt := resp.Header.Get("Content-Type") |
| 121 | + var ignore []string = []string{} |
| 122 | + if strings.Contains(content, "#") { |
| 123 | + arrayslpit := strings.Split(content, "#") |
| 124 | + for _, i := range arrayslpit { |
| 125 | + if i != "" { |
| 126 | + ignore = append(ignore, i) |
| 127 | + } |
| 128 | + |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + if respcontetnt == content || content == "*" || checkifinarry(ignore, respcontetnt) { |
| 133 | + if len == "*" { |
| 134 | + |
| 135 | + fmt.Printf("Success '%s', '%s', '%s',\n", url, resp.Status, resp.Header.Get("Content-Type")) |
| 136 | + successlist = append(successlist, url) |
| 137 | + } else { |
| 138 | + lennumber, err := strconv.ParseInt(len, 0, 64) |
| 139 | + if err == nil { |
| 140 | + if lennumber >= resp.ContentLength { |
| 141 | + fmt.Printf("Success '%s', '%s', '%s',\n", url, resp.Status, resp.Header.Get("Content-Type")) |
| 142 | + successlist = append(successlist, url) |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + } |
| 147 | + |
| 148 | + } |
| 149 | + |
| 150 | + } |
| 151 | + |
| 152 | + } else { |
| 153 | + //fmt.Printf("'%s', '%s',\n", url, resp.Status) |
| 154 | + } |
| 155 | + |
| 156 | + } |
| 157 | +} |
| 158 | +func checkifinarry(array []string, check string) bool { |
| 159 | + if len(array) == 0 { |
| 160 | + return false |
| 161 | + } |
| 162 | + for _, i2 := range array { |
| 163 | + if strings.Contains(check, i2) { |
| 164 | + return false |
| 165 | + } |
| 166 | + } |
| 167 | + return true |
| 168 | +} |
| 169 | + |
| 170 | +type Sensitive struct { |
| 171 | + Path string `json:"path"` |
| 172 | + Content string `json:"content"` |
| 173 | + Lentgh string `json:"lentgh"` |
| 174 | +} |
| 175 | +type SensitiveList struct { |
| 176 | + Sensitive []Sensitive `json:"Sensitive"` |
| 177 | + Git []Sensitive `json:"Gitfile"` |
| 178 | + Env []Sensitive `json:Env` |
| 179 | + Shell []Sensitive `json:shell` |
| 180 | +} |
0 commit comments