Permalink
Browse files

Added Shodan.io module

  • Loading branch information...
Nhoya committed Jan 21, 2018
1 parent 32b6aab commit faa2ea909d1e0d91938f8168d3cbca3c02d9818b
Showing with 118 additions and 23 deletions.
  1. +1 −0 .travis.yml
  2. +23 −19 README.md
  3. +2 −1 build.sh
  4. +3 −0 config/config.json
  5. +6 −2 gOSINT.go
  6. +61 −0 shodan.go
  7. +1 −1 telegram.go
  8. +21 −0 utils.go
View
@@ -17,4 +17,5 @@ install:
- go get github.com/jessevdk/go-flags
- go get gopkg.in/src-d/go-git.v4
- go get github.com/jaytaylor/html2text
- gopkg.in/ns3777k/go-shodan.v2/shodan
- go build
View
@@ -47,6 +47,7 @@ go get "github.com/nhoya/goPwned"
go get "github.com/jessevdk/go-flags"
go get "gopkg.in/src-d/go-git.v4"
go get "github.com/jaytaylor/html2text"
go get "gopkg.in/ns3777k/go-shodan.v2/shodan"
```
`git clone https://github.com/Nhoya/gOSINT && cd gOSINT && go build`
@@ -59,36 +60,35 @@ Currently `gOSINT` is still an early version and few modules are supported
- [x] Search for mails in PGP Server
- [x] [https://haveibeenpwned.com/](http://haveibeenpwned.com/) search for mail in databreach
- [x] Retrive Telegram Public Group Messages
- [ ] WHOIS support (the module is ready but has to be integrated)
- [x] Search for mail address in source
- [ ] [https://shodan.io](https://shodan.io) search
- [x] [https://shodan.io](https://shodan.io) search
- [ ] Social Media search
- [ ] Search Engine search
## Usage
```
Usage:
gOSINT [OPTIONS]
gOSINT [OPTIONS]
Application Options:
-m, --module=[pgp|pwnd|git|plainSearch|telegram] Specify module
-v, --version Print version
--url= Specify target URL
--gitAPI=[github|bitbucket] Specify git website API to use (for git module,optional)
-c, --clone Enable clone function for plainSearch module (need to specify repo URL)
--mail= Specify mail target (for pgp and pwnd module)
--grace= Specify telegram messages grace period (default: 15)
-g, --tgroup= Specify Telegram group/channel name
-s, --tgstart= Specify first message to scrape
-e, --tgend= Specify last message to scrape
--dumpfile Create and resume messages from dumpfile
--ask-confirmation Ask confirmation before adding mail to set (for plainSearch module)
-p, --path= Specify target path (for plainSearch module)
-f, --full Make deep search using linked modules
-m, --module=[pgp|pwnd|git|plainSearch|telegram|shodan] Specify module
-v, --version Print version
--url= Specify target URL
--gitAPI=[github|bitbucket] Specify git website API to use (for git module,optional)
-c, --clone Enable clone function for plainSearch module (need to specify repo URL)
--mail= Specify mail target (for pgp and pwnd module)
--grace= Specify telegram messages grace period (default: 15)
-g, --tgroup= Specify Telegram group/channel name
-s, --tgstart= Specify first message to scrape
-e, --tgend= Specify last message to scrape
--dumpfile Create and resume messages from dumpfile
--ask-confirmation Ask confirmation before adding mail to set (for plainSearch module)
-p, --path= Specify target path (for plainSearch module)
-t, --target= Specify shodan target host
-f, --full Make deep search using linked modules
Help Options:
-h, --help Show this help message
-h, --help Show this help message
```
## Examples
@@ -152,6 +152,10 @@ the output will be stored in a file, if the file is already populated it will re
Set start and end messages for scraping
`gOSINT -m shodan -t [HOST IP]`
Start Scan for Host
## PGP module Demo
[![asciicast](https://asciinema.org/a/21PCpbgFqyHiTbPINexHKEywj.png)](https://asciinema.org/a/21PCpbgFqyHiTbPINexHKEywj)
View
@@ -22,7 +22,7 @@ if [[ "$version" =~ $go_version_regex ]]; then
fi
fi
dependencies=( github.com/deckarep/golang-set github.com/nhoya/goPwned github.com/jessevdk/go-flags gopkg.in/src-d/go-git.v4 github.com/jaytaylor/html2text)
dependencies=( github.com/deckarep/golang-set github.com/nhoya/goPwned github.com/jessevdk/go-flags gopkg.in/src-d/go-git.v4 github.com/jaytaylor/html2text gopkg.in/ns3777k/go-shodan.v2/shodan )
echo -e "${GREEN}[+] Installing dependencies${END}"
@@ -41,3 +41,4 @@ echo -e "${GREEN}[+] Building gOSINT${END}"
go build
echo -e "${GREEN}[+] Installing gOSINT${END}"
sudo mv gOSINT /usr/local/bin
mv config/config.json $HOME/.config/gOSINT.conf
View
@@ -0,0 +1,3 @@
{
"ShodanAPIKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
View
@@ -8,10 +8,10 @@ import (
"github.com/jessevdk/go-flags"
)
const ver = "v0.4c"
const ver = "v0.5"
var opts struct {
Module string `short:"m" long:"module" description:"Specify module" choice:"pgp" choice:"pwnd" choice:"git" choice:"plainSearch" choice:"telegram"`
Module string `short:"m" long:"module" description:"Specify module" choice:"pgp" choice:"pwnd" choice:"git" choice:"plainSearch" choice:"telegram" choice:"shodan"`
Version bool `short:"v" long:"version" description:"Print version"`
// git module
URL string `long:"url" default:"" description:"Specify target URL"`
@@ -28,6 +28,8 @@ var opts struct {
// plainSearch module
Confirm bool `long:"ask-confirmation" description:"Ask confirmation before adding mail to set (for plainSearch module)"`
Path string `short:"p" long:"path" description:"Specify target path (for plainSearch module)"`
// shodan module
ShodanTarget string `short:"t" long:"target" description:"Specify shodan target host"`
// generic
Mode bool `short:"f" long:"full" description:"Make deep search using linked modules"`
}
@@ -67,5 +69,7 @@ func main() {
initPlainSearch(mailSet)
case "telegram":
initTelegram()
case "shodan":
initShodan()
}
}
View
@@ -0,0 +1,61 @@
package main
import (
"fmt"
"gopkg.in/ns3777k/go-shodan.v2/shodan"
"os"
"strconv"
)
func initShodan() {
if opts.ShodanTarget == "" {
fmt.Println("[-] You need to specify the target")
os.Exit(1)
}
APIKey := getConfigFile().ShodanAPIKey
if APIKey == "" {
fmt.Println("[-] Unable to retrive Shodan API Key from config file")
os.Exit(1)
}
getShodanHostInfo(opts.ShodanTarget, APIKey)
}
func getShodanHostInfo(target string, APIKey string) {
client := shodan.NewClient(nil, APIKey)
report, err := client.GetServicesForHost(target, &shodan.HostServicesOptions{false, false})
if err != nil {
fmt.Println("[-] Unable to get Report")
fmt.Println(err)
os.Exit(1)
}
fmt.Println("==== REPORT FOR " + target + " ====")
fmt.Println("ISP: " + report.ISP)
fmt.Println("Organization: " + report.Organization)
if report.OS != "" {
fmt.Println("OS: " + report.OS)
}
fmt.Println("Ports:", report.Ports)
fmt.Println("Hostnames:", report.Hostnames)
if len(report.Vulnerabilities) > 0 {
fmt.Println("Vulnerabilities:", report.Vulnerabilities)
}
fmt.Println("Country:", report.HostLocation.Country)
fmt.Println("City:", report.HostLocation.City)
fmt.Println("Last Update: " + report.LastUpdate)
getShodanServicesData(report.Data)
}
func getShodanServicesData(services []*shodan.HostData) {
for _, service := range services {
if service.Product == "" {
service.Product = "Unknown"
}
fmt.Println("Service on port " + strconv.Itoa(service.Port) + ": " + service.Product + " " + string(service.Version))
if service.Title != "" {
fmt.Println("\tTitle: " + service.Title)
}
if service.OS != "" {
fmt.Println("\tOS " + service.OS)
}
}
}
View
@@ -42,7 +42,7 @@ func getTelegramGroupHistory(group string, grace int, dumpFlag bool, startMessag
readFromTelegramDump(&startMessage, dumpfile, dumpFlag, &messageCounter)
//add a counter to remember the first message
firstMessageCounter := messageCounter - startMessage
//this is needed because if a file is availabe it will start from the next to the last found
//this is needed because if a file is available it will start from the next to the last found
messageCounter++
//if -e or - s is set but on the dumpfile the message is already scraped
if dumpFlag && ((endMessage != 0 && messageCounter >= endMessage) || (startMessage != 0 && messageCounter >= startMessage)) {
View
@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
@@ -11,6 +12,10 @@ import (
"github.com/deckarep/golang-set"
)
type Configuration struct {
ShodanAPIKey string
}
func retrieveRequestBody(domain string) string {
resp, err := http.Get(domain)
if err != nil {
@@ -89,3 +94,19 @@ func simpleQuestion(question string) bool {
}
return false
}
func getConfigFile() Configuration {
file, err := os.Open(os.Getenv("HOME") + "/.config/gOSINT.conf")
if err != nil {
fmt.Println("[-] Unable to open config file, be sure it exists")
os.Exit(1)
}
decoder := json.NewDecoder(file)
config := Configuration{}
err = decoder.Decode(&config)
if err != nil {
fmt.Println("[-] Unable to read config file")
os.Exit(1)
}
return config
}

0 comments on commit faa2ea9

Please sign in to comment.