Projects STRLCPY metabigor Commits 5b1bfbb8
🤬
  • Fix the issue when no input detected in scan command

  • Loading...
  • j3ssie committed 2 years ago
    5b1bfbb8
    1 parent 7b8c30ef
  • ■ ■ ■ ■ ■ ■
    cmd/net.go
    1 1  package cmd
    2 2   
    3 3  import (
    4  - "fmt"
    5  - "github.com/j3ssie/metabigor/core"
    6  - "github.com/j3ssie/metabigor/modules"
    7  - jsoniter "github.com/json-iterator/go"
    8  - "github.com/panjf2000/ants"
    9  - "github.com/spf13/cast"
    10  - "github.com/spf13/cobra"
    11  - "github.com/thoas/go-funk"
    12  - "inet.af/netaddr"
    13  - "net"
    14  - "os"
    15  - "strings"
    16  - "sync"
     4 + "fmt"
     5 + "github.com/j3ssie/metabigor/core"
     6 + "github.com/j3ssie/metabigor/modules"
     7 + jsoniter "github.com/json-iterator/go"
     8 + "github.com/panjf2000/ants"
     9 + "github.com/spf13/cast"
     10 + "github.com/spf13/cobra"
     11 + "github.com/thoas/go-funk"
     12 + "inet.af/netaddr"
     13 + "net"
     14 + "os"
     15 + "strings"
     16 + "sync"
    17 17  )
    18 18   
    19 19  func init() {
    20  - var netCmd = &cobra.Command{
    21  - Use: "net",
    22  - Short: "Discover Network Information about targets (same with net command but use static data)",
    23  - Long: fmt.Sprintf(`Metabigor - Intelligence Framework but without API key - %v by %v`, core.VERSION, core.AUTHOR),
    24  - RunE: runNet,
    25  - }
     20 + var netCmd = &cobra.Command{
     21 + Use: "net",
     22 + Short: "Discover Network Information about targets (same with net command but use static data)",
     23 + Long: core.DESC,
     24 + RunE: runNet,
     25 + }
    26 26   
    27  - netCmd.Flags().Bool("asn", false, "Take input as ASN")
    28  - netCmd.Flags().Bool("org", false, "Take input as Organization")
    29  - netCmd.Flags().Bool("ip", false, "Take input as a single IP address")
    30  - netCmd.Flags().Bool("domain", false, "Take input as a domain")
    31  - netCmd.Flags().BoolVarP(&options.Net.ExactMatch, "exact", "x", false, "Only get from highly trusted source")
    32  - RootCmd.AddCommand(netCmd)
     27 + netCmd.Flags().Bool("asn", false, "Take input as ASN")
     28 + netCmd.Flags().Bool("org", false, "Take input as Organization")
     29 + netCmd.Flags().Bool("ip", false, "Take input as a single IP address")
     30 + netCmd.Flags().Bool("domain", false, "Take input as a domain")
     31 + netCmd.Flags().BoolVarP(&options.Net.ExactMatch, "exact", "x", false, "Only get from highly trusted source")
     32 + RootCmd.AddCommand(netCmd)
    33 33   
    34  - var netdCmd = &cobra.Command{
    35  - Use: "netd",
    36  - Short: "Discover Network Information about targets (similar with 'net' command but use 3rd data)",
    37  - Long: fmt.Sprintf(`Metabigor - Intelligence Framework but without API key - %v by %v`, core.VERSION, core.AUTHOR),
    38  - RunE: runNetD,
    39  - }
     34 + var netdCmd = &cobra.Command{
     35 + Use: "netd",
     36 + Short: "Discover Network Information about targets (similar with 'net' command but use 3rd data)",
     37 + Long: fmt.Sprintf(`Metabigor - Intelligence Framework but without API key - %v by %v`, core.VERSION, core.AUTHOR),
     38 + RunE: runNetD,
     39 + }
    40 40   
    41  - netdCmd.Flags().Bool("asn", false, "Take input as ASN")
    42  - netdCmd.Flags().Bool("org", false, "Take input as Organization")
    43  - netdCmd.Flags().Bool("ip", false, "Take input as a single IP address")
    44  - netdCmd.Flags().Bool("domain", false, "Take input as a domain")
    45  - netdCmd.Flags().BoolP("accurate", "x", false, "Only get from highly trusted source")
    46  - RootCmd.AddCommand(netdCmd)
     41 + netdCmd.Flags().Bool("asn", false, "Take input as ASN")
     42 + netdCmd.Flags().Bool("org", false, "Take input as Organization")
     43 + netdCmd.Flags().Bool("ip", false, "Take input as a single IP address")
     44 + netdCmd.Flags().Bool("domain", false, "Take input as a domain")
     45 + netdCmd.Flags().BoolP("accurate", "x", false, "Only get from highly trusted source")
     46 + RootCmd.AddCommand(netdCmd)
    47 47  }
    48 48   
    49 49  var ASNMap modules.AsnMap
    50 50   
    51 51  func runNet(cmd *cobra.Command, _ []string) error {
    52  - asn, _ := cmd.Flags().GetBool("asn")
    53  - org, _ := cmd.Flags().GetBool("org")
    54  - ip, _ := cmd.Flags().GetBool("ip")
    55  - domain, _ := cmd.Flags().GetBool("domain")
     52 + asn, _ := cmd.Flags().GetBool("asn")
     53 + org, _ := cmd.Flags().GetBool("org")
     54 + ip, _ := cmd.Flags().GetBool("ip")
     55 + domain, _ := cmd.Flags().GetBool("domain")
    56 56   
    57  - if asn {
    58  - options.Net.SearchType = "asn"
    59  - } else if org {
    60  - options.Net.SearchType = "org"
    61  - } else if ip {
    62  - options.Net.SearchType = "ip"
    63  - } else if domain {
    64  - options.Net.SearchType = "domain"
    65  - }
    66  - if options.Net.SearchType == "" {
    67  - fmt.Fprintf(os.Stderr, "You need to specify search type with one of these flag: --asn, --org or --ip")
    68  - os.Exit(-1)
    69  - }
     57 + if asn {
     58 + options.Net.SearchType = "asn"
     59 + } else if org {
     60 + options.Net.SearchType = "org"
     61 + } else if ip {
     62 + options.Net.SearchType = "ip"
     63 + } else if domain {
     64 + options.Net.SearchType = "domain"
     65 + }
     66 + if options.Net.SearchType == "" {
     67 + fmt.Fprintf(os.Stderr, "You need to specify search type with one of these flag: --asn, --org or --ip")
     68 + os.Exit(-1)
     69 + }
    70 70   
    71  - var err error
    72  - ASNMap, err = modules.GetAsnMap()
    73  - if err != nil {
    74  - fmt.Fprintf(os.Stderr, "Error to generate asn info")
    75  - os.Exit(-1)
    76  - }
     71 + var err error
     72 + ASNMap, err = modules.GetAsnMap()
     73 + if err != nil {
     74 + fmt.Fprintf(os.Stderr, "Error to generate asn info")
     75 + os.Exit(-1)
     76 + }
    77 77   
    78  - var wg sync.WaitGroup
    79  - p, _ := ants.NewPoolWithFunc(options.Concurrency, func(i interface{}) {
    80  - job := i.(string)
    81  - var osintResult []string
    82  - osintResult = runNetJob(job, options)
    83  - StoreData(osintResult, options)
    84  - wg.Done()
    85  - }, ants.WithPreAlloc(true))
    86  - defer p.Release()
     78 + var wg sync.WaitGroup
     79 + p, _ := ants.NewPoolWithFunc(options.Concurrency, func(i interface{}) {
     80 + job := i.(string)
     81 + var osintResult []string
     82 + osintResult = runNetJob(job, options)
     83 + StoreData(osintResult, options)
     84 + wg.Done()
     85 + }, ants.WithPreAlloc(true))
     86 + defer p.Release()
    87 87   
    88  - for _, target := range options.Inputs {
    89  - wg.Add(1)
    90  - _ = p.Invoke(strings.TrimSpace(target))
    91  - }
    92  - wg.Wait()
     88 + for _, target := range options.Inputs {
     89 + wg.Add(1)
     90 + _ = p.Invoke(strings.TrimSpace(target))
     91 + }
     92 + wg.Wait()
    93 93   
    94  - if options.Output != "" && !core.FileExists(options.Output) {
    95  - core.ErrorF("No data found")
    96  - }
    97  - return nil
     94 + if options.Output != "" && !core.FileExists(options.Output) {
     95 + core.ErrorF("No data found")
     96 + }
     97 + return nil
    98 98  }
    99 99   
    100 100  func runNetJob(input string, options core.Options) []string {
    101  - var data []string
    102  - var asnInfos []modules.ASInfo
     101 + var data []string
     102 + var asnInfos []modules.ASInfo
    103 103   
    104  - if !options.Net.ExactMatch {
    105  - input = strings.ToLower(input)
     104 + if !options.Net.ExactMatch {
     105 + input = strings.ToLower(input)
    106 106   
    107  - }
     107 + }
    108 108   
    109  - switch options.Net.SearchType {
    110  - case "asn":
    111  - input = strings.ToLower(input)
    112  - if strings.Contains(input, "as") {
    113  - input = strings.ReplaceAll(input, "as", "")
    114  - }
    115  - asInfos := ASNMap.ASInfo(cast.ToInt(input))
    116  - if len(asInfos) > 0 {
    117  - asnInfos = append(asnInfos, asInfos...)
    118  - }
     109 + switch options.Net.SearchType {
     110 + case "asn":
     111 + input = strings.ToLower(input)
     112 + if strings.Contains(input, "as") {
     113 + input = strings.ReplaceAll(input, "as", "")
     114 + }
     115 + asInfos := ASNMap.ASInfo(cast.ToInt(input))
     116 + if len(asInfos) > 0 {
     117 + asnInfos = append(asnInfos, asInfos...)
     118 + }
    119 119   
    120  - case "org":
    121  - asnNums := ASNMap.ASDesc(input)
    122  - if len(asnNums) > 0 {
    123  - for _, asnNum := range asnNums {
    124  - asnInfos = append(asnInfos, ASNMap.ASInfo(asnNum)...)
    125  - }
    126  - }
     120 + case "org":
     121 + asnNums := ASNMap.ASDesc(input)
     122 + if len(asnNums) > 0 {
     123 + for _, asnNum := range asnNums {
     124 + asnInfos = append(asnInfos, ASNMap.ASInfo(asnNum)...)
     125 + }
     126 + }
    127 127   
    128  - case "ip":
    129  - asnInfos = append(asnInfos, searchByIP(input)...)
     128 + case "ip":
     129 + asnInfos = append(asnInfos, searchByIP(input)...)
    130 130   
    131  - case "domain":
    132  - ips, err := net.LookupHost(input)
    133  - if err == nil {
    134  - for _, ip := range ips {
    135  - asnInfos = append(asnInfos, searchByIP(ip)...)
    136  - }
    137  - }
    138  - }
     131 + case "domain":
     132 + ips, err := net.LookupHost(input)
     133 + if err == nil {
     134 + for _, ip := range ips {
     135 + asnInfos = append(asnInfos, searchByIP(ip)...)
     136 + }
     137 + }
     138 + }
    139 139   
    140  - if len(asnInfos) == 0 {
    141  - core.ErrorF("No result found for: %s", input)
    142  - return data
    143  - }
     140 + if len(asnInfos) == 0 {
     141 + core.ErrorF("No result found for: %s", input)
     142 + return data
     143 + }
    144 144   
    145  - for _, asnInfo := range asnInfos {
    146  - line := genOutput(asnInfo)
    147  - data = append(data, line)
    148  - }
     145 + for _, asnInfo := range asnInfos {
     146 + line := genOutput(asnInfo)
     147 + data = append(data, line)
     148 + }
    149 149   
    150  - return data
     150 + return data
    151 151  }
    152 152   
    153 153  func genOutput(asnInfo modules.ASInfo) string {
    154  - var line string
    155  - if options.JsonOutput {
    156  - if content, err := jsoniter.MarshalToString(asnInfo); err == nil {
    157  - return content
    158  - }
    159  - return line
    160  - }
    161  - if options.Verbose {
    162  - line = fmt.Sprintf("%d - %s - %s - %s", asnInfo.Number, asnInfo.CIDR, asnInfo.Description, asnInfo.CountryCode)
    163  - } else {
    164  - line = asnInfo.CIDR
    165  - }
    166  - return line
     154 + var line string
     155 + if options.JsonOutput {
     156 + if content, err := jsoniter.MarshalToString(asnInfo); err == nil {
     157 + return content
     158 + }
     159 + return line
     160 + }
     161 + if options.Verbose {
     162 + line = fmt.Sprintf("%d - %s - %s - %s", asnInfo.Number, asnInfo.CIDR, asnInfo.Description, asnInfo.CountryCode)
     163 + } else {
     164 + line = asnInfo.CIDR
     165 + }
     166 + return line
    167 167  }
    168 168   
    169 169  func searchByIP(input string) []modules.ASInfo {
    170  - var asnInfo []modules.ASInfo
     170 + var asnInfo []modules.ASInfo
    171 171   
    172  - ip, err := netaddr.ParseIP(input)
    173  - if err != nil {
    174  - return asnInfo
    175  - }
     172 + ip, err := netaddr.ParseIP(input)
     173 + if err != nil {
     174 + return asnInfo
     175 + }
    176 176   
    177  - if asn := ASNMap.ASofIP(ip); asn.AS != 0 {
    178  - return ASNMap.ASInfo(asn.AS)
    179  - }
    180  - return asnInfo
     177 + if asn := ASNMap.ASofIP(ip); asn.AS != 0 {
     178 + return ASNMap.ASInfo(asn.AS)
     179 + }
     180 + return asnInfo
    181 181  }
    182 182   
    183 183  /////////// netd command
    184 184   
    185 185  func runNetD(cmd *cobra.Command, _ []string) error {
    186  - asn, _ := cmd.Flags().GetBool("asn")
    187  - org, _ := cmd.Flags().GetBool("org")
    188  - ip, _ := cmd.Flags().GetBool("ip")
    189  - domain, _ := cmd.Flags().GetBool("domain")
    190  - options.Net.Optimize, _ = cmd.Flags().GetBool("accurate")
     186 + asn, _ := cmd.Flags().GetBool("asn")
     187 + org, _ := cmd.Flags().GetBool("org")
     188 + ip, _ := cmd.Flags().GetBool("ip")
     189 + domain, _ := cmd.Flags().GetBool("domain")
     190 + options.Net.Optimize, _ = cmd.Flags().GetBool("accurate")
    191 191   
    192  - var wg sync.WaitGroup
    193  - p, _ := ants.NewPoolWithFunc(options.Concurrency, func(i interface{}) {
    194  - job := i.(string)
    195  - var osintResult []string
    196  - if asn {
    197  - osintResult = runASN(job, options)
    198  - } else if org {
    199  - osintResult = runOrg(job, options)
    200  - } else if ip {
    201  - options.Net.IP = job
    202  - osintResult = runSingle(job, options)
    203  - } else if domain {
    204  - options.Net.Domain = job
    205  - osintResult = runSingle(job, options)
    206  - }
    207  - StoreData(osintResult, options)
     192 + var wg sync.WaitGroup
     193 + p, _ := ants.NewPoolWithFunc(options.Concurrency, func(i interface{}) {
     194 + job := i.(string)
     195 + var osintResult []string
     196 + if asn {
     197 + osintResult = runASN(job, options)
     198 + } else if org {
     199 + osintResult = runOrg(job, options)
     200 + } else if ip {
     201 + options.Net.IP = job
     202 + osintResult = runSingle(job, options)
     203 + } else if domain {
     204 + options.Net.Domain = job
     205 + osintResult = runSingle(job, options)
     206 + }
     207 + StoreData(osintResult, options)
    208 208   
    209  - wg.Done()
    210  - }, ants.WithPreAlloc(true))
    211  - defer p.Release()
     209 + wg.Done()
     210 + }, ants.WithPreAlloc(true))
     211 + defer p.Release()
    212 212   
    213  - for _, target := range options.Inputs {
    214  - wg.Add(1)
    215  - _ = p.Invoke(strings.TrimSpace(target))
    216  - }
     213 + for _, target := range options.Inputs {
     214 + wg.Add(1)
     215 + _ = p.Invoke(strings.TrimSpace(target))
     216 + }
    217 217   
    218  - wg.Wait()
     218 + wg.Wait()
    219 219   
    220  - if options.Output != "" && !core.FileExists(options.Output) {
    221  - core.ErrorF("No data found")
    222  - }
    223  - return nil
     220 + if options.Output != "" && !core.FileExists(options.Output) {
     221 + core.ErrorF("No data found")
     222 + }
     223 + return nil
    224 224  }
    225 225   
    226 226  func runSingle(input string, options core.Options) []string {
    227  - core.BannerF("Starting get ASN from: ", input)
    228  - var data []string
    229  - ans := modules.ASNFromIP(options)
     227 + core.BannerF("Starting get ASN from: ", input)
     228 + var data []string
     229 + ans := modules.ASNFromIP(options)
    230 230   
    231  - // get more IP by result ASN
    232  - for _, item := range ans {
    233  - if strings.HasPrefix(strings.ToLower(item), "as") {
    234  - data = append(data, runASN(item, options)...)
    235  - }
    236  - }
    237  - return data
     231 + // get more IP by result ASN
     232 + for _, item := range ans {
     233 + if strings.HasPrefix(strings.ToLower(item), "as") {
     234 + data = append(data, runASN(item, options)...)
     235 + }
     236 + }
     237 + return data
    238 238  }
    239 239   
    240 240  func runASN(input string, options core.Options) []string {
    241  - core.BannerF("Starting get IP Info from ASN: ", input)
    242  - options.Net.Asn = input
    243  - var data []string
    244  - var wg sync.WaitGroup
     241 + core.BannerF("Starting get IP Info from ASN: ", input)
     242 + options.Net.Asn = input
     243 + var data []string
     244 + var wg sync.WaitGroup
    245 245   
    246  - wg.Add(1)
    247  - go func() {
    248  - data = append(data, modules.GetIPInfo(options)...)
    249  - wg.Done()
    250  - }()
     246 + wg.Add(1)
     247 + go func() {
     248 + data = append(data, modules.GetIPInfo(options)...)
     249 + wg.Done()
     250 + }()
    251 251   
    252  - wg.Wait()
    253  - return data
     252 + wg.Wait()
     253 + return data
    254 254  }
    255 255   
    256 256  func runOrg(input string, options core.Options) []string {
    257  - core.BannerF("Starting get IP Info for Organization: ", input)
    258  - options.Net.Org = input
    259  - var data []string
    260  - var wg sync.WaitGroup
    261  - wg.Add(1)
    262  - go func() {
    263  - data = append(data, modules.OrgBgpDotNet(options)...)
    264  - wg.Done()
    265  - }()
     257 + core.BannerF("Starting get IP Info for Organization: ", input)
     258 + options.Net.Org = input
     259 + var data []string
     260 + var wg sync.WaitGroup
     261 + wg.Add(1)
     262 + go func() {
     263 + data = append(data, modules.OrgBgpDotNet(options)...)
     264 + wg.Done()
     265 + }()
    266 266   
    267  - wg.Add(1)
    268  - go func() {
    269  - data = append(data, modules.OrgBgbView(options)...)
    270  - wg.Done()
    271  - }()
     267 + wg.Add(1)
     268 + go func() {
     269 + data = append(data, modules.OrgBgbView(options)...)
     270 + wg.Done()
     271 + }()
    272 272   
    273  - // disable when enable trusted source
    274  - if !options.Net.Optimize {
    275  - wg.Add(1)
    276  - go func() {
    277  - data = append(data, modules.ASNLookup(options)...)
    278  - wg.Done()
    279  - }()
    280  - }
    281  - wg.Wait()
     273 + // disable when enable trusted source
     274 + if !options.Net.Optimize {
     275 + wg.Add(1)
     276 + go func() {
     277 + data = append(data, modules.ASNLookup(options)...)
     278 + wg.Done()
     279 + }()
     280 + }
     281 + wg.Wait()
    282 282   
    283  - var cidrs []string
    284  - // get more IP by result ASN
    285  - for _, item := range data {
    286  - // get more range from ASN
    287  - if strings.HasPrefix(strings.ToLower(item), "as") {
    288  - wg.Add(1)
    289  - go func(item string) {
    290  - cidrs = append(cidrs, runASN(item, options)...)
    291  - wg.Done()
    292  - }(item)
    293  - continue
    294  - } else if core.StartWithNum(item) {
    295  - cidrs = append(cidrs, item)
    296  - }
    297  - }
    298  - wg.Wait()
    299  - return funk.Uniq(cidrs).([]string)
     283 + var cidrs []string
     284 + // get more IP by result ASN
     285 + for _, item := range data {
     286 + // get more range from ASN
     287 + if strings.HasPrefix(strings.ToLower(item), "as") {
     288 + wg.Add(1)
     289 + go func(item string) {
     290 + cidrs = append(cidrs, runASN(item, options)...)
     291 + wg.Done()
     292 + }(item)
     293 + continue
     294 + } else if core.StartWithNum(item) {
     295 + cidrs = append(cidrs, item)
     296 + }
     297 + }
     298 + wg.Wait()
     299 + return funk.Uniq(cidrs).([]string)
    300 300  }
    301 301   
    302 302  // StoreData store data to output
    303 303  func StoreData(data []string, options core.Options) {
    304  - if len(data) == 0 {
    305  - core.ErrorF("Empty data to write")
    306  - return
    307  - }
     304 + if len(data) == 0 {
     305 + core.ErrorF("Empty data to write")
     306 + return
     307 + }
    308 308   
    309  - fmt.Println(strings.Join(data, "\n"))
    310  - _, err := core.AppendToContent(options.Output, strings.Join(data, "\n"))
    311  - if err == nil {
    312  - core.InforF("Write output to: %v", options.Output)
    313  - }
     309 + fmt.Println(strings.Join(data, "\n"))
     310 + _, err := core.AppendToContent(options.Output, strings.Join(data, "\n"))
     311 + if err == nil {
     312 + core.InforF("Write output to: %v", options.Output)
     313 + }
    314 314  }
    315 315   
  • ■ ■ ■ ■ ■ ■
    cmd/related.go
    1 1  package cmd
    2 2   
    3 3  import (
    4  - "fmt"
    5  - "github.com/j3ssie/metabigor/core"
    6  - "github.com/j3ssie/metabigor/modules"
    7  - jsoniter "github.com/json-iterator/go"
    8  - "github.com/panjf2000/ants"
    9  - "github.com/spf13/cobra"
    10  - "strings"
    11  - "sync"
     4 + "fmt"
     5 + "github.com/j3ssie/metabigor/core"
     6 + "github.com/j3ssie/metabigor/modules"
     7 + jsoniter "github.com/json-iterator/go"
     8 + "github.com/panjf2000/ants"
     9 + "github.com/spf13/cobra"
     10 + "strings"
     11 + "sync"
    12 12  )
    13 13   
    14 14  func init() {
    15  - var tldCmd = &cobra.Command{
    16  - Use: "related",
    17  - Aliases: []string{"tld", "relate"},
    18  - Short: "Finding more related domains of the target by applying various techniques",
    19  - Long: fmt.Sprintf(`Metabigor - Intelligence Tool but without API key - %v by %v`, core.VERSION, core.AUTHOR),
    20  - RunE: runTLD,
    21  - }
    22  - tldCmd.Flags().StringVarP(&options.Tld.Source, "src", "s", "all", "Source for gathering TLD")
    23  - RootCmd.AddCommand(tldCmd)
     15 + var tldCmd = &cobra.Command{
     16 + Use: "related",
     17 + Aliases: []string{"tld", "relate"},
     18 + Short: "Finding more related domains of the target by applying various techniques",
     19 + Long: core.DESC,
     20 + RunE: runTLD,
     21 + }
     22 + tldCmd.Flags().StringVarP(&options.Tld.Source, "src", "s", "all", "Source for gathering TLD")
     23 + RootCmd.AddCommand(tldCmd)
    24 24  }
    25 25   
    26 26  func runTLD(_ *cobra.Command, _ []string) error {
    27  - var wg sync.WaitGroup
    28  - p, _ := ants.NewPoolWithFunc(options.Concurrency, func(i interface{}) {
    29  - job := i.(string)
    30  - TLDJob(job)
    31  - wg.Done()
    32  - }, ants.WithPreAlloc(true))
    33  - defer p.Release()
     27 + var wg sync.WaitGroup
     28 + p, _ := ants.NewPoolWithFunc(options.Concurrency, func(i interface{}) {
     29 + job := i.(string)
     30 + TLDJob(job)
     31 + wg.Done()
     32 + }, ants.WithPreAlloc(true))
     33 + defer p.Release()
    34 34   
    35  - for _, target := range options.Inputs {
    36  - wg.Add(1)
    37  - _ = p.Invoke(strings.TrimSpace(target))
    38  - }
     35 + for _, target := range options.Inputs {
     36 + wg.Add(1)
     37 + _ = p.Invoke(strings.TrimSpace(target))
     38 + }
    39 39   
    40  - wg.Wait()
    41  - return nil
     40 + wg.Wait()
     41 + return nil
    42 42  }
    43 43   
    44 44  func TLDJob(raw string) {
    45  - var results []core.RelatedDomain
    46  - switch options.Tld.Source {
    47  - case "all":
    48  - results = append(results, modules.CrtSH(raw, options)...)
    49  - results = append(results, modules.ReverseWhois(raw, options)...)
    50  - results = append(results, modules.GoogleAnalytic(raw, options)...)
    51  - case "crt", "cert":
    52  - results = append(results, modules.CrtSH(raw, options)...)
    53  - case "whois", "who":
    54  - results = append(results, modules.ReverseWhois(raw, options)...)
    55  - case "ua", "gtm", "google-analytic":
    56  - results = append(results, modules.GoogleAnalytic(raw, options)...)
    57  - }
     45 + var results []core.RelatedDomain
     46 + switch options.Tld.Source {
     47 + case "all":
     48 + results = append(results, modules.CrtSH(raw, options)...)
     49 + results = append(results, modules.ReverseWhois(raw, options)...)
     50 + results = append(results, modules.GoogleAnalytic(raw, options)...)
     51 + case "crt", "cert":
     52 + results = append(results, modules.CrtSH(raw, options)...)
     53 + case "whois", "who":
     54 + results = append(results, modules.ReverseWhois(raw, options)...)
     55 + case "ua", "gtm", "google-analytic":
     56 + results = append(results, modules.GoogleAnalytic(raw, options)...)
     57 + }
    58 58   
    59  - for _, item := range results {
    60  - if options.JsonOutput {
    61  - if data, err := jsoniter.MarshalToString(item); err == nil {
    62  - fmt.Println(data)
    63  - }
    64  - continue
    65  - }
     59 + for _, item := range results {
     60 + if options.JsonOutput {
     61 + if data, err := jsoniter.MarshalToString(item); err == nil {
     62 + fmt.Println(data)
     63 + }
     64 + continue
     65 + }
    66 66   
    67  - if options.Verbose {
    68  - fmt.Println(item.Output)
    69  - } else {
    70  - fmt.Println(item.Domain)
    71  - }
    72  - }
     67 + if options.Verbose {
     68 + fmt.Println(item.Output)
     69 + } else {
     70 + fmt.Println(item.Domain)
     71 + }
     72 + }
    73 73  }
    74 74   
  • ■ ■ ■ ■ ■ ■
    cmd/scan.go
    1 1  package cmd
    2 2   
    3 3  import (
    4  - "fmt"
    5  - "github.com/thoas/go-funk"
    6  - "io/ioutil"
    7  - "os"
    8  - "strings"
    9  - "sync"
     4 + "fmt"
     5 + "github.com/thoas/go-funk"
     6 + "io/ioutil"
     7 + "os"
     8 + "strings"
     9 + "sync"
    10 10   
    11  - "github.com/j3ssie/metabigor/core"
    12  - "github.com/j3ssie/metabigor/modules"
    13  - "github.com/spf13/cobra"
     11 + "github.com/j3ssie/metabigor/core"
     12 + "github.com/j3ssie/metabigor/modules"
     13 + "github.com/spf13/cobra"
    14 14  )
    15 15   
    16 16  func init() {
    17  - var scanCmd = &cobra.Command{
    18  - Use: "scan",
    19  - Short: "Wrapper to run port scan from provided input",
    20  - Long: core.DESC,
    21  - RunE: runScan,
    22  - }
    23  - // scan options
    24  - scanCmd.Flags().StringVarP(&options.Scan.Ports, "ports", "p", "0-65535", "Port range for previous command")
    25  - scanCmd.Flags().StringVarP(&options.Scan.Rate, "rate", "r", "3000", "rate limit for masscan command")
    26  - scanCmd.Flags().BoolVarP(&options.Scan.All, "join", "A", false, "Join all inputs to a file first then do a scan")
    27  - // scan strategy option
    28  - scanCmd.Flags().BoolVarP(&options.Scan.Flat, "flat", "f", true, "format output like this: 1.2.3.4:443")
    29  - scanCmd.Flags().BoolVarP(&options.Scan.NmapOverview, "nmap", "n", false, "Use nmap instead of masscan for overview scan")
    30  - scanCmd.Flags().BoolVarP(&options.Scan.ZmapOverview, "zmap", "z", false, "Only scan range with zmap")
    31  - scanCmd.Flags().BoolVarP(&options.Scan.SkipOverview, "skip-masscan", "s", false, "run nmap from input format like this: 1.2.3.4:443")
    32  - scanCmd.Flags().BoolVarP(&options.Scan.InputFromRustScan, "rstd", "R", false, "run nmap from rustscan input format like: 1.2.3.4 -> [80,443,8080,8443,8880]")
    33  - // more nmap options
    34  - scanCmd.Flags().StringVarP(&options.Scan.NmapScripts, "script", "S", "", "nmap scripts")
    35  - scanCmd.Flags().StringVar(&options.Scan.NmapTemplate, "nmap-command", "nmap -sSV -sC -p {{.ports}} {{.input}} {{.script}} -T4 --open -oA {{.output}}", "Nmap template command to run")
    36  - scanCmd.Flags().StringVar(&options.Scan.GrepString, "grep", "", "match string to confirm script success")
    37  - scanCmd.Flags().String("result-folder", "", "Result folder")
    38  - scanCmd.Flags().BoolVar(&options.Scan.IPv4, "4", true, "Filter input to only get ipv4")
    39  - scanCmd.Flags().BoolVar(&options.Scan.Skip80And443, "8", false, "Skip ports 80 and 443. Useful when you want to look for service behind the list of pre-scanned data")
    40  - //scanCmd.Flags().Bool("6", false, "Filter input to only get ipv4")
    41  - scanCmd.Flags().BoolP("detail", "D", false, "Do Nmap scan based on previous output")
    42  - scanCmd.Flags().Bool("uniq", true, "Unique input first")
    43  - scanCmd.SetHelpFunc(ScanHelp)
    44  - RootCmd.AddCommand(scanCmd)
     17 + var scanCmd = &cobra.Command{
     18 + Use: "scan",
     19 + Short: "Wrapper to run port scan from provided input",
     20 + Long: core.DESC,
     21 + RunE: runScan,
     22 + }
     23 + // scan options
     24 + scanCmd.Flags().StringVarP(&options.Scan.Ports, "ports", "p", "0-65535", "Port range for previous command")
     25 + scanCmd.Flags().StringVarP(&options.Scan.Rate, "rate", "r", "3000", "rate limit for masscan command")
     26 + scanCmd.Flags().BoolVarP(&options.Scan.All, "join", "A", false, "Join all inputs to a file first then do a scan")
     27 + // scan strategy option
     28 + scanCmd.Flags().BoolVarP(&options.Scan.Flat, "flat", "f", true, "format output like this: 1.2.3.4:443")
     29 + scanCmd.Flags().BoolVarP(&options.Scan.NmapOverview, "nmap", "n", false, "Use nmap instead of masscan for overview scan")
     30 + scanCmd.Flags().BoolVarP(&options.Scan.ZmapOverview, "zmap", "z", false, "Only scan range with zmap")
     31 + scanCmd.Flags().BoolVarP(&options.Scan.SkipOverview, "skip-masscan", "s", false, "run nmap from input format like this: 1.2.3.4:443")
     32 + scanCmd.Flags().BoolVarP(&options.Scan.InputFromRustScan, "rstd", "R", false, "run nmap from rustscan input format like: 1.2.3.4 -> [80,443,8080,8443,8880]")
     33 + // more nmap options
     34 + scanCmd.Flags().StringVarP(&options.Scan.NmapScripts, "script", "S", "", "nmap scripts")
     35 + scanCmd.Flags().StringVar(&options.Scan.NmapTemplate, "nmap-command", "nmap -sSV -sC -p {{.ports}} {{.input}} {{.script}} -T4 --open -oA {{.output}}", "Nmap template command to run")
     36 + scanCmd.Flags().StringVar(&options.Scan.GrepString, "grep", "", "match string to confirm script success")
     37 + scanCmd.Flags().String("result-folder", "", "Result folder")
     38 + scanCmd.Flags().BoolVar(&options.Scan.IPv4, "4", true, "Filter input to only get ipv4")
     39 + scanCmd.Flags().BoolVar(&options.Scan.Skip80And443, "8", false, "Skip ports 80 and 443. Useful when you want to look for service behind the list of pre-scanned data")
     40 + //scanCmd.Flags().Bool("6", false, "Filter input to only get ipv4")
     41 + scanCmd.Flags().BoolP("detail", "D", false, "Do Nmap scan based on previous output")
     42 + scanCmd.Flags().Bool("uniq", true, "Unique input first")
     43 + scanCmd.SetHelpFunc(ScanHelp)
     44 + RootCmd.AddCommand(scanCmd)
    45 45  }
    46 46   
    47 47  func runScan(cmd *cobra.Command, _ []string) error {
    48  - // only parse result
    49  - resultFolder, _ := cmd.Flags().GetString("result-folder")
    50  - uniq, _ := cmd.Flags().GetBool("uniq")
    51  - if resultFolder != "" {
    52  - parseResult(resultFolder, options)
    53  - os.Exit(0)
    54  - }
     48 + // only parse result
     49 + resultFolder, _ := cmd.Flags().GetString("result-folder")
     50 + uniq, _ := cmd.Flags().GetBool("uniq")
     51 + if resultFolder != "" {
     52 + parseResult(resultFolder, options)
     53 + os.Exit(0)
     54 + }
    55 55   
    56  - if options.Scan.InputFromRustScan {
    57  - options.Scan.SkipOverview = true
    58  - }
     56 + if options.Scan.InputFromRustScan {
     57 + options.Scan.SkipOverview = true
     58 + }
    59 59   
    60  - if options.Input == "-" || options.Input == "" {
    61  - core.ErrorF("No input found")
    62  - os.Exit(1)
    63  - }
    64  - 
    65  - var inputs []string
    66  - if strings.Contains(options.Input, "\n") {
    67  - inputs = strings.Split(options.Input, "\n")
    68  - } else {
    69  - inputs = append(inputs, options.Input)
    70  - }
    71  - 
    72  - // make sure input is valid
    73  - if options.Scan.IPv4 {
    74  - // only filter when run zmap
    75  - if !options.Scan.SkipOverview {
    76  - inputs = core.FilterIpv4(inputs)
    77  - }
    78  - }
    79  - if uniq {
    80  - inputs = funk.UniqString(inputs)
    81  - }
    82  - if len(inputs) == 0 {
    83  - core.ErrorF("No input provided")
    84  - os.Exit(1)
    85  - }
     60 + // make sure input is valid
     61 + if options.Scan.IPv4 {
     62 + // only filter when run zmap
     63 + if !options.Scan.SkipOverview {
     64 + options.Inputs = core.FilterIpv4(options.Inputs)
     65 + }
     66 + }
     67 + if uniq {
     68 + options.Inputs = funk.UniqString(options.Inputs)
     69 + }
     70 + if len(options.Inputs) == 0 {
     71 + core.ErrorF("No input provided")
     72 + os.Exit(1)
     73 + }
    86 74   
    87  - var result []string
    88  - var wg sync.WaitGroup
    89  - jobs := make(chan string)
     75 + var result []string
     76 + var wg sync.WaitGroup
     77 + jobs := make(chan string)
    90 78   
    91  - if options.Scan.All || options.Scan.ZmapOverview {
    92  - options.Scan.InputFile = StoreTmpInput(inputs, options)
    93  - core.DebugF("Store temp input in: %v", options.Scan.InputFile)
     79 + if options.Scan.All || options.Scan.ZmapOverview {
     80 + options.Scan.InputFile = StoreTmpInput(options.Inputs, options)
     81 + core.DebugF("Store temp input in: %v", options.Scan.InputFile)
    94 82   
    95  - if options.Scan.ZmapOverview {
    96  - ports := core.GenPorts(options.Scan.Ports)
    97  - core.DebugF("Run port scan with: %v", strings.Trim(strings.Join(ports, ","), ","))
    98  - if options.Scan.InputFile == "" || len(ports) == 0 {
    99  - core.ErrorF("Error gen input or ports")
    100  - return nil
    101  - }
    102  - for i := 0; i < options.Concurrency; i++ {
    103  - wg.Add(1)
    104  - go func() {
    105  - defer wg.Done()
    106  - for job := range jobs {
    107  - // do real stuff here
    108  - core.BannerF("Run zmap scan on port ", job)
    109  - result = modules.RunZmap(options.Scan.InputFile, job, options)
    110  - StoreData(result, options)
    111  - }
    112  - }()
    113  - }
    114  - for _, port := range ports {
    115  - jobs <- port
    116  - }
    117  - close(jobs)
    118  - wg.Wait()
    119  - return nil
    120  - }
     83 + if options.Scan.ZmapOverview {
     84 + ports := core.GenPorts(options.Scan.Ports)
     85 + core.DebugF("Run port scan with: %v", strings.Trim(strings.Join(ports, ","), ","))
     86 + if options.Scan.InputFile == "" || len(ports) == 0 {
     87 + core.ErrorF("Error gen input or ports")
     88 + return nil
     89 + }
     90 + for i := 0; i < options.Concurrency; i++ {
     91 + wg.Add(1)
     92 + go func() {
     93 + defer wg.Done()
     94 + for job := range jobs {
     95 + // do real stuff here
     96 + core.BannerF("Run zmap scan on port ", job)
     97 + result = modules.RunZmap(options.Scan.InputFile, job, options)
     98 + StoreData(result, options)
     99 + }
     100 + }()
     101 + }
     102 + for _, port := range ports {
     103 + jobs <- port
     104 + }
     105 + close(jobs)
     106 + wg.Wait()
     107 + return nil
     108 + }
    121 109   
    122  - core.BannerF("Run overview scan on port ", options.Scan.InputFile)
    123  - if options.Scan.NmapOverview {
    124  - result = modules.RunNmap(options.Scan.InputFile, "", options)
    125  - } else {
    126  - result = modules.RunMasscan(options.Scan.InputFile, options)
    127  - }
    128  - StoreData(result, options)
    129  - return nil
    130  - }
     110 + core.BannerF("Run overview scan on port ", options.Scan.InputFile)
     111 + if options.Scan.NmapOverview {
     112 + result = modules.RunNmap(options.Scan.InputFile, "", options)
     113 + } else {
     114 + result = modules.RunMasscan(options.Scan.InputFile, options)
     115 + }
     116 + StoreData(result, options)
     117 + return nil
     118 + }
    131 119   
    132  - for i := 0; i < options.Concurrency; i++ {
    133  - wg.Add(1)
    134  - go func() {
    135  - defer wg.Done()
    136  - // do real stuff here
    137  - for job := range jobs {
    138  - if options.Scan.SkipOverview {
    139  - result = directDetail(job, options)
    140  - } else {
    141  - result = runRoutine(job, options)
    142  - }
    143  - StoreData(result, options)
    144  - }
    145  - }()
    146  - }
     120 + for i := 0; i < options.Concurrency; i++ {
     121 + wg.Add(1)
     122 + go func() {
     123 + defer wg.Done()
     124 + // do real stuff here
     125 + for job := range jobs {
     126 + if options.Scan.SkipOverview {
     127 + result = directDetail(job, options)
     128 + } else {
     129 + result = runRoutine(job, options)
     130 + }
     131 + StoreData(result, options)
     132 + }
     133 + }()
     134 + }
    147 135   
    148  - for _, input := range inputs {
    149  - jobs <- input
    150  - }
     136 + for _, input := range options.Inputs {
     137 + jobs <- input
     138 + }
    151 139   
    152  - close(jobs)
    153  - wg.Wait()
     140 + close(jobs)
     141 + wg.Wait()
    154 142   
    155  - return nil
     143 + return nil
    156 144  }
    157 145   
    158 146  func runRoutine(input string, options core.Options) []string {
    159  - var data []string
    160  - core.BannerF("Run overview scan on: ", input)
    161  - if options.Scan.NmapOverview {
    162  - data = append(data, modules.RunNmap(input, "", options)...)
    163  - } else {
    164  - data = append(data, modules.RunMasscan(input, options)...)
    165  - }
     147 + var data []string
     148 + core.BannerF("Run overview scan on: ", input)
     149 + if options.Scan.NmapOverview {
     150 + data = append(data, modules.RunNmap(input, "", options)...)
     151 + } else {
     152 + data = append(data, modules.RunMasscan(input, options)...)
     153 + }
    166 154   
    167  - if !options.Scan.Detail {
    168  - return data
    169  - }
     155 + if !options.Scan.Detail {
     156 + return data
     157 + }
    170 158   
    171  - var wg sync.WaitGroup
    172  - var realData []string
    173  - for _, item := range data {
    174  - wg.Add(1)
    175  - go func(item string) {
    176  - realData = append(realData, runDetail(item, options)...)
    177  - wg.Done()
    178  - }(item)
    179  - }
    180  - wg.Wait()
    181  - return realData
     159 + var wg sync.WaitGroup
     160 + var realData []string
     161 + for _, item := range data {
     162 + wg.Add(1)
     163 + go func(item string) {
     164 + realData = append(realData, runDetail(item, options)...)
     165 + wg.Done()
     166 + }(item)
     167 + }
     168 + wg.Wait()
     169 + return realData
    182 170  }
    183 171   
    184 172  func runDetail(input string, options core.Options) []string {
    185  - if options.Scan.Flat {
    186  - return directDetail(input, options)
    187  - }
    188  - if input == "" {
    189  - return []string{}
    190  - }
    191  - if len(strings.Split(input, " - ")) == 1 {
    192  - return []string{}
    193  - }
     173 + if options.Scan.Flat {
     174 + return directDetail(input, options)
     175 + }
     176 + if input == "" {
     177 + return []string{}
     178 + }
     179 + if len(strings.Split(input, " - ")) == 1 {
     180 + return []string{}
     181 + }
    194 182   
    195  - host := strings.Split(input, " - ")[0]
    196  - ports := strings.Split(input, " - ")[1]
    197  - core.BannerF("Run detail scan on: ", fmt.Sprintf("%v:%v", host, ports))
    198  - return modules.RunNmap(host, ports, options)
     183 + host := strings.Split(input, " - ")[0]
     184 + ports := strings.Split(input, " - ")[1]
     185 + core.BannerF("Run detail scan on: ", fmt.Sprintf("%v:%v", host, ports))
     186 + return modules.RunNmap(host, ports, options)
    199 187  }
    200 188   
    201 189  func directDetail(input string, options core.Options) []string {
    202  - var out []string
    203  - if options.Scan.Skip80And443 {
    204  - if strings.HasSuffix(input, ":80") && strings.HasSuffix(input, ":443") {
    205  - return out
    206  - }
    207  - }
     190 + var out []string
     191 + if options.Scan.Skip80And443 {
     192 + if strings.HasSuffix(input, ":80") && strings.HasSuffix(input, ":443") {
     193 + return out
     194 + }
     195 + }
    208 196   
    209  - if input == "" {
    210  - return out
    211  - }
    212  - var host, ports string
     197 + if input == "" {
     198 + return out
     199 + }
     200 + var host, ports string
    213 201   
    214  - if options.Scan.InputFromRustScan {
    215  - // 1.1.1.1 -> [80,443,2095,2096,8080,8443,8880]
    216  - if !strings.Contains(input, "->") {
    217  - return out
    218  - }
    219  - host = strings.Split(input, " -> ")[0]
    220  - ports = strings.Split(input, " -> ")[1]
    221  - ports = strings.TrimLeft(strings.TrimRight(ports, "]"), "[")
    222  - } else {
    223  - if len(strings.Split(input, ":")) == 1 {
    224  - return out
    225  - }
    226  - host = strings.Split(input, ":")[0]
    227  - ports = strings.Split(input, ":")[1]
    228  - }
     202 + if options.Scan.InputFromRustScan {
     203 + // 1.1.1.1 -> [80,443,2095,2096,8080,8443,8880]
     204 + if !strings.Contains(input, "->") {
     205 + return out
     206 + }
     207 + host = strings.Split(input, " -> ")[0]
     208 + ports = strings.Split(input, " -> ")[1]
     209 + ports = strings.TrimLeft(strings.TrimRight(ports, "]"), "[")
     210 + } else {
     211 + if len(strings.Split(input, ":")) == 1 {
     212 + return out
     213 + }
     214 + host = strings.Split(input, ":")[0]
     215 + ports = strings.Split(input, ":")[1]
     216 + }
    229 217   
    230  - core.BannerF("Run detail scan on: ", fmt.Sprintf("%v:%v", host, ports))
    231  - out = modules.RunNmap(host, ports, options)
    232  - return out
     218 + core.BannerF("Run detail scan on: ", fmt.Sprintf("%v:%v", host, ports))
     219 + out = modules.RunNmap(host, ports, options)
     220 + return out
    233 221  }
    234 222   
    235 223  // only parse result
    236 224  func parseResult(resultFolder string, options core.Options) {
    237  - if !core.FolderExists(resultFolder) {
    238  - core.ErrorF("Result Folder not found: ", resultFolder)
    239  - return
    240  - }
    241  - core.BannerF("Reading result from: ", fmt.Sprintf("%v", resultFolder))
    242  - Files, err := ioutil.ReadDir(resultFolder)
    243  - if err != nil {
    244  - return
    245  - }
     225 + if !core.FolderExists(resultFolder) {
     226 + core.ErrorF("Result Folder not found: ", resultFolder)
     227 + return
     228 + }
     229 + core.BannerF("Reading result from: ", fmt.Sprintf("%v", resultFolder))
     230 + Files, err := ioutil.ReadDir(resultFolder)
     231 + if err != nil {
     232 + return
     233 + }
    246 234   
    247  - if options.Scan.Detail {
    248  - // nmap
    249  - for _, file := range Files {
    250  - filename := file.Name()
    251  - core.DebugF("Reading: %v", filename)
    252  - if strings.HasSuffix(file.Name(), "xml") && strings.HasPrefix(filename, "nmap") {
    253  - data := core.GetFileContent(filename)
    254  - result := modules.ParseNmap(data, options)
    255  - if len(result) > 0 {
    256  - fmt.Printf(strings.Join(result, "\n"))
    257  - }
    258  - }
    259  - }
    260  - return
    261  - }
     235 + if options.Scan.Detail {
     236 + // nmap
     237 + for _, file := range Files {
     238 + filename := file.Name()
     239 + core.DebugF("Reading: %v", filename)
     240 + if strings.HasSuffix(file.Name(), "xml") && strings.HasPrefix(filename, "nmap") {
     241 + data := core.GetFileContent(filename)
     242 + result := modules.ParseNmap(data, options)
     243 + if len(result) > 0 {
     244 + fmt.Printf(strings.Join(result, "\n"))
     245 + }
     246 + }
     247 + }
     248 + return
     249 + }
    262 250   
    263  - // masscan
    264  - for _, file := range Files {
    265  - filename := file.Name()
    266  - core.DebugF("Reading: %v", filename)
    267  - if strings.HasPrefix(filename, "masscan") {
    268  - data := core.GetFileContent(filename)
    269  - fmt.Println(data)
    270  - rawResult := modules.ParsingMasscan(data)
    271  - fmt.Println(rawResult)
    272  - for k, v := range rawResult {
    273  - for _, port := range v {
    274  - fmt.Printf("%v:%v\n", k, port)
    275  - }
    276  - }
    277  - }
    278  - }
     251 + // masscan
     252 + for _, file := range Files {
     253 + filename := file.Name()
     254 + core.DebugF("Reading: %v", filename)
     255 + if strings.HasPrefix(filename, "masscan") {
     256 + data := core.GetFileContent(filename)
     257 + fmt.Println(data)
     258 + rawResult := modules.ParsingMasscan(data)
     259 + fmt.Println(rawResult)
     260 + for k, v := range rawResult {
     261 + for _, port := range v {
     262 + fmt.Printf("%v:%v\n", k, port)
     263 + }
     264 + }
     265 + }
     266 + }
    279 267  }
    280 268   
    281 269  // StoreTmpInput store list of string to tmp file
    282 270  func StoreTmpInput(raw []string, options core.Options) string {
    283  - tmpDest := options.Scan.TmpOutput
    284  - tmpFile, _ := ioutil.TempFile(options.Scan.TmpOutput, "joined-*.txt")
    285  - if tmpDest != "" {
    286  - tmpFile, _ = ioutil.TempFile(tmpDest, "joined-input-*.txt")
    287  - }
    288  - tmpDest = tmpFile.Name()
    289  - core.WriteToFile(tmpDest, strings.Join(raw, "\n"))
    290  - return tmpDest
     271 + tmpDest := options.Scan.TmpOutput
     272 + tmpFile, _ := ioutil.TempFile(options.Scan.TmpOutput, "joined-*.txt")
     273 + if tmpDest != "" {
     274 + tmpFile, _ = ioutil.TempFile(tmpDest, "joined-input-*.txt")
     275 + }
     276 + tmpDest = tmpFile.Name()
     277 + core.WriteToFile(tmpDest, strings.Join(raw, "\n"))
     278 + return tmpDest
    291 279  }
    292 280   
    293 281  // ScanHelp print help message
    294 282  func ScanHelp(cmd *cobra.Command, _ []string) {
    295  - fmt.Println(cmd.UsageString())
    296  - h := "\nExample Commands:\n"
    297  - h += " # Run Nmap with output from rustscan\n"
    298  - h += " echo '1.2.3.4 -> [80,443,2222]' | metabigor scan -R\n"
    299  - h += " # Only run masscan full ports\n"
    300  - h += " echo '1.2.3.4/24' | metabigor scan -o result.txt\n\n"
    301  - h += " # Only run nmap detail scan\n"
    302  - h += " echo '1.2.3.4:21' | metabigor scan -s -c 10\n"
    303  - h += " echo '1.2.3.4:21' | metabigor scan --tmp /tmp/raw-result/ -s -o result.txt\n\n"
    304  - h += " # Only run scan with zmap \n"
    305  - h += " cat ranges.txt | metabigor scan -p '443,80' -z\n"
    306  - h += "\n"
    307  - fmt.Printf(h)
     283 + fmt.Println(cmd.UsageString())
     284 + h := "\nExample Commands:\n"
     285 + h += " # Run Nmap with output from rustscan\n"
     286 + h += " echo '1.2.3.4 -> [80,443,2222]' | metabigor scan -R\n"
     287 + h += " # Only run masscan full ports\n"
     288 + h += " echo '1.2.3.4/24' | metabigor scan -o result.txt\n\n"
     289 + h += " # Only run nmap detail scan\n"
     290 + h += " echo '1.2.3.4:21' | metabigor scan -s -c 10\n"
     291 + h += " echo '1.2.3.4:21' | metabigor scan --tmp /tmp/raw-result/ -s -o result.txt\n\n"
     292 + h += " # Only run scan with zmap \n"
     293 + h += " cat ranges.txt | metabigor scan -p '443,80' -z\n"
     294 + h += "\n"
     295 + fmt.Printf(h)
    308 296  }
    309 297   
  • ■ ■ ■ ■ ■ ■
    core/version.go
    skipped 2 lines
    3 3  import "fmt"
    4 4   
    5 5  const (
    6  - // VERSION current version of this project
    7  - VERSION = "v1.2"
    8  - // AUTHOR of this project
    9  - AUTHOR = "@j3ssiejjj"
     6 + // VERSION current version of this project
     7 + VERSION = "v1.2.1"
     8 + // AUTHOR of this project
     9 + AUTHOR = "@j3ssiejjj"
    10 10  )
    11 11   
    12  -var DESC = fmt.Sprintf(`Metabigor - Intelligence Tool but without API key - %v by %v`, VERSION, AUTHOR)
     12 +var DESC = fmt.Sprintf(`Metabigor - OSINT tools and more but without API key - %v by %v`, VERSION, AUTHOR)
    13 13   
  • ■ ■ ■ ■
    modules/ga.go
    skipped 35 lines
    36 36   }
    37 37   
    38 38   // regex 3
    39  - //regex = regexp.MustCompile(`UA-\d+-\d+`)
     39 + //regex = regexp.MustCompile(`UA-[0-9]+-[0-9]+`)
    40 40   //ua := regex.FindAllStringSubmatch(content, -1)
    41 41   //for _, id := range ua {
    42 42   // results = append(results, id[0])
    skipped 4 lines
Please wait...
Page is in error, reload to recover