This commit is contained in:
Jack Halford 2017-09-27 19:34:04 +02:00
parent a75160775a
commit c9be993efd
4 changed files with 13 additions and 9 deletions

View file

@ -54,7 +54,6 @@ struct s_data
struct sockaddr source_addr; struct sockaddr source_addr;
int ports[USHRT_MAX + 1]; int ports[USHRT_MAX + 1];
int threads; int threads;
int src_port;
int scan; int scan;
}; };
@ -79,7 +78,7 @@ enum e_port_status
struct s_host struct s_host
{ {
char *node; // user inputed node (ip or dn) char *host; // user input host (ip or dn)
char *dn; // ai_canonname char *dn; // ai_canonname
char ip[INET6_ADDRSTRLEN]; // readable ip address (4 or 6) char ip[INET6_ADDRSTRLEN]; // readable ip address (4 or 6)
int sock_tcp; int sock_tcp;

View file

@ -27,8 +27,8 @@ int main(int ac, char **av)
} }
int port_chan = chmake(sizeof(int)); int port_chan = chmake(sizeof(int));
go(nmap_listener(&data)); go(nmap_listener(&data));
go(nmap_ports(&data, port_chan)); /* go(nmap_ports(&data, port_chan)); */
/* go(nmap_collector(&data)); */ /* go(nmap_collector(&data)); */
nmap(&data); int chan = nmap(&data);
return (0); return (0);
} }

View file

@ -14,17 +14,17 @@ unsigned short cksum(void *b, int len)
return (~(sum + (sum >> 16))); return (~(sum + (sum >> 16)));
} }
coroutine void nmap_scan_port(t_data *data, struct iphdr *iph, int port) coroutine void nmap_scan_node(t_host *host, struct iphdr *iph, int port)
{ {
int channel; int channel;
t_tcp_packet packet; t_tcp_packet packet;
channel = data.channels[port]; channel = host.channels[port];
packet.iph = *iph; packet.iph = *iph;
tcphdr_init(&packet.tcph); tcphdr_init(&packet.tcph);
packet.tcph.dest = htons(port); packet.tcph.dest = htons(port);
packet.tcph.source = htons(data->src_port); packet.tcph.source = ;
/* packet.tcph.syn = 1; */ /* packet.tcph.syn = 1; */
packet.tcph.check = cksum(&packet, sizeof(t_tcp_packet)); packet.tcph.check = cksum(&packet, sizeof(t_tcp_packet));
@ -58,6 +58,7 @@ void nmap(t_data *data)
iph.saddr = *(uint32_t*)&((struct sockaddr_in*)&data->source_addr)->sin_addr; iph.saddr = *(uint32_t*)&((struct sockaddr_in*)&data->source_addr)->sin_addr;
iph.tot_len = htons(sizeof(t_tcp_packet)); iph.tot_len = htons(sizeof(t_tcp_packet));
int fan_in = chmake();
for (t_list *list = data->host; list != NULL; list = list->next) for (t_list *list = data->host; list != NULL; list = list->next)
{ {
t_host *host = list->content; t_host *host = list->content;
@ -65,7 +66,11 @@ void nmap(t_data *data)
for (port = 1; port < USHRT_MAX; port++;) for (port = 1; port < USHRT_MAX; port++;)
{ {
if (data.ports[port]) if (data.ports[port])
go(nmap_scan_port(data, iph, port)); {
int fan_in_local = hdup(fan_in);
go(nmap_scan_node(data, iph, port, fan_in_local));
}
} }
} }
return (fan_in);
} }

View file

@ -27,7 +27,7 @@ static int nmap_get_host(char *node, t_data *data)
} }
host.addr = servinfo->ai_addr; host.addr = servinfo->ai_addr;
host.addrlen = servinfo->ai_addrlen; host.addrlen = servinfo->ai_addrlen;
host.node = node; host.host = node;
host.dn = servinfo->ai_canonname; host.dn = servinfo->ai_canonname;
void *addr; void *addr;