ftp scriptchen
-
Hallo,
Ich wollte mir ein kleines ftp script proggen, welches in meinem firmen lan alle pcs testet bei denen man sich bei dem ftp service als anonymous anmelden kann.
realisiert habe ich das folgendermaßen:
main.cpp
#include <iostream> #include <fstream> #include <string.h> #include <pthread.h> #include "socket.h" using namespace std; int main (int argc, char* argv[]) { char buffer[5]; char rip[1000]; for (int i=1; i<40; i++) { strcpy (rip, argv[1]); sprintf(buffer, "%d", i); strcat (rip, buffer); pthread_t th[40]; pthread_create(&th[i], NULL, client, (void*) &rip); } }
socket.h
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> using namespace std; void* client (void* index) { char buffer[5000]; char* k = (char*)index; cout << k << endl; int s; struct sockaddr_in srv; s = socket(AF_INET, SOCK_STREAM, 0); if (s == -1) { perror("socket failed()"); } srv.sin_addr.s_addr = inet_addr(k); srv.sin_port = htons( (unsigned short int) 21); srv.sin_family = AF_INET; if (connect(s, (struct sockaddr*) &srv, sizeof(srv)) == -1) { perror("connect failed()"); } recv (s, buffer, sizeof(buffer), 0); send (s, "USER ftp\r\n", strlen("USER ftp\r\n"), 0); recv (s, buffer, sizeof(buffer), 0); send (s, "PASS ftp@localhost.com\r\n", strlen("PASS ftp@localhost.com\r\n"), 0); recv (s, buffer, sizeof(buffer), 0); if (strstr (buffer, "230") != 0) cout << "Found ano login on host: " << k << endl; else cout << "\tHost: [" << k << "] does not support anonymous login" << endl << endl; }
Das Ergebnis des Programm-Runs ist dann:
./main 127.0.0.
127.0.0.7127.0.0.7127.0.0.7
127.0.0.8
127.0.0.8
127.0.0.8
127.0.0.8127.0.0.8
127.0.0.10
127.0.0.10
127.0.0.11
127.0.0.12
127.0.0.13
127.0.0.14
127.0.0.15
127.0.0.16
127.0.0.17
127.0.0.18
127.0.0.19
127.0.0.20
127.0.0.21
127.0.0.22
127.0.0.23
127.0.0.24
127.0.0.25
127.0.0.26
127.0.0.27
127.0.0.28
127.0.0.29
127.0.0.30
127.0.0.31
127.0.0.32
127.0.0.33
127.0.0.34
127.0.0.35
127.0.0.36
127.0.0.37
127.0.0.38
127.0.0.39Kann mir bitte jemand weiterhelfen?
Vielen herzlichen Dank!
-
uuuuuuuuuuuuuups....
das problem
auf 127.0.0.1 läuft ein ftp server, der anonymes einloggen erlaubt => d.h. das programm soltle eig. eine meldung geben... tuts aber netaußerdem fängts iwie nicth bei .1 an zu scannen ?