循环渐进NsDoor(二)
先水下….
今天竟然在YC某商场看到黑色6300,够炫….
可惜没看到6122c,期待….
昨天男篮比赛我都快郁闷死的说….功败垂成….
最近太兴奋,晚上要整到快一点,然后到床上也还睡不着/..
水完了….
这一节比较无聊,本来准备把它放后面随便亮下像的,可惜今天测试单管道,双管道,反弹型后门全失败(主要是有些bug,估计是编译器问题)….
目前网上流传的主流代码我试了下全部在VS08下编译通过,运行信息显示却又出入,所以只好先把这个东西拿出来顶一天…
第一个通信实例,我们的客户端使用的telnet服务…
现在实现一个客户端,代码也是相当简单,就当复习了下socket了….
1 //NsClient1
2 #include<iostream>
3 #include<winsock.h>
4 #pragma comment(lib,"Ws2_32")
5
6 int main(int argc,char* argv[])
7 {
8 const int PORT = 1517;
9 const int MAXDATASIZE = 1024;
10 int sockfd,numbytes;
11 char buf[MAXDATASIZE];
12 struct sockaddr_in their_addr;
13 if(argc != 2)//2 or 1?
14 {
15 cout<<"please give me the hostname"<<endl;
16 exit(1);
17 }
18
19 WSADATA ws;
20 WSAStartup(MAKEWORD(2,2),&ws);
21
22 if( (sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1)
23 {
24 cout<<"socket error"<<endl;
25 exit(1);
26 }
27
28 their_addr.sin_family = AF_INET;
29 their_addr.sin_port = htons(PORT);
30 their_addr.sin_addr.s_addr = inet_addr(argv[1]);
31
32 if(connect(sockfd,(struct sockaddr*)&their_addr,sizeof(struct sockaddr)) == -1)
33 {
34 cout<<"connect error"<<endl;
35 closesocket(sockfd);
36 exit(1);
37 }
38 if( (numbytes=recv(sockfd,buf,MAXDATASIZE,0)) == -1)
39 {
40 cout<<"recv error"<<endl;
41 closesocket(sockfd):
42 exit(1);
43 }
44 buf[numbytes] = '"0';
45 cout<<"Received:"<<buf<<endl;
46 closesocket(sockfd);
47
48 return 0;
49 }
50
2 #include<iostream>
3 #include<winsock.h>
4 #pragma comment(lib,"Ws2_32")
5
6 int main(int argc,char* argv[])
7 {
8 const int PORT = 1517;
9 const int MAXDATASIZE = 1024;
10 int sockfd,numbytes;
11 char buf[MAXDATASIZE];
12 struct sockaddr_in their_addr;
13 if(argc != 2)//2 or 1?
14 {
15 cout<<"please give me the hostname"<<endl;
16 exit(1);
17 }
18
19 WSADATA ws;
20 WSAStartup(MAKEWORD(2,2),&ws);
21
22 if( (sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1)
23 {
24 cout<<"socket error"<<endl;
25 exit(1);
26 }
27
28 their_addr.sin_family = AF_INET;
29 their_addr.sin_port = htons(PORT);
30 their_addr.sin_addr.s_addr = inet_addr(argv[1]);
31
32 if(connect(sockfd,(struct sockaddr*)&their_addr,sizeof(struct sockaddr)) == -1)
33 {
34 cout<<"connect error"<<endl;
35 closesocket(sockfd);
36 exit(1);
37 }
38 if( (numbytes=recv(sockfd,buf,MAXDATASIZE,0)) == -1)
39 {
40 cout<<"recv error"<<endl;
41 closesocket(sockfd):
42 exit(1);
43 }
44 buf[numbytes] = '"0';
45 cout<<"Received:"<<buf<<endl;
46 closesocket(sockfd);
47
48 return 0;
49 }
50
这个代码就是客户端啦…
编译后:
一个是昨天的服务端,一个就是客户端了
在我的本本上直接测试这两个啦,我的IP是192.168.0.20
先运行服务端:
和昨天一样的(而且也遭到防火墙拦截)
再运行客户端:
这个需要有命令行参数的,所以只好用CMD调用..
把客户端放C盘根目录里
参数如上所示,点回车后看到:
如愿得到了welcome 那句话…
再看服务端此时反应:
OK,测试成功….
第一节提出的遗留问题以后再解决….
-------------NewSketcher
Time: 080813 20:47