etc~ scripts and random things |
| git clone https://github.com/djnnvx/etc.git |
| log | files | refs | archive |
main.go (2778B)
1 package main 2 3 import ( 4 "github.com/spf13/cobra" 5 6 "evil.djnn.sh/djnn/maildigger/dkim" 7 8 "bufio" 9 "fmt" 10 "net" 11 "os" 12 ) 13 14 const version = "0.0.2" 15 const ASCII_ART = ` 16 17 .-. 18 /'v'\ maildigger 19 (/ \) ~djnn.sh 20 ==='="="===< 21 |_| v0.0.2 22 23 s/o vsim<3 24 hack the planet, 25 travel the world . . . 26 ----------------------------------------------------------------------------- 27 DNS scrapping tool to recover DKIM 28 records & enum DNS TXT records 29 30 => https://evil.djnn.sh/etc/file/pentest/recon/maildigger/README.md.html <= 31 ----------------------------------------------------------------------------- 32 33 ` 34 35 var ( 36 domainsFilepath string 37 nameserver string 38 39 domain string 40 41 maxLenDKIM int32 42 maxLenSPF int32 43 ) 44 45 var rootCmd = &cobra.Command{ 46 Use: "maildigger", 47 Short: "simple cli to scrape DKIM or SPF records", 48 Long: ASCII_ART, 49 Version: version, 50 Run: func(cmd *cobra.Command, args []string) { 51 println(ASCII_ART) /* why make hacking CLIs if you cant print silly ascii art ? */ 52 53 if domainsFilepath == "" { 54 println("[!] error: please specify domain.") 55 os.Exit(1) 56 } 57 58 file, err := os.Open(domainsFilepath) 59 if err != nil { 60 panic(err) 61 } 62 defer file.Close() 63 64 domains := make([]string, 1) 65 scanner := bufio.NewScanner(file) 66 for scanner.Scan() { 67 domains = append(domains, scanner.Text()) 68 } 69 70 if err := scanner.Err(); err != nil { 71 panic(err) 72 } 73 fmt.Printf("[+] Loaded %d domains...\n", len(domains)) 74 75 dkimRunner := dkim.DkimRunner{ 76 DnsServer: nameserver, 77 Domains: domains, 78 } 79 80 err = dkimRunner.Run(maxLenDKIM) 81 if err != nil { 82 println("[!] Error while recovering DKIM records") 83 panic(err) 84 } 85 86 println("[+] DKIM check done.") 87 88 }, 89 } 90 91 var getTxtCmd = &cobra.Command{ 92 Use: "get-txt", 93 Short: "retrieves TXT records", 94 Long: ASCII_ART, 95 Version: version, 96 Run: func(cmd *cobra.Command, args []string) { 97 if domain == "" { 98 println("[!] You need to check a domain name") 99 os.Exit(1) 100 } 101 102 txts, err := net.LookupTXT(domain) 103 if err != nil { 104 panic(err) 105 } 106 107 for _, txt := range txts { 108 fmt.Printf("TXT[%s] => %s\n", domain, txt) 109 } 110 111 }, 112 } 113 114 func main() { 115 116 rootCmd.Flags().StringVarP(&nameserver, "nameserver", "n", "8.8.8.8", "DNS nameserver") 117 rootCmd.Flags().StringVarP(&domainsFilepath, "domains", "d", "domains.txt", "file containing list of domains (line by line)") 118 rootCmd.Flags().Int32VarP(&maxLenDKIM, "dkim-max-len", "", 128, "DKIM key max size") 119 120 getTxtCmd.Flags().StringVarP(&domain, "domain", "d", "djnn.crossbone.cc", "DNS nameserver") 121 122 rootCmd.AddCommand(getTxtCmd) 123 124 rootCmd.ExecuteC() 125 }