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

pscan3.c

pscan3.c
Posted Jul 13, 2000
Authored by Ozone

Pscan3 is a simple tcp port scanner.

Changes: Compilation fixes for BSD and IRIX, better output format.
tags | tool, scanner, tcp
systems | unix
SHA-256 | 929b9403329467a87e7c37f21463a42f40fb36faddfaeb9419647a607144eab9

pscan3.c

Change Mirror Download
/*              \                  /
** _________)) ((__________
** /.-------./\\ \ / //\.--------.\
** //#######//##\\ )) (( //##\\########\\
** //#######//###(( (( )) ))###\\########\\
** ((#######((#####\\ \\ // //#####))########))
** \##' `###\######\\ \)(/ //######/####' `##/
** )' ``#)' `##\`->xx<-'/##' `(#'' `(
** ( ``\`..'/'' )
** \""(
** `- )
** pscan v3.0 / / by oz0ne
** ( /\
** /\| \
** ( \
** )
** /
** (
** oz0ne7@hushmail.com
**
**
** pscan v3 is a tcp port scanner that prints the number
** of each open tcp port (within specified range) and the
** corresponding service name (if its registered) on the target host.
**
** compile: gcc pscan3.c -o pscan
** usage: ./pscan <target> <start port> <end port>
**
** Warning: scanning unauthorized hosts is illegal.
** I take no responsibility for what you choose to do with this tool.
** This code is free and without warranty
**
** 2000
*/

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

#define MIN_PORT 1
#define MAX_PORT 65535

void usage(char *, char *);

int main(int argc, char *argv[])
{
struct hostent *hostinfo;
struct servent *servinfo;
struct sockaddr_in address;
int port, end_port, sockfd, len, result;
char *host, **ipnum, **ipnum_buf, *service;

if (argc < 4) {
usage(argv[0], "pscan v3 by oz0ne (oz0ne7@hushmail.com)");
exit(EXIT_FAILURE);
}

host = argv[1];
hostinfo = gethostbyname(host);
if (!hostinfo) {
usage(argv[0], "pscan: unable to get info for target host");
exit(EXIT_FAILURE);
}
ipnum = hostinfo -> h_addr_list;
ipnum_buf = hostinfo -> h_addr_list;
len = sizeof(hostinfo);
port = atoi(argv[2]);
end_port = atoi(argv[3]);

printf("\npscan v3 by oz0ne (oz0ne7@hushmail.com)\n");
if (port < MIN_PORT | port > MAX_PORT) {
printf("pscan: invalid start port, using default (%d)\n", MIN_PORT);
port = MIN_PORT;
}
if (end_port < port | end_port > MAX_PORT) {
printf("pscan: invalid end port, using default (%d)\n", MAX_PORT);
end_port = MAX_PORT;
}

printf("\naddress(es): ");
while(*ipnum) {
printf("%s", inet_ntoa(*(struct in_addr *)*ipnum));
ipnum++;
}
printf("\nscanning (%s) tcp ports %d - %d\n",
inet_ntoa(*(struct in_addr*)*ipnum_buf), port, end_port);

printf("open ports:\n\n");

while ( port <= end_port ) {
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
address.sin_family = AF_INET;
address.sin_port = htons(port);
address.sin_addr = *(struct in_addr *)*hostinfo -> h_addr_list;
len = sizeof(address);
result = connect(sockfd, (struct sockaddr *)&address, len);

if (result < 0) { port++; }
else {
servinfo = getservbyport(address.sin_port, "tcp");
if (servinfo == NULL) { service = " "; }
else { service = servinfo -> s_name; }
printf("%d\t%s\n", port, service);
port++;
}
close(sockfd);
}

printf("\nDone.\n");
exit(EXIT_SUCCESS);
}


void usage(char *name, char *text) {
printf("\n%s\n\n", text);
printf("Usage: %s <target> <start port> <end port>\n", name);
printf(" target = ip address or domain name of target host\n");
printf(" start port = first port to scan\n");
printf(" end port = last port to scan\n");
}
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
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 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