Telegram Application detection failed in FORWARD chain of iptables
I want to detect telegram protocol for web and it's application.
I could detect and drop web.telegram. But the telegram application can not detect by ndpi. HTTP_DOWNLOAD is the protocol which is detected by the ndpi.
How is the process of detecting a protocol? first protocol checked by files in /src/lib/protocols OR by entries in ndpi_content_match.c.inc (IP addresses and FQDNs) ?
@kYroL01
why telegram is detect in INPUT chain but in FORWARD chain http_download is detect instead of telegram??
First of all nDPI check IP address and Port range and THEN check eventually dissectors in protocols directory. I tested with your pcap and everything is working correctly. So, did u tried to update and recompile all ?
I close because IMHO now the bug is fixed (as I said above). Reopen if necessary
I think telegram dissector cannot detect telegram flows between the application and server because of the protocol which telegram used for transferring data (MTproto). IMHO the telegram dissector code is not complete.
Ok I'll check asap
Thanx I think the matter is when you detect a protocol based on ip address (for example 149.154.166.120 for telegram) you should not continue the detection process. because of this problem http_download is the protocol which is detected instead of telegram.
well I could solve the problem by this change in ndpi_detection_process_packet function.
flow->guessed_protocol_id = (int16_t)ndpi_guess_protocol_id(ndpi_struct, protocol, sport, dport, &user_defined_proto);
if(flow->packet.iph) {
if((flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->saddr)) == NDPI_PROTOCOL_UNKNOWN)
flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->daddr);
if (flow->guessed_host_protocol_id == NDPI_PROTOCOL_TELEGRAM){
ret.master_protocol = flow->guessed_host_protocol_id, ret.protocol = flow->guessed_host_protocol_id;
return(ret);
}
}
if(user_defined_proto && (flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)) {
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN, ret.protocol = flow->guessed_protocol_id;
return(ret);
}
Actually I place the detection based on ip upon the detection based on port.
You could also send a pull request and then I'll check it. I also try to see better, because i try telegram-desktop.pcap you sent me and I detect it correctly. I see
OK. thanx. I send a pull request. 1a6546850652acdd12570345a1ec71a13ad5405d