Created
March 14, 2019 19:04
-
-
Save kpcyrd/015107a51a9abab849414360aadb8ccb to your computer and use it in GitHub Desktop.
rickmer/ct-sub-domains-0.1.0.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/ct-sub-domains.lua | |
+++ b/ct-sub-domains.lua | |
@@ -6,10 +6,17 @@ | |
function run(domain) | |
session = http_mksession() | |
- request = http_request(session, 'GET', 'https://api.certspotter.com/v1/issuances?include_subdomains=true&expand=dns_names&expand=issuer&expand=cert&domain=' .. domain['value'], { | |
+ request = http_request(session, 'GET', 'https://api.certspotter.com/v1/issuances', { | |
+ query={ | |
+ include_subdomains='true', | |
+ expand='dns_names', | |
+ expand='issuer', | |
+ expand='cert', | |
+ domain=domain['value'], | |
+ }, | |
user_agent='sn0int cert spotter module' | |
}) | |
- | |
+ | |
response = http_send(request) | |
if last_err() then return end | |
if response['status'] ~= 200 then | |
@@ -24,18 +31,12 @@ | |
do | |
new_domain = api_output[cert_counter]['dns_names'][domain_counter] | |
new_psl_domain = psl_domain_from_dns_name(new_domain) | |
- if new_domain == new_psl_domain then | |
- db_add('domain', { | |
- value=new_domain, | |
- }) | |
- else | |
- domain_id = db_select('domain', new_psl_domain) | |
- if domain_id == nil then | |
- db_add('domain', { | |
- value=new_psl_domain, | |
- }) | |
- domain_id = db_select('domain', new_psl_domain) | |
- end | |
+ | |
+ domain_id = db_add('domain', { | |
+ value=new_psl_domain, | |
+ }) | |
+ -- if domain isn't unscoped | |
+ if domain_id ~= nil then | |
db_add('subdomain', { | |
domain_id=domain_id, | |
value=new_domain, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use a query hash in line 9, the request parameters have to be changed, as the keys in a dict are uniqe and the url parameter keys are not.
Line 44 will add the domain name as its own subdomain. Here new_domain ~= new_psl_domain needs to be checked too.