From a937f1f67d0f66680dc4a5f1ffd4410354025d5f Mon Sep 17 00:00:00 2001 From: caffix Date: Fri, 29 Nov 2024 00:49:50 -0500 Subject: [PATCH] fixed the JSON portion of the query --- initdb-assetdb.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/initdb-assetdb.sh b/initdb-assetdb.sh index 801ebfc..f365fb2 100644 --- a/initdb-assetdb.sh +++ b/initdb-assetdb.sh @@ -44,9 +44,9 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ INNER JOIN entities AS ips ON r2.to_entity_id = ips.entity_id) WHERE fqdns.etype = 'FQDN' AND srvs.etype = 'FQDN' AND ips.etype = 'IPAddress' AND r1.etype IN ('PrefDNSRelation', 'SRVDNSRelation') AND r1.content->>'label' = 'dns_record' - AND r1.content->>'header.rr_type' IN ('33', '2', '15') + AND r1.content->'header'->'rr_type' IN ('33', '2', '15') AND r2.etype = 'BasicDNSRelation' AND r2.content->>'label' = 'dns_record' - AND r2.content->>'header.rr_type' IN ('1', '28') + AND r2.content->'header'->'rr_type' IN ('1', '28') AND r1.updated_at >= _from AND r1.updated_at <= _to AND r2.updated_at >= _from AND r2.updated_at <= _to AND fqdns.content->>'name' = ANY(_names) ) LOOP fqdn = _var_r.name; @@ -62,7 +62,7 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ INNER JOIN entities AS ips ON edges.to_entity_id = ips.entity_id) WHERE fqdns.etype = 'FQDN' AND ips.etype = 'IPAddress' AND edges.etype = 'BasicDNSRelation' AND edges.content->>'label' = 'dns_record' - AND edges.content->>'header.rr_type' IN ('1', '28') AND edges.updated_at >= _from + AND edges.content->'header'->'rr_type' IN ('1', '28') AND edges.updated_at >= _from AND edges.updated_at <= _to AND fqdns.content->>'name' = ANY(_names) ) LOOP fqdn = _var_r.name; ip_addr = _var_r.addr; @@ -81,7 +81,7 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ WHERE fqdns.etype = 'FQDN' AND cnames.etype = 'FQDN' AND edges.updated_at >= _from AND edges.updated_at <= _to AND edges.etype = 'BasicDNSRelation' AND edges.content->>'label' = 'dns_record' - AND edges.content->>'header.rr_type' = '5' + AND edges.content->'header'->'rr_type' = '5' AND fqdns.content->>'name' = traverse_cname._fqdn) SELECT fqdns.content->>'name' AS "name", ips.content->>'address' AS "addr" FROM ((entities AS fqdns INNER JOIN edges ON fqdns.entity_id = edges.from_entity_id) @@ -89,7 +89,7 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ WHERE fqdns.etype = 'FQDN' AND ips.etype = 'IPAddress' AND edges.updated_at >= _from AND edges.updated_at <= _to AND edges.etype = 'BasicDNSRelation' AND edges.content->>'label' = 'dns_record' - AND edges.content->>'header.rr_type' IN ('1', '28') + AND edges.content->'header'->'rr_type' IN ('1', '28') AND fqdns.content->>'name' IN (SELECT _fqdn FROM traverse_cname) ) LOOP fqdn = _name; ip_addr = _var_r.addr;