libft submoduel gone
This commit is contained in:
parent
c9be993efd
commit
b18fc7924e
8 changed files with 83 additions and 51 deletions
3
nmap/.gitmodules
vendored
3
nmap/.gitmodules
vendored
|
|
@ -1,3 +0,0 @@
|
|||
[submodule "libft"]
|
||||
path = libft
|
||||
url = https://github.com/jzck/libft
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||
# Updated: 2017/04/22 19:26:34 by jhalford ### ########.fr #
|
||||
# Updated: 2017/10/08 19:09:21 by jhalford ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -48,7 +48,9 @@ all :
|
|||
$(NAME): $(LIBFT_LIB) $(OBJ_DIR) $(OBJS) $(CLIENT_OBJ)
|
||||
@$(CC) $(OBJS) -o $@ \
|
||||
-I $(INC_DIR) \
|
||||
-I $(HOME)/.bin/include \
|
||||
-I $(LIBFT_INC) \
|
||||
-L $(HOME)/.bin/lib \
|
||||
$(LIBFT_LIB) $(CLIENT_OBJ) $(FLAGS) \
|
||||
-lm -lpcap -lpthread /usr/local/lib/libdill.a
|
||||
@printf "\r\033[38;5;117m✓ MAKE $@ \033[0m\033[K\n"
|
||||
|
|
@ -67,6 +69,7 @@ $(OBJ_DIR)%.o : $(SRC_DIR)%.c | $(OBJ_DIR)
|
|||
@printf "\r\033[38;5;%dm⌛ [%s]: %2d%% `printf '█%.0s' {0..$(DONE)}`%*s❙%*.*s\033[0m\033[K" $(COLOR) $(NAME) $(PERCENT) $(TO_DO) "" $(DELTA) $(DELTA) "$(shell echo "$@" | sed 's/^.*\///')"
|
||||
@$(CC) $(FLAGS) $(OBJ_FLAG) -MMD -c $< -o $@\
|
||||
-I $(INC_DIR) \
|
||||
-I $(HOME)/.bin/include \
|
||||
-I $(LIBFT_INC)
|
||||
@$(eval INDEX=$(shell echo $$(($(INDEX)+1))))
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/04/22 14:10:24 by jhalford #+# #+# */
|
||||
/* Updated: 2017/04/22 15:52:07 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/10/08 21:27:51 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
# include <pthread.h>
|
||||
# include <ifaddrs.h>
|
||||
|
||||
# include <libdill.h>
|
||||
# include "libdill.h"
|
||||
|
||||
# define SCAN_TCP (1 << 0)
|
||||
# define SCAN_SYN (1 << 1)
|
||||
|
|
@ -51,21 +51,13 @@ struct s_data
|
|||
t_flag flag;
|
||||
char **av_data;
|
||||
t_list *host;
|
||||
struct sockaddr source_addr;
|
||||
int ports[USHRT_MAX + 1];
|
||||
|
||||
int sock_tcp;
|
||||
int threads;
|
||||
int scan;
|
||||
};
|
||||
|
||||
/* enum e_scan_type */
|
||||
/* { */
|
||||
/* SCAN_SYN, */
|
||||
/* SCAN_NULL, */
|
||||
/* SCAN_ACK, */
|
||||
/* SCAN_FIN, */
|
||||
/* SCAN_XMAS, */
|
||||
/* SCAN_UDP, */
|
||||
/* }; */
|
||||
struct
|
||||
|
||||
enum e_port_status
|
||||
{
|
||||
|
|
@ -81,15 +73,17 @@ struct s_host
|
|||
char *host; // user input host (ip or dn)
|
||||
char *dn; // ai_canonname
|
||||
char ip[INET6_ADDRSTRLEN]; // readable ip address (4 or 6)
|
||||
int sock_tcp;
|
||||
int sock_udp;
|
||||
int sock_icmp;
|
||||
t_port_status results[USHRT_MAX + 1];
|
||||
int channels[USHRT_MAX + 1];
|
||||
struct s_target ports[USHRT_MAX + 1];
|
||||
struct sockaddr *addr;
|
||||
size_t addrlen;
|
||||
};
|
||||
|
||||
struct s_target
|
||||
{
|
||||
int in_channel;
|
||||
t_port_status results[SCAN_MAX];
|
||||
};
|
||||
|
||||
struct s_tcp_packet
|
||||
{
|
||||
struct iphdr iph;
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 8c0961c50468d42c3527c208d7f4ae3c98646882
|
||||
|
|
@ -8,11 +8,11 @@ static void packet_callback(u_char *arg, const struct pcap_pkthdr *pkthdr, const
|
|||
(void)pkthdr;
|
||||
(void)packet;
|
||||
t_data *data = (t_data*)arg;
|
||||
printf("received packet !!!\n");
|
||||
ft_printf("received packet !!!\n");
|
||||
hexdump(&packet, sizeof(packet));
|
||||
}
|
||||
|
||||
coroutine void nmap_listener(void *arg)
|
||||
coroutine void nmap_listener(t_data *data)
|
||||
{
|
||||
t_data *data;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
|
@ -44,11 +44,10 @@ coroutine void nmap_listener(void *arg)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* signal(SIGALRM, sigalrm_handler); */
|
||||
printf("listener loop\n");
|
||||
fflush(stdout);
|
||||
ft_printf("listener loop\n");
|
||||
if (pcap_loop(pcap_obj, -1, packet_callback, (u_char*)data) == -1)
|
||||
{
|
||||
printf("pcap_loop fail\n");
|
||||
ft_printf("pcap_loop fail\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
free(str);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/08 19:10:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/08 21:27:57 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "nmap.h"
|
||||
|
||||
#define NMAP_USAGE1 " [--ip HOST] [--file FILE]"
|
||||
|
|
@ -20,15 +32,19 @@ int main(int ac, char **av)
|
|||
printf("or nmap"NMAP_USAGE1 NMAP_USAGE2"\n");
|
||||
exit(1);
|
||||
}
|
||||
if (reserve_port(&data.src_port))
|
||||
|
||||
// single tcp port
|
||||
struct sockaddr_in sa;
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr.s_addr = INADDR_ANY;
|
||||
if (reserve_port(data.sock_tcp, &sa))
|
||||
{
|
||||
fprintf(stderr, "couldn't reserve port\n");
|
||||
exit(1);
|
||||
}
|
||||
int port_chan = chmake(sizeof(int));
|
||||
|
||||
go(nmap_listener(&data));
|
||||
/* go(nmap_ports(&data, port_chan)); */
|
||||
/* go(nmap_collector(&data)); */
|
||||
int chan = nmap(&data);
|
||||
nmap_collector(chan, &data);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* nmap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/08 19:10:07 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/08 21:27:50 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "nmap.h"
|
||||
|
||||
unsigned short cksum(void *b, int len)
|
||||
|
|
@ -36,7 +48,8 @@ coroutine void nmap_scan_node(t_host *host, struct iphdr *iph, int port)
|
|||
return (1);
|
||||
|
||||
|
||||
if (sendto(host->sock_tcp, &packet, sizeof(packet), 0, host->addr, host->addrlen) < 0)
|
||||
if (sendto(data->sock_tcp, &packet, sizeof(packet), 0,
|
||||
host->addr, host->addrlen) < 0)
|
||||
{
|
||||
perror("sendto");
|
||||
exit(1);
|
||||
|
|
@ -57,8 +70,7 @@ void nmap(t_data *data)
|
|||
iph.daddr = *(uint32_t*)&((struct sockaddr_in*)host->addr)->sin_addr;
|
||||
iph.saddr = *(uint32_t*)&((struct sockaddr_in*)&data->source_addr)->sin_addr;
|
||||
iph.tot_len = htons(sizeof(t_tcp_packet));
|
||||
|
||||
int fan_in = chmake();
|
||||
int fan_in = chmake(sizeof());
|
||||
for (t_list *list = data->host; list != NULL; list = list->next)
|
||||
{
|
||||
t_host *host = list->content;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parser.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/08 19:10:05 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/08 21:05:14 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "nmap.h"
|
||||
|
||||
static t_cliopts g_opts[] =
|
||||
|
|
|
|||
Loading…
Reference in a new issue