Copy Link
Add to Bookmark
Report

The Death Knights port scanner 2.0

Death Knights Issue 5

eZine's profile picture
Published in 
Death Knights
 · 18 Oct 2022

by Cacaio

No zine deathknights02, apresentei a primeira versao deste port scanner feito por mim. Agora, depois de muitas pequenas versoes anteriores, apresento a versao 2.0.

O que tem de novo:

  • Problemas de compilacao com linux Red Hat e unixes resolvidos
  • Ele esta' mais rapido
  • Problemas de alguns ANSI's corrigidos
  • Se aparecer algum 'UNKNOWN' em alguma porta e voce souber do que e' esta porta, basta adiciona-la a seu /etc/services que na proxima vez o port scanner a reconhecera'.
  • Mudancas simples na estrutura

Mas para que serve um port scanner? O nome ja diz...


Port = Porta
Scanner = Localizador

Logo, ele procura por portas. Como as portas fechadas nao podem ser detectadas (ohhhh!!!), logo ele procura por portas abertas. Isto e' util para voce ver quais as portas estao abertas em algum sistema, e fehca-las se nao estiver usando *ou* pode ser usado com outros fins por usuarios mal intencionados.

O port scanner (deathscan.c) esta anexado a esta zine. Faca bom proveito :)


cya nex time

Cacaio               Cacaio@DeathKnights.com 
`'`'`' `'`'`'`'`'`'`'`'`'`'`'`


deathscan.c

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

#define MAX_PORT 1024

int s;
struct sockaddr_in addr;
char rmt_host[100];

int skan(port)
int port;
{
int r;
s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s < 0) {
printf("ERROR: socket() failed\n");
exit(0);
}
addr.sin_family = PF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(rmt_host);
r = connect(s,(struct sockaddr *) &addr, sizeof(addr));
close(s);
if (r==-1) {
return (1 == 0);
}
return (1 == 1);
}

main(argc,argv)
int argc;
char *argv[];
{
int a,b,c,d,e,f;
struct hostent *foo;
struct servent *death;
if (argc < 2) {
fprintf(stderr,"\nusage: %s <host> [highest port]\n\n",argv[0]);
fprintf(stderr, "The Death Knights Port Scanner 2.0 by Cacaio!\n");
fprintf(stderr, "http://www.deatknights.com Cacaio@deathknights.com\n\n");
exit(0);
}
if (sscanf(argv[1],"%d.%d.%d.%d",&a,&b,&c,&d) != 4) {
foo = gethostbyname(argv[1]);
if (foo == NULL) {
fprintf(stderr,"\nerror: cannot resolve host %s.\n\n",argv[1]);
fprintf(stderr, "The Death Knights Port Scanner 2.0 by Cacaio!\n");
fprintf(stderr, "http://www.deatknights.com Cacaio@deathknights.com\n\n");
exit(0);
}
sprintf(rmt_host,"%d.%d.%d.%d",(unsigned char )foo->h_addr_list[0][0],
(unsigned char ) foo->h_addr_list[0][1],
(unsigned char ) foo->h_addr_list[0][2],
(unsigned char ) foo->h_addr_list[0][3]);
} else {
strncpy(rmt_host,argv[1],99);
}
if (argc > 2) {
f = atoi(argv[2]);
} else
f = MAX_PORT;
fprintf(stdout,"\nScanning host %s - TCP ports 1 through %d\n\n",rmt_host,f);
fprintf(stdout, "The Death Knights Port Scanner 2.0 by Cacaio!\n");
fprintf(stdout, "http://www.deatknights.com Cacaio@deathknights.com\n\n");
fprintf(stdout, "If appears an UNKNOWN in any port, that is because that port is not listed\n");
fprintf(stdout, "in your /etc/services.\n\n");
for (e =1;e<=f;e++) {
char serv[100];
if (skan(e)) {
death = getservbyport(htons(e),"tcp");
printf("%d (%s) is running.\n",e,(death == NULL) ? "UNKNOWN" :
death->s_name);
}
}
}

← previous
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT