Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit a312042

Browse files
authored
0.1
first release
1 parent f7e9eaa commit a312042

File tree

19 files changed

+1124
-0
lines changed

19 files changed

+1124
-0
lines changed

cmd/custom.go

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/thisisiliya/httpr/pkg/engines"
8+
"github.com/thisisiliya/httpr/pkg/extract"
9+
"github.com/thisisiliya/httpr/pkg/start"
10+
"github.com/thisisiliya/httpr/pkg/validate"
11+
12+
"github.com/spf13/cobra"
13+
"golang.org/x/exp/slices"
14+
)
15+
16+
var (
17+
customCommand string
18+
customTargetHost string
19+
customSpiltBy string
20+
customDepth int
21+
customShowHost bool
22+
customShowPath bool
23+
customShowSub bool
24+
25+
customCmd = &cobra.Command{
26+
Use: "custom",
27+
Short: "custom dork command to scrape",
28+
Long: ("\ngoogle page(s) scrape by custom dork commands" +
29+
"\nusage: -c site:www.google.com,inurl:map -t google.com --depth 1"),
30+
Run: customEnum,
31+
}
32+
)
33+
34+
func customEnum(_ *cobra.Command, _ []string) {
35+
36+
start.Start(rootCmd)
37+
38+
customCommand = strings.ReplaceAll(customCommand, customSpiltBy, " ")
39+
40+
for page := 0; page < customDepth; page++ {
41+
42+
wg.Add(1)
43+
44+
go func() {
45+
46+
defer wg.Done()
47+
48+
URL = engines.EncodeGoogleURL(customCommand, page)
49+
50+
for _, r := range *extract.Scrape(URL, customTargetHost, rootRetry, extract.GoogleExt) {
51+
52+
if customValidate(r) {
53+
54+
switch true {
55+
56+
case customShowHost:
57+
fmt.Println(r.Host)
58+
59+
case customShowPath:
60+
fmt.Println(r.Path)
61+
62+
case customShowSub:
63+
fmt.Println(r.Subdomain)
64+
65+
default:
66+
fmt.Println(r.URL)
67+
}
68+
}
69+
}
70+
}()
71+
72+
start.Sleep(rootCmd)
73+
}
74+
75+
wg.Wait()
76+
}
77+
78+
func customValidate(d extract.Data) bool {
79+
80+
if d.URL != "" {
81+
82+
if !slices.Contains(results, d.URL) {
83+
84+
if rootVerify {
85+
86+
if validate.Verify(d.URL) {
87+
88+
results = append(results, d.URL)
89+
return true
90+
}
91+
} else {
92+
93+
results = append(results, d.URL)
94+
return true
95+
}
96+
}
97+
}
98+
99+
return false
100+
}
101+
102+
func init() {
103+
104+
rootCmd.AddCommand(customCmd)
105+
106+
customCmd.Flags().StringVarP(&customCommand, "command", "c", "", "dork command to scrape")
107+
customCmd.Flags().StringVarP(&customTargetHost, "target-host", "t", "", "filter result by host")
108+
customCmd.Flags().StringVar(&customSpiltBy, "split-by", ",", "dork commands split character")
109+
customCmd.Flags().IntVar(&customDepth, "depth", 1, "number of pages to scrape")
110+
customCmd.Flags().BoolVar(&customShowHost, "show-host", false, "show hosts as result")
111+
customCmd.Flags().BoolVar(&customShowSub, "show-sub", false, "show subdomains as result")
112+
customCmd.Flags().BoolVar(&customShowPath, "show-path", false, "show paths as result")
113+
114+
customCmd.MarkFlagRequired("command")
115+
customCmd.MarkFlagsMutuallyExclusive("show-host", "show-sub", "show-path")
116+
}

cmd/key.go

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/thisisiliya/httpr/pkg/engines"
7+
"github.com/thisisiliya/httpr/pkg/extract"
8+
"github.com/thisisiliya/httpr/pkg/start"
9+
"github.com/thisisiliya/httpr/pkg/validate"
10+
11+
"github.com/spf13/cobra"
12+
"golang.org/x/exp/slices"
13+
)
14+
15+
var (
16+
keyDomain string
17+
keyDomains string
18+
keyKeyword string
19+
keyKeywords string
20+
keyDepth int
21+
keyShowHost bool
22+
keyShowPath bool
23+
keyShowSub bool
24+
25+
keyCmd = &cobra.Command{
26+
Use: "key",
27+
Short: "keywords enumeration for domains",
28+
Long: ("\nkeyword(s) enumeration for domain(s)" +
29+
"\nusage: -d www.google.com -k exploit --depth 3"),
30+
Run: keyExt,
31+
}
32+
)
33+
34+
func keyExt(_ *cobra.Command, _ []string) {
35+
36+
start.Start(rootCmd)
37+
38+
switch {
39+
40+
case keyDomain != "":
41+
opt.Domain = keyDomain
42+
43+
switch {
44+
45+
case keyKeyword != "":
46+
opt.Key = keyKeyword
47+
keyEnum()
48+
49+
case keyKeywords != "":
50+
for _, key := range extract.ReadFile(keyKeywords) {
51+
52+
opt.Key = key
53+
keyEnum()
54+
}
55+
}
56+
57+
case keyDomains != "":
58+
switch {
59+
60+
case keyKeyword != "":
61+
opt.Key = keyKeyword
62+
63+
for _, domain := range extract.ReadFile(keyDomains) {
64+
65+
opt.Domain = domain
66+
keyEnum()
67+
}
68+
69+
case keyKeywords != "":
70+
for _, domain := range extract.ReadFile(keyDomains) {
71+
72+
opt.Domain = domain
73+
74+
for _, key := range extract.ReadFile(keyKeywords) {
75+
76+
opt.Key = key
77+
keyEnum()
78+
}
79+
}
80+
}
81+
}
82+
}
83+
84+
func keyEnum() {
85+
86+
opt.Page = 0
87+
88+
for opt.Page < keyDepth {
89+
90+
wg.Add(1)
91+
92+
go func() {
93+
94+
defer wg.Done()
95+
96+
URL = engines.GoogleURL(&opt)
97+
98+
for _, r := range *extract.Scrape(URL, opt.Domain, rootRetry, extract.GoogleExt) {
99+
100+
if keyValidate(r) {
101+
102+
switch true {
103+
104+
case customShowHost:
105+
fmt.Println(r.Host)
106+
107+
case customShowPath:
108+
fmt.Println(r.Path)
109+
110+
case customShowSub:
111+
fmt.Println(r.Subdomain)
112+
113+
default:
114+
fmt.Println(r.URL)
115+
}
116+
}
117+
}
118+
}()
119+
120+
opt.Page++
121+
start.Sleep(rootCmd)
122+
}
123+
124+
wg.Wait()
125+
}
126+
127+
func keyValidate(d extract.Data) bool {
128+
129+
if d.Host == opt.Domain || d.Host == "www."+opt.Domain {
130+
131+
if !slices.Contains(results, d.URL) {
132+
133+
if rootVerify {
134+
135+
if validate.Verify(d.URL) {
136+
137+
results = append(results, d.URL)
138+
return true
139+
}
140+
} else {
141+
142+
results = append(results, d.URL)
143+
return true
144+
}
145+
}
146+
}
147+
148+
return false
149+
}
150+
151+
func init() {
152+
153+
rootCmd.AddCommand(keyCmd)
154+
155+
keyCmd.Flags().StringVarP(&keyDomain, "domain", "d", "", "target domain to search keyword(s)")
156+
keyCmd.Flags().StringVar(&keyDomains, "domains", "", "target domains file path")
157+
keyCmd.Flags().StringVarP(&keyKeyword, "keyword", "k", "", "target keyword to search")
158+
keyCmd.Flags().StringVar(&keyKeywords, "keywords", "", "target keywords path")
159+
keyCmd.Flags().IntVar(&keyDepth, "depth", 3, "number of pages to scrape per key")
160+
keyCmd.Flags().BoolVar(&keyShowHost, "show-host", false, "show hosts as result")
161+
keyCmd.Flags().BoolVar(&keyShowSub, "show-sub", false, "show subdomains as result")
162+
keyCmd.Flags().BoolVar(&keyShowPath, "show-path", false, "show paths as result")
163+
164+
keyCmd.MarkFlagsMutuallyExclusive("domain", "domains")
165+
keyCmd.MarkFlagsMutuallyExclusive("keyword", "keywords")
166+
}

0 commit comments

Comments
 (0)