-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipScanModule.c
66 lines (52 loc) · 1.16 KB
/
ipScanModule.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <string.h>
#include <signal.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <pthread.h>
#include "net.h"
#include "ipScanModule.h"
#define NUM_THREADS 254
void *FUNC_THREAD(void *threadid)
{
FILE *dosya_yaz;
dosya_yaz = fopen("userlist.txt","a");
long tid;
tid = (long)threadid;
char str[20];
sprintf(str,"192.168.2.%ld",(tid+1));
int conn;
conn = connect_socket(10001,str);
char inbuffer[512];
if (conn != -1)
{
recv(conn,inbuffer,512,0);
fprintf(dosya_yaz,"%s %s\n",str,inbuffer);
}
close(conn);
fclose(dosya_yaz);
pthread_exit(NULL);
}
void ipScan()
{
remove("userlist.txt");
pthread_t threads[NUM_THREADS];
int rc;
int i;
for( i=0; i < NUM_THREADS; i++ )
{
//printf("main() : creating thread, %d\n",i);
rc = pthread_create(&threads[i], NULL,FUNC_THREAD, (void *)i);
if (rc)
{
printf("Error:unable to create thread, %d\n",rc);
exit(1);
}
}
}