Board logo

标题: [讨论]关于POST提交返回数据的问题 [打印本页]

作者: wlfjck    时间: 2008-7-25 01:11     标题: [讨论]关于POST提交返回数据的问题

[讨论]关于POST提交返回数据的问题
议题作者:掐断你的温柔
信息来源:邪恶八进制信息安全团队(www.eviloctal.com

下面的c代码不知道哪里有问题,不能完全返回数据,希望高人能指点指点。 谢谢了!
复制内容到剪贴板
代码:
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include <string.h>

#pragma comment(lib, "ws2_32.lib")

char a[]={"POST /ip-domains.html HTTP/1.1"};
char b[]={"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*"};
char c[]={"Referer: http://www.seologs.com/ip-domains.html"};
char d[]={"Accept-Language: zh-cn"};
char e[]={"Content-Type: application/x-www-form-urlencoded"};
char f[]={"UA-CPU: x86"};
char g[]={"Accept-Encoding: gzip, deflate"};
char h[]={"User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"};
char i[]={"Host: www.seologs.com"};
char j[]={"Content-Length: "};
char k[]={"Connection: Keep-Alive"};
char l[]={"Cache-Control: no-cache"};

char name[]="domainname=";
char temp[1024],temp1[10240];
int   ren=0;

int  main(int argc,char *argv[])
{
  WSADATA wsadata;
  struct sockaddr_in serveraddr;
  SOCKET s;
  struct hostent *phostent;

  if(argc!=2)
  {
    printf("Usage:\n");
    printf("   whois  <domain|ip>\n");
    return 0;
  }
  strcat(name,argv[1]);
  sprintf(temp,"%s\r\n""%s\r\n""%s\r\n""%s\r\n""%s\r\n""%s\r\n""%s\r\n""%s\r\n""%s\r\n""%s%d\r\n""%s\r\n""%s\r\n""\r\n""%s",
    a,b,c,d,e,f,g,h,i,j,strlen(name),k,l,name);
  
  if(WSAStartup(MAKEWORD(2,2),&wsadata)!=0)
  {
    printf("WSAStartup fieald with error\n");
    return 0;
  }

  //printf("%s\n",temp);
  phostent=gethostbyname("www.seologs.com");
  s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  serveraddr.sin_port=htons(80);
  serveraddr.sin_family=AF_INET;
  serveraddr.sin_addr.s_addr=*(long *)phostent->h_addr_list[0];
           connect(s,(SOCKADDR *)&serveraddr,sizeof(serveraddr));

  send(s,temp,strlen(temp),0);
  while((ren = recv(s,temp1+strlen(temp1),10240-strlen(temp1),0))<=0){;}
  printf("%s",temp1);
  closesocket(s);
  WSACleanup();
  return 0;
}
帖子1 精华0 积分6 阅读权限40 在线时间3 小时




欢迎光临 【3.A.S.T】网络安全爱好者 (http://3ast.com/) Powered by Discuz! 7.2