Exemplo n.º 1
0
static void* scanHost(void* arg) {
	threaddata* d = arg;
	rocksock skt;
	rocksock* soc = &skt;
	rocksock_init(soc);
	rocksock_set_timeout(soc, 1500);

	if (!rocksock_connect(soc, d->host, d->port, 0)){
		d->status = 1;
	} else {
		//printf("%s\n", soc->lasterror.errormsg);
		d->status = 0;
	}

	rocksock_disconnect(soc);
	rocksock_clear(soc);

	pthread_mutex_lock(&mutex);
	done++;
	pthread_mutex_unlock(&mutex);
	return 0;
}
Exemplo n.º 2
0
int main(int argc, char** argv) {
	rocksock sock;
	rocksock* psock = &sock;
	int ret;
	char inbuf[1024];
	size_t bytesread;
	size_t chunksize = 512;

	if(argc < 2) {
		puts("need ip or dns name of a ftpserver as argv1");
		exit(1);
	}
#ifdef USE_SSL
	rocksock_init_ssl();
#endif
	rs_proxy proxies[4];
	rocksock_init(psock, proxies);
	rocksock_set_timeout(psock, 10000);
	//ret = rocksock_connect(psock, "b12.wimbli.com", 80, 0);
	rocksock_add_proxy(psock, RS_PT_SOCKS4, "127.0.0.1", 9050, NULL, NULL);
	//rocksock_add_proxy(psock, RS_PT_SOCKS5, "127.0.0.1", 31337, NULL, NULL);
	//rocksock_add_proxy(psock, RS_PT_SOCKS5, "98.216.80.12", 5639, NULL, NULL);


	ret = rocksock_connect(psock, argv[1],
#ifndef USE_SSL
		21, 0
#else
		443, 1
#endif
		);
	checkerr;
	do {
		ret = rocksock_readline(psock, inbuf, sizeof(inbuf)-1, &bytesread);
		checkerr;
		if(bytesread) puts(inbuf);
	} while (bytesread && memcmp(inbuf, "220 ", 4));

	ret = rocksock_send(psock, inbuf, snprintf(inbuf, sizeof(inbuf), "USER ftp\r\n"), 0, &bytesread);
	checkerr;
	puts(inbuf);

	do {
		ret = rocksock_readline(psock, inbuf, sizeof(inbuf)-1, &bytesread);
		checkerr;
		if(bytesread) puts(inbuf);
	} while (bytesread && memcmp(inbuf, "331 ", 4));

	ret = rocksock_send(psock, inbuf, snprintf(inbuf, sizeof(inbuf), "PASS none\r\n"), 0, &bytesread);
	checkerr;
	puts(inbuf);

	do {
		ret = rocksock_readline(psock, inbuf, sizeof(inbuf)-1, &bytesread);
		checkerr;
		if(bytesread) puts(inbuf);
	} while (bytesread && memcmp(inbuf, "230 ", 4));

	ret = rocksock_send(psock, inbuf, snprintf(inbuf, sizeof(inbuf), "PASV\r\n"), 0, &bytesread);
	checkerr;
	puts(inbuf);

	do {
		ret = rocksock_readline(psock, inbuf, sizeof(inbuf)-1, &bytesread);
		checkerr;
		if(bytesread) puts(inbuf);
	} while (bytesread && memcmp(inbuf, "230 ", 4));

	ret = rocksock_send(psock, inbuf, snprintf(inbuf, sizeof(inbuf), "LIST\r\n"), 0, &bytesread);
	checkerr;
	puts(inbuf);

	do {
		ret = rocksock_readline(psock, inbuf, sizeof(inbuf)-1, &bytesread);
		checkerr;
		if(bytesread) puts(inbuf);
	} while (bytesread && memcmp(inbuf, "230 ", 4));

	ret = rocksock_readline(psock, inbuf, sizeof(inbuf)-1, &bytesread);
	checkerr;
	if(bytesread) puts(inbuf);

	rocksock_disconnect(psock);
	rocksock_clear(psock);
#ifdef USE_SSL
	rocksock_free_ssl();
#endif
	return 0;
}