mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-06 13:01:42 -07:00
beautifications
This commit is contained in:
parent
e6b376293c
commit
2246030c21
1 changed files with 186 additions and 186 deletions
98
hydra-rtsp.c
98
hydra-rtsp.c
|
@ -16,124 +16,125 @@ char *buf;
|
||||||
char packet[500];
|
char packet[500];
|
||||||
char packet2[500];
|
char packet2[500];
|
||||||
|
|
||||||
int is_Unauthorized(char * s){
|
int is_Unauthorized(char *s) {
|
||||||
|
|
||||||
if (strstr(s,"401 Unauthorized")!= NULL){
|
if (strstr(s, "401 Unauthorized") != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_NotFound(char * s){
|
int is_NotFound(char *s) {
|
||||||
|
|
||||||
if (strstr(s,"404 Stream Not Found")!= NULL){
|
if (strstr(s, "404 Stream Not Found") != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_Authorized(char * s){
|
int is_Authorized(char *s) {
|
||||||
|
|
||||||
if (strstr(s,"200 OK")!= NULL){
|
if (strstr(s, "200 OK") != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int use_Basic_Auth(char * s){
|
int use_Basic_Auth(char *s) {
|
||||||
|
|
||||||
if(strstr(s,"WWW-Authenticate: Basic")!=NULL){
|
if (strstr(s, "WWW-Authenticate: Basic") != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int use_Digest_Auth(char * s){
|
int use_Digest_Auth(char *s) {
|
||||||
|
|
||||||
if(strstr(s,"WWW-Authenticate: Digest")!=NULL){
|
if (strstr(s, "WWW-Authenticate: Digest") != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void create_core_packet(int control,char* ip, int port){
|
void create_core_packet(int control, char *ip, int port) {
|
||||||
|
|
||||||
char buffer[500];
|
char buffer[500];
|
||||||
char * target=hydra_address2string(ip);
|
char *target = hydra_address2string(ip);
|
||||||
if (control==0){
|
|
||||||
if (strlen(packet) <= 0){
|
if (control == 0) {
|
||||||
sprintf(packet, "DESCRIBE rtsp://%.260s:%i RTSP/1.0\r\nCSeq: 2\r\n\r\n",target,port);
|
if (strlen(packet) <= 0) {
|
||||||
|
sprintf(packet, "DESCRIBE rtsp://%.260s:%i RTSP/1.0\r\nCSeq: 2\r\n\r\n", target, port);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if (strlen(packet2) <= 0){
|
if (strlen(packet2) <= 0) {
|
||||||
sprintf(packet2, "DESCRIBE rtsp://%s.260:%i RTSP/1.0\r\nCSeq: 3\r\n",target,port);
|
sprintf(packet2, "DESCRIBE rtsp://%s.260:%i RTSP/1.0\r\nCSeq: 3\r\n", target, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int start_rtsp(int s, char *ip, int port, unsigned char options, char *miscptr, FILE * fp)
|
int start_rtsp(int s, char *ip, int port, unsigned char options, char *miscptr, FILE * fp) {
|
||||||
{
|
|
||||||
char *empty = "";
|
char *empty = "";
|
||||||
char *login, *pass, buffer[500],buffer2[500];
|
char *login, *pass, buffer[500], buffer2[500];
|
||||||
|
|
||||||
char * lresp;
|
char *lresp;
|
||||||
|
|
||||||
if (strlen(login = hydra_get_next_login()) == 0)
|
if (strlen(login = hydra_get_next_login()) == 0)
|
||||||
login = empty;
|
login = empty;
|
||||||
if (strlen(pass = hydra_get_next_password()) == 0)
|
if (strlen(pass = hydra_get_next_password()) == 0)
|
||||||
pass = empty;
|
pass = empty;
|
||||||
|
|
||||||
create_core_packet(0,ip,port);
|
create_core_packet(0, ip, port);
|
||||||
|
|
||||||
if (hydra_send(s, packet, strlen(packet), 0) < 0) {
|
if (hydra_send(s, packet, strlen(packet), 0) < 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
lresp = hydra_receive_line(s);
|
lresp = hydra_receive_line(s);
|
||||||
|
|
||||||
if (lresp == NULL){
|
if (lresp == NULL) {
|
||||||
fprintf(stderr, "[ERROR] no server reply");
|
fprintf(stderr, "[ERROR] no server reply");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_NotFound(lresp)){
|
if (is_NotFound(lresp)) {
|
||||||
printf("[INFO] Server does not need credentials\n");
|
printf("[INFO] Server does not need credentials\n");
|
||||||
hydra_completed_pair_found();
|
hydra_completed_pair_found();
|
||||||
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0){
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
create_core_packet(1,ip, port);
|
create_core_packet(1, ip, port);
|
||||||
|
|
||||||
if (use_Basic_Auth(lresp)==1) {
|
if (use_Basic_Auth(lresp) == 1) {
|
||||||
|
|
||||||
sprintf(buffer2,"%.260s:%.260s",login,pass);
|
sprintf(buffer2, "%.260s:%.260s", login, pass);
|
||||||
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
|
hydra_tobase64((unsigned char *) buffer2, strlen(buffer2), sizeof(buffer2));
|
||||||
|
|
||||||
sprintf(buffer, "%sAuthorization: : Basic %s\r\n\r\n",packet2,buffer2);
|
sprintf(buffer, "%sAuthorization: : Basic %s\r\n\r\n", packet2, buffer2);
|
||||||
|
|
||||||
if (debug){
|
if (debug) {
|
||||||
hydra_report(stderr, "C:%s\n", buffer);
|
hydra_report(stderr, "C:%s\n", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(use_Digest_Auth(lresp)==1){
|
if (use_Digest_Auth(lresp) == 1) {
|
||||||
char *dbuf = dbuffer[500] = "";
|
char *dbuf = dbuffer[500] = "";
|
||||||
char aux[500] = "";
|
char aux[500] = "";
|
||||||
|
|
||||||
char *pbuffer = hydra_strcasestr(lresp,"WWW-Authenticate: Digest ");
|
char *pbuffer = hydra_strcasestr(lresp, "WWW-Authenticate: Digest ");
|
||||||
strncpy(aux,pbuffer + strlen("WWW-Authenticate: Digest "), sizeof(buffer));
|
|
||||||
aux[sizeof(aux)-1]='\0';
|
strncpy(aux, pbuffer + strlen("WWW-Authenticate: Digest "), sizeof(buffer));
|
||||||
|
aux[sizeof(aux) - 1] = '\0';
|
||||||
#ifdef LIBOPENSSL
|
#ifdef LIBOPENSSL
|
||||||
sasl_digest_md5(dbuf, login, pass, aux, miscptr, "rtsp", hydra_address2string(ip), port, "");
|
sasl_digest_md5(dbuf, login, pass, aux, miscptr, "rtsp", hydra_address2string(ip), port, "");
|
||||||
#endif
|
#else
|
||||||
printf("[ERROR] Digest auth required but compiled without OpenSSL/MD5 support\n");
|
printf("[ERROR] Digest auth required but compiled without OpenSSL/MD5 support\n");
|
||||||
return 3;
|
return 3;
|
||||||
#endif
|
#endif
|
||||||
|
@ -144,7 +145,7 @@ int start_rtsp(int s, char *ip, int port, unsigned char options, char *miscptr,
|
||||||
}
|
}
|
||||||
sprintf(buffer, "%sAuthorization: Digest %s\r\n\r\n", packet2, dbuf);
|
sprintf(buffer, "%sAuthorization: Digest %s\r\n\r\n", packet2, dbuf);
|
||||||
|
|
||||||
if (debug){
|
if (debug) {
|
||||||
hydra_report(stderr, "C:%s\n", buffer);
|
hydra_report(stderr, "C:%s\n", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,11 +158,11 @@ int start_rtsp(int s, char *ip, int port, unsigned char options, char *miscptr,
|
||||||
|
|
||||||
lresp = hydra_receive_line(s);
|
lresp = hydra_receive_line(s);
|
||||||
|
|
||||||
if ((is_NotFound(lresp))){
|
if ((is_NotFound(lresp))) {
|
||||||
|
|
||||||
hydra_completed_pair_found();
|
hydra_completed_pair_found();
|
||||||
|
|
||||||
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0){
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -171,7 +172,7 @@ int start_rtsp(int s, char *ip, int port, unsigned char options, char *miscptr,
|
||||||
hydra_completed_pair();
|
hydra_completed_pair();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
||||||
return 3;
|
return 3;
|
||||||
|
|
||||||
//not rechead
|
//not rechead
|
||||||
|
@ -192,11 +193,11 @@ void service_rtsp(char *ip, int sp, unsigned char options, char *miscptr, FILE *
|
||||||
|
|
||||||
switch (run) {
|
switch (run) {
|
||||||
case 1: /* connect and service init function */
|
case 1: /* connect and service init function */
|
||||||
if (sock >= 0){
|
if (sock >= 0) {
|
||||||
sock = hydra_disconnect(sock);
|
sock = hydra_disconnect(sock);
|
||||||
}
|
}
|
||||||
if ((options & OPTION_SSL) == 0) {
|
if ((options & OPTION_SSL) == 0) {
|
||||||
if (port != 0){
|
if (port != 0) {
|
||||||
myport = port;
|
myport = port;
|
||||||
}
|
}
|
||||||
sock = hydra_connect_tcp(ip, myport);
|
sock = hydra_connect_tcp(ip, myport);
|
||||||
|
@ -208,7 +209,7 @@ void service_rtsp(char *ip, int sp, unsigned char options, char *miscptr, FILE *
|
||||||
hydra_child_exit(1);
|
hydra_child_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
next_run=2;
|
next_run = 2;
|
||||||
break;
|
break;
|
||||||
case 2: /* run the cracking function */
|
case 2: /* run the cracking function */
|
||||||
next_run = start_rtsp(sock, ip, port, options, miscptr, fp);
|
next_run = start_rtsp(sock, ip, port, options, miscptr, fp);
|
||||||
|
@ -239,4 +240,3 @@ int service_rtsp_init(char *ip, int sp, unsigned char options, char *miscptr, FI
|
||||||
// -1 error, hydra will exit, so print a good error message here
|
// -1 error, hydra will exit, so print a good error message here
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue