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

identscan.c

identscan.c
Posted Apr 11, 2000
Authored by john bloogg spam

identscan.c is a port scanner with identd lookup, to find the UID that each remote service is running under.

tags | tool, remote, scanner
systems | unix
SHA-256 | 5a5939479da9aeb9dba6f180b8420fbce981b280585ed177d171d87030487ebf

identscan.c

Change Mirror Download

/* This is my IDENTD port scanner, it requires the
host to be running identd, it looks up the UID of each
open port, it also works very fast too :-), if you
would like to get in contact with me, please drop into
irc.pulltheplug.com #linhelp my linux help channel,
very new and sponored by slashdot, or email em at
mike11785_cool@yahoo.com thankyou */

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>

enum errlist
{
BAD_ARGS,BAD_HOST,NO_IDENT,SOCK_ERR
};

void
usage(error)
enum errlist error;
{
fprintf(stderr,"Scanner: ");
switch(error)
{

case BAD_ARGS: fprintf(stderr,"usage: (hostname)
(low port-1) (hi port-9999)\n"); break;
case BAD_HOST: fprintf(stderr,"error: cant resolve
hostname\n");
break;
case NO_IDENT: fprintf(stderr,"error: ident isnt
running on host\n");
break;
case SOCK_ERR: fprintf(stderr,"error: socket()
failed\n");
break;
}
exit(-1);
}

struct hostent *
fill_host(machine,host)
char *machine;
struct hostent *host;
{

if ((host=gethostbyname(machine))==NULL)
{
if
((host=gethostbyaddr(machine,4,AF_INET))==NULL)
return(host);
}
return(host);
}

int
main(argc,argv)
int argc;
char **argv;
{
struct sockaddr_in forconnect,forport,forident;
int
i,sockfd,identfd,len=sizeof(forport),hiport=9999,loport=1,curport;
struct servent *service;
struct hostent *host;
char identbuf[15], recieved[85], *uid;

if ((argc<2) || (argc>4))
usage(BAD_ARGS);
if (argc>2)
loport=atoi(argv[2]);
if (argc>3)
hiport=atoi(argv[3]);
if ((host=fill_host(argv[1],host))==NULL)
usage(BAD_HOST);
forconnect.sin_family=host->h_addrtype;
forconnect.sin_addr.s_addr=*((long *)host->h_addr);
forident.sin_family=host->h_addrtype;
forident.sin_addr.s_addr=*((long *)host->h_addr);
forident.sin_port=htons(113);

if ((identfd=socket(AF_INET,SOCK_STREAM,0))== -1)
usage(SOCK_ERR);
if ((connect(identfd,(struct sockaddr
*)&forident,sizeof(forident)))!=0)
usage(NO_IDENT);
close(identfd);

for(curport=loport;curport<=hiport;curport++)
{
for(i=0;i!=85;i++)
recieved[i]='\0';
forconnect.sin_port=htons(curport);
if ((sockfd=socket(AF_INET,SOCK_STREAM,0))== -1)
usage(SOCK_ERR);

if (connect(sockfd,(struct sockaddr
*)&forconnect,sizeof(forconnect))==0)
{
if (getsockname(sockfd,(struct sockaddr
*)&forport,&len)==0)
{
if
((identfd=socket(AF_INET,SOCK_STREAM,0))== -1)
usage(SOCK_ERR);
if (connect(identfd,(struct sockaddr
*)&forident,sizeof(forident))==0)
{

sprintf(identbuf,"%u,%u",htons(forconnect.sin_port),
htons(forport.sin_port));


write(identfd,identbuf,strlen(identbuf)+1);
read(identfd,recieved,80);
recieved[strlen(recieved)-1]='\0';
uid=strrchr(recieved,' ');

service=getservbyport(forconnect.sin_port,"tcp");
printf("Port: %3d\tService: %10s\tUserid:
%s\n",curport,

(service==NULL)?"(?)":service->s_name,uid);
}
}
}
close(sockfd);
close(identfd);
}
}



*** END OF CODE ***

Thanks alot to everyone at packetstorm, and by the
way, your site is AMAZING!!

well good bye
-- Sultrix

http://sultrix.sekure.de
mike11785_cool@yahoo.com
irc.pulltheplug.com #wargames #linhelp

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
Login or Register to add favorites

File Archive:

May 2024

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