C port scanner

C port scanner

Post by Dean Parson » Mon, 28 Jun 1999 04:00:00



Hello there all.

I have been writing some Client / Server apps in C.
I was wondering and how i would go about writting a port
scanner to scan server ports to see what services are
availabe.

any ideas???


Dean

 
 
 

C port scanner

Post by Joe Sha » Mon, 28 Jun 1999 04:00:00


All you'd have to do to write a simple TCP port scanner is write a program
that connects to a tcp port, then change the port from a static number to
possibly the counter of a for loop.  When connect() returns 0 for a
successful connection, log the port number in an array, or just print the
successful connection to stdout.

Here's a quick example I banged out:

/********************************************************************************
* Very simple portscanner written as an excercise on doing so.  It doesn't have *
* any of the fancy features of a sophisticated portscanner like nmap, but it    *
* does do a simple scan of TCP ports 0-1023 in order to find listening TCP ports*
*                                                                               *
* You can modify this code if you wish, but please give credit to the original  *
* author.  I make no guarantees that this code actually does anyyhing or        *
* if it wil even work on any given operating system.  Summary: USE AT YOUR OWN  *
* RISK.                                                                         *

********************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>

int splash()
{
        printf("\nSimple tcp port scanner I wrote to pass the time.\n");
        printf("Enjoy, and maybe it'll teach someone something somewhere...\n");

Quote:}

int main(int argc, char *argv[])
{
        int clientSocket, remotePort, open_ports, status;
        struct hostent *hostPtr = NULL;
        struct sockaddr_in serverName = { 0 };
        struct servent *servPort;
        char buffer[256] = "";
        char *remoteHost = NULL;
        char serv[20];

        if (argc < 2){
                fprintf(stderr, "Usage: %s <serverHost>\n", argv[0]);
                exit(1);
        }

        splash();

        open_ports = 0;

        remoteHost = argv[1];
        for(remotePort = 0; remotePort < 1024; remotePort++){

        clientSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

        if (clientSocket == -1){
                perror("socket()");
                exit(1);
        }

        hostPtr = gethostbyname(remoteHost);
        if (hostPtr == NULL){
                hostPtr = gethostbyaddr(remoteHost, strlen(remoteHost), AF_INET);
                if (hostPtr == NULL){
                        perror("Errer resolving server address");
                        exit(1);
                }
        }

        serverName.sin_family = AF_INET;
        serverName.sin_port = htons(remotePort);
        (void) memcpy(&serverName.sin_addr,
                hostPtr->h_addr,
                hostPtr->h_length);

        status = connect(clientSocket, (struct sockaddr*) &serverName, sizeof(serverName));
        if(status == 0){
                servPort = getservbyport(htons(remotePort),"tcp");
                printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);
                ++open_ports;
        }
        close(clientSocket);

Quote:}

        printf("\nSummary: %d ports open on %s\n", open_ports, remoteHost);

Quote:}

--

* Computer Security Consultant and Perl Programmer
Free UNIX advocate - "I hack, therefore I am."

> Hello there all.

> I have been writing some Client / Server apps in C.
> I was wondering and how i would go about writting a port
> scanner to scan server ports to see what services are
> availabe.

> any ideas???


> Dean


 
 
 

C port scanner

Post by Dean Parson » Mon, 28 Jun 1999 04:00:00


I dont quit understand why u do this.... why a memcpy() and what is the (void) in front for??

        (void) memcpy(&serverName.sin_addr,
                hostPtr->h_addr,
                hostPtr->h_length)

Is there a way to do with out this, or do it another way?

dean
Thanks for your help


> All you'd have to do to write a simple TCP port scanner is write a program
> that connects to a tcp port, then change the port from a static number to
> possibly the counter of a for loop.  When connect() returns 0 for a
> successful connection, log the port number in an array, or just print the
> successful connection to stdout.

> Here's a quick example I banged out:

> /********************************************************************************
> * Very simple portscanner written as an excercise on doing so.  It doesn't have *
> * any of the fancy features of a sophisticated portscanner like nmap, but it    *
> * does do a simple scan of TCP ports 0-1023 in order to find listening TCP ports*
> *                                                                               *
> * You can modify this code if you wish, but please give credit to the original  *
> * author.  I make no guarantees that this code actually does anyyhing or        *
> * if it wil even work on any given operating system.  Summary: USE AT YOUR OWN  *
> * RISK.                                                                         *

> ********************************************************************************/

> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <unistd.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
> #include <netdb.h>

> int splash()
> {
>         printf("\nSimple tcp port scanner I wrote to pass the time.\n");
>         printf("Enjoy, and maybe it'll teach someone something somewhere...\n");
> }

> int main(int argc, char *argv[])
> {
>         int clientSocket, remotePort, open_ports, status;
>         struct hostent *hostPtr = NULL;
>         struct sockaddr_in serverName = { 0 };
>         struct servent *servPort;
>         char buffer[256] = "";
>         char *remoteHost = NULL;
>         char serv[20];

>         if (argc < 2){
>                 fprintf(stderr, "Usage: %s <serverHost>\n", argv[0]);
>                 exit(1);
>         }

>         splash();

>         open_ports = 0;

>         remoteHost = argv[1];
>         for(remotePort = 0; remotePort < 1024; remotePort++){

>         clientSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

>         if (clientSocket == -1){
>                 perror("socket()");
>                 exit(1);
>         }

>         hostPtr = gethostbyname(remoteHost);
>         if (hostPtr == NULL){
>                 hostPtr = gethostbyaddr(remoteHost, strlen(remoteHost), AF_INET);
>                 if (hostPtr == NULL){
>                         perror("Errer resolving server address");
>                         exit(1);
>                 }
>         }

>         serverName.sin_family = AF_INET;
>         serverName.sin_port = htons(remotePort);
>         (void) memcpy(&serverName.sin_addr,
>                 hostPtr->h_addr,
>                 hostPtr->h_length);

>         status = connect(clientSocket, (struct sockaddr*) &serverName, sizeof(serverName));
>         if(status == 0){
>                 servPort = getservbyport(htons(remotePort),"tcp");
>                 printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);
>                 ++open_ports;
>         }
>         close(clientSocket);
> }
>         printf("\nSummary: %d ports open on %s\n", open_ports, remoteHost);
> }

> --

> * Computer Security Consultant and Perl Programmer
> Free UNIX advocate - "I hack, therefore I am."


> > Hello there all.

> > I have been writing some Client / Server apps in C.
> > I was wondering and how i would go about writting a port
> > scanner to scan server ports to see what services are
> > availabe.

> > any ideas???


> > Dean

 
 
 

C port scanner

Post by Dean Parson » Mon, 28 Jun 1999 04:00:00


I dont quit understand why u do this.... why a memcpy() and what is the (void) in front for??

        (void) memcpy(&serverName.sin_addr,
                hostPtr->h_addr,
                hostPtr->h_length)

Is there a way to do with out this, or do it another way?

dean
Thanks for your help


> All you'd have to do to write a simple TCP port scanner is write a program
> that connects to a tcp port, then change the port from a static number to
> possibly the counter of a for loop.  When connect() returns 0 for a
> successful connection, log the port number in an array, or just print the
> successful connection to stdout.

> Here's a quick example I banged out:

> /********************************************************************************
> * Very simple portscanner written as an excercise on doing so.  It doesn't have *
> * any of the fancy features of a sophisticated portscanner like nmap, but it    *
> * does do a simple scan of TCP ports 0-1023 in order to find listening TCP ports*
> *                                                                               *
> * You can modify this code if you wish, but please give credit to the original  *
> * author.  I make no guarantees that this code actually does anyyhing or        *
> * if it wil even work on any given operating system.  Summary: USE AT YOUR OWN  *
> * RISK.                                                                         *

> ********************************************************************************/

> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <unistd.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
> #include <netdb.h>

> int splash()
> {
>         printf("\nSimple tcp port scanner I wrote to pass the time.\n");
>         printf("Enjoy, and maybe it'll teach someone something somewhere...\n");
> }

> int main(int argc, char *argv[])
> {
>         int clientSocket, remotePort, open_ports, status;
>         struct hostent *hostPtr = NULL;
>         struct sockaddr_in serverName = { 0 };
>         struct servent *servPort;
>         char buffer[256] = "";
>         char *remoteHost = NULL;
>         char serv[20];

>         if (argc < 2){
>                 fprintf(stderr, "Usage: %s <serverHost>\n", argv[0]);
>                 exit(1);
>         }

>         splash();

>         open_ports = 0;

>         remoteHost = argv[1];
>         for(remotePort = 0; remotePort < 1024; remotePort++){

>         clientSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

>         if (clientSocket == -1){
>                 perror("socket()");
>                 exit(1);
>         }

>         hostPtr = gethostbyname(remoteHost);
>         if (hostPtr == NULL){
>                 hostPtr = gethostbyaddr(remoteHost, strlen(remoteHost), AF_INET);
>                 if (hostPtr == NULL){
>                         perror("Errer resolving server address");
>                         exit(1);
>                 }
>         }

>         serverName.sin_family = AF_INET;
>         serverName.sin_port = htons(remotePort);
>         (void) memcpy(&serverName.sin_addr,
>                 hostPtr->h_addr,
>                 hostPtr->h_length);

>         status = connect(clientSocket, (struct sockaddr*) &serverName, sizeof(serverName));
>         if(status == 0){
>                 servPort = getservbyport(htons(remotePort),"tcp");
>                 printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);
>                 ++open_ports;
>         }
>         close(clientSocket);
> }
>         printf("\nSummary: %d ports open on %s\n", open_ports, remoteHost);
> }

> --

> * Computer Security Consultant and Perl Programmer
> Free UNIX advocate - "I hack, therefore I am."


> > Hello there all.

> > I have been writing some Client / Server apps in C.
> > I was wondering and how i would go about writting a port
> > scanner to scan server ports to see what services are
> > availabe.

> > any ideas???


> > Dean

 
 
 

C port scanner

Post by Dean Parson » Mon, 28 Jun 1999 04:00:00


There is a bug in your code...
it core dumps on scanning some port after 515 for some reason.

PS i now know i dont really need the:

        (void) memcpy(&serverName.sin_addr,
                hostPtr->h_addr,
                hostPtr->h_length)

snip of code.

dean


> All you'd have to do to write a simple TCP port scanner is write a program
> that connects to a tcp port, then change the port from a static number to
> possibly the counter of a for loop.  When connect() returns 0 for a
> successful connection, log the port number in an array, or just print the
> successful connection to stdout.

> Here's a quick example I banged out:

> /********************************************************************************
> * Very simple portscanner written as an excercise on doing so.  It doesn't have *
> * any of the fancy features of a sophisticated portscanner like nmap, but it    *
> * does do a simple scan of TCP ports 0-1023 in order to find listening TCP ports*
> *                                                                               *
> * You can modify this code if you wish, but please give credit to the original  *
> * author.  I make no guarantees that this code actually does anyyhing or        *
> * if it wil even work on any given operating system.  Summary: USE AT YOUR OWN  *
> * RISK.                                                                         *

> ********************************************************************************/

> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <unistd.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
> #include <netdb.h>

> int splash()
> {
>         printf("\nSimple tcp port scanner I wrote to pass the time.\n");
>         printf("Enjoy, and maybe it'll teach someone something somewhere...\n");
> }

> int main(int argc, char *argv[])
> {
>         int clientSocket, remotePort, open_ports, status;
>         struct hostent *hostPtr = NULL;
>         struct sockaddr_in serverName = { 0 };
>         struct servent *servPort;
>         char buffer[256] = "";
>         char *remoteHost = NULL;
>         char serv[20];

>         if (argc < 2){
>                 fprintf(stderr, "Usage: %s <serverHost>\n", argv[0]);
>                 exit(1);
>         }

>         splash();

>         open_ports = 0;

>         remoteHost = argv[1];
>         for(remotePort = 0; remotePort < 1024; remotePort++){

>         clientSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

>         if (clientSocket == -1){
>                 perror("socket()");
>                 exit(1);
>         }

>         hostPtr = gethostbyname(remoteHost);
>         if (hostPtr == NULL){
>                 hostPtr = gethostbyaddr(remoteHost, strlen(remoteHost), AF_INET);
>                 if (hostPtr == NULL){
>                         perror("Errer resolving server address");
>                         exit(1);
>                 }
>         }

>         serverName.sin_family = AF_INET;
>         serverName.sin_port = htons(remotePort);
>         (void) memcpy(&serverName.sin_addr,
>                 hostPtr->h_addr,
>                 hostPtr->h_length);

>         status = connect(clientSocket, (struct sockaddr*) &serverName, sizeof(serverName));
>         if(status == 0){
>                 servPort = getservbyport(htons(remotePort),"tcp");
>                 printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);
>                 ++open_ports;
>         }
>         close(clientSocket);
> }
>         printf("\nSummary: %d ports open on %s\n", open_ports, remoteHost);
> }

> --

> * Computer Security Consultant and Perl Programmer
> Free UNIX advocate - "I hack, therefore I am."


> > Hello there all.

> > I have been writing some Client / Server apps in C.
> > I was wondering and how i would go about writting a port
> > scanner to scan server ports to see what services are
> > availabe.

> > any ideas???


> > Dean

 
 
 

C port scanner

Post by Dean Parson » Mon, 28 Jun 1999 04:00:00


The bug is at line:
 printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);

The core dump must be due to the servPort ->s_name

The way i was going to approch this was to open a socket... connect to N
where N is 0 to 1024 ( or what ever ). Read from the socket using recv()
and then printf() the port number and what it read from that socket.

PS your port scanner says that there is a port available on a certain server.
if i "telnet" to this server at that port it says:

Trying zzz.bbb.ccc.ddd
telnet: Unable to connect to remote host: Connection refused

Even though that port has a service attached to it.

What bout if i just try to connect to a port and then just to a read from it to see
what the port says. ( will it give me what the port actually does?? ) for example If i just
connect to a port and do a read will it send back [ ssh ] or [ ftp ]  or [ telnet ] ... etc.??

Dean


> There is a bug in your code...
> it core dumps on scanning some port after 515 for some reason.

> PS i now know i dont really need the:

>         (void) memcpy(&serverName.sin_addr,
>                 hostPtr->h_addr,
>                 hostPtr->h_length)

> snip of code.

> dean


> > All you'd have to do to write a simple TCP port scanner is write a program
> > that connects to a tcp port, then change the port from a static number to
> > possibly the counter of a for loop.  When connect() returns 0 for a
> > successful connection, log the port number in an array, or just print the
> > successful connection to stdout.

> > Here's a quick example I banged out:

> > /********************************************************************************
> > * Very simple portscanner written as an excercise on doing so.  It doesn't have *
> > * any of the fancy features of a sophisticated portscanner like nmap, but it    *
> > * does do a simple scan of TCP ports 0-1023 in order to find listening TCP ports*
> > *                                                                               *
> > * You can modify this code if you wish, but please give credit to the original  *
> > * author.  I make no guarantees that this code actually does anyyhing or        *
> > * if it wil even work on any given operating system.  Summary: USE AT YOUR OWN  *
> > * RISK.                                                                         *

> > ********************************************************************************/

> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <sys/types.h>
> > #include <sys/socket.h>
> > #include <unistd.h>
> > #include <netinet/in.h>
> > #include <arpa/inet.h>
> > #include <netdb.h>

> > int splash()
> > {
> >         printf("\nSimple tcp port scanner I wrote to pass the time.\n");
> >         printf("Enjoy, and maybe it'll teach someone something somewhere...\n");
> > }

> > int main(int argc, char *argv[])
> > {
> >         int clientSocket, remotePort, open_ports, status;
> >         struct hostent *hostPtr = NULL;
> >         struct sockaddr_in serverName = { 0 };
> >         struct servent *servPort;
> >         char buffer[256] = "";
> >         char *remoteHost = NULL;
> >         char serv[20];

> >         if (argc < 2){
> >                 fprintf(stderr, "Usage: %s <serverHost>\n", argv[0]);
> >                 exit(1);
> >         }

> >         splash();

> >         open_ports = 0;

> >         remoteHost = argv[1];
> >         for(remotePort = 0; remotePort < 1024; remotePort++){

> >         clientSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

> >         if (clientSocket == -1){
> >                 perror("socket()");
> >                 exit(1);
> >         }

> >         hostPtr = gethostbyname(remoteHost);
> >         if (hostPtr == NULL){
> >                 hostPtr = gethostbyaddr(remoteHost, strlen(remoteHost), AF_INET);
> >                 if (hostPtr == NULL){
> >                         perror("Errer resolving server address");
> >                         exit(1);
> >                 }
> >         }

> >         serverName.sin_family = AF_INET;
> >         serverName.sin_port = htons(remotePort);
> >         (void) memcpy(&serverName.sin_addr,
> >                 hostPtr->h_addr,
> >                 hostPtr->h_length);

> >         status = connect(clientSocket, (struct sockaddr*) &serverName, sizeof(serverName));
> >         if(status == 0){
> >                 servPort = getservbyport(htons(remotePort),"tcp");
> >                 printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);
> >                 ++open_ports;
> >         }
> >         close(clientSocket);
> > }
> >         printf("\nSummary: %d ports open on %s\n", open_ports, remoteHost);
> > }

> > --

> > * Computer Security Consultant and Perl Programmer
> > Free UNIX advocate - "I hack, therefore I am."


> > > Hello there all.

> > > I have been writing some Client / Server apps in C.
> > > I was wondering and how i would go about writting a port
> > > scanner to scan server ports to see what services are
> > > availabe.

> > > any ideas???


> > > Dean

 
 
 

C port scanner

Post by Joe Sha » Mon, 28 Jun 1999 04:00:00



> There is a bug in your code...
> it core dumps on scanning some port after 515 for some reason.

What OS are you compiling it on?  It works fine past ports 515 for me on a
Slackware Linux 3.4 box running kernel 2.0.36.

TCP connection: [port 21][ftp]
TCP connection: [port 22][ssh]  
TCP connection: [port 23][telnet]
TCP connection: [port 25][smtp]
TCP connection: [port 37][time]
TCP connection: [port 80][www]  
TCP connection: [port 110][pop3]
TCP connection: [port 113][auth]  
TCP connection: [port 543][klogin]
TCP connection: [port 544][kshell]

Summary: 10 ports open on localhost

I got the same results from my OpenBSD 2.5 box and my FreeBSD 2.2.8 box.

Quote:> PS i now know i dont really need the:

>         (void) memcpy(&serverName.sin_addr,
>                 hostPtr->h_addr,
>                 hostPtr->h_length)

the (void) isn't necessary in front of the memcpy (I think it could be
handled by the C pre-processor) since it compiles properly without it.
All the memcpy function is really doing is copying hostPtr->h_length bytes
from pointer hostPtr->h_addr to the variable serverName.sin_addr.  It's
possible that this can be handled differently, but it's the way I was
taught, and I'll be glad to move to another way of doing it if there's a
better way.

My C isn't nearly as good as my PERL.

However, after using nmap, there's no real point to writing your own
portscanner.  It'd take entirely too long to write one with as many
features as the one Fyodor has made, and there's no real point in
re-inventing the wheel when the current one does just about everything
you'd ever need.

--

* Computer Security Consultant and Perl Programmer
Free UNIX advocate - "I hack, therefore I am."

 
 
 

C port scanner

Post by Joe Sha » Mon, 28 Jun 1999 04:00:00


Ahh, I see what I did wrong.  I should have checked for getservbyport to
return a NULL pointer.  

It's coredumping because it's finding a port open on the box you're
scanning that doesn't have an entry in /etc/services.  So,
getservbyport is returning a NULL pointer, causing

printf("TCP connection: [port %d][%s]\n", remotePort,servPort->s_name);

to dump core because it's not intended to handle the NULL.  The way to fix
this is by replacing the following code:

if(status == 0){
        servPort = getservbyport(htons(remotePort),"tcp");
        printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);
        ++open_ports;

Quote:}

with:

if(status == 0){
   if((servPort = getservbyport(htons(remotePort),"tcp")) != NULL){
        printf("TCP connection: [port %d][%s]\n", remotePort,servPort->s_name);
   } else {
        printf("TCP connection: [port %d][UNKNOWN]\n", remotePort);
   }
   ++open_ports;

Quote:}

Instead of coredumping, it now prints UNKNOWN as the service if it
getservbyport returns a NULL pointer.


> The bug is at line:
>  printf("TCP connection: [port %d][%s]\n", remotePort, servPort->s_name);

> The core dump must be due to the servPort ->s_name

> The way i was going to approch this was to open a socket... connect to N
> where N is 0 to 1024 ( or what ever ). Read from the socket using recv()
> and then printf() the port number and what it read from that socket.

The only problem is some services don't print anything once they've opened
without some sort of input from the remote host (i.e. http).

Quote:> PS your port scanner says that there is a port available on a certain server.
> if i "telnet" to this server at that port it says:

> Trying zzz.bbb.ccc.ddd
> telnet: Unable to connect to remote host: Connection refused

> Even though that port has a service attached to it.

Very odd behaviour.  I've not been able to reproduce that one yet.

Quote:> What bout if i just try to connect to a port and then just to a read from it to see
> what the port says. ( will it give me what the port actually does?? ) for example If i just
> connect to a port and do a read will it send back [ ssh ] or [ ftp ]  or [ telnet ] ... etc.??

I was getting the service name (referenced by the pointer
servPort->s_name) by performing a getservbyport once a tcp connection was
successfully established to a port.  You could read from the port and get
some information from it, depending on the service, but as I stated, some
services don't write anything to the port without first getting something
form the remote host.

As the comment in the head of the code says,  there's no guarantee that
it acutally does anything properly.  It was merely supplied as an example
of how to write the code to accomplish what you asked.

Quote:> Dean

--

* Computer Security Consultant and Perl Programmer
Free UNIX advocate - "I hack, therefore I am."
 
 
 

C port scanner

Post by Dean Parson » Tue, 29 Jun 1999 04:00:00


Hello there Joe,

in your scan code i noticed u are using

    socket( PF_INET ................ )
Then i realized it's the same as AF_INET isnt's it?? ::::

#define PF_INET         AF_INET ( found in an include file )

But what is:
IPPROTO_TCP    ??

in writing Socket transport layers for client and servers i use:
socket( AF_INET, SOCK_STREAM, 0 )

Dean



> > There is a bug in your code...
> > it core dumps on scanning some port after 515 for some reason.

> What OS are you compiling it on?  It works fine past ports 515 for me on a
> Slackware Linux 3.4 box running kernel 2.0.36.

> TCP connection: [port 21][ftp]
> TCP connection: [port 22][ssh]
> TCP connection: [port 23][telnet]
> TCP connection: [port 25][smtp]
> TCP connection: [port 37][time]
> TCP connection: [port 80][www]
> TCP connection: [port 110][pop3]
> TCP connection: [port 113][auth]
> TCP connection: [port 543][klogin]
> TCP connection: [port 544][kshell]

> Summary: 10 ports open on localhost

> I got the same results from my OpenBSD 2.5 box and my FreeBSD 2.2.8 box.

> > PS i now know i dont really need the:

> >         (void) memcpy(&serverName.sin_addr,
> >                 hostPtr->h_addr,
> >                 hostPtr->h_length)

> the (void) isn't necessary in front of the memcpy (I think it could be
> handled by the C pre-processor) since it compiles properly without it.
> All the memcpy function is really doing is copying hostPtr->h_length bytes
> from pointer hostPtr->h_addr to the variable serverName.sin_addr.  It's
> possible that this can be handled differently, but it's the way I was
> taught, and I'll be glad to move to another way of doing it if there's a
> better way.

> My C isn't nearly as good as my PERL.

> However, after using nmap, there's no real point to writing your own
> portscanner.  It'd take entirely too long to write one with as many
> features as the one Fyodor has made, and there's no real point in
> re-inventing the wheel when the current one does just about everything
> you'd ever need.

> --

> * Computer Security Consultant and Perl Programmer
> Free UNIX advocate - "I hack, therefore I am."

 
 
 

C port scanner

Post by Joe Sha » Tue, 29 Jun 1999 04:00:00



> Hello there Joe,

> But what is:
> IPPROTO_TCP    ??

netinet/in.h on my linux box includes linux/in.h which defines:

  IPPROTO_IP = 0,               /* Dummy protocol for TCP               */
  IPPROTO_ICMP = 1,             /* Internet Control Message Protocol    */
  IPPROTO_IGMP = 2,             /* Internet Group Management Protocol   */    
  IPPROTO_IPIP = 4,             /* IPIP tunnels                         */
  IPPROTO_TCP = 6,              /* Transmission Control Protocol        */
  IPPROTO_EGP = 8,              /* Exterior Gateway Protocol            */
  IPPROTO_PUP = 12,             /* PUP protocol                         */
  IPPROTO_UDP = 17,             /* User Datagram Protocol               */

Quote:> in writing Socket transport layers for client and servers i use:
> socket( AF_INET, SOCK_STREAM, 0 )

You can use either 0 or 6 and it will work, but I choose to use
IPPROTO_TCP (6) for clarity.

Quote:> Dean

--

* Computer Security Consultant and Perl Programmer
Free UNIX advocate - "I hack, therefore I am."
 
 
 

1. Parallel port scanners

Hi,
Just got a parallel port scanner, badged Boeder artiscan, which turns
out to be a Taramack
rebadged affair, model 9600/600c.

I have been looking for linux drivers. I came accross SANE but this
seems to be only for SCSI
scanners. Are there any parallel port scanner drivers out there?

Any info welcomed.


TIA Ian

--



www.eee.kcl.ac.uk/~ianc          www.geocities.com/ResearchTriangle/Lab/1782/

2. problems with USB Zip drive on Red Hat

3. Throw out my parallel port flatbed scanner?

4. Mach-32, X-windows, VT switching.

5. Parallel Port Scanner: HP3200C

6. Xgui to display who has access to this file

7. Can I use a parallel port scanner with linux?

8. SCSI timeouts

9. Port Scanner for Linux

10. Any interest in MicroTek Labs parallel port/SCSI scanners?

11. USB Port Scanner

12. Microtek ScanMaker E3 Plus Parallel Port Scanner?

13. ocr linux scanner: ocr support for linux scanners?