]> granicus.if.org Git - pdns/commitdiff
implement fixupCase(true) or fixupCase(false) so you can make your 0x20 violating...
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 9 Dec 2015 12:57:39 +0000 (13:57 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 9 Dec 2015 12:57:39 +0000 (13:57 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist-tcp.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

index f50beee1e76afcb2d0fcd1cf5df57a72ffa11a29..62a45fd8d974b70ba07aeb3a74dcbdc97b613fed 100644 (file)
@@ -273,6 +273,7 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
     });
 
   g_lua.writeFunction("truncateTC", [](bool tc) { g_truncateTC=tc; });
+  g_lua.writeFunction("fixupCase", [](bool fu) { g_fixupCase=fu; });
 
   g_lua.registerMember("name", &ServerPolicy::name);
   g_lua.registerMember("policy", &ServerPolicy::policy);
index 3b77395aab1aa6ee477f1ecba9db48d468bff8d1..77e63045bbb4900adb929e096025257f81fc8e92 100644 (file)
@@ -366,6 +366,11 @@ void* tcpClientThread(int pipefd)
           }
         }
 
+       if(g_fixupCase) {
+         string realname = qname.toDNSString();
+         memcpy(response+12, realname.c_str(), realname.length());
+       }
+
         if (putNonBlockingMsgLen(ci.fd, responseLen, ds->tcpSendTimeout))
           writen2WithTimeout(ci.fd, response, responseLen, ds->tcpSendTimeout);
 
index 3695b54c43dc38199b1267ab5ee026189b17aa2a..d8080c2371fe76bced020475d078f996faa6cb2b 100644 (file)
@@ -109,6 +109,7 @@ int g_tcpRecvTimeout{2};
 int g_tcpSendTimeout{2};
 
 bool g_truncateTC{1};
+bool g_fixupCase{0};
 static void truncateTC(const char* packet, unsigned int* len)
 try
 {
@@ -171,10 +172,14 @@ void* responderThread(std::shared_ptr<DownstreamState> state)
     else
       --state->outstanding;  // you'd think an attacker could game this, but we're using connected socket
 
+    if(g_fixupCase) {
+      string realname = ids->qname.toDNSString();
+      memcpy(packet+12, realname.c_str(), realname.length());
+    }
+
     if(dh->tc && g_truncateTC) {
       truncateTC(packet, (unsigned int*)&len);
     }
-
     uint16_t * flags = getFlagsFromDNSHeader(dh);
     uint16_t origFlags = ids->origFlags;
     /* clear the flags we are about to restore */
index 444dc910bc374bbcd955117ddc387614305d92ab..115361f7c16628ede5da50524134cb93f1c74ade 100644 (file)
@@ -398,6 +398,7 @@ extern std::vector<std::pair<ComboAddress, bool>> g_locals; // not changed at ru
 extern vector<ClientState*> g_frontends;
 extern std::string g_key; // in theory needs locking
 extern bool g_truncateTC;
+extern bool g_fixupCase;
 extern int g_tcpRecvTimeout;
 extern int g_tcpSendTimeout;
 extern uint16_t g_maxOutstanding;