检查DNSBL(RBLs)中是否列出了IP地址的Ruby脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检查DNSBL(RBLs)中是否列出了IP地址的Ruby脚本相关的知识,希望对你有一定的参考价值。

  1. #!/usr/bin/env ruby # ==DNSBL Checker
  2.  
  3. # Checks your IP address against dozens of blacklists and reports
  4.  
  5. # which ones you may be listed on.
  6.  
  7. #
  8.  
  9. # Author:: Michael Behan (jabberwock /at tenebrous /dot com)
  10.  
  11. # Copyright:: (c) 2007 Michael Behan
  12.  
  13. #
  14.  
  15. # ===Usage::
  16.  
  17. # ./dnsblcheck.rb <ip-address>
  18.  
  19. # ------------------------------------------------------------------
  20.  
  21. require 'resolv'
  22.  
  23. $lists = %w[
  24.  
  25. 3y.spam.mrs.kithrup.com
  26. access.redhawk.org
  27. all.rbl.kropka.net
  28. all.spamblock.unit.liu.se
  29. assholes.madscience.nl
  30. bl.borderworlds.dk
  31. bl.csma.biz
  32. bl.redhatgate.com
  33. bl.spamcannibal.org
  34. bl.spamcop.net
  35. bl.starloop.com
  36. bl.technovision.dk
  37. blackholes.five-ten-sg.com
  38. blackholes.intersil.net
  39. blackholes.mail-abuse.org
  40. blackholes.sandes.dk
  41. blackholes.uceb.org
  42. blackholes.wirehub.net
  43. blacklist.sci.kun.nl
  44. blacklist.spambag.org
  45. block.dnsbl.sorbs.net
  46. blocked.hilli.dk
  47. blocklist.squawk.com
  48. blocklist2.squawk.com
  49. cart00ney.surriel.com
  50. cbl.abuseat.org
  51. dev.null.dk
  52. dews.qmail.org
  53. dialup.blacklist.jippg.org
  54. dialup.rbl.kropka.net
  55. dialups.mail-abuse.org
  56. dialups.visi.com
  57. dnsbl.ahbl.org
  58. dnsbl.antispam.or.id
  59. dnsbl.cyberlogic.net
  60. dnsbl.kempt.net
  61. dnsbl.njabl.org
  62. dnsbl.solid.net
  63. dnsbl.sorbs.net
  64. dnsbl-1.uceprotect.net
  65. dnsbl-2.uceprotect.net
  66. dnsbl-3.uceprotect.net
  67. dsbl.dnsbl.net.au
  68. duinv.aupads.org
  69. dul.dnsbl.sorbs.net
  70. dul.ru
  71. dun.dnsrbl.net
  72. dynablock.njabl.org
  73. dynablock.wirehub.net
  74. fl.chickenboner.biz
  75. forbidden.icm.edu.pl
  76. form.rbl.kropka.net
  77. hil.habeas.com
  78. http.dnsbl.sorbs.net
  79. http.opm.blitzed.org
  80. intruders.docs.uu.se
  81. ip.rbl.kropka.net
  82. korea.services.net
  83. l1.spews.dnsbl.sorbs.net
  84. l2.spews.dnsbl.sorbs.net
  85. lame-av.rbl.kropka.net
  86. list.dsbl.org
  87. mail-abuse.blacklist.jippg.org
  88. map.spam-rbl.com
  89. misc.dnsbl.sorbs.net
  90. msgid.bl.gweep.ca
  91. multihop.dsbl.org
  92. no-more-funn.moensted.dk
  93. ohps.bl.reynolds.net.au
  94. ohps.dnsbl.net.au
  95. omrs.bl.reynolds.net.au
  96. omrs.dnsbl.net.au
  97. op.rbl.kropka.net
  98. opm.blitzed.org
  99. or.rbl.kropka.net
  100. orbs.dorkslayers.com
  101. orid.dnsbl.net.au
  102. orvedb.aupads.org
  103. osps.bl.reynolds.net.au
  104. osps.dnsbl.net.au
  105. osrs.bl.reynolds.net.au
  106. osrs.dnsbl.net.au
  107. owfs.bl.reynolds.net.au
  108. owfs.dnsbl.net.au
  109. owps.bl.reynolds.net.au
  110. owps.dnsbl.net.au
  111. pdl.dnsbl.net.au
  112. probes.dnsbl.net.au
  113. proxy.bl.gweep.ca
  114. psbl.surriel.com
  115. pss.spambusters.org.ar
  116. rbl.cluecentral.net
  117. rbl.rangers.eu.org
  118. rbl.schulte.org
  119. rbl.snark.net
  120. rbl.triumf.ca
  121. rblmap.tu-berlin.de
  122. rdts.bl.reynolds.net.au
  123. rdts.dnsbl.net.au
  124. relays.bl.gweep.ca
  125. relays.bl.kundenserver.de
  126. relays.dorkslayers.com
  127. relays.mail-abuse.org
  128. relays.nether.net
  129. relays.visi.com
  130. ricn.bl.reynolds.net.au
  131. ricn.dnsbl.net.au
  132. rmst.bl.reynolds.net.au
  133. rmst.dnsbl.net.au
  134. rsbl.aupads.org
  135. satos.rbl.cluecentral.net
  136. sbl.csma.biz
  137. sbl.spamhaus.org
  138. sbl-xbl.spamhaus.org
  139. smtp.dnsbl.sorbs.net
  140. socks.dnsbl.sorbs.net
  141. socks.opm.blitzed.org
  142. sorbs.dnsbl.net.au
  143. spam.dnsbl.sorbs.net
  144. spam.dnsrbl.net
  145. spam.olsentech.net
  146. spam.wytnij.to
  147. spamguard.leadmon.net
  148. spamsites.dnsbl.net.au
  149. spamsources.dnsbl.info
  150. spamsources.fabel.dk
  151. spamsources.yamta.org
  152. spews.dnsbl.net.au
  153. t1.bl.reynolds.net.au
  154. t1.dnsbl.net.au
  155. ucepn.dnsbl.net.au
  156. unconfirmed.dsbl.org
  157. vbl.messagelabs.com
  158. vox.schpider.com
  159. web.dnsbl.sorbs.net
  160. whois.rfc-ignorant.org
  161. will-spam-for-food.eu.org
  162. wingate.opm.blitzed.org
  163. xbl.spamhaus.org
  164. zombie.dnsbl.sorbs.net
  165. ztl.dorkslayers.com
  166.  
  167. ]
  168.  
  169. $stdout.sync=true
  170.  
  171. raise ArgumentError, "You must specify an IP address to check" if !ARGV[0]
  172.  
  173. $ip = ARGV[0].chomp
  174.  
  175. raise ArgumentError, "Invalid IP specified" if !$ip.match(/d{1,3}.d{1,3}.d{1,3}.d{1,3}/)
  176.  
  177. $check = $ip.split('.').reverse.join('.')
  178.  
  179. $listed = []
  180.  
  181. puts "Checking blacklists for #{$ip}..."
  182.  
  183. $lists.each do |list|
  184.  
  185. begin
  186.  
  187. $host = $check+'.'+list
  188.  
  189. printf "%-50s", $host
  190.  
  191. Resolv::getaddress($host)
  192.  
  193. printf(": e[0;31mLISTED on %se[0m ", list)
  194.  
  195. $listed << list
  196.  
  197. rescue Exception => e
  198.  
  199. case e
  200. when Resolv::ResolvError
  201.  
  202. puts ": e[0;32mOKe[0m "
  203.  
  204. when Interrupt
  205.  
  206. puts " Caught signal SIGINT. Exiting..."
  207.  
  208. exit 1
  209.  
  210. else
  211.  
  212. puts ": e[0;47mTIMEOUTe[0m "
  213.  
  214. end
  215.  
  216. end
  217.  
  218. end
  219.  
  220. puts "SUMMARY"
  221.  
  222. puts "-------"
  223.  
  224. if $listed.size > 0
  225.  
  226. printf "You are listed on the following #{$listed.size} blacklists "
  227.  
  228. $listed.each do |list|
  229.  
  230.  
  231. printf "%5s ", list
  232.  
  233. end
  234.  
  235. else
  236.  
  237. puts "Your IP was not found on any of the blacklists. Congratulations!"
  238.  
  239. end

以上是关于检查DNSBL(RBLs)中是否列出了IP地址的Ruby脚本的主要内容,如果未能解决你的问题,请参考以下文章

pfBlockerNG设置指南

脚本学习列出一组IP内所有活动主机

如何检查一个IP地址是不是在PHP中的两个IP范围内?

如何列出集群中所有可用的 Kafka 代理?

Go - 检查 IP 地址是不是在网络中

网络不通排查