elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  [C] ScanPort
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [C] ScanPort  (Leído 1,644 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[C] ScanPort
« en: 8 Enero 2012, 18:42 pm »

Un simple programa para scannear puertos, solo funciona bajo linux.


Código
  1. /**
  2. * ScanPort 0.1
  3. * Coded by Doddy H
  4. **/
  5.  
  6. #include<stdio.h>
  7. #include<sys/socket.h>
  8. #include<sys/types.h>
  9. #include<stdlib.h>
  10. #include<netdb.h>
  11.  
  12. void head() {
  13.  printf("\n-- == ScanPort 0.1 == --\n");
  14. }
  15.  
  16. void end() {
  17.  printf("\n\nWritten By Doddy H\n\n");
  18. }
  19.  
  20. int main(int argc,char **argv) {
  21.  
  22.  char *ip;
  23.  int port,control,partedos,portstart,portend;
  24.  struct sockaddr_in parteuno;
  25.  
  26.  head();
  27.  if(argc != 4) {
  28.    printf("\n[+] sintax : port <ip> <portstart> <portend>");
  29.  } else {
  30.    ip = argv[1];
  31.    portstart = atoi(argv[2]);
  32.    portend = atoi(argv[3]);
  33.    printf("\n[+] Scanning %s\n",ip);
  34.    printf("\n[+] Parameters : %d-%d\n",portstart,portend);
  35.    for(port=portstart;port<portend;port++) {
  36.      parteuno.sin_family=AF_INET;
  37.      parteuno.sin_port=htons(port);
  38.      parteuno.sin_addr.s_addr=inet_addr(ip);
  39.      partedos=socket(AF_INET,SOCK_STREAM,0);
  40.      control=connect(partedos,(struct sockaddr_in *)&parteuno,sizeof(parteuno));
  41.      if(control>=0) {
  42.        printf("\n[+] Port Found : %d",port);
  43.      }  
  44.    }
  45.  }
  46.  end();
  47.  return 0;
  48. }
  49.  
  50. /** The End ? **/
  51.  
  52.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Perl] ScanPort 0.5
Scripting
BigBear 0 1,531 Último mensaje 3 Diciembre 2011, 16:33 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines