@@ -3,17 +3,15 @@ package cmd
3
3
import (
4
4
"bytes"
5
5
"context"
6
- "crypto/tls"
7
6
"encoding/json"
8
7
"io"
9
- "net/http"
10
8
"net/url"
11
9
"os"
12
10
"path"
13
11
"strconv"
14
12
"strings"
15
- "time"
16
13
14
+ "github.com/CompassSecurity/pipeleak/helper"
17
15
"github.com/perimeterx/marshmallow"
18
16
"github.com/rs/zerolog/log"
19
17
"github.com/spf13/cobra"
@@ -32,7 +30,7 @@ type result struct {
32
30
Hostnames []string `json:"hostnames"`
33
31
Port int `json:"port"`
34
32
IPString string `json:"ip_str"`
35
- Shodan shodan `json:"shodan "`
33
+ Shodan shodan `json:"_shodan "`
36
34
}
37
35
38
36
func NewShodanCmd () * cobra.Command {
@@ -63,7 +61,7 @@ func Shodan(cmd *cobra.Command, args []string) {
63
61
64
62
data , _ := io .ReadAll (jsonFile )
65
63
ctx := context .Background ()
66
- group := parallel .Unlimited (ctx )
64
+ group := parallel .Limited (ctx , 4 )
67
65
ctr := 0
68
66
69
67
for _ , line := range bytes .Split (data , []byte {'\n' }) {
@@ -74,9 +72,9 @@ func Shodan(cmd *cobra.Command, args []string) {
74
72
log .Error ().Stack ().Err (err ).Msg ("failed unmarshalling jsonl line" )
75
73
} else {
76
74
77
- isHttps := true
78
- if strings .EqualFold ("http " , d .Shodan .Module ) {
79
- isHttps = false
75
+ isHttps := false
76
+ if strings .EqualFold ("https " , d .Shodan .Module ) {
77
+ isHttps = true
80
78
}
81
79
82
80
if len (d .Hostnames ) == 0 {
@@ -126,10 +124,7 @@ func isRegistrationEnabled(base string) (bool, error) {
126
124
u .Path = path .Join (u .Path , "/users/somenotexistigusr/exists" )
127
125
s := u .String ()
128
126
129
- tr := & http.Transport {
130
- TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
131
- }
132
- client := & http.Client {Transport : tr , Timeout : 15 * time .Second }
127
+ client := helper .GetNonVerifyingHTTPClient ()
133
128
res , err := client .Get (s )
134
129
135
130
if err != nil {
@@ -160,10 +155,8 @@ func checkNrPublicRepos(base string) (int, error) {
160
155
if err != nil {
161
156
return 0 , err
162
157
}
163
- tr := & http.Transport {
164
- TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
165
- }
166
- client := & http.Client {Transport : tr , Timeout : 15 * time .Second }
158
+
159
+ client := helper .GetNonVerifyingHTTPClient ()
167
160
u .Path = "/api/v4/projects"
168
161
s := u .String ()
169
162
res , err := client .Get (s + "?per_page=100" )
0 commit comments