day
This commit is contained in:
parent
a75160775a
commit
c9be993efd
4 changed files with 13 additions and 9 deletions
|
|
@ -54,7 +54,6 @@ struct s_data
|
|||
struct sockaddr source_addr;
|
||||
int ports[USHRT_MAX + 1];
|
||||
int threads;
|
||||
int src_port;
|
||||
int scan;
|
||||
};
|
||||
|
||||
|
|
@ -79,7 +78,7 @@ enum e_port_status
|
|||
|
||||
struct s_host
|
||||
{
|
||||
char *node; // user inputed node (ip or dn)
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ int main(int ac, char **av)
|
|||
}
|
||||
int port_chan = chmake(sizeof(int));
|
||||
go(nmap_listener(&data));
|
||||
go(nmap_ports(&data, port_chan));
|
||||
/* go(nmap_ports(&data, port_chan)); */
|
||||
/* go(nmap_collector(&data)); */
|
||||
nmap(&data);
|
||||
int chan = nmap(&data);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ unsigned short cksum(void *b, int len)
|
|||
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;
|
||||
t_tcp_packet packet;
|
||||
|
||||
channel = data.channels[port];
|
||||
channel = host.channels[port];
|
||||
|
||||
packet.iph = *iph;
|
||||
tcphdr_init(&packet.tcph);
|
||||
packet.tcph.dest = htons(port);
|
||||
packet.tcph.source = htons(data->src_port);
|
||||
packet.tcph.source = ;
|
||||
/* packet.tcph.syn = 1; */
|
||||
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.tot_len = htons(sizeof(t_tcp_packet));
|
||||
|
||||
int fan_in = chmake();
|
||||
for (t_list *list = data->host; list != NULL; list = list->next)
|
||||
{
|
||||
t_host *host = list->content;
|
||||
|
|
@ -65,7 +66,11 @@ void nmap(t_data *data)
|
|||
for (port = 1; port < USHRT_MAX; 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ static int nmap_get_host(char *node, t_data *data)
|
|||
}
|
||||
host.addr = servinfo->ai_addr;
|
||||
host.addrlen = servinfo->ai_addrlen;
|
||||
host.node = node;
|
||||
host.host = node;
|
||||
host.dn = servinfo->ai_canonname;
|
||||
|
||||
void *addr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue