elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Mantis 2.0
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Mantis 2.0  (Leído 2,933 veces)
SH4V

Desconectado Desconectado

Mensajes: 39



Ver Perfil WWW
Mantis 2.0
« en: 25 Diciembre 2009, 18:39 pm »

Os presento a Mantis, una herramienta diseñada para recopilar información sobre servidores DNS y nombres de dominio. Creo que no me equivoco al decir que compite por ser una de las mejores y más completas herramientas de toda la red en cuanto al protocolo DNS se refiere. Os dejo el código fuente. Para utilizarla necesitaréis:

- Intérprete Ruby en su versión 1.8.6 mínimo.
- Rubygems
- Mechanize
- Net-DNS en su versión 0.5.3 (La versión 0.6.0 tiene un bug y de momento está inoperativa hasta la versión 0.7.0

Podéis instalar el interprete Ruby y Rubygems desde los repositorios ó bien compilandolo desde el código fuente desde aquí:

http://www.ruby-lang.org/en/downloads/
http://docs.rubygems.org/read/chapter/3

Mechanize y net-dns se instalan desde rubygems de la siguiente manera:

gem install mechanize
gem install net-dns -v 0.5.3

La versión 2.0. Incluye dos modalidades más de ataque.

1.- Ataque "--all": Realiza un barrido de querys a los servidores DNS.
2.- Ataque "--mantis": Realiza un barrido inverso con puntero inverso PTR y a las direcciones IP no resueltas, aplica un Reverse DNS para ver posibles Vhosts con ese nombre de dominio.


Cómo no, Open Source =)

Código
  1. #!/usr/bin/ruby
  2. # Programmed by Sh4V. N-D Security Team.
  3. # Visit http://n3t-datagrams.net && http://foro.undersecurity.net
  4. require 'socket'
  5. require 'ftools'
  6. require 'rubygems'
  7. require 'mechanize'
  8. require 'net/dns/rr'
  9. require 'net/dns/packet'
  10. require 'net/dns/resolver'
  11. mantis="
  12.        :::   :::       :::     ::::    ::: ::::::::::: ::::::::::: ::::::::
  13.      :+:+: :+:+:    :+: :+:   :+:+:   :+:     :+:         :+:    :+:    :+:
  14.    +:+ +:+:+ +:+  +:+   +:+  :+:+:+  +:+     +:+         +:+    +:+        
  15.   +#+  +:+  +#+ +#++:++#++: +#+ +:+ +#+     +#+         +#+    +#++:++#++  
  16.  +#+       +#+ +#+     +#+ +#+  +#+#+#     +#+         +#+           +#+    
  17. #+#       #+# #+#     #+# #+#   #+#+#     #+#         #+#    #+#    #+#    
  18. ###       ### ###     ### ###    ####     ###     ########### ########      
  19.  
  20.  
  21.                       ::::::::       :::::::
  22.                     :+:    :+:     :+:   :+:
  23.                          +:+      +:+   +:+  
  24.                       +#+        +#+   +:+  
  25.                    +#+          +#+   +#+    
  26.                  #+#       #+# #+#   #+#    
  27.                ########## ###  #######      
  28. ==========================================================================
  29. "
  30.  
  31. version= "v2.0"
  32.  
  33. puts "Mantis #{version} by Sh4V http://n3t-datagrams.net"
  34.  
  35. sub=["foro","access",  "accounting", "accounts", "active", "ad", "admin", "administracion", "administrador", "administrator", "administration", "advertising", "agent", "ap", "apple", "archives", "area", "as", "b2b", "b2c", "backup", "backups", "bart", "beta", "bigip", "billing", "blackboard", "blog", "blogs", "book", "books", "c2b", "c2c", "ca", "carro", "cart", "catalog", "catalogue", "channel", "channels", "chat", "chimera", "cisco", "citrix", "classroom", "conect", "connect", "controller", "conferece", "core", "corporate", "cpanel", "csg", "customers", "database", "db", "dbs", "demo", "demostration", "design", "desk", "desktop", "dev", "devel", "developers", "development", "directory", "dmz", "dns", "dns1", "dns2", "dns3", "domain", "domain1", "domain2", "domain3", "domaincontroller", "download", "downloads", "ds", "eaccess", "e", "eng", "es", "events", "example", "examples", "exchange", "exec", "extranet", "feed", "feeds", "file", "files", "fileserver", "finance", "firewall", "forum", "foro","forums", "fs", "ftp", "ftpd", "fw", "gallery", "game", "games", "gateway", "groups", "guide", "gw", "help", "helpdesk", "home", "hotspot", "hp-ux", "hpux", "ids", "im", "images", "imail", "imap", "imap1", "imap2", "imap3", "imgs", "internal", "intranet", "ipsec", "irc", "irc1", "irc2", "irc3", "irix", "itil", "lab", "laboratories", "labs", "lan", "ldap", "library", "linux", "localhost", "login", "logs", "lotus", "mail", "mail1", "mail2", "mail3", "mailgate", "main", "man", "manager", "maps", "marketing", "member", "members", "mercury", "messenger", "meeting", "mmc", "mngt", "mobil", "mobile", "mom", "money", "monitor", "monitoring", "moodle","mrtg", "mssql", "mx", "mx1", "mx2", "mx3", "mysql", "mysql1", "mysql2", "mysql3", "nameserver", "neon", "netmail", "netmeeting", "netscaler", "netscreen", "netstats", "network", "news", "news", "newsfeed", "newsfeeds", "newsgroups", "newton", "noc", "notes", "novell", "ns", "null", "online", "open", "openbsd", "openview", "operations", "oracle", "outlook", "owa", "pan", "partner", "partners", "pc", "pcanywhere", "pegasus", "peoplesoft", "personal", "photo", "photos", "podcast", "podcasts", "pop", "portal", "postgres", "ppp", "printer", "priv", "priv8", "private", "proxy", "prtg", "public", "radius", "ras", "relay", "remote", "reports", "research", "restricted", "router", "rss", "sales", "sample", "samples", "sandbox", "search", "secure", "security", "sendmail", "server", "server1", "server2", "server3", "services", "share", "sharepoint", "shop", "shopping", "sms", "smtp", "smtp1", "smtp2", "smtp3", "solaris", "sql", "squirrel", "squirrelmail", "ssh", "staff", "stage", "staging", "stats", "storage", "sun", "support", "sus", "test", "tftp", "tmp", "transfer", "ts", "uddi", "unix", "upload", "uploads", "vid", "video", "videos", "virtual", "vista", "vnc", "vpn", "wan", "wap", "web", "webadmin", "webct", "webcast", "webcasts", "webmail", "webmaster", "wiki","windows", "wingate", "wlan", "wsus", "ww", "www", "www1", "www2", "www3", "xml"]
  36.  
  37. def resolv(domain, query,all)
  38. res=Net::DNS::Resolver.new
  39. res.tcp_timeout=10
  40. begin
  41. que=res.query(domain, query)
  42. rescue Net::DNS::RR::ArgumentError
  43. puts "The argument #{query} is wrong."
  44. rescue
  45. puts "An error ocurred while the #{query} query was sent."
  46. else
  47. if all==0
  48. puts "Answer section:"
  49. puts que.answer
  50. print "\n"
  51. puts"Additional section:"
  52. puts que.additional
  53. elsif all==1
  54. puts "Answer section:"
  55. puts que.answer
  56. print "\n"
  57. else
  58. puts "aaa"
  59. end
  60. end
  61. end
  62.  
  63. def axfr(domain)
  64. puts "Collecting information from DNS servers in domain: #{domain}
  65. "
  66. ns=Net::DNS::Resolver.new
  67. begin
  68. que=ns.query(domain, Net::DNS::NS)
  69. rescue
  70. puts "An error ocurred while the NS query was sent."
  71. else
  72. ip=que.answer.to_a
  73. iparr=[]
  74. nsarr=[]
  75. ip.each do |ipx|
  76. ipx=ipx.to_s
  77. ipx << "*"
  78. ipx=ipx.split('NS      ')
  79. ipx.shift
  80. ipx.each do |x|
  81. x=x.gsub('*',  '')
  82. nsarr<<x
  83. end
  84. end
  85. nsarr.each do |x|
  86. iparr << Socket.getaddrinfo(x, 80)[0][3]
  87. end
  88. puts "DNS server(s) IP's:"
  89. iparr.each do |x|
  90. puts "[-] #{x}"
  91. end
  92. print "\n"
  93. iparr.each do |ip|
  94. puts "[+]Trying AXFR attack with DNS server: #{ip}"
  95. ns.nameservers=ip
  96. ns.tcp_timeout=10
  97. begin
  98. axfr=ns.send(domain, Net::DNS::AXFR)
  99. rescue
  100. puts "An error ocurred while the AXFR attack was sent."
  101. else
  102. if axfr.answer.length != 0
  103. print "\n"
  104. puts axfr.answer
  105. print "\n"
  106. else
  107. puts "Zone transfer failed."
  108. print "\n"
  109. end
  110. end
  111. end
  112. end
  113. end
  114.  
  115.  
  116. def ixfr(domain)
  117. puts "Collecting information from DNS servers in domain: #{domain}
  118. "
  119. res=Net::DNS::Resolver.new
  120. begin
  121. soa=res.query(domain, Net::DNS::SOA)
  122. rescue
  123. puts "An error ocurred while the SOA query was sent."
  124. else
  125. dat=soa.answer.to_s.split('. ')
  126. fields=dat[3].split(' ')
  127. fields[0,0]=dat[1].split('SOA     ')[1]
  128. fields[1,0]=dat[2]
  129. begin
  130. ns=res.query(domain, Net::DNS::NS)
  131. rescue
  132. puts "An error ocurred while the NS query was sent."
  133. else
  134. ip=ns.answer.to_a
  135. nsarr=[]
  136. iparr=[]
  137. ip.each do |ipx|
  138. ipx=ipx.to_s
  139. ipx << "*"
  140. ipx=ipx.split('NS      ')
  141. ipx.shift
  142. ipx.each do |x|
  143. x=x.gsub('*',  '')
  144. nsarr<<x
  145. end
  146. end
  147. nsarr.each do |x|
  148. iparr << Socket.getaddrinfo(x, 80)[0][3]
  149. end
  150. puts "DNS server(s) IP's:"
  151. iparr.each do |x|
  152. puts "[-] #{x}"
  153. end
  154. print "\n"
  155.  
  156. rrauth = Net::DNS::RR.new(
  157. :name => domain,
  158. :ttl =>86400,
  159.               :mname    => fields[0],
  160. :rname => fields[1],
  161.                :serial => fields[2].to_i,
  162. :refresh => fields[3].to_i,
  163. :retry =>fields[4].to_i,
  164. :expire => fields[5].to_i,
  165. :minimum =>fields[6].to_i,
  166.                :cls     => "IN",
  167.                :type    => "SOA"
  168.        )
  169. rrques = Net::DNS::Question.new(domain, Net::DNS::IXFR)
  170. packet=Net::DNS::Packet.new(domain)
  171. packet.authority= rrauth
  172. packet.question=rrques
  173. resixfr=Net::DNS::Resolver.new
  174.  
  175. iparr.each do |ip|
  176. puts "[+]Trying IXFR attack with DNS server: #{ip}"
  177. resixfr.nameservers=ip
  178. resixfr.tcp_timeout=10
  179. begin
  180. ixfr=resixfr.send(packet)
  181. rescue
  182. puts "An error ocurred while the IXFR attack was sent."
  183. else
  184. header=ixfr.authority
  185. if ixfr.answer.length != 0
  186. print "\n"
  187. puts ixfr.answer
  188. print "\n"
  189. else
  190. puts "Incremental zone transfer failed."
  191. print "\n"
  192. end
  193. end
  194. end
  195. end
  196. end
  197. end
  198.  
  199. def ptr(ipi, ipf)
  200. control=''
  201. ipi.each do |x|
  202. if x.to_i>=255
  203. control << "+"
  204. end
  205. end
  206. ipf.each do |x|
  207. if x.to_i>=255
  208. control << "+"
  209. end
  210. end
  211.  
  212. if ipi[0]==ipf[0] && ipi[1]==ipf[1] && ipi[2]==ipf[2]  && ipi[3]<=ipf[3]&& control.length == 0
  213. res=Net::DNS::Resolver.new
  214. ipi[3]=ipi[3].to_i
  215. ipf[3]=ipf[3].to_i
  216. if ipi[3]==0 && ipf[3]==0
  217. ipi[3]=1
  218. ipf[3]=254
  219. elsif ipi[3]==0
  220. ipi[3]=1
  221. end
  222. ipfalse=[]
  223. while ipi[3]<ipf[3]+1
  224. ip="#{ipi[0]}.#{ipi[1]}.#{ipi[2]}.#{ipi[3]}"
  225. arpaip="#{ipi[3]}.#{ipi[2]}.#{ipi[1]}.#{ipi[0]}.in-addr.arpa"
  226. begin
  227. que=res.query(arpaip, Net::DNS::PTR)
  228. rescue
  229. puts "An error ocurred while the PTR query was sent."
  230. else
  231. if name=que.answer.to_s.split('PTR   ')[1]
  232. else
  233. name=que.answer.to_s.split('CNAME   ')[1]
  234. end
  235. if que.answer.to_s!=''
  236. puts "#{ip} => #{name}"
  237. else
  238. puts "#{ip} => Not resolved."
  239. ipfalse << ip
  240. end
  241. ipi[3]+=1
  242. end
  243. end
  244. else
  245. puts "Invalid IP address structure or interval. Example:"
  246. puts "#{$0} -4 192.168.1.1 192.168.1.254"
  247. end
  248. return ipfalse
  249. end
  250.  
  251. def reverse(ip)
  252. if ip.split('.')[0].to_i == 0 || ip.split('.')[1].to_i == 0 || ip.split('.')[2].to_i == 0 || ip.split('.')[3].to_i == 0 || ip.split('.').length != 4
  253. begin
  254. ip= Socket.getaddrinfo(ip, 800)[0][3]
  255. rescue
  256. puts "Incorrect IP Address or Domain Name."
  257. end
  258. end
  259. puts ip
  260. id=0
  261. control=Array.new
  262. dom=Array.new
  263. domains=Array.new
  264. until id==10000
  265. agent=WWW::Mechanize.new
  266. url=agent.get("http://api.search.live.net/json.aspx?AppId=7066FAEB6435DB963AE3CD4AC79CBED8B962779C&Query=IP:#{ip}&Sources=web&Web.Offset=#{id}")
  267. res=url.body.split('"DisplayUrl":"')
  268. control=dom
  269. dom=Array.new
  270. res.each do |x|
  271. dom<<x.split('",')[0].gsub("\\", '').split('/')[0].gsub("www.", '')
  272. end
  273. dom.shift
  274. domains << dom
  275. if control[0]==dom[0]
  276. id=9990
  277. end
  278. id+=10
  279. end
  280. domains=domains.flatten.uniq
  281. puts domains
  282. end
  283.  
  284. def trysubsock(domain)
  285. sub='as234kj43fh2a34ieasf2234sadf3'.split('').sort_by{rand}.join
  286. begin
  287. sock=TCPSocket.new("#{sub}.#{domain}", 80)
  288. rescue
  289. puts "Incorrect IP Address or Domain Name."
  290. else
  291. sock.print("GET / HTTP/1.1\r\nHost:#{domain}\r\n\r\n")
  292. rec=sock.recv(20)
  293. sock.close
  294. if rec.include?('200')
  295. return false
  296. else
  297. return true
  298. end
  299. end
  300. end
  301.  
  302. def trysubdns(domain)
  303. sub='as234kj43fh2a34ieasf2234sadf3'.split('').sort_by{rand}.join
  304. res=Net::DNS::Resolver.new
  305. begin
  306. rcode=res.query("#{sub}.#{domain}", Net::DNS::CNAME).header.rCode_str[0]
  307. if rcode== "NXDomain"
  308. return true
  309. else
  310. return false
  311. end
  312. rescue
  313. puts "Incorrect IP Address or Domain Name."
  314. end
  315. end
  316.  
  317. def sockcrawl(sub, domain)
  318. begin
  319. sock=TCPSocket.new("#{sub}.#{domain}", 80)
  320. rescue
  321. puts "Incorrect IP Address or Domain Name."
  322. else
  323. sock.print("GET / HTTP/1.1\r\nHost:#{domain}\r\n\r\n")
  324. rec=sock.recv(20)
  325. sock.close
  326. if rec.include?('200')
  327. puts "[-] #{sub}.#{domain}"
  328. return '+'
  329. else
  330. return '-'
  331.  
  332. end
  333. end
  334. end
  335.  
  336. def dnscrawl(sub, domain)
  337. res=Net::DNS::Resolver.new
  338. begin
  339. rcode=res.query("#{sub}.#{domain}", Net::DNS::CNAME).header.rCode_str[0]
  340. rescue
  341. puts "Incorrect IP Address or Domain Name."
  342. else
  343. if rcode!= "NXDomain"
  344. puts "[-] #{sub}.#{domain}"
  345. return '+'
  346. else
  347. return '-'
  348.  
  349. end
  350. end
  351. end
  352.  
  353. def crawl(domain, sub)
  354. if ARGV[2] && File.exist?(ARGV[2]) == true && ARGV[2] != "-o"
  355. dic=File.open(ARGV[2], 'r')
  356. sub=dic.read.split("\n")
  357. elsif ARGV[2] && ARGV[2]!= "-o"
  358. puts "No such file or directory."
  359. end
  360. #arr=Array.new
  361. #while i < sub.length
  362. # x = ["#{sub[i]}","#{sub[i]}0","#{sub[i]}1","#{sub[i]}2","#{sub[i]}3"]
  363. # arr[i,1] = x
  364. # i+=1
  365. #end
  366. #sub=arr
  367. control=0
  368. succ=''
  369. print "Crawling subdomains names. This will take some minutes. Be patient.\n\n"
  370. if trysubdns(domain) == true
  371. control=1
  372. sub.each do |sub|
  373. succ << dnscrawl(sub, domain)
  374. end
  375. puts
  376. end
  377. if trysubsock(domain)  == true and control==0
  378. sub.each do |sub|
  379. succ << sockcrawl(sub, domain)
  380. end
  381. end
  382.  
  383. if  trysubdns(domain)  || trysubsock(domain)
  384. succ=succ.gsub('-', '').length
  385. print "\n-----------------------------------------------------------\n"
  386. puts "SUBDOMAINS SUCCESSES IN #{domain}: #{succ}"
  387. puts "-----------------------------------------------------------"
  388.  
  389. else
  390.  
  391. puts "The #{domain} server is protected against subdomains crawling."
  392.  
  393. end
  394. end
  395.  
  396. # The magic of Ruby has begun ^^
  397.  
  398. case ARGV[0]
  399.  
  400. when "-0"
  401. query = ARGV[1].upcase
  402. domain= ARGV[2]
  403. resolv(domain, query, 0)
  404.  
  405. when "-1"
  406. domain = ARGV[1]
  407. axfr(domain)
  408.  
  409. when "-2"
  410. domain = ARGV[1]
  411. ixfr(domain)
  412.  
  413. when "-3"
  414. domain=ARGV[1]
  415. crawl(domain, sub)
  416.  
  417. when "-4"
  418. ipi=ARGV[1].split('.')
  419. if !ARGV[2]
  420. ipf=ARGV[1].split('.')
  421. else
  422. ipf=ARGV[2].split('.')
  423. end
  424. ptr(ipi, ipf)
  425.  
  426. when "-5"
  427. ip=ARGV[1]
  428. reverse(ip)
  429.  
  430. when "--all"
  431. domain=ARGV[1]
  432.  
  433. que0={
  434. "NS" => 2,
  435. "MX" => 15
  436. }
  437.  
  438. que1={
  439. "SIGZERO" => 0,
  440. "A" => 1,  
  441. "CNAME" => 5,
  442. "SOA" => 6,  
  443. "WKS" => 10,
  444. "HINFO" => 13,
  445. "MINFO" => 14,
  446. "TXT" => 16,
  447. "GPOS" => 27 ,
  448. "LOC" => 29,
  449. "SRV" => 33
  450. }
  451.  
  452. puts mantis
  453.  
  454. que0.each_pair do |key, value|
  455. puts "Resolving #{key} query:"
  456. resolv(domain, value,0)
  457. puts "-----------------------------------------------------------------------"
  458. end
  459.  
  460. que1.each_pair do |key, value|
  461. puts "Resolving #{key} query:"
  462. resolv(domain, value,1)
  463. puts "-----------------------------------------------------------------------"
  464. end
  465.  
  466. axfr(domain)
  467. ixfr(domain)
  468. crawl(domain, sub)
  469.  
  470. when "--mantis"
  471. puts mantis
  472. domain = ARGV[1]
  473. ipi=ARGV[1].split('.')
  474. if !ARGV[2]
  475. ipf=ARGV[1].split('.')
  476. else
  477. ipf=ARGV[2].split('.')
  478. end
  479. ips=ptr(ipi, ipf)
  480. print "\n"
  481. puts "Glup! Reversing has start with:"
  482. ips.each do |ip|
  483. print "[+] "
  484. reverse(ip)
  485. end
  486.  
  487. when "-h"
  488. puts "Mantis is a tool to collect information about DNS servers of a domain name.
  489.  
  490. [-0] Makes a DNS query simple query.
  491. #{$0} -0 mx domain.net
  492.  
  493. [-1] Starts a zone transfer(s) (axfr) to all DNS servers associated with the domain name.
  494. #{$0} -1 domain.net
  495.  
  496. [-2] Starts an incremental zone transfer(s) (ixfr) to all DNS servers associated with the domain name.
  497. #{$0} -2 domain.net
  498.  
  499. [-3] Makes a crawl of subdomains in the domain name given. It includes a dictionary but you can also use your own.
  500. #{$0} -3 domain.net
  501. #{$0} -3 domain.net dic.txt
  502.  
  503. [-4] Makes a reverse domain scan with an IP address interval given.
  504. #{$0} -4 192.168.1.0
  505. #{$0} -4 192.168.1.231
  506. #{$0} -4 192.168.1.1 192.168.1.164
  507.  
  508. [-5] Resolves domains name in the same server (Vhosts).
  509. #{$0} -5 domain.net
  510. #{$0} -5 192.168.114
  511.  
  512. [--all] Make a torbelline of querys.
  513. #{$o} --all domain.net
  514.  
  515. [--mantis] Make a Mantis Attack.
  516. #{$0} --mantis 192.168.1.0
  517. #{$0} --mantis 192.168.1.231
  518. #{$0} --mantis 192.168.1.1 192.168.1.164
  519.  
  520. Enjoy =)"
  521.  
  522. else
  523.  
  524. puts "Type #{$0} for help"
  525.  
  526. end

http://n3t-datagrams.net/lab/mantis2.rb.txt

Espero gente que la pruebe con sus correspondientes críticas positivas.

gracias ^^


En línea

Citar
javascript:đ=+!!{};(this)[ł={ŋ:''+!'[]',ŧ:''+!!đ},ł.ŋ[đ]+ł.ŋ[đ+đ]+ł.ŋ[++đ+đ]+ł.ŧ[--đ]+ł.ŧ[+!đ]](đ)
leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: Mantis 2.0
« Respuesta #1 en: 25 Diciembre 2009, 20:14 pm »

Qué bien, algo de ruby en el foro, gracias por el aporte.


En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines