mirror of https://github.com/nyancrimew/goop.git
Add the ability to pass in an entire list of domains
This commit is contained in:
parent
def3cc683a
commit
0f7fb8ae6c
21
cmd/goop.go
21
cmd/goop.go
|
@ -8,24 +8,33 @@ import (
|
|||
)
|
||||
|
||||
var force bool
|
||||
var list bool
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "goop",
|
||||
Use: "goop",
|
||||
Short: "goop is a very fast tool to grab sources from exposed .git folders",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var dir string
|
||||
if len(args) >= 2 {
|
||||
dir = args[1]
|
||||
}
|
||||
if err := goop.Clone(args[0], dir, force); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
if list {
|
||||
if err := goop.CloneList(args[0], dir, force); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
if err := goop.Clone(args[0], dir, force); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&force, "force", "f",false, "overrides DIR if it already exists")
|
||||
rootCmd.PersistentFlags().BoolVarP(&force, "force", "f", false, "overrides DIR if it already exists")
|
||||
rootCmd.PersistentFlags().BoolVarP(&list, "list", "l", false, "allows you to supply the name of a file containing a list of domain names instead of just one domain")
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package goop
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
|
@ -45,6 +46,38 @@ func waitForQueue(queue chan string) {
|
|||
close(queue)
|
||||
}
|
||||
|
||||
func CloneList(listFile, baseDir string, force bool) error {
|
||||
lf, err := os.Open(listFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer lf.Close()
|
||||
|
||||
listScan := bufio.NewScanner(lf)
|
||||
for listScan.Scan() {
|
||||
u := listScan.Text()
|
||||
if u == "" {
|
||||
continue
|
||||
}
|
||||
dir := baseDir
|
||||
if dir != "" {
|
||||
parsed, err := url.Parse(u)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %s\n", err)
|
||||
continue
|
||||
}
|
||||
dir = utils.Url(dir, parsed.Host)
|
||||
}
|
||||
fmt.Printf("[-] Downloading %s to %s\n", u, dir)
|
||||
if err := Clone(u, dir, force); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %s\n", err)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Clone(u, dir string, force bool) error {
|
||||
baseUrl := strings.TrimSuffix(u, "/")
|
||||
baseUrl = strings.TrimSuffix(baseUrl, "/HEAD")
|
||||
|
|
Loading…
Reference in New Issue