mIRC32 - Ejemplos ya programados: Detector de Wingates. Fecha creación: 20/12/99 - Última revisión: 06/01/00
 
;########################
; 
;      WinGate Scan
;    By [SaRRiO] 2000
;   sarrio@univers.org
;
;########################


; para iniciar el detector de wingates, escribe: /dwingates
; carga la interfaz gráfica del detector de wingates...

alias dwingates {
  if (%wingates.kehacer == $null) set %wingates.kehacer escribir
  if ($dialog(wingates) != $null) dialog -x wingates
  set %temp.dir.wingate.txt $mircdir $+ wingates.txt
  if ($exists(%temp.dir.wingate.txt) == $false) write -c wingates.txt
  dialog -m wingates wingates
  unset %temp.dir.wingate.txt
}

; cuando el detector de wingates recibe informacion por los sockets...


; comprueba si el puerto esta abierto o no

on 1:SOCKOPEN:WINGATESCAN*:{
  if ($sockerr > 0) {
    if (%wingate.p.ip == $sock($sockname,1).ip) {
      .timer -m 1 1 wingates.informa off %wingate.p.ip $sock($sockname,1).ip tiene el puerto 1080 cerrado 
    unset %wingate.p.ip }
  }
  else {
    if (%wingate.p.ip == $sock($sockname,1).ip) {  
    .timer -m 1 1 wingates.informa on $sock($sockname,1).ip $sock($sockname,1).ip es un wingate/proxy! 
     unset %wingate.p.ip | sockclose $sockname | return
    }
    if ($read -s $+ $sock($sockname,1).ip wingates.txt == $null) {
      .timer -m 1 1 wingates.lokiere $sock($sockname,1).ip %wingate.nickname
    }
  }
  sockclose $sockname
  halt
}


; dialog de configuracion...

dialog wingates {  
  title "wingates"  
  size -1 -1 260 307
  button "añadir",1, 167 16 80 25
  button "",111, 300 250 80 25, default ok
  button "eliminar",2, 167 46 80 25
  button "comprobar",3, 167 76 80 25
  button "usar de firewall",4, 167 106 80 25
  box "",24,5 0 250 143

  box "",26,5 220 250 80
  text "al detectar un wingate, informar y...",80,15 235 250 15
  radio "preguntar si quieres añadirlo a la lista",81, 12 255 200 15
  radio "añadirlo a la lista directamente sin preguntar",82, 12 275 225 15
  list 14,12 13 150 135,sort extsel
  box "comprobar wingate cuando...",25,5 150 250 65
  check "recibas un privado de un usuario",94, 15 170 175 15
  check "un usuario entre en un canal",95, 15 190 165 15

}

on 1:DIALOG:wingates:INIT:0:{
  wingates.read
  did -b wingates 3 | did -b wingates 2 | did -b wingates 4
  if ($group(#wingate.entrar) == on) did -c wingates 95
  if ($group(#wingate.query) == on) did -c wingates 94
  if (%wingates.kehacer == preguntar) did -c wingates 81
  else did -c wingates 82
  dialog -t wingates wingates - $lines(wingates.txt) proxies en la lista -
}
on 1:DIALOG:wingates:SCLICK:*:{
  if ($did == 2) {
    did -b wingates 3
    did -b wingates 4
    did -b wingates 2  
    write -dl $+ $did(wingates,14).sel wingates.txt
    wingates.read
    haltdef
  }
  if ($did == 81) { set %wingates.kehacer preguntar }
  if ($did == 82) { set %wingates.kehacer escribir }
  if ($did == 1) { .timer -m 1 1 wingates.add  }
  if ($did == 4) { .timer -m 1 1 wingates.firewall }
  if ($did == 94) {
    if ($did(94).state == 1) .enable #wingate.query
    else .disable #wingate.query
  }
  if ($did == 95) {
    if ($did(95).state == 1) .enable #wingate.entrar
    else .disable #wingate.entrar
  }
  if ($did == 3) { 
   .timer -m 1 1 wingates.comprueba $did(wingates,14,$did(wingates,14).sel).text 
   dialog -x wingates
  }
  if ($did == 14) {
    if ($did(14).sel == $null) { did -b wingates 3 | did -b wingates 2 | did -b wingates 4 }
    if ($did(14).sel != $null) { did -e wingates 3 | did -e wingates 2 | did -e wingates 4 }
  }
  halt
}

; mantenimiento del wingates.txt y el dialog de configuracion

alias wingates.add {
  if ($1 == $null)  set %wingate.add $$?="IP/Host que deseas añadir a la lista de wingates?"
  else set %wingate.add $1
  write wingates.txt %wingate.add
  unset %wingate.add
  wingates.read
}

alias wingates.read {
  did -r wingates 14
  set %wingate.archivo 0
  : loop
  inc %wingate.archivo 1
  if ($read -l $+ %wingate.archivo wingates.txt != $null) {
    did -a wingates 14 $read -l $+ %wingate.archivo wingates.txt | goto loop }
}

alias wingates.firewall {
  set %wingate.firewall $$?="Servidor IRC por donde conectar?"
  set %wingate.tmp Seguro que deseas desconectarte, y volver a conectar por
  set %wingate.tmp2 $did(wingates,14,$did(wingates,14).sel).text
  if ($$?!="%wingate.tmp %wingate.firewall usando wingate.tmp2 como firewall?") {
    disconnect
    .firewall on wingate.tmp2
    server %wingate.firewall  
  }
  unset %wingate.tmp*
}

alias wingates.informa {
  if ($dialog(wingateinform) != $null) dialog -x wingateinform
  dialog -m wingateinform wingateinform
  did -a wingateinform 69 $3-
  dialog -t wingateinform resultados de $2
  if ($1 == off) { did -v wingateinform 7 | unset %wingate.p.ip }
}

alias wingates.comprueba {
  set %wingate.p.ip $1
  sockopen WINGATESCAN $+ $1 $1 1080
}

alias wingates.lokiere {
  if (%wingate.kehacer == preguntar) { 
    if ($$?!="El usuario $2 esta usando un WinGate: $1 $+ . Quieres añadirlo a tu lista de WinGates?") {
      write wingates.txt $1
    }
  } 
  else write wingates.txt $1
  if ($dialog(wingates) != $null) {
    .timer -m 1 1 dwingates
    .timer -m 1 1 wingates.read
  }
}

; dialog de informes...

dialog wingateinform {  
  title "resultados"  
  size -1 -1 265 115
  button "aceptar",60, 200 85 60 25, default ok
  button "borrar de la lista",7, 95 85 100 25, hide
  box "",24,5 0 255 80
  text "",69, 15 15 235 60
}

on 1:DIALOG:wingateinform:SCLICK:*:{
  if ($did == 7) {
    write -ds $+ %wingate.desaparece wingates.txt
    dialog -x wingateinform
  }
  if ($dialog(wingates) == $null)       .timer -m 1 1 dwingates
  else wingates.read

}

; comprobar wingate de un usuario que entra en el canal

#wingate.entrar on
on 1:JOIN:#:{
  set %wingate.nickname $nick 
  sockopen WINGATESCAN $+ $nick $remove($mask($address($nick,2),2),*!*@) 1080
}
#wingate.entrar end

; comprobar wingate de un usuario que te hace un privado

#wingate.query on
on 1:OPEN:?:{
  set %wingate.nickname $nick | set %temp $nick $+ ! $+ $address 
  sockopen WINGATESCAN $+ $nick $remove($mask(%temp,2),*!*@) 1080
}
#wingate.query end

; este scan de wingates podria mejorarse, pero no esta mal del todo xD
; si quereis copiar este script, por favor mandame un mail comunicandomelo,
; no pondre ninguna pega si me mencionas en los créditos y me avisas.

 Volver a la página principal