my tiny scanner
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: my tiny scanner

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    26

    Smile my tiny scanner

    hi whats up ??
    before 2 days ago i was so board so i started to write a port scanner her it is :
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <netinet/in.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <errno.h>
    #include <string.h>
    #include <netdb.h>
    #include <sys/types.h>
    #include <sys/socket.h>
        
        int main(int argc, char *argv[])
        {
            int sockfd, port;
            struct hostent *host;
            
            printf("welcome to Fast-scanner 1.4 \n");
            
    	if (argc != 2) {
                fprintf(stderr,"ip or hostname\n");
                exit(1);
            }
    
            if ((host=gethostbyname(argv[1])) == NULL) { 
                perror("gproblem finding victim :(");
                exit(1);
            }
    	for(port=0; port<=65000; port++)
    	{
    	struct sockaddr_in host_addr; 
            if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
                perror("problem in socket");
                exit(1);
            }
    
            host_addr.sin_family = AF_INET;   
            host_addr.sin_port = htons(port);  
            host_addr.sin_addr = *((struct in_addr *)host->h_addr);
            memset(&(host_addr.sin_zero), '\0', 8);  
    
            if (connect(sockfd, (struct sockaddr *)&host_addr, sizeof(struct sockaddr)) == -1) {
                //printf(".");
    	    close(sockfd);
            }
    	else { 
    	printf("*****this port %i is open*****\n", port);
    	close(sockfd);
    	}
    	}
            printf("for more info on port numbers :http://www.iana.org/assignments/port-numbers\n"); 	
    	printf("Mr-Unix Tm Mr.uN1x.sec@gmail.com \n");
    	}
    tell me what you think about my scanner and what to improve
    tnx

  2. #2
    There is nothing to say much about your scanner. It is a simple, common port scanner. Actualy all port scanners are the same. But it is an idea, you can start adding stuff and features and it will probably become a famous security scanner.

    Good luck in your projects!
    The access to the computer or
    anything else that shows us how the
    world works must be total and
    unlimited.

  3. #3
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    The forum inserted a smiley into your code, but it compiles and runs.


    Scan a nonexistant host and it hangs.


    Code:
    rcgreen@blue:~/prog/c$ ./ascan 192.168.1.3
    welcome to Fast-scanner 1.4
    Tcpdump shows that it was making an arp request.

    Code:
    12:56:44.445160 arp who-has genius.localdomain tell blue.localdomain
    12:56:45.445160 arp who-has genius.localdomain tell blue.localdomain
    12:56:46.445229 arp who-has genius.localdomain tell blue.localdomain
    12:56:47.445160 arp who-has genius.localdomain tell blue.localdomain
    12:56:48.445160 arp who-has genius.localdomain tell blue.localdomain
    12:56:49.445185 arp who-has genius.localdomain tell blue.localdomain
    12:56:50.445160 arp who-has genius.localdomain tell blue.localdomain
    12:56:51.445160 arp who-has genius.localdomain tell blue.localdomain
    12:56:52.445181 arp who-has genius.localdomain tell blue.localdomain
    I came in to the world with nothing. I still have most of it.

  4. #4
    Ofcourse it is doing an arp request, you are in a network and scanning the internal network IP adress.
    The access to the computer or
    anything else that shows us how the
    world works must be total and
    unlimited.

  5. #5
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    Ofcourse it is doing an arp request
    I mean, that, because the host was down, the program hangs.
    It needs to time out and exit with an error message,
    to be more polished.
    I came in to the world with nothing. I still have most of it.

  6. #6
    Junior Member
    Join Date
    Feb 2006
    Posts
    26
    tnx on your replys i will fix the scanner and upload the scanner again

    tnx

  7. #7
    Senior Member gore's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    7,177
    http://www.antionline.com/showthread...hreadid=268776

    This one only does TCP, but it's a start as well.

    The lisence is open, I found it on a Perl web site and started changing a few things to help me learn Perl.

  8. #8
    Senior Member
    Join Date
    Nov 2001
    Posts
    4,786
    this is what we need more of, new users that are willing to give instead of just taking with lame-ass questions. not that we dont all learn from question but...ahh you know what i mean.

    thanks mr-unix! stick around.
    Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”

  9. #9
    The Prancing Pirate
    Join Date
    Jul 2004
    Posts
    548
    Thanks mr-unix for that! Admittedly, I'll be sticking to nmap for quite a while - but I hope you keep this project going! Instead of reinventing the wheel though, maybe you could incorporte what you've already written into a different, more unique app. That'd be cool.

    Cheers,

    -jk
    TAZForum <---- click

  10. #10
    Junior Member
    Join Date
    Feb 2006
    Posts
    26
    dont worry i will stick around.

    tnx for your love ppl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •