Ignore:
Timestamp:
12/14/13 17:04:51 (10 years ago)
Author:
obi
Message:

[networkbrowser] upgrade ass win7 share scan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/networkbrowser/networkbrowser.h

    r25208 r25213  
    932932        if(error == 1 && found == 0)
    933933        {
    934                 char* cmd = NULL;
    935                 cmd = ostrcat("smbclient -L //" , s, 0, 0);
     934                char* cmd = NULL, *bin = NULL;
     935                cmd = ostrcat("which smbclient3 | wc -l", NULL , 0, 0);
     936                debug(70, "cmd: %s", cmd);
     937
     938                char* tmpstr1 = command(cmd);
     939                debug(70, "---- binary check ----");
     940                debug(70, "%s", tmpstr1);
     941                debug(70, "----------------------");
     942                if(!ostrncmp("0", tmpstr1, 1))
     943                {
     944                        textbox(_("Message"), _("For Better Win7 Support install please Tpk Install > Network > Smbclient"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 5, 0);
     945                        bin = ostrcat("smbclient", NULL , 0, 0);
     946                }
     947                else
     948                        bin = ostrcat("smbclient3", NULL , 0, 0);
     949
     950                free(cmd), cmd = NULL;
     951                free(tmpstr1), tmpstr1 = NULL;
     952
     953                cmd = ostrcat(bin, " -L //" , 0, 0);
     954                cmd = ostrcat(cmd , r, 1, 0);
    936955                cmd = ostrcat(cmd, " -U '" , 1, 0);
    937956                cmd = ostrcat(cmd, u , 1, 0);
     
    941960                debug(70, "cmd: %s", cmd);
    942961
    943                 char* tmpstr1 = command(cmd);
    944                 printf("tmpstr1: %s\n",tmpstr1);
     962                tmpstr1 = command(cmd);
     963                debug(70, "------ result 1 ------");
    945964                debug(70, "%s", tmpstr1);
    946 
    947                 char* tmpstr2 = string_resub("---------      ----      -------", "This machine has a browse list:", tmpstr1, 0);
     965                debug(70, "----------------------");
     966
     967                char* tmpstr2 = NULL;
     968                if(ostrstr(tmpstr1, "This machine has a browse list:") != NULL)
     969                        tmpstr2 = string_resub("---------      ----      -------", "This machine has a browse list:", tmpstr1, 0);
     970                else
     971                        tmpstr2 = string_resub("---------       ----      -------", "Server               Comment", tmpstr1, 0);
     972
     973                debug(70, "------ result 2 ------");
     974                debug(70, "%s", tmpstr2);
     975                debug(70, "----------------------");
     976                               
    948977                free(tmpstr1), tmpstr1 = NULL;
    949978
     
    951980                {
    952981                        free(cmd), cmd = NULL;
    953                         cmd = ostrcat("smbclient -N -L //" , s, 0, 0);
     982                        cmd = ostrcat(bin, "  -N -L //" , 0, 0);
     983                        cmd = ostrcat(cmd , r, 1, 0);
    954984                        debug(70, "cmd: %s", cmd);
    955985       
    956986                        tmpstr1 = command(cmd);
     987                        debug(70, "------ result 3 ------");
    957988                        debug(70, "%s", tmpstr1);
     989                        debug(70, "----------------------");
    958990
    959991                        free(tmpstr2), tmpstr2 = NULL;
    960                         tmpstr2 = string_resub("---------      ----      -------", "This machine has a browse list:", tmpstr1, 0);
     992                        if(ostrstr(tmpstr1, "This machine has a browse list:") != NULL)
     993                                tmpstr2 = string_resub("---------      ----      -------", "This machine has a browse list:", tmpstr1, 0);
     994                        else
     995                                tmpstr2 = string_resub("---------       ----      -------", "Server               Comment", tmpstr1, 0);
     996
     997                        debug(70, "------ result 4 ------");
     998                        debug(70, "%s", tmpstr2);
     999                        debug(70, "----------------------");
     1000
     1001                        if(tmpstr2 == NULL)
     1002                        {
     1003                                if(ostrstr(tmpstr1, "Anonymous login successful") != NULL && ostrstr(tmpstr1, "Error returning browse list: NT_STATUS_ACCESS_DENIED") != NULL)
     1004                                {
     1005                                        textbox(_("Message"), _("Anonymous login Access Denied !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 5, 0);
     1006                                        found = 1;
     1007                                }
     1008                                else if(ostrstr(tmpstr1, "Anonymous login successful") != NULL)
     1009                                        textbox(_("Message"), _("Anonymous login successful"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 5, 0);
     1010                                else if(ostrstr(tmpstr1, "Access denied") != NULL)
     1011                                        textbox(_("Message"), _("Anonymous login Access Denied !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 5, 0);
     1012                        }
     1013                       
    9611014                        free(tmpstr1), tmpstr1 = NULL;
    9621015                }
     
    9641017                if(tmpstr2 != NULL)
    9651018                {
     1019                        if(ostrstr(tmpstr2, "Anonymous login successful") != NULL && ostrstr(tmpstr2, "Error returning browse list: NT_STATUS_ACCESS_DENIED") != NULL)
     1020                        {
     1021                                textbox(_("Message"), _("Anonymous login Access Denied !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 5, 0);
     1022                                found = 1;
     1023                        }
     1024                        else if(ostrstr(tmpstr2, "Anonymous login successful") != NULL)
     1025                                textbox(_("Message"), _("Anonymous login successful"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 5, 0);
     1026                                       
    9661027                        char* tmpstr3 = ostrcat("\t", tmpstr2, 0, 0);
    9671028
     
    9711032                        ret1 = strsplit(tmpstr3, "\n", &count);
    9721033
    973                         if(ret1 != NULL && count > 0)
     1034                        if(found == 0 && ret1 != NULL && count > 0)
    9741035                        {
    9751036                                int max = count;
    9761037                                for(j = 0; j < max; j++)
    9771038                                {
     1039                                        if(!ostrncmp("Error returning", ret1[j].part, 15))
     1040                                        {
     1041                                                debug(70, "break: Error returning: %s\n", ret1[j].part);
     1042                                                break;
     1043                                        }
     1044
    9781045                                        if(ostrncmp("\t", ret1[j].part, 1))
    9791046                                        {
     1047                                                debug(70, "continue: no tab: %s\n", ret1[j].part);
    9801048                                                continue;
    9811049                                        }
     
    9891057
    9901058                                        char* tmpstr6 = string_resub("\t", tmpstr5, ret1[j].part, 0);
    991                                        
     1059
    9921060                                        stringreplacechar(tmpstr5, ' ', '\0');                                                                 
    9931061
     
    11191187                char* user = NULL, *pass = NULL;
    11201188
    1121                 if(textbox(_("Message"), _("Use User authentication ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
     1189                if(textbox(_("Message"), _("Use User authentication ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 700, 200, 0, 0) == 1)
    11221190                {
    11231191                        user = ostrcat(user, getconfig("netbrowser_user", NULL), 1, 0);
Note: See TracChangeset for help on using the changeset viewer.