exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

ports2.c

ports2.c
Posted Apr 20, 2000
Authored by Dorian Goldman

Port scanner with a nice interface. Prompts for banner.

tags | tool, scanner
systems | unix
SHA-256 | 8bd800104043b93ad61675985333a24b5e4beecff4a27488c42726047481d2a1

ports2.c

Change Mirror Download
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <fcntl.h>
#include <sys/file.h>
void checkport(char *host);
#define MAXPORT 1024
#define STARTPORT 1
#define COLOR "\E[32m"
#define WHITE "\E[m"
#define COLORS "\E[33m"
#define RED "\E[31m"
main(int argc, char *argv[])
{
int sockfd, port;
struct sockaddr_in sin;
struct hostent *h;
struct servent *s;
int x, y;
int secport;
char b[100];
char buffer[100];
struct sockaddr_in sins;
int socks;
if(argc < 2) {
fprintf(stderr, COLORS " [pHelon's Internet Port Scanner]\n");
fprintf(stderr, WHITE " phelon@antionline.org \n\n");
fprintf(stderr, "usage: %s [-help] <hostname> [start-port] [max-port]\n", argv[0]);
exit(1);
}
if(strcmp(argv[1], "-help") == 0) {
printf(COLOR "\n ____________-=HELP SCREEN=-_____________\n\n");

printf(RED "Argument Description\n");
printf(WHITE "-----------------------------------------------\n");

printf("Hostname The hostname is the address of\n");
printf(" the computer that you want to \n");
printf(" scan the ports on. It can be a\n");
printf(" numerical address (IP) in the \n");
printf(" form of 127.0.0.1. Or it can be\n");
printf(" in the form of a hostname, such \n");
printf(" as samba.berkeley.edu. Port scanning\n");
printf(" is not illegal but you could get\n");
printf(" kicked off of your ISP.\n");
printf("\n");
printf("Start/End Port Computers have things called ports.\n");
printf(" These ports could have possible vulnerabilites\n");
printf(" that can possibly be exploited. So, try to\n");
printf(" scan as high as you can, I think its 650000 or\n");
printf(" something. By default, the ports are 1 to 1024\n");
printf("\n");
printf("Help This help screen\n");
printf("\n");
exit(0);
}
if((h = gethostbyname(argv[1])) == NULL) {
herror(argv[1]);
exit(1);
}
if(argc > 2)
x = atoi(argv[2]);
else
x = STARTPORT;
if(argc > 3)
y = atoi(argv[3]);
else
y = MAXPORT;
printf(COLOR "Open Ports for %s:\n\n", argv[1]);
printf(WHITE "Scanning...\n");
sin.sin_family = AF_INET;
sin.sin_addr = *((struct in_addr *)h->h_addr);
printf(COLORS "Port Protocol Service\n");
printf(WHITE "------------------------------------------------------------\n");
for(port = x; port <= y; port++) {
sockfd = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_port = htons(port);
s = getservbyport(htons(port), "tcp");

if(connect(sockfd, (struct sockaddr *)&sin, sizeof(sin)) == 0)



printf("%i %s %s\n", port, (s == NULL) ? "NULL" : s->s_proto, (s == NULL) ? "UNKNOWN" : s->s_name);
if(port == 7000 || port == 31337 || port == 30464 || port == 12345) {
printf(COLOR "\t*** Port: %d is most likeley a Trojan Horse ***", port);
printf(WHITE ".\n");

}
close(sockfd);
}

close(sockfd);
printf("-------------------------------------------------------------\n");
checkport(argv[1]);
close(sockfd);

return 0;
}
void checkport(char *host) {
char buffers[100];
char bufsalot[100];
int portsalot;
int sock;
struct sockaddr_in newsin;
struct hostent *hostent;

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

if((hostent = gethostbyname(host)) == NULL) {
herror(host);
exit(1);
}

printf("Would you like further information? ");
scanf("%s", &buffers);
if(strstr(buffers, "y")) {
printf("Which port? ");
scanf("%d", &portsalot);


newsin.sin_family = AF_INET;
newsin.sin_addr = *((struct in_addr *)hostent->h_addr);
newsin.sin_port = htons(portsalot);

if(connect(sock, (struct sockaddr *)&newsin, sizeof(newsin)) == 0) {
while(read(sock, bufsalot, sizeof(bufsalot)) > 0) {
printf(COLOR "%s\n", bufsalot);
printf(WHITE "[Check bugtraq to see if daemon is vulnerable at http://www.securityfocus.com]\n");
exit(0);
}
exit(0);
} else {
printf("Connection Failed\n");
exit(0);
}
}
}
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    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