diff --git a/cli/parser.go b/cli/parser.go
@@ -11,21 +11,63 @@ import (
func GetParser(opts *StandardOptions) *cobra.Command {
+ var osintCmd = &cobra.Command{
+ Use: "osint",
+ Short: "Run OSINT tools to retrieve IP addresses and interesting assets",
+ Long: "Runs subfinder & dnsx on all domains to find subdomains which are passed to httpx. Also runs google dorks.",
+ Args: cobra.MinimumNArgs(0),
+ Run: func(cmd *cobra.Command, args []string) {
+
+ if opts.OutDirName == "" && opts.TargetFilePath == "" {
+ fmt.Println("[!] Error: target cannot be empty. Please run with --target [something] or --file [something]")
+ fmt.Println("\nIf you're confused, feel free to use --help option. :)~")
+ os.Exit(1)
+ }
+
+ helpers.CheckProxy(opts.Proxy)
+ helpers.DisplayNetInfo()
+
+ if opts.OutDirName == "" || !helpers.Exists(opts.OutDirName) {
+ println("[!] collected assets will be sent to current working directory")
+ }
+
+ /*
+ createOutDirectory()
+ checkProxy()
+ displayNetInfo()
+
+ if targetPath == "" {
+ scanDomain(domain)
+ return
+ }
+
+ scanner := loadTargetFile()
+ defer scanner.Close()
+
+ for scanner.Scan() {
+ targetDomain := scanner.Text()
+ scanDomain(targetDomain)
+ }
+ */
+
+ },
+ }
+
var createDirectories = &cobra.Command{
Use: "create",
- Short: "create a work tree to perform scanning, OSINT, and other targets",
+ Short: "Create a work tree to perform scanning, OSINT, and other targets",
Long: "Set up a clean-cut architecture at the launch of your assessments",
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
- if opts.TargetName == "" {
- fmt.Println("[!] Error: target cannot be empty. Please run with --target [something]")
- fmt.Println("\nIf you're confused, feel free to use --help option. :)~")
- os.Exit(1)
- }
+ if opts.OutDirName == "" {
+ fmt.Println("[!] Error: target cannot be empty. Please run with --target [something]")
+ fmt.Println("\nIf you're confused, feel free to use --help option. :)~")
+ os.Exit(1)
+ }
- dirname := "./" + helpers.ReplaceWithHyphen(opts.TargetName)
- fmt.Println("[+] setting up directory architecture for ", dirname)
+ dirname := helpers.ReplaceWithHyphen(opts.OutDirName)
+ fmt.Println("[+] setting up directory architecture for", dirname)
_ = os.MkdirAll(dirname, 0775)
helpers.CreateDirectory(dirname, []helpers.Folder{
@@ -49,14 +91,16 @@ func GetParser(opts *StandardOptions) *cobra.Command {
defaults := GetDefaultOptions()
var rootCmd = createDirectories
+ rootCmd.Flags().StringVarP(&opts.OutDirName, "dir-name", "d", defaults.OutDirName, "Pentest target, will be the name of the directories created, for instance")
- rootCmd.Flags().StringVarP(&opts.TargetName, "target", "t", defaults.TargetName, "Pentest target, will be the name of the directories created, for instance")
- rootCmd.Flags().BoolVarP(&opts.RunDry, "dry", "d", defaults.RunDry, "Run a dry-run (test mode)")
- rootCmd.Flags().StringVarP(&opts.Proxy, "proxy", "p", defaults.Proxy, "Proxy URL (used for the tools supporting it. Other will prompt a warning msg)")
- rootCmd.Flags().BoolVarP(&opts.UseHttpInsecure, "insecure", "k", defaults.UseHttpInsecure, "Ignore SSL warnings and force http")
- rootCmd.Flags().Int32VarP(&opts.RateLimit, "rate-limit", "r", defaults.RateLimit, "Requests rate-limit (used for the tools supporting it. Other will prompt a warning msg)")
- rootCmd.Flags().StringVarP(&opts.WordlistPath, "wordlist", "w", defaults.WordlistPath, "Wordlist to use (if any)")
- rootCmd.Flags().StringVarP(&opts.TargetFilePath, "file", "f", defaults.TargetFilePath, "File containing list of targets (should be a list of IP Addresses or domains)")
+ rootCmd.AddCommand(osintCmd)
+ osintCmd.Flags().StringVarP(&opts.OutDirName, "dir-name", "d", defaults.OutDirName, "Pentest target, will be the name of the directories created, for instance")
+ osintCmd.Flags().StringVarP(&opts.Proxy, "proxy", "p", defaults.Proxy, "Proxy URL (used for the tools supporting it. Other will prompt a warning msg)")
+ osintCmd.Flags().BoolVarP(&opts.RunDry, "dry", "", defaults.RunDry, "Run a dry-run (test mode)")
+ osintCmd.Flags().BoolVarP(&opts.UseHttpInsecure, "insecure", "k", defaults.UseHttpInsecure, "Ignore SSL warnings and force http")
+ osintCmd.Flags().Int32VarP(&opts.RateLimit, "rate-limit", "r", defaults.RateLimit, "Requests rate-limit (used for the tools supporting it. Other will prompt a warning msg)")
+ osintCmd.Flags().StringVarP(&opts.WordlistPath, "wordlist", "w", defaults.WordlistPath, "Wordlist to use (if any)")
+ osintCmd.Flags().StringVarP(&opts.TargetFilePath, "file", "f", defaults.TargetFilePath, "File containing list of targets (should be a list of IP Addresses or domains)")
return rootCmd
}
diff --git a/cli/types.go b/cli/types.go
@@ -4,7 +4,7 @@ type StandardOptions struct {
// Pentest target, will be the name of the directories created, for instance
// if no target file is specified for OSINT command, will use that instead
- TargetName string
+ OutDirName string
// Run a dry-run (test mode)
RunDry bool
@@ -27,7 +27,7 @@ type StandardOptions struct {
func GetDefaultOptions() StandardOptions {
opts := StandardOptions{
- TargetName: "",
+ OutDirName: "",
RunDry: false,
Proxy: "",
UseHttpInsecure: false,
diff --git a/helpers/directories.go b/helpers/directories.go
@@ -10,12 +10,18 @@ type Folder struct {
Children []Folder
}
+func Exists(path string) bool {
+ _, err := os.Stat(path)
+ if err == nil {
+ return true
+ }
+ return false
+}
+
func CreateDirectory(base string, folders []Folder) {
for _, f := range folders {
current := fmt.Sprintf("%s/%s", base, f.Name)
- if e := os.Mkdir(current, 0775); e != nil {
- fmt.Println(e)
- }
+ _ = os.Mkdir(current, 0775)
if len(f.Children) != 0 {
CreateDirectory(current, f.Children)
}
diff --git a/helpers/net.go b/helpers/net.go
@@ -0,0 +1,80 @@
+package helper
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "os"
+)
+
+func GetHttpTransport() *http.Transport {
+ var proxy = os.Getenv("HTTP_PROXY")
+ url, err := url.Parse(proxy)
+
+ if proxy != "" && err == nil {
+ return &http.Transport{
+ DisableKeepAlives: true,
+ Proxy: http.ProxyURL(url),
+ }
+ }
+ return &http.Transport{}
+}
+
+func GetUserAgent() string {
+ return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
+}
+
+func GetCurrentIP() string {
+ ht := GetHttpTransport()
+ ua := GetUserAgent()
+
+ cli := &http.Client{
+ Transport: ht,
+ }
+
+ req, err := http.NewRequest("GET", "http://icanhazip.com", nil)
+ if err != nil {
+ fmt.Printf("[!] Could not query public IP address: %s\n", err.Error())
+ return "127.0.0.1" // if the service is offline or not reachable, we should be able to keep going
+ }
+
+ req.Header.Add("User-Agent", ua)
+ resp, err := cli.Do(req)
+
+ if err != nil || resp == nil {
+ fmt.Printf("[!] Could not query public IP address: %s\n", err.Error())
+ return ""
+ }
+
+ result, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ fmt.Printf("[!] Could not IP address: %s\n", err.Error())
+ return ""
+ }
+
+ return string(result)
+}
+
+func DisplayNetInfo() {
+ ip := GetCurrentIP()
+ ua := GetUserAgent()
+
+ if ip == "" {
+ os.Exit(1)
+ }
+
+ fmt.Println("[~] Current Public IP: " + ip)
+ fmt.Println("[~] Prefered User-Agent: " + ua)
+}
+
+func CheckProxy(proxy string) {
+ os.Setenv("HTTP_PROXY", proxy)
+ os.Setenv("HTTPS_PROXY", proxy)
+
+ if proxy != "" {
+ fmt.Println("[+] Proxy configuration: %s", proxy)
+ } else {
+ fmt.Println("[+] No proxy has been set")
+ }
+}
diff --git a/osint/run.go b/osint/run.go
@@ -0,0 +1 @@
+package osint
| | | | |