Skip to content

Commit 56ed726

Browse files
committed
initial implementation
1 parent 749dc07 commit 56ed726

File tree

10 files changed

+2284
-16
lines changed

10 files changed

+2284
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
nuclei-api
2+
Taskfile.yaml

cmd/client.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
package cmd
17+
18+
import (
19+
"context"
20+
"fmt"
21+
pb "github.com/pyneda/nuclei-api/service"
22+
"github.com/spf13/cobra"
23+
"google.golang.org/grpc"
24+
"google.golang.org/grpc/credentials/insecure"
25+
"io"
26+
"log"
27+
"time"
28+
)
29+
30+
// clientCmd represents the client command
31+
var clientCmd = &cobra.Command{
32+
Use: "client",
33+
Short: "A brief description of your command",
34+
Run: func(cmd *cobra.Command, args []string) {
35+
fmt.Println("client called")
36+
target, err := cmd.Flags().GetString("target")
37+
if err != nil {
38+
log.Fatalf("Error parsing flags: %v", err)
39+
}
40+
conn, err := grpc.Dial("localhost:8555", grpc.WithTransportCredentials(insecure.NewCredentials()))
41+
if err != nil {
42+
log.Fatalf("did not connect: %v", err)
43+
}
44+
defer conn.Close()
45+
c := pb.NewNucleiApiClient(conn)
46+
47+
// Contact the server and print out its response.
48+
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*60)
49+
defer cancel()
50+
stream, err := c.Scan(ctx, &pb.ScanRequest{
51+
Url: target,
52+
AutomaticScan: true,
53+
})
54+
if err != nil {
55+
log.Fatalf("Error: %v", err)
56+
}
57+
for {
58+
result, err := stream.Recv()
59+
if err == io.EOF {
60+
break
61+
}
62+
if err != nil {
63+
log.Fatalf("client.Scan failed: %v", err)
64+
}
65+
log.Printf("Result %v", result)
66+
}
67+
},
68+
}
69+
70+
func init() {
71+
rootCmd.AddCommand(clientCmd)
72+
73+
// Here you will define your flags and configuration settings.
74+
75+
// Cobra supports Persistent Flags which will work for this command
76+
// and all subcommands, e.g.:
77+
// clientCmd.PersistentFlags().String("foo", "", "A help for foo")
78+
clientCmd.Flags().StringP("target", "t", "", "Target to scan")
79+
clientCmd.MarkFlagRequired("target")
80+
// Cobra supports local flags which will only run when this command
81+
// is called directly, e.g.:
82+
// clientCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
83+
}

cmd/start.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,23 +16,34 @@ limitations under the License.
1616
package cmd
1717

1818
import (
19-
"fmt"
20-
19+
"github.com/pyneda/nuclei-api/server"
20+
pb "github.com/pyneda/nuclei-api/service"
2121
"github.com/spf13/cobra"
22+
"google.golang.org/grpc"
23+
"google.golang.org/grpc/reflection"
24+
25+
"log"
26+
"net"
2227
)
2328

2429
// startCmd represents the start command
2530
var startCmd = &cobra.Command{
2631
Use: "start",
2732
Short: "A brief description of your command",
28-
Long: `A longer description that spans multiple lines and likely contains examples
29-
and usage of using your command. For example:
3033

31-
Cobra is a CLI library for Go that empowers applications.
32-
This application is a tool to generate the needed files
33-
to quickly create a Cobra application.`,
3434
Run: func(cmd *cobra.Command, args []string) {
35-
fmt.Println("start called")
35+
log.Println("Starting nuclei-api server...")
36+
listener, err := net.Listen("tcp", ":8555")
37+
if err != nil {
38+
panic(err)
39+
}
40+
41+
s := grpc.NewServer()
42+
pb.RegisterNucleiApiServer(s, &server.Server{})
43+
reflection.Register(s)
44+
if err := s.Serve(listener); err != nil {
45+
log.Fatalf("failed to serve: %v", err)
46+
}
3647
},
3748
}
3849

go.mod

Lines changed: 197 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,214 @@ module github.com/pyneda/nuclei-api
33
go 1.20
44

55
require (
6+
github.com/logrusorgru/aurora v2.0.3+incompatible
7+
github.com/projectdiscovery/nuclei/v2 v2.9.8
8+
github.com/projectdiscovery/ratelimit v0.0.9
9+
github.com/spf13/cobra v1.7.0
10+
github.com/spf13/viper v1.16.0
11+
google.golang.org/grpc v1.55.0
12+
google.golang.org/protobuf v1.30.0
13+
)
14+
15+
require (
16+
aead.dev/minisign v0.2.0 // indirect
17+
git.mills.io/prologic/smtpd v0.0.0-20210710122116-a525b76c287a // indirect
18+
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
19+
github.com/Masterminds/semver/v3 v3.2.1 // indirect
20+
github.com/Mzack9999/gcache v0.0.0-20230410081825-519e28eab057 // indirect
21+
github.com/Mzack9999/go-http-digest-auth-client v0.6.1-0.20220414142836-eb8883508809 // indirect
22+
github.com/Mzack9999/gostruct v0.0.0-20230415193108-30b70932da81 // indirect
23+
github.com/Mzack9999/ldapserver v1.0.2-0.20211229000134-b44a0d6ad0dd // indirect
24+
github.com/VividCortex/ewma v1.2.0 // indirect
25+
github.com/akrylysov/pogreb v0.10.1 // indirect
26+
github.com/alecthomas/chroma v0.10.0 // indirect
27+
github.com/alecthomas/jsonschema v0.0.0-20211022214203-8b29eab41725 // indirect
28+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
29+
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
30+
github.com/andybalholm/brotli v1.0.5 // indirect
31+
github.com/andygrunwald/go-jira v1.16.0 // indirect
32+
github.com/antchfx/htmlquery v1.3.0 // indirect
33+
github.com/antchfx/xmlquery v1.3.15 // indirect
34+
github.com/antchfx/xpath v1.2.3 // indirect
35+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
36+
github.com/aws/aws-sdk-go-v2 v1.18.1 // indirect
37+
github.com/aws/aws-sdk-go-v2/config v1.18.27 // indirect
38+
github.com/aws/aws-sdk-go-v2/credentials v1.13.26 // indirect
39+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4 // indirect
40+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34 // indirect
41+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28 // indirect
42+
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 // indirect
43+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 // indirect
44+
github.com/aws/aws-sdk-go-v2/service/sso v1.12.12 // indirect
45+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12 // indirect
46+
github.com/aws/aws-sdk-go-v2/service/sts v1.19.2 // indirect
47+
github.com/aws/smithy-go v1.13.5 // indirect
48+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
49+
github.com/aymerick/douceur v0.2.0 // indirect
50+
github.com/bluele/gcache v0.0.2 // indirect
51+
github.com/caddyserver/certmagic v0.17.2 // indirect
52+
github.com/charmbracelet/glamour v0.6.0 // indirect
53+
github.com/cheggaaa/pb/v3 v3.1.2 // indirect
54+
github.com/cloudflare/cfssl v1.6.4 // indirect
55+
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
56+
github.com/corpix/uarand v0.2.0 // indirect
57+
github.com/dimchansky/utfbom v1.1.1 // indirect
58+
github.com/dlclark/regexp2 v1.8.1 // indirect
59+
github.com/docker/go-units v0.5.0 // indirect
60+
github.com/dsnet/compress v0.0.1 // indirect
61+
github.com/fatih/color v1.14.1 // indirect
62+
github.com/fatih/structs v1.1.0 // indirect
663
github.com/fsnotify/fsnotify v1.6.0 // indirect
64+
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
65+
github.com/gaukas/godicttls v0.0.3 // indirect
66+
github.com/go-ole/go-ole v1.2.6 // indirect
67+
github.com/go-playground/locales v0.14.1 // indirect
68+
github.com/go-playground/universal-translator v0.18.1 // indirect
69+
github.com/go-playground/validator/v10 v10.14.1 // indirect
70+
github.com/go-rod/rod v0.113.0 // indirect
71+
github.com/goburrow/cache v0.1.4 // indirect
72+
github.com/gobwas/httphead v0.1.0 // indirect
73+
github.com/gobwas/pool v0.2.1 // indirect
74+
github.com/gobwas/ws v1.2.1 // indirect
75+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
76+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
77+
github.com/golang/protobuf v1.5.3 // indirect
78+
github.com/golang/snappy v0.0.4 // indirect
79+
github.com/google/certificate-transparency-go v1.1.4 // indirect
80+
github.com/google/go-github v17.0.0+incompatible // indirect
81+
github.com/google/go-github/v30 v30.1.0 // indirect
82+
github.com/google/go-querystring v1.1.0 // indirect
83+
github.com/google/uuid v1.3.0 // indirect
84+
github.com/gorilla/css v1.0.0 // indirect
85+
github.com/h2non/filetype v1.1.3 // indirect
86+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
87+
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
88+
github.com/hashicorp/go-version v1.6.0 // indirect
789
github.com/hashicorp/hcl v1.0.0 // indirect
90+
github.com/hdm/jarm-go v0.0.7 // indirect
91+
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect
892
github.com/inconshreveable/mousetrap v1.1.0 // indirect
93+
github.com/itchyny/gojq v0.12.13 // indirect
94+
github.com/itchyny/timefmt-go v0.1.5 // indirect
95+
github.com/json-iterator/go v1.1.12 // indirect
96+
github.com/julienschmidt/httprouter v1.3.0 // indirect
97+
github.com/kataras/jwt v0.1.8 // indirect
98+
github.com/klauspost/compress v1.16.6 // indirect
99+
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
100+
github.com/leodido/go-urn v1.2.4 // indirect
101+
github.com/libdns/libdns v0.2.1 // indirect
102+
github.com/lor00x/goldap v0.0.0-20180618054307-a546dffdd1a3 // indirect
103+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
104+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
105+
github.com/mackerelio/go-osstat v0.2.4 // indirect
9106
github.com/magiconair/properties v1.8.7 // indirect
107+
github.com/mattn/go-colorable v0.1.13 // indirect
108+
github.com/mattn/go-isatty v0.0.19 // indirect
109+
github.com/mattn/go-runewidth v0.0.14 // indirect
110+
github.com/mholt/acmez v1.0.4 // indirect
111+
github.com/mholt/archiver v3.1.1+incompatible // indirect
112+
github.com/microcosm-cc/bluemonday v1.0.24 // indirect
113+
github.com/miekg/dns v1.1.55 // indirect
114+
github.com/minio/selfupdate v0.6.0 // indirect
115+
github.com/mitchellh/go-homedir v1.1.0 // indirect
10116
github.com/mitchellh/mapstructure v1.5.0 // indirect
117+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
118+
github.com/modern-go/reflect2 v1.0.2 // indirect
119+
github.com/muesli/reflow v0.3.0 // indirect
120+
github.com/muesli/termenv v0.15.1 // indirect
121+
github.com/nwaples/rardecode v1.1.3 // indirect
122+
github.com/olekukonko/tablewriter v0.0.5 // indirect
11123
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
124+
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
125+
github.com/pkg/errors v0.9.1 // indirect
126+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
127+
github.com/projectdiscovery/asnmap v1.0.4 // indirect
128+
github.com/projectdiscovery/blackrock v0.0.1 // indirect
129+
github.com/projectdiscovery/clistats v0.0.19 // indirect
130+
github.com/projectdiscovery/dsl v0.0.13-0.20230703115450-39d83b5a7026 // indirect
131+
github.com/projectdiscovery/fastdialer v0.0.32 // indirect
132+
github.com/projectdiscovery/fasttemplate v0.0.2 // indirect
133+
github.com/projectdiscovery/freeport v0.0.5 // indirect
134+
github.com/projectdiscovery/goflags v0.1.10 // indirect
135+
github.com/projectdiscovery/gologger v1.1.10 // indirect
136+
github.com/projectdiscovery/hmap v0.0.13 // indirect
137+
github.com/projectdiscovery/interactsh v1.1.4 // indirect
138+
github.com/projectdiscovery/mapcidr v1.1.2 // indirect
139+
github.com/projectdiscovery/networkpolicy v0.0.6 // indirect
140+
github.com/projectdiscovery/rawhttp v0.1.16-0.20230703065054-806b4fcfab11 // indirect
141+
github.com/projectdiscovery/rdap v0.9.1-0.20221108103045-9865884d1917 // indirect
142+
github.com/projectdiscovery/retryabledns v1.0.30 // indirect
143+
github.com/projectdiscovery/retryablehttp-go v1.0.18 // indirect
144+
github.com/projectdiscovery/sarif v0.0.1 // indirect
145+
github.com/projectdiscovery/tlsx v1.1.0 // indirect
146+
github.com/projectdiscovery/utils v0.0.40 // indirect
147+
github.com/projectdiscovery/yamldoc-go v1.0.4 // indirect
148+
github.com/refraction-networking/utls v1.3.2 // indirect
149+
github.com/remeh/sizedwaitgroup v1.0.0 // indirect
150+
github.com/rivo/uniseg v0.4.4 // indirect
151+
github.com/rs/xid v1.5.0 // indirect
152+
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
153+
github.com/sashabaranov/go-openai v1.12.0 // indirect
154+
github.com/segmentio/ksuid v1.0.4 // indirect
155+
github.com/shirou/gopsutil/v3 v3.23.5 // indirect
156+
github.com/shoenig/go-m1cpu v0.1.6 // indirect
157+
github.com/spaolacci/murmur3 v1.1.0 // indirect
12158
github.com/spf13/afero v1.9.5 // indirect
13159
github.com/spf13/cast v1.5.1 // indirect
14-
github.com/spf13/cobra v1.7.0 // indirect
15160
github.com/spf13/jwalterweatherman v1.1.0 // indirect
16161
github.com/spf13/pflag v1.0.5 // indirect
17-
github.com/spf13/viper v1.16.0 // indirect
18162
github.com/subosito/gotenv v1.4.2 // indirect
19-
golang.org/x/sys v0.8.0 // indirect
20-
golang.org/x/text v0.9.0 // indirect
163+
github.com/syndtr/goleveldb v1.0.0 // indirect
164+
github.com/tidwall/btree v1.6.0 // indirect
165+
github.com/tidwall/buntdb v1.3.0 // indirect
166+
github.com/tidwall/gjson v1.14.4 // indirect
167+
github.com/tidwall/grect v0.1.4 // indirect
168+
github.com/tidwall/match v1.1.1 // indirect
169+
github.com/tidwall/pretty v1.2.1 // indirect
170+
github.com/tidwall/rtred v0.1.2 // indirect
171+
github.com/tidwall/tinyqueue v0.1.1 // indirect
172+
github.com/tklauser/go-sysconf v0.3.11 // indirect
173+
github.com/tklauser/numcpus v0.6.0 // indirect
174+
github.com/trivago/tgo v1.0.7 // indirect
175+
github.com/ulikunitz/xz v0.5.11 // indirect
176+
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 // indirect
177+
github.com/valyala/bytebufferpool v1.0.0 // indirect
178+
github.com/valyala/fasttemplate v1.2.2 // indirect
179+
github.com/weppos/publicsuffix-go v0.30.1-0.20230422193905-8fecedd899db // indirect
180+
github.com/xanzy/go-gitlab v0.84.0 // indirect
181+
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
182+
github.com/yl2chen/cidranger v1.0.2 // indirect
183+
github.com/ysmood/fetchup v0.2.3 // indirect
184+
github.com/ysmood/goob v0.4.0 // indirect
185+
github.com/ysmood/got v0.34.1 // indirect
186+
github.com/ysmood/gson v0.7.3 // indirect
187+
github.com/ysmood/leakless v0.8.0 // indirect
188+
github.com/yuin/goldmark v1.5.4 // indirect
189+
github.com/yuin/goldmark-emoji v1.0.1 // indirect
190+
github.com/yusufpapurcu/wmi v1.2.3 // indirect
191+
github.com/zmap/rc2 v0.0.0-20190804163417-abaa70531248 // indirect
192+
github.com/zmap/zcrypto v0.0.0-20230422215203-9a665e1e9968 // indirect
193+
go.etcd.io/bbolt v1.3.7 // indirect
194+
go.uber.org/atomic v1.10.0 // indirect
195+
go.uber.org/multierr v1.11.0 // indirect
196+
go.uber.org/zap v1.24.0 // indirect
197+
goftp.io/server/v2 v2.0.0 // indirect
198+
golang.org/x/crypto v0.10.0 // indirect
199+
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
200+
golang.org/x/mod v0.11.0 // indirect
201+
golang.org/x/net v0.11.0 // indirect
202+
golang.org/x/oauth2 v0.9.0 // indirect
203+
golang.org/x/sys v0.9.0 // indirect
204+
golang.org/x/text v0.10.0 // indirect
205+
golang.org/x/time v0.3.0 // indirect
206+
golang.org/x/tools v0.10.0 // indirect
207+
google.golang.org/appengine v1.6.7 // indirect
208+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
209+
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
210+
gopkg.in/corvus-ch/zbase32.v1 v1.0.0 // indirect
211+
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
21212
gopkg.in/ini.v1 v1.67.0 // indirect
213+
gopkg.in/yaml.v2 v2.4.0 // indirect
22214
gopkg.in/yaml.v3 v3.0.1 // indirect
215+
moul.io/http2curl v1.0.0 // indirect
23216
)

0 commit comments

Comments
 (0)