[Javanetsim-cvs] IceScan csubtarget.h, 1.47, 1.48 icedbs.h, 1.6, 1.7 iceparams.h, 1.17, 1.18 udpsca
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2006-12-18 08:40:08
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20286 Modified Files: csubtarget.h icedbs.h iceparams.h udpscan.h Log Message: Index: icedbs.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icedbs.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** icedbs.h 17 Dec 2006 21:03:17 -0000 1.6 --- icedbs.h 18 Dec 2006 08:40:01 -0000 1.7 *************** *** 41,45 **** if(v.size()<4){ ! DBGOUTPUT(tmpbuf); continue; } --- 41,45 ---- if(v.size()<4){ ! //DBGOUTPUT(tmpbuf); continue; } Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** iceparams.h 17 Dec 2006 18:49:55 -0000 1.17 --- iceparams.h 18 Dec 2006 08:40:01 -0000 1.18 *************** *** 86,90 **** reverse_dns = true; ! ethernet = false; no_host_discovery = false; --- 86,91 ---- reverse_dns = true; ! ethernet = false; ! source_iface = 0; no_host_discovery = false; Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** csubtarget.h 17 Dec 2006 21:03:17 -0000 1.47 --- csubtarget.h 18 Dec 2006 08:40:01 -0000 1.48 *************** *** 830,835 **** out->line("PORT STATE SERVICE"); ! std::sort(subtarget_ports.begin(), subtarget_ports.end(), sort_sp); int j = 0; --- 830,836 ---- out->line("PORT STATE SERVICE"); ! #ifndef __CYGWIN__ std::sort(subtarget_ports.begin(), subtarget_ports.end(), sort_sp); + #endif int j = 0; Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** udpscan.h 17 Dec 2006 21:03:17 -0000 1.15 --- udpscan.h 18 Dec 2006 08:40:01 -0000 1.16 *************** *** 19,24 **** int port = 0; ! /*struct ip* ip = (struct ip*) recvmsg; ! int hdrlen = ip->ip_hl << 2; struct icmp* icmppacket = (struct icmp *) (recvmsg + hdrlen); int icmplen = recvbytes - hdrlen; --- 19,24 ---- int port = 0; ! struct iphdr* ip = (struct iphdr*) recvmsg; ! int hdrlen = ip->ihl << 2; struct icmp* icmppacket = (struct icmp *) (recvmsg + hdrlen); int icmplen = recvbytes - hdrlen; *************** *** 26,43 **** if(icmppacket->icmp_type == ICMP_UNREACH && icmppacket->icmp_code == ICMP_UNREACH_PORT){ ! ip = (struct ip*) (&icmppacket->icmp_ip); ! hdrlen = ip->ip_hl << 2; ! if(ip->ip_p == SOL_UDP && ((char*)ip+hdrlen+sizeof(udphdr))-recvmsg<=recvbytes){ struct udphdr* udp = (struct udphdr *) ((char*)ip + hdrlen); port = ntohs(udp->dest); ! if(par->verbose>2) *out << "Recieved icmp port " << port << "unreachable."; return port; } else{ ! DBGOUTPUT("incorrect length of packet"); } ! }*/ return 0; } --- 26,43 ---- if(icmppacket->icmp_type == ICMP_UNREACH && icmppacket->icmp_code == ICMP_UNREACH_PORT){ ! ip = (struct iphdr*) (&icmppacket->icmp_ip); ! hdrlen = ip->ihl << 2; ! if(ip->protocol == SOL_UDP && ((char*)ip+hdrlen+sizeof(udphdr))-recvmsg<=recvbytes){ struct udphdr* udp = (struct udphdr *) ((char*)ip + hdrlen); port = ntohs(udp->dest); ! if(par->verbose>2) *out << "Recieved icmp port " << port << " unreachable." << iceoutput::endl; return port; } else{ ! //DBGOUTPUT("incorrect length of packet"); } ! } return 0; } *************** *** 65,78 **** int repeats; csocket sudp(PF_INET, SOCK_DGRAM); ! crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); ! #ifdef WIN32 ! char *zmsg; ! #else ! char zmsg[UDP_SCAN_ZSIZE]; ! #endif char recvmsg[UDP_SCAN_RECVSIZE]; memset(zmsg, 0, UDP_SCAN_ZSIZE); int recvbytes; int port; char hostname[80]; bool next = true; --- 65,76 ---- int repeats; csocket sudp(PF_INET, SOCK_DGRAM); ! //crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); ! char *zmsg = new char[UDP_SCAN_ZSIZE+4]; char recvmsg[UDP_SCAN_RECVSIZE]; memset(zmsg, 0, UDP_SCAN_ZSIZE); int recvbytes; + unsigned int len; int port; + char* response; char hostname[80]; bool next = true; *************** *** 86,93 **** sudp.bind(hostname, pppp, 0); sudp.nonblock(true); ! sicmp.nonblock(true); int size = 60 * 1024; ! sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, (sockbuf_type *) &size, sizeof(size)); for(repeats = 1; repeats <= UDP_SCAN_REPEATS && next; repeats++){ --- 84,99 ---- sudp.bind(hostname, pppp, 0); sudp.nonblock(true); ! pcap_t* p = init_pcap(par->source_iface); //check for NULL ! if(p == NULL){ ! out->line("Can't open pcap: no raw tcp scan. Exitting."); ! return false; ! } ! char filter_exp[256]; ! sprintf(filter_exp, "host %s icmp", destname.c_str()); ! pcap_filter(p, filter_exp); ! //sicmp.nonblock(true); int size = 60 * 1024; ! //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, (sockbuf_type *) &size, sizeof(size)); for(repeats = 1; repeats <= UDP_SCAN_REPEATS && next; repeats++){ *************** *** 101,137 **** recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); if(recvbytes > 0){ ! struct udphdr* udp = (struct udphdr*) recvmsg; ! port = ntohs(udp->source); ! if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ ! if(isscan){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_OPEN, "udp"); ! } ! else{ ! result = true; ! next = false; ! } ! } } else{ ! // int att = 0; ! // while(att++ < 5 && recvbytes <= 0){ ! // recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); ! // iceusleep(100000); ! // } ! recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); ! if(recvbytes > 0){ ! port = parse_icmp_udp_packet(recvmsg, recvbytes, par, out); ! if(port!=0 && !scanning_ports[port].done && !(scanning_ports.find(port) == scanning_ports.end())){ ! if(isscan){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_CLOSED, "udp"); ! } ! else{ ! result = true; ! next = false; } - } - } } iceusleep(50000*repeats); --- 107,142 ---- recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); if(recvbytes > 0){ ! struct udphdr* udp = (struct udphdr*) recvmsg; ! port = ntohs(udp->source); ! if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ ! if(isscan){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_OPEN, "udp"); ! } ! else{ ! result = true; ! next = false; ! } ! } } else{ ! for(int k=0; k<5; k++){ ! response = readip_pcap(p, &len, NULL); ! if(response){ ! recvbytes = len; ! port = parse_icmp_udp_packet(response, len, par, out); ! if(port!=0 && !scanning_ports[port].done && !(scanning_ports.find(port) == scanning_ports.end())){ ! if(isscan){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_CLOSED, "udp"); ! } ! else{ ! result = true; ! next = false; ! } ! } ! } ! iceusleep(10000*repeats); } } iceusleep(50000*repeats); *************** *** 149,155 **** } sudp.shutdown(); - sicmp.shutdown(); sudp.close(); ! sicmp.close(); } else{ --- 154,162 ---- } sudp.shutdown(); sudp.close(); ! //sicmp.shutdown(); ! //sicmp.close(); ! close_pcap(p); ! delete[] zmsg; } else{ |