PSCAN — File Browser

PSCANv1.0 / PSCANv1.0 / pscan.mrc

pscan.mrc — 3.35 KB — Download this file

;Simple Port Scanner by cold on irc.rizon.net
; Usage: 
;  /pscan or Psacn in menu
;  Enter ip address, start port and end port
;  Press start 
; 
;     Enjoy :)

alias pscan { if (!$dialog(pscan)) { dialog -md pscan pscan } }
dialog pscan {
  title "Ip Scanner | by cold"
  size -1 -1 123 187
  option dbu
  box "Info", 1, 2 2 120 44
  text "Ip Address:", 2, 5 15 40 8, center
  edit "", 3, 48 14 71 11
  text "Start port:", 4, 5 29 40 8, center
  edit "", 5, 48 28 30 11
  text "~", 6, 81 30 5 8
  edit "", 7, 89 28 30 11
  box "Status", 8, 2 51 120 104
  text "Completed:", 9, 8 63 29 8, right
  edit "", 10, 40 62 27 11, read
  text "Time:", 11, 66 63 15 8, right
  edit "", 12, 84 62 36 11, read
  text "Percentage:", 13, 6 79 31 8, right
  edit "", 14, 41 78 26 11, read
  text "Socks:", 15, 68 79 16 8
  edit "", 16, 85 78 35 11, read
  list 17, 6 93 113 58, size vsbar
  button "Start >", 18, 1 162 32 12, flat
  button "< Stop", 19, 90 162 32 12, flat
  button "Exit", 20, 47 162 28 12, default flat cancel
  edit "", 21, 0 176 123 11, read
}
on *:dialog:*:*:*: {
  if ($dname == pscan) {
    if ($devent == sclick) {
      if ($did == 18) { 
        if ($numtok($did(3).text,46) != 4) { 
          did -ra pscan 21 Error; Ip address must contain 4 octets. 
          return 
        }
        did -ra pscan 10 0 | did -ra pscan 12 0:00 | did -ra pscan 14 0% | did -ra pscan 16 0 | did -r pscan 17
        did -ra pscan 21 Starting scan of $did(3).text from port $did(5).text to $did(7).text
        pscan_ $did(3).text $did(5).text $did(7).text
      }
      if ($did == 19) {
        .timerscan* off
      }
    }
  }
}
alias pscan_ {
  set %found 0 | set %ip $1 | set %sport $calc($2 - 1) | set %eport $3 | set %ctime $ctime
  unset %found1 
  .timerscan 0 0 goscan 
}
alias goscan {
  if (!$dialog(pscan)) { .timerscan off }
  if (%sport > $calc(%eport - 2)) { 
    if ($dialog(pscan)) {
      .timer 1 3 did -ra pscan 16 $sock(pscan.*,0) 
      did -ra pscan 21 Found; $chr(91) $+ %found $+ $chr(93) Ports; $chr(91) $+ $right($replace(%found1,$chr(32),$chr(44)),-1) $+ $chr(93) Time; $chr(91) $+ $duration($calc($ctime - %ctime)) $+ $chr(93) 
      .timerscan off 
      unset %found,%found1,%ip,%sport,%eport,%ctime 
    } 
  }
  inc %sport 
  did -ra pscan 10 $calc($did(pscan,10) + 1) 
  did -ra pscan 14 $_percent(%sport,%eport) $+ $chr(37)
  did -ra pscan 12 $duration($calc($ctime - %ctime)) 
  .sockopen pscan. $+ %ip $+ . $+ %sport %ip %sport 
  did -ra pscan 16 $sock(pscan.*,0)
}
alias _percent { return $iif(($1 == 0) || ($2 == 0) || ($1 !isnum) || ($2 !isnum),0,$round($calc($1 * 100 / $2),$iif(($3 isnum) && ($3 >= 0),$3,0))) }
on *:sockopen:pscan.*: {
  if ($sockerr > 0) { return }
  did -a pscan 17 Ip: $sock($sockname).ip Port: $sock($sockname).port
  did -ra pscan 21 Ip: $sock($sockname).ip Port: $sock($sockname).port
  inc %found | set %found1 %found1 $+ $chr(32) $+ $sock($sockname).port
  .sockclose $sockname
}
menu channel,status {
  Pscan
  ..Pscan: /pscan
  ..Advertise: /me is scanning Ip: [ $+ %ip $+ ] Found; [ $+ %found $+ ] Ports; [ $+ $right($replace(%found1,$chr(32),$chr(44)),-1) $+ ] Percentage; [ $+ $_percent(%sport,%eport) $+ $chr(37) $+ ] Current port; [ $+ %sport $+ ] End port; [ $+ %eport $+ ] Time; [ $+ $duration($calc($ctime - %ctime)) $+ ] - by cold.
}