diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-04-26 16:02:47 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-04-26 16:02:47 +0000 |
commit | f67f36978ca9a9f8b1a6065db7d26763c1cc456c (patch) | |
tree | d36e6c0c249c96672d6264f8ddf14b498b6c9e35 /src/server | |
parent | e9a0ed1fde6df9cee8ab093bce1624d89eb47ac2 (diff) | |
download | shibari-f67f36978ca9a9f8b1a6065db7d26763c1cc456c.tar.xz |
Support dns-0x20 BULLSHIT
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/shibari_packet_tdb_answer_query.c | 15 | ||||
-rw-r--r-- | src/server/shibari_packet_tdb_axfr.c | 12 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/server/shibari_packet_tdb_answer_query.c b/src/server/shibari_packet_tdb_answer_query.c index d9e9474..74b08a2 100644 --- a/src/server/shibari_packet_tdb_answer_query.c +++ b/src/server/shibari_packet_tdb_answer_query.c @@ -2,9 +2,12 @@ #include <skalibs/cdb.h> +#include <s6-dns/s6dns-domain.h> + #include <shibari/constants.h> #include <shibari/tdb.h> #include <shibari/packet.h> +#include <shibari/util.h> static unsigned int childzone (shibari_packet *pkt, cdb const *tdb, s6dns_domain_t const *q, char const *loc, tain const *stamp, uint16_t nplen, uint16_t zplen) { @@ -28,6 +31,7 @@ static unsigned int childzone (shibari_packet *pkt, cdb const *tdb, s6dns_domain unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *tdb, s6dns_message_header_t const *qhdr, s6dns_domain_t const *q, uint16_t qtype, char const *loc, tain const *stamp) { + s6dns_domain_t ql ; unsigned int rcode = 0 ; uint32_t flagyxdomain = 0 ; int nplen, zplen ; @@ -35,8 +39,9 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td uint16_t wildpos = 0 ; shibari_packet_begin(pkt, qhdr->id, q, qtype) ; + shibari_util_canon_domain(&ql, q) ; pkt->hdr.rd = qhdr->rd ; - zplen = shibari_tdb_find_authority(tdb, q->s, q->len, loc, stamp, &nplen) ; + zplen = shibari_tdb_find_authority(tdb, ql.s, ql.len, loc, stamp, &nplen) ; switch (zplen) { case -2 : return 9 ; @@ -44,7 +49,7 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td default : break ; } if (nplen >= 0 && nplen < zplen) - return childzone(pkt, tdb, q, loc, stamp, nplen, zplen) ; + return childzone(pkt, tdb, &ql, loc, stamp, nplen, zplen) ; pkt->hdr.aa = 1 ; /* we're in the zone, man */ @@ -54,7 +59,7 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td for (;;) { shibari_tdb_entry entry ; - int r = shibari_tdb_read_entry(tdb, &state, &entry, q->s + wildpos, q->len - wildpos, qtype, !!wildpos, loc, stamp, &flagyxdomain) ; + int r = shibari_tdb_read_entry(tdb, &state, &entry, ql.s + wildpos, ql.len - wildpos, qtype, !!wildpos, loc, stamp, &flagyxdomain) ; if (r == -1) return 2 ; if (!r) break ; if (!shibari_packet_add_rr(pkt, &entry, 0, wildpos, 2)) @@ -81,12 +86,12 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td if (!pkt->hdr.counts.an) { - unsigned int r = shibari_packet_assert_authority(pkt, tdb, q->s + zplen, q->len - zplen, zplen, loc, stamp) ; + unsigned int r = shibari_packet_assert_authority(pkt, tdb, ql.s + zplen, ql.len - zplen, zplen, loc, stamp) ; if (r) return r ; } else if (gluetype) { - unsigned int r = shibari_packet_add_glue(pkt, tdb, q->s, q->len, gluetype, q->s + zplen, q->len - zplen, zplen, wildpos, loc, stamp) ; + unsigned int r = shibari_packet_add_glue(pkt, tdb, q->s, q->len, gluetype, ql.s + zplen, ql.len - zplen, zplen, wildpos, loc, stamp) ; if (r) return r ; } diff --git a/src/server/shibari_packet_tdb_axfr.c b/src/server/shibari_packet_tdb_axfr.c index 5613b67..c8ef4e7 100644 --- a/src/server/shibari_packet_tdb_axfr.c +++ b/src/server/shibari_packet_tdb_axfr.c @@ -34,15 +34,15 @@ int shibari_packet_tdb_axfr (buffer *b, char const *axfrok, char const *loc, cdb { shibari_tdb_entry soa ; shibari_tdb_entry cur ; + s6dns_domain_t z = *zone ; uint32_t pos = CDB_TRAVERSE_INIT() ; if (axfrok && axfrok[0] != '*') { - s6dns_domain_t decoded = *zone ; unsigned int zonelen ; size_t len = strlen(axfrok) + 1 ; char zbuf[256] ; - if (!s6dns_domain_decode(&decoded)) return 1 ; - zonelen = s6dns_domain_tostring(zbuf, 256, &decoded) ; + if (!s6dns_domain_decode(&z)) return 1 ; + zonelen = s6dns_domain_tostring(zbuf, 256, &z) ; while (len) { size_t seppos = byte_in(axfrok, len, SEPS, sizeof(SEPS)) ; @@ -53,9 +53,11 @@ int shibari_packet_tdb_axfr (buffer *b, char const *axfrok, char const *loc, cdb if (!len) return 5 ; } + shibari_util_canon_domain(&z, zone) ; + { cdb_find_state state = CDB_FIND_STATE_ZERO ; - int r = shibari_tdb_read_entry(tdb, &state, &soa, zone->s, zone->len, SHIBARI_T_SOA, 0, loc, wstamp, 0) ; + int r = shibari_tdb_read_entry(tdb, &state, &soa, z.s, z.len, SHIBARI_T_SOA, 0, loc, wstamp, 0) ; if (r == -1) return 2 ; if (!r) return 9 ; } @@ -71,7 +73,7 @@ int shibari_packet_tdb_axfr (buffer *b, char const *axfrok, char const *loc, cdb int r = cdb_traverse_next(tdb, &cur.key, &data, &pos) ; if (r == -1) return 2 ; if (!r) break ; - prefixlen = shibari_util_get_prefixlen(cur.key.s, cur.key.len, zone->s, zone->len) ; + prefixlen = shibari_util_get_prefixlen(cur.key.s, cur.key.len, z.s, z.len) ; if (prefixlen == -1) continue ; r = shibari_tdb_entry_parse(&cur, data.s, data.len, SHIBARI_T_ANY, 2, loc, wstamp) ; if (r == -1) return 2 ; |