Exploit the possiblities

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
MD5 | 20cfda79f08a7d2ebc8be6b97c40b47c

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);
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

November 2017

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2016 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close