-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.c
48 lines (43 loc) · 1.3 KB
/
scan.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
# Desenvolvido por Adriel Freud!
# Contato: usuariocargo2016@gmail.com
# FB: http://www.facebook.com/xrn401
# =>DebutySecTeamSecurity<=
*/
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <time.h>
#define inithread() time_t rawtime; struct tm * timeinfo;time(&rawtime);timeinfo=localtime(&rawtime); printf("\t%s\n", asctime(timeinfo));
void fatal(char *mnsg){fprintf(stderr, "[WARNING] - %s", mnsg);exit(EXIT_FAILURE);}
int main(int argc, char *argv[]){
int meusocket;
int conecta;
int port;
int inicio = 0;
int final = 1024;
char *destino = argv[1];
struct sockaddr_in alvo;
if (argc < 2){
fatal("\n\t=> AdrielFreud <=\n\nUSAGE: root@localhost~# ./scan IP // 192.168.0.100\n");
}else{
fatal("Init THREADING on:");
inithread();
for(port=inicio; port < final; port++){
meusocket = socket(AF_INET, SOCK_STREAM, 0);
alvo.sin_family = AF_INET;
alvo.sin_port = htons(port);
alvo.sin_addr.s_addr = inet_addr(destino);
conecta = connect(meusocket, (struct sockaddr *)&alvo, sizeof alvo);
if(conecta == 0){
printf("[!] Porta %d - Status [ABERTA]\n",port);
close(meusocket);
close(conecta);
}else{
close(meusocket);
close(conecta);
}
}
}
return EXIT_SUCCESS;
}