Thread: [Javanetsim-cvs] IceScan csubtarget.h,1.14,1.15
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2006-12-13 18:28:26
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16694 Modified Files: csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** csubtarget.h 13 Dec 2006 13:22:00 -0000 1.14 --- csubtarget.h 13 Dec 2006 18:28:21 -0000 1.15 *************** *** 162,166 **** //add UID 0 check ! if(par->verbose>0) *out << "Starting TCP FIN scan against " << hostname.c_str() << "...\n"; --- 162,166 ---- //add UID 0 check ! if(par->verbose > 0) *out << "Starting TCP FIN scan against " << hostname.c_str() << "...\n"; *************** *** 170,178 **** rawrecv.nonblock(true); int attempts = 0; ! while(attempts++ < 5){ ! std::map <int, scanning_port>::iterator i; ! for(i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ if(! (*i).second.done ){ --- 170,183 ---- rawrecv.nonblock(true); + int one = 1; + const int *val = &one; + if (rawsend.setsockopt (IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0) + perror("Setsockopt HDRINCL:"); + int attempts = 0; ! std::map <int, scanning_port>::iterator i; ! ! while(attempts++ < 5){ for(i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ if(! (*i).second.done ){ *************** *** 191,210 **** int bytes; char response[65535]; - //, remote_hostname[ICEMAXHOSTNAME]; struct iphdr *ip = (struct iphdr *) response; struct tcphdr *tcp; while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ if(ip->saddr = saddress.sin_addr.s_addr){ tcp = (struct tcphdr *) (response + 4 * ip->ihl); if (tcp->th_flags & TH_RST) { ! crawsocket::print_tcppacket(response, bytes); int closed_port = ntohs(tcp->th_sport); set_port_status(closed_port, PORT_CLOSED); ! //if(scanning_ports.find(closed_port)) scanning_ports[closed_port].done = true; } --- 196,217 ---- int bytes; char response[65535]; struct iphdr *ip = (struct iphdr *) response; struct tcphdr *tcp; + int at = 0; + while(at++<10){ while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ if(ip->saddr = saddress.sin_addr.s_addr){ tcp = (struct tcphdr *) (response + 4 * ip->ihl); if (tcp->th_flags & TH_RST) { ! //crawsocket::print_tcppacket(response, bytes); int closed_port = ntohs(tcp->th_sport); set_port_status(closed_port, PORT_CLOSED); ! //if(scanning_ports.find(closed_port)) scanning_ports[closed_port].done = true; + //^^^^UGLY, please check } *************** *** 212,219 **** bzero(response, 65534); } ! ! done = false; } show_ports(); --- 219,233 ---- bzero(response, 65534); } ! usleep(1000); ! } } + for(i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ + if(! (*i).second.done){ + (*i).second.done = true; + set_port_status((*i).first, get_no_response_status()); + } + } + show_ports(); *************** *** 273,276 **** --- 287,298 ---- } + enum port_status get_no_response_status(){ + switch(par->scan_type){ + case FIN_SCAN: + return PORT_OPEN_FILTERED; + break; + } + } + int get_first_free_socket(){ int f; *************** *** 443,447 **** sprintf(output_buf, "Discovered filtered port %d/tcp on %s.", port, hostname.c_str()); out->line(output_buf); ! } } --- 465,472 ---- sprintf(output_buf, "Discovered filtered port %d/tcp on %s.", port, hostname.c_str()); out->line(output_buf); ! }else if(ps == PORT_OPEN_FILTERED && par->verbose > 2){ ! sprintf(output_buf, "Discovered open|filtered port %d/tcp on %s.", port, hostname.c_str()); ! out->line(output_buf); ! } } *************** *** 610,613 **** --- 635,641 ---- sprintf(output_buf, "%5d/tcp open %s", subtarget_ports[j].port_number, isnd->get_tcp_service(subtarget_ports[j].port_number).c_str()); out->line(output_buf); + }else if(subtarget_ports[j].status == PORT_OPEN_FILTERED){ + sprintf(output_buf, "%5d/tcp o|f %s", subtarget_ports[j].port_number, isnd->get_tcp_service(subtarget_ports[j].port_number).c_str()); + out->line(output_buf); }else if(subtarget_ports[j].status == PORT_CLOSED && show_closed){ sprintf(output_buf, "%5d/tcp closed %s", subtarget_ports[j].port_number, isnd->get_tcp_service(subtarget_ports[j].port_number).c_str()); |