Skip to content

Add builtwith as a subdomain source#122

Merged
edoardottt merged 10 commits intoedoardottt:mainfrom
ajistrying:ajistrying/builtwith-subdomain
Nov 30, 2023
Merged

Add builtwith as a subdomain source#122
edoardottt merged 10 commits intoedoardottt:mainfrom
ajistrying:ajistrying/builtwith-subdomain

Conversation

@ajistrying
Copy link
Copy Markdown
Contributor

Attempts to add BuiltWith as a subdomain source for the subdomain command

Comment thread pkg/input/keys.go Outdated

return keys.BuiltWith
}

Copy link
Copy Markdown
Contributor Author

@ajistrying ajistrying Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edoardottt I have the GetBuiltWithKey() ready for use, but since it shares so much base functionality with GetVirusTotalKey(), I created a GetKey(api string) function below that just returns the needed key based on an api string passed in.

Usage is on lines 369 and 375 of pkg/runner/runner.go. If this is desirable, we can go back to the separate functions, but thought I'd attempt to dry things up here, lmk your thoughts and I can clean this file up based on the direction you'd like.

@ajistrying ajistrying marked this pull request as ready for review November 20, 2023 04:43
@auto-assign auto-assign bot requested a review from edoardottt November 20, 2023 04:43
@edoardottt
Copy link
Copy Markdown
Owner

@ajistrying golangci-lint is failing, fix that and I'll start reviewing :)

@ajistrying
Copy link
Copy Markdown
Contributor Author

ajistrying commented Nov 21, 2023

@ajistrying golangci-lint is failing, fix that and I'll start reviewing :)

Managed to fix the one warning that I had caused to pop up, but there's a couple that popped up where I didn't touch the code, and I don't necessarily think the warnings are worth pursuing, what are your thoughts? Here they are:

image

@edoardottt
Copy link
Copy Markdown
Owner

edoardottt commented Nov 21, 2023

what are your thoughts?

For those ones it's better to build the string using fmt.Sprintf. Then we could check the lint errors again :)

P.S. We should update the readme accordingly as well

@ajistrying
Copy link
Copy Markdown
Contributor Author

ajistrying commented Nov 22, 2023

readme updated and linter warnings addressed, hopefully this is what you had in mind!

Copy link
Copy Markdown
Owner

@edoardottt edoardottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you ever tried the code you've written?
Is it working properly?
Because it looks like you copied the virustotal part here, imo it can't work

@ajistrying ajistrying marked this pull request as draft November 22, 2023 19:17
@ajistrying
Copy link
Copy Markdown
Contributor Author

ajistrying commented Nov 22, 2023

Have you ever tried the code you've written? Is it working properly? Because it looks like you copied the virustotal part here, imo it can't work

Sorry I should've been more clear, I wanted to see if I was on the right track while working through this. I didn't realize that I instinctively moved the PR over to ready for review, but should have given that CI has been running (it's been a long couple of weeks 😅)

The builtwith implementation is taken from virustotal and I'm not done with it, but I was using the virustotal implementation as a base since I'm guessing some of the same functionality will be used.

Sorry for the misunderstanding!

@ajistrying ajistrying marked this pull request as ready for review November 23, 2023 02:44
@auto-assign auto-assign bot requested a review from edoardottt November 23, 2023 02:44
@ajistrying
Copy link
Copy Markdown
Contributor Author

@edoardottt Now it's really ready for review lol, went through and tested https://api.builtwith.com/domain-api with some test credits and everything looks to be in good shape, here are some screenshots verifying that we're getting back what we need:

(Tested that we were getting back a legit response from Builtwith)
image

(Cleaned up version)
image

@edoardottt
Copy link
Copy Markdown
Owner

Sorry for the misunderstanding!

No worries :)

There's a check failing (go build), I'll start reviewing the pr when all the checks are passing

@ajistrying
Copy link
Copy Markdown
Contributor Author

Wanted to bump this :)

Copy link
Copy Markdown
Owner

@edoardottt edoardottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not working + deprecated method

Comment thread pkg/input/keys.go
BuiltWith string `yaml:"BuiltWith,omitempty"`
}

// ReadKeys gets as input a filename (keys.yaml) and returns a Keys object.
Copy link
Copy Markdown
Owner

@edoardottt edoardottt Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 47 uses ioutil.ReadFile but it's deprecated, we should use os.ReadFile

Comment thread pkg/opendb/builtwith.go
return result
}

for _, elem := range bwrWrapper.Results[0].Result.Paths {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got this error whie trying to use option -bw:

================ SCANNING SUBDOMAINS ================
Pulling data from BuiltWith
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/edoardottt/scilla/pkg/opendb.BuiltWithSubdomains({0x7ffdbf2f80f9, 0xa}, {0xc00058c030, 0x24}, 0xf9?)
	/home/edoardottt/test/scilla-ftr/pkg/opendb/builtwith.go:151 +0x4e8
github.com/edoardottt/scilla/pkg/runner.SubdomainSubcommandHandler({{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
	/home/edoardottt/test/scilla-ftr/pkg/runner/runner.go:376 +0xff2
github.com/edoardottt/scilla/pkg/runner.(*Runner).Execute(0xc00031fc70, 0x0?, 0x0?)
	/home/edoardottt/test/scilla-ftr/pkg/runner/runner.go:84 +0x1e8
main.main()
	/home/edoardottt/test/scilla-ftr/cmd/scilla/main.go:39 +0xc5
exit status 2

Copy link
Copy Markdown
Contributor Author

@ajistrying ajistrying Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I think might be happening here is that for some domains entered, the expected Result array we get back from the api in the response is coming up empty, so I think a simple length check is needed to just early return an empty result and move on if that Result array is indeed empty.

Tested this case with a random domain wqeqwd.com, got your error, and after adding in a fix in tested again and the application flowed as expected.

Copy link
Copy Markdown
Owner

@edoardottt edoardottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only result I get with a valid API key:

=====================================================
target: google.com
================ SCANNING SUBDOMAINS ================
Pulling data from BuiltWith
google.com.google.com

@ajistrying
Copy link
Copy Markdown
Contributor Author

ajistrying commented Nov 29, 2023

This is the only result I get with a valid API key:

=====================================================
target: google.com
================ SCANNING SUBDOMAINS ================
Pulling data from BuiltWith
google.com.google.com

I'm getting the same response from testing the api using the documented call in the docs with google.com as well, so unsure of what your expectation was of what subdomains would be coming back from this service. If that's not what was expected, what was your expectation? Also, if this is the incorrect api that I'm using could you point me to the correct api within Builtwith that you believe needs to be used instead?

@edoardottt
Copy link
Copy Markdown
Owner

Trying with the domain builtwith.com as input I get more results and it seems to work fine. Due to the fact that for now it's not that reliable I think the best option is to merge this PR adding builtwith as subdomain source but commenting the adding phase in the runner file. This means this source will not be used for now. What do you think?

@ajistrying
Copy link
Copy Markdown
Contributor Author

Trying with the domain builtwith.com as input I get more results and it seems to work fine. Due to the fact that for now it's not that reliable I think the best option is to merge this PR adding builtwith as subdomain source but commenting the adding phase in the runner file. This means this source will not be used for now. What do you think?

I think that makes sense, unfortunate that it didn't work out as a reliable source, but it happens! I added the comment // Service not fully reliable yet, is that okay or should I use // Service not working like the others?

@edoardottt edoardottt changed the base branch from main to devel November 30, 2023 07:35
@edoardottt edoardottt self-assigned this Nov 30, 2023
@edoardottt edoardottt changed the base branch from devel to main November 30, 2023 07:47
@edoardottt edoardottt merged commit dddc0ef into edoardottt:main Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants