Skip to content

Commit f163650

Browse files
Summary update
1 parent 60393bf commit f163650

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

cli/webscan.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"fmt"
5+
"os"
56
"strings"
67

78
"oott/helper"
@@ -109,10 +110,19 @@ func StartWebScan(domains []string) []webscans.WebsiteDetails {
109110
csvData = append(csvData, []string{domain, technologyName, result.StatusCode, result.Source, strings.Join(result.Urls, ",")})
110111
}
111112

112-
helper.ResultPrintf(" +- Extracted URLs: %d\n", len(result.Urls))
113+
if len(result.Urls) > 0 {
114+
helper.ResultPrintf(" +- Extracted URLs: %d\n", len(result.Urls))
115+
}
113116

114-
helper.ResultPrintln(">> Total Tech: ", len(result.Technologies), ", Files saved in:", result.CrawlDirectory)
115-
helper.ResultPrintln("+> Diff files saved in:", result.CrawlDirectory+".diff", "\n")
117+
if result.CrawlDirectory != "" {
118+
helper.ResultPrintln(">> Total Tech: ", len(result.Technologies), ", Files saved in:", result.CrawlDirectory)
119+
// Check if the diff file exists
120+
if _, err := os.Stat(result.CrawlDirectory + ".diff"); err == nil {
121+
helper.ResultPrintln("+> Diff files saved in:", result.CrawlDirectory+".diff", "\n")
122+
}
123+
} else {
124+
helper.ResultPrintln(">> Total Tech: ", len(result.Technologies))
125+
}
116126
}
117127
helper.InfoPrintln("<========================================================================================")
118128

webscans/crawler.go

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@ import (
2020

2121
type Crawler struct {
2222
// any necessary fields specific
23-
outputDir string
24-
done chan bool
25-
depth int
26-
domains map[string]bool // Store unique domains
23+
outputDir string
24+
done chan bool
25+
depth int
26+
websiteDetails []WebsiteDetails
2727
}
2828

2929
func (c *Crawler) ScanWebsites(domains []string) ([]WebsiteDetails, error) {
3030
helper.InfoPrintln("[+] Scanning URLs in domain:", domains)
3131
c.outputDir = lib.Config.Tmpfolder + "result/crawler/websites"
3232
c.depth = lib.Config.LevelOfDepth
33-
c.domains = make(map[string]bool) // Initialize domains map
34-
35-
var websiteDetails []WebsiteDetails
3633

3734
// Create the output directory and its parent directories
3835
if err := os.MkdirAll(c.outputDir, 0755); err != nil {
@@ -131,13 +128,13 @@ func (c *Crawler) ScanWebsites(domains []string) ([]WebsiteDetails, error) {
131128
helper.ErrorPrintln("[!] Error on diff directory", err)
132129
}
133130

134-
websiteDetails = append(websiteDetails, *websiteDetail)
131+
c.websiteDetails = append(c.websiteDetails, *websiteDetail)
135132

136133
// Stop loading animation
137134
c.done <- true
138135
}
139136

140-
return websiteDetails, nil
137+
return c.websiteDetails, nil
141138
}
142139

143140
func (c *Crawler) startLoadingAnimation() {
@@ -208,14 +205,36 @@ func (c *Crawler) fetchAndParseURLs(isHttps bool, domain string, urlString strin
208205
}
209206

210207
// Store the discovered domain if it's new
211-
if parsedURL.Host != "" && !c.domains[parsedURL.Host] {
212-
c.domains[parsedURL.Host] = true
213-
// Append to last-fetched-domains.txt file
214-
if domainsFile, err := os.OpenFile(filepath.Join(c.outputDir, "last-fetched-domains.txt"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
215-
fmt.Fprintln(domainsFile, parsedURL.Host)
216-
domainsFile.Close()
208+
if parsedURL.Host != "" {
209+
// Check if we've already seen this domain
210+
domainExists := false
211+
for _, detail := range c.websiteDetails {
212+
if detail.DomainName == parsedURL.Host {
213+
domainExists = true
214+
break
215+
}
216+
}
217+
218+
if !domainExists {
219+
// Append to last-fetched-domains.txt file
220+
if domainsFile, err := os.OpenFile(filepath.Join(c.outputDir, "last-fetched-domains.txt"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
221+
fmt.Fprintln(domainsFile, parsedURL.Host)
222+
domainsFile.Close()
223+
}
224+
helper.InfoPrintln("[+] Discovered new domain:", parsedURL.Host)
225+
226+
// Create new WebsiteDetails for the discovered domain
227+
newDetail := WebsiteDetails{
228+
DomainName: parsedURL.Host,
229+
CrawlDirectory: filepath.Join(c.outputDir, parsedURL.Host),
230+
}
231+
c.websiteDetails = append(c.websiteDetails, newDetail)
232+
233+
// Create directory for the new domain
234+
if err := os.MkdirAll(newDetail.CrawlDirectory, 0755); err != nil {
235+
helper.ErrorPrintln("[!] Error creating directory for new domain:", err)
236+
}
217237
}
218-
helper.InfoPrintln("[+] Discovered new domain:", parsedURL.Host)
219238
}
220239

221240
// Use the actual host for storage directory

0 commit comments

Comments
 (0)