The Poor Man's (or Woman's) Intrusion Detection System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

62 lines
1.7 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // Dump Black Listed whole domain (*.domain.tld) entries
  3. // Written by Jonathan A. Foster <jon@jfpossibilities.com>
  4. // Started December 28th, 2021
  5. // Copyright JF Possibilities, Inc. All rights reserved.
  6. //
  7. // Read the "dns_wild" table and dump all black listed domain names as
  8. // "address" entries for a dnsmasq.conf file. This will black list the
  9. // whole domain, subdomains, hosts and all.
  10. //////////////////////////////////////////////////////////////////////
  11. #include <string>
  12. #include <map>
  13. #include <iostream>
  14. #include <stdio.h>
  15. #include <libgen.h>
  16. #include "../strutil.h"
  17. #include "appbase.h"
  18. using namespace std;
  19. //////////////////////////////////////////////////////////////////////
  20. // Connection Report Generator Application Class
  21. //////////////////////////////////////////////////////////////////////
  22. struct DomainBlackList: BlackListBaseApp {
  23. int main() {
  24. cppdb::result qry;
  25. string s;
  26. int x;
  27. /// SETUP & VALIDATE CLI ///
  28. if(x=BlackListBaseApp::main()) return x; // Parse CLI args, open conf & db
  29. /// Query & load data ///
  30. qry = db <<
  31. "SELECT name "
  32. "FROM dns_wild "
  33. "WHERE status=2 " // 2 = blocked... need this doc'd somewhere...
  34. "ORDER BY name";
  35. while(qry.next()) {
  36. qry >> s;
  37. if(ipv4!="") cout << "address=/" << s << '/' << ipv4 << '\n';
  38. if(ipv6!="") cout << "address=/" << s << '/' << ipv6 << '\n';
  39. }
  40. return 0;
  41. }
  42. };
  43. //////////////////////////////////////////////////////////////////////
  44. // Lets run the report and dump it out
  45. //////////////////////////////////////////////////////////////////////
  46. MAIN(DomainBlackList)