Skip to content

Commit

Permalink
Added another query for crt.sh in case the organization query is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ssie committed Mar 2, 2024
1 parent 2362747 commit e53fe3a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
name: "CodeQL"

on: push
# on: push

jobs:
analyze:
Expand Down
31 changes: 22 additions & 9 deletions modules/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,41 @@ package modules

import (
"fmt"
"net/url"
"strings"

"github.com/PuerkitoBio/goquery"
"github.com/j3ssie/metabigor/core"
jsoniter "github.com/json-iterator/go"
"github.com/thoas/go-funk"
"net/url"
"strings"
)

// CrtSHOrg get IPInfo from https://crt.sh
func CrtSHOrg(org string, options core.Options) []string {
crtURL := fmt.Sprintf(`https://crt.sh/?O=%v`, url.QueryEscape(org))
var result []string
var content string
var err error

core.InforF("Get data from: %v", crtURL)
content, err := core.GetResponse(crtURL, options)
// simple retry if something went wrong
if err != nil {
if content, err = core.GetResponse(crtURL, options); err != nil {
// simple retry if something went wrong
content, err = core.GetResponse(crtURL, options)
if err != nil || content == "" {
core.ErrorF("Error sending request to: %v", crtURL)
return result
}
}
if content == "" {
core.ErrorF("Error sending request to: %v", crtURL)
return result

// change the query
if strings.Contains(content, "None found") {
crtURL = fmt.Sprintf(`https://crt.sh/?q=%v`, url.QueryEscape(org))
core.InforF("No data found, change the query to: %v", crtURL)

if content, err = core.GetResponse(crtURL, options); err != nil {
core.ErrorF("Error sending request to: %v", crtURL)
return result
}
}

infos := ParseCertSH(content, options)
Expand All @@ -36,7 +50,6 @@ func CrtSHOrg(org string, options core.Options) []string {
if !options.Quiet {
fmt.Println(data)
}

}
continue
}
Expand Down
3 changes: 2 additions & 1 deletion modules/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package modules
import (
"bytes"
"fmt"
"github.com/thoas/go-funk"
"io/ioutil"
"os/exec"
"os/user"
"path/filepath"
"strings"
"text/template"

"github.com/thoas/go-funk"

jsoniter "github.com/json-iterator/go"

"github.com/j3ssie/metabigor/core"
Expand Down

0 comments on commit e53fe3a

Please sign in to comment.