View Full Version : scanner perso
Hello!
I am coding a scanner multithread with a function random!
I have a few pieces of codes which I must rewrite and I need assistance!
I use devc++
Thanks a lot of
1/
aleatip=htonl(inet_addr("200.200.200.200")); //is ok
aleatip=htonl(inet_addr("a.b.c.d")); //don't work but no error message
2/
for (;startip <= endip;startip++)
{
while (!nthread) _sleep(500);
{
conf = (struct config *) malloc(sizeof(struct config) );
conf->ip = aleatip;
conf->port = port;
conf->hthread = CreateThread(NULL, 0, &connection, conf, 0, 0);
nthread--;
}
}
If ipstart=endip, I'have no result!
do you really writing this by your self ? better tell true.
I will not lie! Certain party of the code are of me
The remainder, I made like much, I pumped on the Net
I think of having understood the problems! It remains me with
the resoudre
For a IP, the thread is finished before having been able to
receive an answer So problem of time out
For the other problem, it is necessary that I manage to convert
entireties into character strings
it's a waste of time to help you looking at the code you are copy pasting, is it a joke ?
Try to understand what you are grabbing from all google caches because for example , you doesnt show us startip declared ... ,
while (!nthread) _sleep(500);
{
new c style ?
etc, etc....
Sorry, I will try to explain me!
This code is a simple ip port scanner with 4 choice:
choice of range of ip to scan
choice of port
choice of thread
generate random ip to scan
I did not dare to put all the code
But if that interests somebody I would put it.
I think of having to identify the problems. It remains me to solve
them with my friend google.
1)
int a,b,c,d;
So a.b.c.d is an address IP generated by the function random.
I must generated character strings made up of a.b.c.d to the
instruction inet_addr:
aleatip=htonl(inet_addr("a.b.c.d"));
2)
for the second problem
if I scan only one IP the loop too quickly finishes before to have
received the response of connection. It is a problem of tempo
int nthread;
int startip;
int endip;
int port;
int aleatip;
struct config * conf = NULL;
for (;startip <= endip;startip++)
{
while ( !nthread ) _sleep(100);
{
conf = (struct config *) malloc(sizeof(struct config) );
conf->ip = startip;
conf->port = port;
conf->hthread = CreateThread(NULL, 0, &connection, conf, 0, 0);
nthread--;
}
I try to find all alone on google how to correct all that.
Thanks a lot of!
for (startip=???;startip <= endip;
and so:
while ( !nthread ) _sleep(100);
{
conf = (struct config *) malloc(sizeof(struct config) );
conf->ip = startip;
conf->port = port;
conf->hthread = CreateThread(NULL, 0, &connection, conf, 0, 0);
nthread--;
}
I guess ur code between {} is neever executed , try it like this
while ( !nthread ) _sleep(100);
else
{
conf = (struct config *) malloc(sizeof(struct config) );
conf->ip = startip;
conf->port = port;
conf->hthread = CreateThread(NULL, 0, &connection, conf, 0, 0);
nthread--;
}
and so if you startip++ into the for{} , you will have to declare your aleatip better than this because you will simply add +1 to it to target the next ip , which I think you want aleatip.
thanks class101 but code between {} is executed
the function scan normal goes very well
I solved the problem of the tempo :
I placed the tempo out of the loop for
for (;startip <= endip;startip++)
{
while ( !nthread );
{
conf = (struct config *) malloc(sizeof(struct config) );
conf->ip = startip;
conf->port = port;
conf->hthread = CreateThread(NULL, 0, &connection, conf, 0, 0);
nthread--;
}
}
_sleep(150);
for random scan:
int i=1;
for (;i = i;i++) //for loop infinite
{
a=rand()%255;
b=rand()%255;
c=rand()%255;
d=rand()%255;
while (!nthread);
{
aleatip=inet_addr("a.b.c.d");
conf = (struct config *) malloc(sizeof(struct config) );
conf->ip = aleatip;
conf->port = port;
conf->hthread = CreateThread(NULL, 0, &connection, conf, 0, 0);
nthread--;
}
}
_sleep(150);
the problem is to transform a.b.c.d into string of caracters
because you try to indetaddr a char instead of an int, you should before transform a.b.c.d into a fixed ip address, your program doesnt know "a.b.c.d", try to put for example a sample ip adress at argv[4] and code inet_addr(argv[4]), you will see it should work because argv[4] is an int.
and
while ( !nthread );
there is no ";" at the end, you arent prolly compiling this , or I dunno a compiler allowing to compile this code.
int a,b,c,d;
char str[20];
a=rand()%255;
b=rand()%255;
c=rand()%255;
d=rand()%255;
sprintf(str,"%d.%d.%d.%d",a,b,c,d);
aleatip=htonl(inet_addr(str));
And here is the function random functions!
:lol:
while ( !nthread );
there is no ";" at the end, you arent prolly compiling this , or I dunno a compiler allowing to compile this code.
I use devc++
it compiles me that without error
thanks a lot of
class101
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by
vBSEO 3.1.0