what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Ports.c

Ports.c
Posted Mar 3, 2000
Authored by Zinc_Sh | Site maxlepi.zap.to

Handy TCP Portscanner - Simple TCP port scanner. Allows you to choose the range of ports to scan. Tested on slackware.

tags | tool, scanner, tcp
systems | linux, unix, slackware
SHA-256 | 64c7b432035c2ef565c2552db3897e0f915216db92b7a6ca14e90c15f11d117d

Ports.c

Change Mirror Download
/*

Handy TCP Portscanner 08/03/00
By ZinC_Sh(C)


COMPILE: gcc -Wall ports.c -o ports

RUN IT:
1) Usage: 'ports 10.0.0.200 - -' : will scan the remote-host from 1->1024 port
2) Usage: 'ports 10.0.0.200 20 30' : will scan the rempte-host from 20->30 port

DESCRIPTION: Handy TCP Portscanner.-

MADE ON: SlackWare.-

E-MAIL: zinc_sh@hotmail.com
WEB: http://maxlepi.zap.to

May The Poula Kapribekou Be With You...

*/

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

#define DEF_STR_PORT 1
#define DEF_STP_PORT 1024
#define OXO 1

struct sockaddr_in addr;
struct hostent *rh;
struct servent *rp;

int sock,i;
int str_ptr, stp_ptr;
int Usage(char *ARG);
int CONNECTION(int port);

int main(int argc, char *argv[])
{

if (argc != 4)
Usage(argv[0]);

str_ptr = atoi(argv[2]);
stp_ptr = atoi(argv[3]);
if (strcmp(argv[2],"-")==0 && strcmp(argv[3],"-")==0){
str_ptr = DEF_STR_PORT;
stp_ptr = DEF_STP_PORT;
}

if ( str_ptr > stp_ptr){
fprintf(stderr,"DetecT ErroR !!! On PortS, <Star-Port> Can't Be Greater Than <Stop-Port>.-\n");
Usage(argv[0]);
exit(OXO);
}

if ((rh=gethostbyname(argv[1])) == NULL){
fprintf(stderr,"Can't Resolve Host %s .-\n",argv[1]);
Usage(argv[0]);
exit(OXO);
}

printf("ScanninG Host %s From %d TcP Port To %d .-\n",argv[1],str_ptr,stp_ptr);
for (i=str_ptr; i <= stp_ptr; i++)
{
if (CONNECTION(i)==0)
{
rp=getservbyport(htons(i),"tcp");
printf("Port %d Is Open !!! <%s> ServicE.-\n",i,(rp == NULL)?"UknowN":rp->s_name);
}
close(sock);
}

return 0;
}

int CONNECTION(int port)
{

if ((sock=socket(AF_INET,SOCK_STREAM,0)) == -1){
perror("SockeT");
exit(OXO);
}

addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr = *((struct in_addr *)rh->h_addr);

if ((connect(sock,(struct sockaddr *) &addr, sizeof(addr))) == 0)
return 0;
else
return 1;
}

int Usage(char *ARG)
{
fprintf(stderr,"TCPPortS.c By ZinC_Sh(C).-\n");
fprintf(stderr,"Usage: %s <Remote-Host> <Start-Port> <Stop-Port>.-\n",ARG);
exit(OXO);
}
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close