开源 网站目录扫描器源码

Sky

0x04|共鸣者
07
121
78
奇源币
0
管理成员
版主
VIP
代码:
package main

import (
"bufio"
"fmt"
"net/http"
"os"
"strings"
)

func checkDirectory(url string, direcotry string, showNotFound bool) {
fullURL := fmt.Sprintf("%s/%s", url, direcotry)
response, err := http.get(fullURL)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}

defer response.Body.Close()

if response.StatusCode == http.StatusOK {
fmt.Printf("(200) Found: %s\n", fullURL)
} else if response.StatusCode == http.StatusNotFound && showNotFound {
fmt.Printf("(404) Not Found: %s\n", fullURL)
}
}

func scanWithWordlist(url string, wordlist string, showNotFound bool) {
file, err := os.Open(wordlist)
if err != nil {
fmt.Printf("Failed to Open Wordlists: %v\n", err)
return
}
defer file.Close()

scanner := bufio.NewScanner(file)
fmt.Println("\nScanning with Wordlists: ")
for scanner.Scan() {
directory := scanner.Text()
checkDirectory(url, direcotry, showNotFound)
}

if err := scanner.Err(); err != nil {
fmt.Printf("Failed to read Wordlists: %v\n", err)
}
}

func main() {
var url, wordlist string
fmt.Printf("Enter the URL: ")
fmt.Scanln(&url)

if !strings.HasPrefix(url, "https") {
url = "https://" + url
}

fmt.Print("Enter the Wordlist Path: ")
fmt.Scanln(&wordlist)

var disableNotFound string
fmt.print("Do you want to remove (404) Not found Errors? (y/n): ")
fmt.Scanln(&disableNotFound)
showNotFound := strings.ToLower(disableNotFound) != "y"

scanWithWordlist(url, wordlist, showNotFound)
}
 
后退
顶部