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

sshscan.c

sshscan.c
Posted Jul 19, 2001
Authored by Spaceork | Site dhp.com

Sshscan.c scans for port 22, grabs server type and version. Uses a list of IPs.

tags | tool, scanner
systems | unix
SHA-256 | 7eb790e4b309675487eb6113534ae3090026d8b6fb4f55a2279b59d861b627ef

sshscan.c

Change Mirror Download
/* sshscan.c - scans port 22 for server type and version  */
/* */
/* compile: host:~$ gcc sshscan.c -o sshscan */
/* usage: host:~$ ./sshscan infile > outfile */
/* */
/* based on wscan.c */
/* CHANGES: */
/* -aesthetics */
/* -modified serv function */
/* */
/* 2.18.01 spaceork@dhp.com */


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

#define ERROR -1

int sock;
char buffer[1024];
void usage(char *s);
void scan(char *i);

int serv(char *host);
unsigned long int res(char *p);

void usage(char *s)
{
printf("Usage: %s <inputfile>\n", s);
exit(ERROR);
}

int main(int argc, char **argv)
{
printf("sshscan - a ssh server information grabber, by spaceork@dhp.com\n");

if (argc != 2)
usage(argv[0]);

printf("\n-Getting version information-\n\n");
scan(argv[1]);
}

void scan(char *i)
{
FILE *iff;
char buf[512];

if((iff = fopen(i, "r")) == NULL)
return;

while(fgets(buf, 512, iff) != NULL)
{
buf[strlen(buf) - 1] = 0;
serv(buf);
}

fclose(iff);
}

int serv(char *host)
{
struct sockaddr_in target;

target.sin_addr.s_addr = res(host);
target.sin_family = AF_INET;
target.sin_port = htons(22);

sock=socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
printf("error in creating socket\n");
exit(-1);
}

if (!connect(sock, (struct sockaddr *) &target, sizeof(target)))
{
recv(sock, buffer, sizeof(buffer), 0);
printf("Host %s\n", host);
printf("Version:\n%s\n", buffer);
}

else
printf("could not connect to %s port 22\n\n", host);

close(sock);
}

/* generic DNS resolving function */
unsigned long int res(char *p)
{
struct hostent *h;
unsigned long int rv;

h=gethostbyname(p);
if(h!=NULL)
memcpy(&rv, h->h_addr, h->h_length);

else
rv=inet_addr(p);

return rv;
}

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