scanner perso [Sitemap] - HeapOverflow Computer Security Community & Forums : Heap Overflow.com

PDA

View Full Version : scanner perso


fredo
08-07-05, 13:51
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!

rscience
08-07-05, 14:18
do you really writing this by your self ? better tell true.

fredo
08-07-05, 14:34
I will not lie! Certain party of the code are of me

The remainder, I made like much, I pumped on the Net

fredo
08-07-05, 17:21
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

class101
08-07-05, 18:34
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....

fredo
09-07-05, 02:56
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!

class101
09-07-05, 13:21
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.

fredo
11-07-05, 01:57
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

class101
11-07-05, 11:16
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.

fredo
11-07-05, 12:18
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