Skip to content

Commit

Permalink
Rewrite the tool in Go
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ssie committed Dec 31, 2019
0 parents commit 30c092f
Show file tree
Hide file tree
Showing 20 changed files with 1,613 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_STORE
.goreleaser.yml
dist
out*
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2019 j3ssie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<p align="center">
<img alt="Metabigor" src="https://image.flaticon.com/icons/svg/2303/2303030.svg" height="140" />
<p align="center">Intelligence Framework but without API key</p>
<p align="center">
<a href="https://github.com/j3ssie/metabigor"><img alt="Release" src="https://img.shields.io/badge/version-1.0-red.svg"></a>
<a href=""><img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>
</p>
</p>

## What is Metabigor?
Metabigor is Intelligence Framework, its goal is to do OSINT tasks and more but without any API key.


## Installation

```
go get -u https://github.com/j3ssie/metabigor
```


### Example Commands

```
# discovery IP of ASN
echo "company" | metabigor net --org -o /tmp/result.txt
# discovery IP of ASN
echo "ASN1111" | metabigor net --asn -o /tmp/result.txt
cat list_of_ASNs | metabigor net --asn -o /tmp/result.txt
# running masscan on port 443
echo "1.2.3.4/24" | metabigor scan -p 443 -o /tmp/result.txt
# running masscan on port all port and nmap on open port
cat list_of_IPs | metabigor scan --detail -o /tmp/result.txt
```

## Credits

Logo from [flaticon](https://www.flaticon.com/free-icon/metabolism_1774457) by [freepik
](https://www.flaticon.com/authors/freepik)

## Disclaimer

This tool is for educational purposes only. You are responsible for your own actions. If you mess something up or break any laws while using this software, it's your fault, and your fault only.

## License

`Metabigor` is made with ♥ by [@j3ssiejjj](https://twitter.com/j3ssiejjj) and it is released under the MIT license.
146 changes: 146 additions & 0 deletions cmd/net.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package cmd

import (
"fmt"
"strings"
"sync"

"github.com/j3ssie/metabigor/core"
"github.com/j3ssie/metabigor/modules"
"github.com/spf13/cobra"
"github.com/thoas/go-funk"
)

var netCmd *cobra.Command

func init() {
// byeCmd represents the bye command
var netCmd = &cobra.Command{
Use: "net",
Short: "Discover Network Inforamtion about targets",
Long: fmt.Sprintf(`Metabigor - Intelligence Framework but without API key - %v by %v`, core.VERSION, core.AUTHOR),
RunE: runNet,
}

netCmd.Flags().Bool("asn", false, "Take input as ASN")
netCmd.Flags().Bool("org", false, "Take input as Organization")
RootCmd.AddCommand(netCmd)
}

func runNet(cmd *cobra.Command, args []string) error {
asn, _ := cmd.Flags().GetBool("asn")
org, _ := cmd.Flags().GetBool("org")
var inputs []string

if strings.Contains(options.Input, "\n") {
inputs = strings.Split(options.Input, "\n")
} else {
inputs = append(inputs, options.Input)
}

var wg sync.WaitGroup
jobs := make(chan string)

for i := 0; i < options.Concurrency; i++ {
wg.Add(1)
go func() {
defer wg.Done()
// do real stuff here
for job := range jobs {
var osintResult []string
if asn {
osintResult = runASN(job, options)
} else if org {
osintResult = runOrg(job, options)
}
StoreData(osintResult, options)
}
}()
}

for _, input := range inputs {
jobs <- input
}

close(jobs)
wg.Wait()

if !core.FileExists(options.Output) {
core.ErrorF("No data found")
}
return nil
}

func runASN(input string, options core.Options) []string {
core.BannerF("Starting get IP Info from ASN: ", input)
options.Net.Asn = input
var data []string
var wg sync.WaitGroup
wg.Add(1)
go func() {
data = append(data, modules.ASNBgpDotNet(options)...)
wg.Done()
}()

wg.Add(1)
go func() {
data = append(data, modules.IPInfo(options)...)
wg.Done()
}()

// wg.Add(1)
// go func() {
// data = append(data, modules.ASNSpyse(options)...)
// wg.Done()
// }()

wg.Wait()
return data
}

func runOrg(input string, options core.Options) []string {
core.BannerF("Starting get IP Info for Organization: ", input)
options.Net.Org = input
var data []string
var wg sync.WaitGroup
wg.Add(1)
go func() {
data = append(data, modules.OrgBgpDotNet(options)...)
wg.Done()
}()
wg.Add(1)
go func() {
data = append(data, modules.ASNLookup(options)...)
wg.Done()
}()
wg.Wait()

var cidrs []string
// get more IP by result ASN
for _, item := range data {
// get more range from ASN
if strings.HasPrefix(strings.ToLower(item), "as") {
wg.Add(1)
go func(item string) {
cidrs = append(cidrs, runASN(item, options)...)
wg.Done()
}(item)
continue
} else if core.StartWithNum(item) {
cidrs = append(cidrs, item)
}
}
wg.Wait()
return funk.Uniq(cidrs).([]string)
}

// StoreData store data to output
func StoreData(data []string, options core.Options) {
if len(data) > 0 {
fmt.Println(strings.Join(data, "\n"))
_, err := core.AppendToContent(options.Output, strings.Join(data, "\n"))
if err == nil {
core.InforF("Write output to: %v", options.Output)
}
}
}
89 changes: 89 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package cmd

import (
"bufio"
"fmt"
"os"
"strings"

"github.com/j3ssie/metabigor/core"
"github.com/spf13/cobra"
)

var options = core.Options{}
var config struct {
defaultSign string
secretCollab string
port string
}

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "metabigor",
Short: "Metabigor",
Long: fmt.Sprintf(`Metabigor - Intelligence Framework but without API key - %v by %v`, core.VERSION, core.AUTHOR),
}

// Execute main function
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&options.ConfigFile, "configFile", "~/.metabigor/config.yaml", "root Project")
RootCmd.PersistentFlags().StringVar(&options.Scan.TmpOutput, "tmp", "", "Temp Output folder")
RootCmd.PersistentFlags().StringVar(&options.Proxy, "proxy", "", "Proxy for doing request")
RootCmd.PersistentFlags().IntVarP(&options.Concurrency, "concurrency", "c", 3, "concurrency")
RootCmd.PersistentFlags().IntVar(&options.Timeout, "timeout", 10, "timeout")
RootCmd.PersistentFlags().StringVarP(&options.Input, "input", "i", "-", "input as a string, file or from stdin")
RootCmd.PersistentFlags().StringVarP(&options.Output, "output", "o", "out.txt", "output name")
RootCmd.PersistentFlags().BoolVar(&options.Debug, "debug", false, "Debug")
RootCmd.PersistentFlags().BoolVarP(&options.Verbose, "verbose", "v", false, "Verbose")
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
if options.Debug {
options.Verbose = true
}
if options.Verbose {
core.InforF("Metabigor %v by %v\n", core.VERSION, core.AUTHOR)
}
core.InitLog(options)
// planned feature
// if !core.FileExists(options.ConfigFile) {
// core.InitConfig(options)
// }
if options.Scan.TmpOutput != "" && !core.FolderExists(options.Scan.TmpOutput) {
core.InforF("Create new temp folder: %v", options.Scan.TmpOutput)
os.MkdirAll(options.Scan.TmpOutput, 0750)
}

// got input from stdin
if options.Input == "-" {
stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
var data []string
sc := bufio.NewScanner(os.Stdin)
for sc.Scan() {
data = append(data, sc.Text())
}
options.Input = strings.Join(data, "\n")
}
} else {
// get input from a file or just a string
if core.FileExists(options.Input) {
options.Input = core.GetFileContent(options.Input)
}
}

if options.Input == "-" || options.Input == "" {
core.ErrorF("No input found")
os.Exit(1)
}

}
Loading

0 comments on commit 30c092f

Please sign in to comment.