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

pscan2.c

pscan2.c
Posted Jul 1, 2000
Authored by Ozone

pscan2.c is a simple tcp port scanner.

tags | tool, scanner, tcp
systems | unix
SHA-256 | b0d7e7fb643bea96a8889be0860892cb5a5daa4d44c3329f0e9a5920ab3a4566

pscan2.c

Change Mirror Download
/*              \                  /
* _________)) ((__________
* /.-------./\\ \ / //\.--------.\
* //#######//##\\ )) (( //##\\########\\
* //#######//###(( (( )) ))###\\########\\
* ((#######((#####\\ \\ // //#####))########))
* \##' `###\######\\ \)(/ //######/####' `##/
* )' ``#)' `##\`->xx<-'/##' `(#'' `(
* ( ``\`..'/'' )
* \""(
* `- )
* pscan v2.0 / / by oz0ne
* ( /\
* /\| \
* ( \
* )
* /
* (
* oz0ne7@hushmail.com
*
*
* pscan is a basic port scanner that prints the number
* of each open port (within specified range) on the target host.
* It can take an ip address or a domain name as its argument.
*
* compile: gcc pscan2.c -o pscan
* usage: ./pscan <ipnumber> | <domainname>
*
* 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
*
*/

#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>
#include <signal.h>

#define START_PORT 1
#define END_PORT 1024

void quit(int);
int usage(char *);

int main(int argc, char *argv[])
{
char *host, **names, **addrs;
struct hostent *hostinfo;
struct sockaddr_in address;
int port, sockfd, len, result;

struct sigaction act;
act.sa_handler = quit;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(SIGINT, &act, 0);

if (argc == 1) {
usage(argv[0]);
exit(EXIT_FAILURE);
}

else { host = argv[1]; }

hostinfo = gethostbyname(host);
if (!hostinfo) {
fprintf(stderr, "Error: cannot get info for host: %s:\n", host);
exit(EXIT_FAILURE);
}

printf("Results for %s\n", host);
printf("Name: %s\n", hostinfo -> h_name);
printf("Aliases:");
while(*names) {
printf("%s ", **names);
names++;
}
printf("\n");

if(hostinfo -> h_addrtype != AF_INET) {
fprintf(stderr, "Error: Not an IP host!\n");
exit(EXIT_FAILURE);
}

addrs = hostinfo -> h_addr_list;
while (*addrs) {
printf(" %s", inet_ntoa(*(struct in_addr *)*addrs));
addrs++;
}

printf("\n");
printf("Scanning ports %d - %d\n", START_PORT, END_PORT);
printf("Open ports:\n");

port = START_PORT;
while ( port <= END_PORT ) {

sockfd = socket(AF_INET, SOCK_STREAM, 0);
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 == -1) { port++; }

else {
printf("%d\n", port);
port++;
}

close(sockfd);
}

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

void quit(int sig) {
printf("Process Interupted!!\n");
printf("Done.\n");
exit(EXIT_FAILURE);
}

int usage(char *name) {
printf("pscan v2.0 by oz0ne (oz0ne7@hushmail.com)\n");
printf("Usage: %s <ipaddress> | <domainname>\n", name);
return(1);
}
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
    16 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