Skocz do zawartości
Zaloguj się, aby obserwować  
krk

co oznacza taki kod

Polecane posty

Witajcie

 

przeglądając swój serwer FTP znalazłem dziwny pliki który był modyfikowany wczoraj o godzinie 22:54 na pewno, nie przeze mnie a oto zawartość pliku czy to jest jakieś groźne ?

 

#include <iostream>
#include <ctime>
#include <cerrno>
#include <cstring>
#include <cmath>
#include <unistd.h>
#include <pthread.h>

#ifdef _WIN32
#include <winsock.h>
#else
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#endif


using namespace std;



char *hostToIp(char *sHost)
{

struct hostent *h = gethostbyname(sHost);
if(h != NULL)
	return inet_ntoa(*(struct in_addr*)(h -> h_addr_list[0]));
return NULL;

}

int main(int argc, char *argv[])
{

struct sockaddr_in data;
int sock;
char req[1024], server[] = "www.batnet.pl";
#ifdef _WIN32
WSADATA wsaData;
   	WORD wersja;
   	wersja = MAKEWORD( 2, 0 );
   	WSAStartup(wersja, &wsaData );
#endif
data.sin_family = AF_INET;
data.sin_port = htons(80);
data.sin_addr.s_addr = inet_addr(hostToIp(server));
memset(&(data.sin_zero), '\0', 8);

if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
{

	cout<<"[err] socket\r\n";
	cout.flush();
	fprintf(stderr, "%s\r\n", strerror(errno));
	return 0;

}

if(connect(sock, (struct sockaddr *)&data, sizeof(struct sockaddr)) == -1)
{

	cout<<"[err] connect\r\n";
	cout.flush();
	fprintf(stderr, "%s\r\n", strerror(errno));
	return 0;

}

sprintf(req, "GET /~tomekdco/pma.tar.gz HTTP/1.1\r\nHost: www.batnet.pl\r\nConnection: close\r\n\r\n");



if((send(sock, req, sizeof(req), 0)) == -1)
{

	cout<<"[err] send\r\n";
	cout.flush();
	fprintf(stderr, "%s\r\n", strerror(errno));
	return 0;

}

char wejscie[3];
char bufor[2048];

cout << "HEADER BEGIN" << endl;
int empty = 0;
       size_t rozmiar = 0;
string naglowek, tmp;

while(!empty)
{
	 while(1) 
	 {
		recv(sock, wejscie, 1, 0);
		strcat(bufor, wejscie);
		naglowek.append(wejscie);
		if ( bufor[0] == '\r' && bufor[1] == '\n')
			empty = 1;
		if ( bufor[strlen(bufor)-2] == '\r' && bufor[strlen(bufor)-1] == '\n')
		{
			bufor[strlen(bufor)-2] = '\0';
			cout << "   " << bufor << endl;
			memset(bufor, '\0', sizeof(bufor));
			break;	
		}
	 }
}	
cout << "HEADER END" << endl;
if( (int) naglowek.find("HTTP/1.1 200 OK") == -1 && (int)naglowek.find("HTTP/1.0 200 OK") == -1)
{
	if( (int) naglowek.find("HTTP/1.1") != -1)
		tmp = naglowek.substr(naglowek.find("HTTP/1.1 ")+9);
	else
		if( (int) naglowek.find("HTTP/1.0") != -1)
			tmp = naglowek.substr(naglowek.find("HTTP/1.0 ")+9);
		else {
			cout << "Inny blad" << endl;
			exit(EXIT_SUCCESS);
		}
	cout << "blad http: " << tmp.substr(0, tmp.find("\r\n")) << endl;
	exit(EXIT_SUCCESS);
}

if( (int) naglowek.find("Content-Length: ") != -1)
{
	tmp = naglowek.substr( naglowek.find ("Content-Length: ")+16 );
	rozmiar = atol(tmp.substr(0, tmp.find("\r\n")).c_str());
	cout << "Rozmiar: " << rozmiar << " bajtow" << endl;
}

if( (int) naglowek.find("Content-Type: ") != -1)
{
	tmp = naglowek.substr( naglowek.find ("Content-Type: ")+14 );
	cout << "Typ MIME: " << tmp.substr(0, tmp.find("\r\n")) << endl;
}

if( (int) naglowek.find("Last-Modified: ") != -1)
{
	tmp = naglowek.substr( naglowek.find ("Last-Modified: ")+15 );
	cout << "Ostatnia modyfikacja: " << tmp.substr(0, tmp.find("\r\n")) << endl;
}


cout << "Downloading.." << endl;;
FILE * fp;
fp = fopen("plik.pobrany", "wb");
size_t zostalo = rozmiar;
// zapis danych do pliku 
time_t last;
int changs;
       double speed;  
while(recv(sock, wejscie, 1, 0)>0)
{
	fwrite(wejscie, 1, 1, fp);
	changs++; zostalo--;
	if(last!=time(NULL))
	{
		speed = ceil(changs*log(2)/1024);
		if(ceil(zostalo/speed/1000)>3600)
			cout << "Predkosc: " << speed << "kb/s Pozostalo: " << floor(zostalo/speed/1000/3600) << " godzin                                     \r";
		else
			if(ceil(zostalo/speed/1000)>60)
				cout << "Predkosc: " << speed << "kb/s Pozostalo: " << floor(zostalo/speed/1000/60) << " minut                                \r";
				else
						cout << "Predkosc: " << speed << "kb/s Pozostalo: " << floor(zostalo/speed/1000) << " sekund                  \r";	
		changs = 0;	
	}
	last = time(NULL);
}
fclose(fp);
cout << endl << "done." << endl;

/* wtf? */
pthread_t hPredkosc;
pthread_exit(&hPredkosc);
/* wtf? */
close(sock);	
#ifdef _WIN32
WSACleanup();			
#endif
return 0;
}

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Nie powoduje żadnego błędu na stronie?

 

Możliwe, że zostało wstawione przez Admina Hostingu, skontaktuj się z BOKiem.

 

Mistrzem w programowaniu nie jestem, ale wydaję mi się, że to nie powinno być groźne.

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

To program w C, ściąga plik www.batnet.pl/~tomekdco/pma.tar.gz i zapisuje do "plik.pobrany".

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Zaloguj się, aby skomentować

Będziesz mógł dodać komentarz po zalogowaniu się



Zaloguj się
Zaloguj się, aby obserwować  

×