没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
###############################################################################
#
# Procedure : dTelnetInit
#
# Purpose : Instantiates a telnet session
#
# Arguments : ip : [In] IP address to be telnetted
# mask : [In] Subnet Mask, addresses to be attempted sequentially
# Default Value - 32
# port : [In] Port Number to establish
# Default Value - 23
# timeout : [In] Timeout
# Default Value - 250
#
# Author : tcrone
#
# Returns : Handles the Telnet session
#
###############################################################################
proc dTelnetInit {ip {port 23} {mask 32} {timeout 250}} {
# From RFC 854:
set GA 249
set WILL 251
set WONT 252
set DO 253
set DONT 254
set IAC 255
set OPTIONS [list 3 1] ;# SuppressGoAhead (RFC 858), Echo (RFC 857)
#
# Procedure : dTelnetInit
#
# Purpose : Instantiates a telnet session
#
# Arguments : ip : [In] IP address to be telnetted
# mask : [In] Subnet Mask, addresses to be attempted sequentially
# Default Value - 32
# port : [In] Port Number to establish
# Default Value - 23
# timeout : [In] Timeout
# Default Value - 250
#
# Author : tcrone
#
# Returns : Handles the Telnet session
#
###############################################################################
proc dTelnetInit {ip {port 23} {mask 32} {timeout 250}} {
# From RFC 854:
set GA 249
set WILL 251
set WONT 252
set DO 253
set DONT 254
set IAC 255
set OPTIONS [list 3 1] ;# SuppressGoAhead (RFC 858), Echo (RFC 857)
set telnetSocket [dSocketInit $ip $port $mask $timeout]
if {$telnetSocket=="Err"} {
return Err
}
set initOutput [dEventRead $telnetSocket 1000 0 1] ;# No errcheck, binary
set textOutput ""
set servOutput ""
for {set i 0} {$i<[string length $initOutput]} {incr i} {
if {[scan [string index $initOutput $i] %c]==$IAC} {
incr i
if {[lsearch [list $WILL $WONT] [scan [string index $initOutput $i] %c]]!=-1} { ;# The option handling routines have another byte
incr i
set OptionValue [scan [string index $initOutput $i] %c]
if {[lsearch $OPTIONS $OptionValue]==-1} { ;# Option not found, DONT
append servOutput [binary format ccc $IAC $DONT $OptionValue]
puts "Rejecting Telnet Option $OptionValue"
} else { ;# Option was found, DO
append servOutput [binary format ccc $IAC $DO $OptionValue]
puts "Accepting Telnet Option $OptionValue"
}
} elseif {[lsearch [list $DO $DONT] [scan [string index $initOutput $i] %c]]!=-1} {
incr i
set OptionValue [scan [string index $initOutput $i] %c]
if {[lsearch $OPTIONS $OptionValue]==-1} { ;# Option not found, WONT
append servOutput [binary format ccc $IAC $WONT $OptionValue]
puts "Requesting Reject of Telnet Option $OptionValue"
} else { ;# Option was found, WILL
append servOutput [binary format ccc $IAC $WILL $OptionValue]
puts "Requesting Telnet Option $OptionValue"
剩余14页未读,继续阅读
资源评论
itwonderfulit
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功