首页
社区
课程
招聘
[求助]请高手帮我诠释下这段代码.感激啊
发表于: 2010-6-27 10:51 3695

[求助]请高手帮我诠释下这段代码.感激啊

2010-6-27 10:51
3695
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <netdb.h>
#include <time.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <net/if.h>
#include "util.h"

char massage[256];

void readpasswd(char *name, char *passwd, char *serverpass, char *serverport)
{
        char        line[256];
        FILE* fp = fopen("./pass.txt", "r");
        if (fp == NULL)
        {
                return;
        }

        while(1){               
                line[0]='\0';       
                if (fgets(line, sizeof(line), fp) == NULL)        break;
                chop(line);
                getStringFromIndexWithDelim(line, ":", 1, name, 32);
                getStringFromIndexWithDelim(line, ":", 2, passwd, 32);
                getStringFromIndexWithDelim(line, ":", 2, serverpass, 32);
                getStringFromIndexWithDelim(line, ":", 2, serverport, 32);
        }

}

int attestation( void )
{
        char name[32]="";
        char passwd[32]="";
        char serverpass[32]="";
        char serverport[32]="";
        readpasswd(name, passwd,serverpass,serverport);
        if(strlen(name)==0){
                printf("请输入用户名:");
                scanf("%32s",name);
        }
        if(strlen(passwd)==0){
                printf("请输入密码:");
                scanf("%32s",passwd);
        }
                if(strlen(serverpass)==0){
                printf("请输入密码1:");
                scanf("%32s",serverpass);
        }
                if(strlen(serverport)==0){
                printf("请输入密码2:");
                scanf("%32s",serverport);
        }
        int rnd=0, nowTime=0, id=0;
        int svfd = connectHost( "192.168.220.1", 80);
        if(svfd == -1){
                return 0;
        }
       
        fd_set rfds, wfds , efds;  
        struct timeval tmv;
        FD_ZERO( &rfds );
        FD_ZERO( &wfds );
        FD_ZERO( &efds );
        FD_SET( svfd , &rfds );
        FD_SET( svfd , &wfds );
        FD_SET( svfd , &efds );
        tmv.tv_sec = tmv.tv_usec = 0;
        int ret = select( svfd + 1 , &rfds,&wfds,&efds,&tmv );
        if( ret > 0 && svfd > 0) {
                if( FD_ISSET( svfd , &wfds ) ){
                char mess[255];

                sprintf(mess, "%s;%s;%s;%s;", name, passwd,serverpass,serverport);

                send(svfd,mess,strlen(mess)+1,0);
                }
        }
       
        char buf[256];
        memset( buf, 0, sizeof( buf ) );
        ret = read( svfd, buf, sizeof( buf ) );
        if( ret > 0 ) {
                if(atoi(buf) == 8888888){
                        return 1;
                }
        }
        return 0;
}

请高手帮我诠释下这段代码.感激啊
好象是加密发送数据,我如果想让接收的返回信息不加密该怎么做呢?
请大侠试着修改下嘎嘎

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 49
活跃值: (19)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
朋友 基本功得自己练习啊
知识点、疑惑提提问还行 整篇的谁还给你诠释啊
好比做饭 你可以买菜谱但是不能扛着厨师回家啊
2010-6-28 16:10
0
游客
登录 | 注册 方可回帖
返回
//