[Icescan-cvs] IceScan protocols, NONE, 1.1 iceprotocol.h, 1.3, 1.4 TODO, 1.41, 1.42 iceparams.h, 1.
Status: Alpha
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2007-01-22 18:06:58
|
Update of /cvsroot/icescan/IceScan In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv17484 Modified Files: iceprotocol.h TODO iceparams.h iceoutput.h caengine.cc ChangeLog icescan.cc Added Files: protocols Log Message: Fixed some issues in ip protocol scan; small redesign of crawsocket; added --badchksum option; added protocol database inital release file; updated TODO and ChangeLog. Index: icescan.cc =================================================================== RCS file: /cvsroot/icescan/IceScan/icescan.cc,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** icescan.cc 22 Jan 2007 16:51:29 -0000 1.33 --- icescan.cc 22 Jan 2007 18:06:49 -0000 1.34 *************** *** 72,75 **** --- 72,76 ---- "\t--ttl <value>: set IP time-to-live field\n" "\t--bounce-http-proxy <<hostname>:<port>>: connect() through HTTP proxy\n" + "\t--badchksum: send packets with a wrong TCP/UDP checksums" "OUTPUT\n" "\t-oI/oG <filename>: Output scan in normal/grepable format to given file\n" *************** *** 255,259 **** par->ethernet = false; }else if(!strcmp(argv[i], "--packet-trace")){ ! par->packet_trace = true; }else if(!strcmp(argv[i], "--bounce-http-proxy")){ if(i+1<argc){ --- 256,262 ---- par->ethernet = false; }else if(!strcmp(argv[i], "--packet-trace")){ ! par->packet_trace = true; ! }else if(!strcmp(argv[i], "--badchksum")){ ! par->badchksum = true; }else if(!strcmp(argv[i], "--bounce-http-proxy")){ if(i+1<argc){ Index: ChangeLog =================================================================== RCS file: /cvsroot/icescan/IceScan/ChangeLog,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ChangeLog 22 Jan 2007 16:16:52 -0000 1.23 --- ChangeLog 22 Jan 2007 18:06:49 -0000 1.24 *************** *** 41,44 **** --- 41,45 ---- + added IP Protocol scan (-SI) * changed (-i) option to (-e). + + added --badchksum option. *** IceScan v. 0.0.5, 18 Dec 2006 *** Index: iceparams.h =================================================================== RCS file: /cvsroot/icescan/IceScan/iceparams.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** iceparams.h 22 Jan 2007 16:51:29 -0000 1.33 --- iceparams.h 22 Jan 2007 18:06:49 -0000 1.34 *************** *** 117,120 **** --- 117,122 ---- int bounce_proxy_port; + bool badchksum; + // Scan Port Range *************** *** 198,201 **** --- 200,205 ---- promisc_mode = false; + badchksum = false; + random_len = 0; *************** *** 233,289 **** void by_default_init(){ ! icestring fstr; ! fstr = find_icefile_path("services", databases_dir); ! this->isnd = new ice_service_name_database (fstr.c_str()); ! fstr = find_icefile_path("protocols", databases_dir); ! ispd = new ice_protocol_name_database (fstr.c_str()); ! fstr = find_icefile_path("ieee-oui.txt", databases_dir); ! this->ismd = new ice_mac_name_database (fstr.c_str()); ! if(scan_type == UNKNOWN_SCAN && (!ip_protocol_scan)){ ! if(root()) ! scan_type = SYN_SCAN; ! else ! scan_type = TCP_CONNECT_SCAN; ! } ! ! if( ! (no_host_discovery || ack_ping_discovery || syn_ping_discovery || icmp_echo_ping_discovery || ! icmp_mask_ping_discovery || icmp_timestamp_ping_discovery || udp_ping_discovery || arp_discovery || ! fin_ping_discovery || passive_discovery) ){ ! ack_ping_discovery = true; ! if(root()) icmp_echo_ping_discovery = true; ! } ! ! if(source_iface){ ! max_retries[source_iface] = MAX_RETRIES; ! max_wait_time[source_iface] = MAX_WAIT_TIME; ! ! if(source_ip == ""){ ! ! if(root()){ ! if(r->get_loopback_interface() == source_iface) ! source_ip = "target"; ! else ! source_ip = cpcapreader::get_dev_ip(source_iface); ! } } } ! if(scan_type == PASSIVE_SCAN) ! passive_discovery = true; ! ! passive_discovery_timeout = MAX(passive_discovery_timeout, passive_scan_timeout); ! ! if(!passive_discovery_timeout) ! passive_discovery_timeout = 60; ! ! if(icedebug::debug) packet_trace=true; ! ! if(input_dumpfile != "" && scan_type == PASSIVE_SCAN) source_iface = 1; ! ! init_default_ports(); } --- 237,293 ---- void by_default_init(){ ! icestring fstr; ! fstr = find_icefile_path("services", databases_dir); ! this->isnd = new ice_service_name_database (fstr.c_str()); ! fstr = find_icefile_path("protocols", databases_dir); ! ispd = new ice_protocol_name_database (fstr.c_str()); ! fstr = find_icefile_path("ieee-oui.txt", databases_dir); ! this->ismd = new ice_mac_name_database (fstr.c_str()); ! if(scan_type == UNKNOWN_SCAN && (!ip_protocol_scan)){ ! if(root()) ! scan_type = SYN_SCAN; ! else ! scan_type = TCP_CONNECT_SCAN; ! } ! ! if( ! (no_host_discovery || ack_ping_discovery || syn_ping_discovery || icmp_echo_ping_discovery || ! icmp_mask_ping_discovery || icmp_timestamp_ping_discovery || udp_ping_discovery || arp_discovery || ! fin_ping_discovery || passive_discovery) ){ ! ack_ping_discovery = true; ! if(root()) icmp_echo_ping_discovery = true; ! } ! ! if(source_iface){ ! max_retries[source_iface] = MAX_RETRIES; ! max_wait_time[source_iface] = MAX_WAIT_TIME; ! ! if(source_ip == ""){ ! ! if(root()){ ! if(r->get_loopback_interface() == source_iface) ! source_ip = "target"; ! else ! source_ip = cpcapreader::get_dev_ip(source_iface); } } + } ! if(scan_type == PASSIVE_SCAN) ! passive_discovery = true; ! ! passive_discovery_timeout = MAX(passive_discovery_timeout, passive_scan_timeout); ! ! if(!passive_discovery_timeout) ! passive_discovery_timeout = 60; ! ! if(icedebug::debug) packet_trace=true; ! ! if(input_dumpfile != "" && scan_type == PASSIVE_SCAN) source_iface = 1; ! ! init_default_ports(); } Index: iceprotocol.h =================================================================== RCS file: /cvsroot/icescan/IceScan/iceprotocol.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** iceprotocol.h 22 Jan 2007 16:51:29 -0000 1.3 --- iceprotocol.h 22 Jan 2007 18:06:49 -0000 1.4 *************** *** 20,59 **** this->out = out; this->par = par; ! this->r_raw = raw_sock; } ! ~cprotocol_scan(){ ! } ! int send(const char *hostname,const u_int proto,int rand_port_val = 0){ ! ! char l_hostname[100]; ! gethostname(l_hostname,100); ! ! u_int exit_now = 1; ! switch(proto){ ! case IPPROTO_ICMP: ! ! r_raw->send_icmp_packet(hostname, ICMP_ECHO, 0, getpid(), 0, 0, 0, 0); ! break; ! case IPPROTO_TCP: ! r_raw->send_tcp_raw(par->ethernet,l_hostname,hostname,csocket::getMagicPort()+rand_port_val,csocket::getMagicPort()+rand_port_val, ! 0,0,TH_ACK,0,0,0,0); ! break; ! case IPPROTO_UDP: ! r_raw->send_udp_raw(par->ethernet,hostname,csocket::getMagicPort()+rand_port_val,csocket::getMagicPort()+rand_port_val,0,0,0,0); ! break; ! ! default: ! exit_now = 0; ! break; ! } ! if (exit_now) ! return 0; ! /// otherwise send a simple frame for that proto ! r_raw->send_ip_raw(par->ethernet,l_hostname,hostname,proto,0,0,0); ! ! return 0; } --- 20,52 ---- this->out = out; this->par = par; ! this->r_raw = raw_sock; } ! ~cprotocol_scan(){ ! } ! int send(const char *hostname, const char *l_hostname, const u_int proto,int rand_port_val = 0){ ! switch(proto){ ! case IPPROTO_ICMP: ! r_raw->send_icmp_packet(hostname, ICMP_ECHO, 0, getpid(), 0, 0, 0, 0); ! break; ! ! case IPPROTO_TCP: ! r_raw->send_tcp_raw(l_hostname,hostname,csocket::getMagicPort()+rand_port_val,csocket::getMagicPort()+rand_port_val, ! 0,0,TH_ACK,0,par->ttl,0,0); ! break; ! ! case IPPROTO_UDP: ! r_raw->send_udp_raw(hostname,csocket::getMagicPort()+rand_port_val,csocket::getMagicPort()+rand_port_val,par->ttl,0,0,0); ! break; ! ! default: ! // otherwise send a simple frame for that proto ! r_raw->send_ip_raw(l_hostname,hostname,proto,par->ttl,0,0); ! break; ! } ! ! return 0; } Index: caengine.cc =================================================================== RCS file: /cvsroot/icescan/IceScan/caengine.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** caengine.cc 22 Jan 2007 16:51:29 -0000 1.13 --- caengine.cc 22 Jan 2007 18:06:49 -0000 1.14 *************** *** 81,92 **** void caengine::print_final_outputs(){ ! for(std::map <icestring, csubtarget *>::iterator i = subtargets.begin(); i!= subtargets.end(); ++i){ ! for (int k = 0; k < OUTPUT_LEVEL; k++){ ! out << (*i).second->output_buffer[k].str(); ! if (out.outs[GREP].exists) ! out.outs[GREP].out << (*i).second->output_buffer_secondary[k][GREP].str(); ! } ! } } --- 81,92 ---- void caengine::print_final_outputs(){ ! for(std::map <icestring, csubtarget *>::iterator i = subtargets.begin(); i!= subtargets.end(); ++i){ ! for (int k = 0; k < OUTPUT_LEVEL; k++){ ! out << (*i).second->output_buffer[k].str(); ! if (out.outs[GREP].exists) ! out.outs[GREP].out << (*i).second->output_buffer_secondary[k][GREP].str(); ! } ! } } *************** *** 228,238 **** } ! //// Assign the scannable protocols to the subtarget ! if (par.ip_protocol_scan){ ! for (int i = 0; i < 25 ; i++){ ! scanning_protocol* pro = new scanning_protocol(i); ! cst->scan_protocols.insert(std::make_pair(i,*pro)); ! } ! } } --- 228,238 ---- } ! //// Assign the scannable protocols to the subtarget ! if (par.ip_protocol_scan){ ! for (int i = 0; i < 256 ; i++){ ! scanning_protocol* pro = new scanning_protocol(i); ! cst->scan_protocols.insert(std::make_pair(i,*pro)); ! } ! } } *************** *** 250,256 **** --- 250,259 ---- cde.r3 = new crawsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if(par.packet_trace) cde.r3->trace(true); + cde.ew = new cethwrapper(true); cde.r2 = new crawsocket(AF_INET, (int) SOCK_RAW, IPPROTO_RAW); if(par.packet_trace) cde.r2->trace(true); + cde.r2->set_ethernet(par.ethernet); + cde.r2->set_badchksum(par.badchksum); int one = 1; *************** *** 510,535 **** switch(st){ case FIN_SCAN: ! cde.r2->send_tcp_raw(par.ethernet, c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_FIN | par.tcpflags, 0, par.ttl, data, len); break; case NULL_SCAN: ! cde.r2->send_tcp_raw(par.ethernet, c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, par.tcpflags, 0, par.ttl, data, len); break; case XMAS_SCAN: ! cde.r2->send_tcp_raw(par.ethernet, c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_FIN | TH_URG | TH_PUSH | par.tcpflags, 0, par.ttl, data, len); break; case WINDOW_SCAN: case ACK_SCAN: ! cde.r2->send_tcp_raw(par.ethernet, c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_ACK, 0, par.ttl, data, len); break; case SYN_SCAN: ! cde.r2->send_tcp_raw(par.ethernet, c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_SYN, 0, par.ttl, data, len); break; case MAIMON_SCAN: ! cde.r2->send_tcp_raw(par.ethernet, c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_FIN | TH_ACK, 0, par.ttl, data, len); break; } --- 513,538 ---- switch(st){ case FIN_SCAN: ! cde.r2->send_tcp_raw(c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_FIN | par.tcpflags, 0, par.ttl, data, len); break; case NULL_SCAN: ! cde.r2->send_tcp_raw(c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, par.tcpflags, 0, par.ttl, data, len); break; case XMAS_SCAN: ! cde.r2->send_tcp_raw(c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_FIN | TH_URG | TH_PUSH | par.tcpflags, 0, par.ttl, data, len); break; case WINDOW_SCAN: case ACK_SCAN: ! cde.r2->send_tcp_raw(c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_ACK, 0, par.ttl, data, len); break; case SYN_SCAN: ! cde.r2->send_tcp_raw(c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_SYN, 0, par.ttl, data, len); break; case MAIMON_SCAN: ! cde.r2->send_tcp_raw(c->source_ip, c->hostname, c->MAGIC_PORT, j->port, 0, 0, TH_FIN | TH_ACK, 0, par.ttl, data, len); break; } *************** *** 642,646 **** } ! temp.send(c->hostname.c_str(),(*i).first,(*i).second.attemps_done()); (*i).second.send_attemp(); --- 645,649 ---- } ! temp.send(c->hostname.c_str(), c->source_ip.c_str(), (*i).first,(*i).second.attemps_done()); (*i).second.send_attemp(); *************** *** 1220,1224 **** subtargets[addr]->scan_probes[port].tv_send, tv); set_port_status(subtargets[addr], port, PORT_OPEN); ! cde.r2->send_tcp_raw(par.ethernet, subtargets[addr]->source_ip, subtargets[addr]->hostname, subtargets[addr]->MAGIC_PORT, port, 0, 0, TH_RST, 0, par.ttl, 0, 0); } --- 1223,1227 ---- subtargets[addr]->scan_probes[port].tv_send, tv); set_port_status(subtargets[addr], port, PORT_OPEN); ! cde.r2->send_tcp_raw(subtargets[addr]->source_ip, subtargets[addr]->hostname, subtargets[addr]->MAGIC_PORT, port, 0, 0, TH_RST, 0, par.ttl, 0, 0); } Index: TODO =================================================================== RCS file: /cvsroot/icescan/IceScan/TODO,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** TODO 22 Jan 2007 16:29:51 -0000 1.41 --- TODO 22 Jan 2007 18:06:49 -0000 1.42 *************** *** 1,24 **** IceScan ToDo: ! What should be in IceScan version 0.1: ############################################################################################################ ! 1. active scan methods: MainMON, FIN, ACK, SYN, connect(), NULL, XMAS, Windows, UDP, NetBIOS. ! 2. active discovery methods: ACK, connect(), FIN, SYN, UDP, NetBIOS. ! 3. passive scan and discover (capturing packts from network interfaces and/or from tcpdump file). ! 4. types of output results: 1) text; 2) grepable nmap-linke output. ! 5. working engine of retramsmissions and tuning parameters ! 6. special options(--promisc: set promiscious mode; --data-length <num>: append random data to sent packets; --badchksum: send packets with bad checksum; --data-dir: set directory which contains the databases; -iL [filename|-] -- input targets from file|stdin, each target on new line; --max_retries option; --max-timeout option) ! 7. own parallel-resolving dns client. ! 8. IP protocol scan ! 9. port to platform: Linux, Win32, OpenBSD, FreeBSD, Cygwin. ! 10. man page and INSTALL.win32, INSTALL.<platfrom-specific> files ############################################################################################################ Reference: ! "+" - new item ! "*" - need bugfixes --- 1,27 ---- IceScan ToDo: ! What should be in IceScan version 0.10: ! ([ ] - not done; [_] - partially done; [*] - seems to be working; [+] - completely done) ############################################################################################################ ! [*] 1. active scan methods: MainMON, FIN, ACK, SYN, connect(), NULL, XMAS, Window, NetBIOS. ! [_] 1.1 active scan methods: UDP ! [*] 2. active discovery methods: ACK, connect(), FIN, SYN. ! [_] 2.1 active discovery methods: UDP, NetBIOS. ! [+] 3. passive scan and discover (capturing packts from network interfaces and/or from tcpdump file). ! [*] 4. types of output results: 1) text; 2) grepable nmap-like output. ! [_] 5. working engine of retramsmissions and tuning parameters ! [_] 6. special options(--promisc: set promiscious mode; --data-length <num>: append random data to sent packets; --badchksum: send packets with bad checksum; --data-dir: set directory which contains the databases; -iL [filename|-] -- input targets from file|stdin, each target on new line; --max_retries option; --max-timeout option) ! [ ] 7. own parallel-resolving dns client. ! [*] 8. IP protocol scan. ! [_] 9. ports to platforms: Linux, Win32, OpenBSD, FreeBSD, Cygwin. ! [_] 10. man page and INSTALL.win32, INSTALL.<platfrom-specific> files. ############################################################################################################ Reference: ! "+" - new item ! "*" - need bugfixes *************** *** 46,50 **** I14 * test IP Protocol Scan (-SI) - I15 + --badchksum option. I16 + UDP RAW Scan (spoofed ip/mac/random data/etc...) I18 + IPX scan (??) --- 49,52 ---- *************** *** 62,66 **** I30 * fix raw tcp scans invalid port status if ports count > 40000 I31 * fix duplicate sending RST on SYN scan. ! I32 + ICMP PortUnreach handling in TCP/UDP raw scans I33 + Decoys (-D) I67 + IP options (R, T, U, S, L) --- 64,68 ---- I30 * fix raw tcp scans invalid port status if ports count > 40000 I31 * fix duplicate sending RST on SYN scan. ! I32 * ICMP PortUnreach messages handling in TCP/UDP raw scans I33 + Decoys (-D) I67 + IP options (R, T, U, S, L) --- NEW FILE: protocols --- # /etc/protocols # # Internet (IP) protocols definition file # # See protocols(5) for more info # ip 0 IP # internet protocol, pseudo protocol number icmp 1 ICMP # internet control message protocol igmp 2 IGMP # Internet Group Management ggp 3 GGP # gateway-gateway protocol ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') st 5 ST # ST datagram mode tcp 6 TCP # transmission control protocol egp 8 EGP # exterior gateway protocol pup 12 PUP # PARC universal packet protocol udp 17 UDP # user datagram protocol hmp 20 HMP # host monitoring protocol xns-idp 22 XNS-IDP # Xerox NS IDP rdp 27 RDP # "reliable datagram" protocol iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 xtp 36 XTP # Xpress Tranfer Protocol ddp 37 DDP # Datagram Delivery Protocol idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport ipv6 41 IPv6 # IPv6 ipv6-route 43 IPv6-Route # Routing Header for IPv6 ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 idrp 45 IDRP # Inter-Domain Routing Protocol rsvp 46 RSVP # Reservation Protocol gre 47 GRE # General Routing Encapsulation esp 50 ESP # Encap Security Payload for IPv6 ah 51 AH # Authentication Header for IPv6 skip 57 SKIP # SKIP ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 rspf 73 RSPF # Radio Shortest Path First. vmtp 81 VMTP # Versatile Message Transport ospf 89 OSPFIGP # Open Shortest Path First IGP ipip 94 IPIP # IP-within-IP Encapsulation Protocol encap 98 ENCAP # Yet Another IP encapsulation pim 103 PIM # Protocol Independent Multicast Index: iceoutput.h =================================================================== RCS file: /cvsroot/icescan/IceScan/iceoutput.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** iceoutput.h 22 Jan 2007 16:51:29 -0000 1.10 --- iceoutput.h 22 Jan 2007 18:06:49 -0000 1.11 *************** *** 25,29 **** public: ! struct out_type outs[4]; static const char endl[]; --- 25,29 ---- public: ! struct out_type outs[4]; static const char endl[]; *************** *** 182,193 **** } ! enum RESULTS_TYPE {RESULT_PORTS = 0,RESULT_PROTOCOLS}; - #define LOOP_ICEITERATOR_BEGIN(a,b) for (std::map <int,##a >::iterator i = b.begin(); \ - i!= b.end(); ++i){ - #define LOOP_ICEITERATOR_END } ! ! // This function used to display port table for given subtarget *c // Now supports only text output. void show_results(csubtarget *c, RESULTS_TYPE res_type = RESULT_PORTS){ --- 182,189 ---- } ! enum RESULTS_TYPE {RESULT_PORTS = 0,RESULT_PROTOCOLS}; ! // This function used to display port table for given subtarget *c // Now supports only text output. void show_results(csubtarget *c, RESULTS_TYPE res_type = RESULT_PORTS){ *************** *** 198,358 **** char output_buf[255]; ! //iceoutput *out = this; ! std::ostringstream *out; ! std::ostringstream* out_secondary_grep; // output_buffer_secondary for grep ! char str_type_scan[100]; ! std::map<int,int> list_output; if(!par.verbose && !c->scan_probes.size() && par.scan_type == PASSIVE_SCAN) return; ! if (res_type == RESULT_PORTS){ ! LOOP_ICEITERATOR_BEGIN(scanning_probe,c->scan_probes) ! list_output.insert(std::make_pair((*i).first,(*i).second.status)); ! LOOP_ICEITERATOR_END ! out = &(c->output_buffer[0]); ! out_secondary_grep = &(c->output_buffer_secondary[0][GREP]); ! sprintf(str_type_scan,"Ports"); ! }else{ ! LOOP_ICEITERATOR_BEGIN(scanning_protocol,c->scan_protocols) ! list_output.insert(std::make_pair((*i).first,(*i).second.status)); ! LOOP_ICEITERATOR_END ! out = &(c->output_buffer[1]); ! out_secondary_grep = &(c->output_buffer_secondary[1][GREP]); ! sprintf(str_type_scan,"Protocols"); ! } ! LOOP_ICEITERATOR_BEGIN(int,list_output) total++; ! if((*i).second == PORT_OPEN){ ! open++; ! }else if((*i).second == PORT_OPEN_FILTERED){ ! open_filtered++; ! }else if((*i).second == PORT_CLOSED){ ! closed++; ! }else if((*i).second == PORT_FILTERED){ ! filtered++; ! }else if((*i).second == PORT_UNFILTERED){ ! unfiltered++; } - LOOP_ICEITERATOR_END ! if(closed < MAX_SHOWED) show_closed = true; ! else{ ! os.str(""); ! os << "" << closed << " closed"; ! not_shown.push_back(os.str()); ! } ! ! if(filtered < MAX_SHOWED) show_filtered = true; ! else{ ! os.str(""); ! os << "" << filtered << " filtered"; ! not_shown.push_back(os.str()); ! } ! ! if(open_filtered < MAX_SHOWED) show_of = true; ! else{ ! os.str(""); ! os << "" << open_filtered << " open/filtered"; ! not_shown.push_back(os.str()); ! } ! ! if(unfiltered < MAX_SHOWED) show_unfiltered = true; ! else{ ! os.str(""); ! os << "" << unfiltered << " unfiltered"; ! not_shown.push_back(os.str()); ! } ! if(strcmp(c->hostname.c_str(), c->reversed_hostname.c_str())){ ! ! *out << "Interesting "<< str_type_scan <<" on " << c->reversed_hostname << " (" << c->hostname << "):"; ! if(outs[GREP].exists) ! //outs[GREP].out << "Host: " << c->reversed_hostname << " (" << c->hostname << ") "<< str_type_scan <<": "; ! *out_secondary_grep << "Host: " << c->reversed_hostname << " (" << c->hostname << ") "<< str_type_scan <<": "; ! }else{ ! *out << "Interesting "<< str_type_scan <<" on " << c->hostname << ":"; ! if(outs[GREP].exists) ! *out_secondary_grep << "Host: " << " "<< str_type_scan <<": "; ! //outs[GREP].out << "Host: " << " "<< str_type_scan <<": "; ! } ! if(c->scan_probes.size() || c->scan_protocols.size()){ ! *out << iceoutput::endl; ! os.str(""); ! os << "Not shown: "; ! for(int i = 0; i < not_shown.size(); i++){ ! if(i+1 == not_shown.size() && i!=0){ ! os << " and " << not_shown[i] << " "<< str_type_scan <<"."; ! }else if(i+1 == not_shown.size() && i!=0){ ! os << not_shown[i] << " "<< str_type_scan <<"."; ! }else if(i == 0){ ! os << not_shown[i]; ! }else{ ! os << ", " << not_shown[i]; } - } ! os << "\n"; ! if(not_shown.size()) *out << os.str(); ! if (res_type == RESULT_PORTS) ! *out << "PORT STATE SERVICE\n"; ! else ! *out << "PROTOCOL STATE SERVICE\n"; ! #ifndef __CYGWIN__ ! //std::sort(c->scan_probes.begin(), c->scan_probes.end(), sort_probes); ! #endif ! int j = 0; ! icestring state = ""; ! //for(std::map <int, scanning_probe>::iterator i = c->scan_probes.begin(); i!= c->scan_probes.end(); ++i){ ! LOOP_ICEITERATOR_BEGIN(int,list_output) ! Bzero(output_buf, 255); ! state = ""; ! ! if((*i).second == PORT_OPEN){ ! state = "open"; ! }else if((*i).second == PORT_OPEN_FILTERED && show_of){ ! state = "o|f"; ! }else if((*i).second == PORT_UNFILTERED && show_unfiltered){ ! state = "unfilt"; ! }else if((*i).second == PORT_FILTERED && show_filtered){ ! state = "filt"; ! }else if((*i).second == PORT_CLOSED && show_closed){ ! state = "closed"; ! } ! if(state.size()){ ! if (res_type == RESULT_PORTS) ! sprintf(output_buf, "%5d/tcp %6s %s", (*i).first, state.c_str(), par.isnd->get_tcp_service((*i).first).c_str()); ! else ! sprintf(output_buf, "%5d %6s %s", (*i).first, state.c_str(), par.ispd->get_protocol((*i).first).c_str()); *out << output_buf << "\n"; if(outs[GREP].exists){ ! if (res_type == RESULT_PORTS) ! grep << (*i).first << "/" << state.c_str() << "/" << "tcp" << "//" ! << par.isnd->get_tcp_service((*i).first).c_str() << ""; ! else ! grep << (*i).first << "/" << state.c_str() << "//" ! << par.ispd->get_protocol((*i).first).c_str() << ""; ! grep << ", "; } } ! LOOP_ICEITERATOR_END --- 194,348 ---- char output_buf[255]; ! std::ostringstream *out; ! std::ostringstream *out_secondary_grep; // output_buffer_secondary for grep ! char str_type_scan[100]; ! std::map<int,int> list_output; if(!par.verbose && !c->scan_probes.size() && par.scan_type == PASSIVE_SCAN) return; ! if (res_type == RESULT_PORTS){ ! for(std::map <int, scanning_probe >::iterator i = c->scan_probes.begin(); i!= c->scan_probes.end(); ++i){ ! list_output.insert(std::make_pair((*i).first,(*i).second.status)); ! } ! out = &(c->output_buffer[0]); ! out_secondary_grep = &(c->output_buffer_secondary[0][GREP]); ! sprintf(str_type_scan,"Ports"); ! }else{ ! for(std::map <int, scanning_protocol >::iterator i = c->scan_protocols.begin(); i!= c->scan_protocols.end(); ++i){ ! list_output.insert(std::make_pair((*i).first,(*i).second.status)); ! } ! out = &(c->output_buffer[1]); ! out_secondary_grep = &(c->output_buffer_secondary[1][GREP]); ! sprintf(str_type_scan,"Protocols"); ! } ! for(std::map <int, int >::iterator i = list_output.begin(); i!= list_output.end(); ++i){ total++; ! if((*i).second == PORT_OPEN){ ! open++; ! }else if((*i).second == PORT_OPEN_FILTERED){ ! open_filtered++; ! }else if((*i).second == PORT_CLOSED){ ! closed++; ! }else if((*i).second == PORT_FILTERED){ ! filtered++; ! }else if((*i).second == PORT_UNFILTERED){ ! unfiltered++; ! } ! } ! ! if(closed < MAX_SHOWED) show_closed = true; ! else{ ! os.str(""); ! os << "" << closed << " closed"; ! not_shown.push_back(os.str()); } ! if(filtered < MAX_SHOWED) show_filtered = true; ! else{ ! os.str(""); ! os << "" << filtered << " filtered"; ! not_shown.push_back(os.str()); ! } ! ! if(open_filtered < MAX_SHOWED) show_of = true; ! else{ ! os.str(""); ! os << "" << open_filtered << " open/filtered"; ! not_shown.push_back(os.str()); ! } ! ! if(unfiltered < MAX_SHOWED) show_unfiltered = true; ! else{ ! os.str(""); ! os << "" << unfiltered << " unfiltered"; ! not_shown.push_back(os.str()); ! } ! if(strcmp(c->hostname.c_str(), c->reversed_hostname.c_str())){ ! *out << "Interesting "<< str_type_scan <<" on " << c->reversed_hostname << " (" << c->hostname << "):"; ! if(outs[GREP].exists) ! *out_secondary_grep << "Host: " << c->reversed_hostname << " (" << c->hostname << ") "<< str_type_scan <<": "; ! }else{ ! *out << "Interesting "<< str_type_scan <<" on " << c->hostname << ":"; ! if(outs[GREP].exists) ! *out_secondary_grep << "Host: " << " "<< str_type_scan <<": "; ! } ! if(c->scan_probes.size() || c->scan_protocols.size()){ ! *out << iceoutput::endl; ! os.str(""); ! os << "Not shown: "; ! for(int i = 0; i < not_shown.size(); i++){ ! if(i+1 == not_shown.size() && i!=0){ ! os << " and " << not_shown[i] << " "<< str_type_scan <<"."; ! }else if(i+1 == not_shown.size() && i!=0){ ! os << not_shown[i] << " "<< str_type_scan <<"."; ! }else if(i == 0){ ! os << not_shown[i]; ! }else{ ! os << ", " << not_shown[i]; ! } } ! os << "\n"; ! if(not_shown.size()) *out << os.str(); ! if (res_type == RESULT_PORTS) ! *out << "PORT STATE SERVICE\n"; ! else ! *out << "PROTOCOL STATE SERVICE\n"; ! #ifndef __CYGWIN__ ! //std::sort(c->scan_probes.begin(), c->scan_probes.end(), sort_probes); ! #endif ! int j = 0; ! icestring state = ""; ! for(std::map <int, int >::iterator i = list_output.begin(); i!= list_output.end(); ++i){ ! Bzero(output_buf, 255); ! state = ""; ! ! if((*i).second == PORT_OPEN){ ! state = "open"; ! }else if((*i).second == PORT_OPEN_FILTERED && show_of){ ! state = "o|f"; ! }else if((*i).second == PORT_UNFILTERED && show_unfiltered){ ! state = "unfilt"; ! }else if((*i).second == PORT_FILTERED && show_filtered){ ! state = "filt"; ! }else if((*i).second == PORT_CLOSED && show_closed){ ! state = "closed"; ! } ! if(state.size()){ ! if (res_type == RESULT_PORTS) ! sprintf(output_buf, "%5d/tcp %6s %s", (*i).first, state.c_str(), par.isnd->get_tcp_service((*i).first).c_str()); ! else ! sprintf(output_buf, "%5d %6s %s", (*i).first, state.c_str(), par.ispd->get_protocol((*i).first).c_str()); *out << output_buf << "\n"; if(outs[GREP].exists){ ! if (res_type == RESULT_PORTS) ! grep << (*i).first << "/" << state.c_str() << "/" << "tcp" << "//" ! << par.isnd->get_tcp_service((*i).first).c_str() << ""; ! else ! grep << (*i).first << "/" << state.c_str() << "//" ! << par.ispd->get_protocol((*i).first).c_str() << ""; grep << ", "; } } ! } *************** *** 362,374 **** trim(gs, ','); ! //outs[GREP].out << gs; ! *out_secondary_grep << gs; } }else{ if(outs[GREP].exists) ! // outs[GREP].out << " no "<< str_type_scan <<" detected."; ! *out_secondary_grep << " no "<< str_type_scan <<" detected."; ! *out << " none "<< str_type_scan <<" detected.\n"; --- 352,361 ---- trim(gs, ','); ! *out_secondary_grep << gs; } }else{ if(outs[GREP].exists) ! *out_secondary_grep << " no "<< str_type_scan <<" detected."; *out << " none "<< str_type_scan <<" detected.\n"; *************** *** 378,389 **** if(outs[GREP].exists) ! *out_secondary_grep << "\n"; ! //outs[GREP].out << "\n"; ! if(c->mac != "" && c->mac != "00:00:00:00:00:00"){ ! icestring mac_msg; ! get_mac_message(c->mac,mac_msg); ! *out << mac_msg.c_str() << "\n\n"; ! } } --- 365,375 ---- if(outs[GREP].exists) ! *out_secondary_grep << "\n"; ! if(c->mac != "" && c->mac != "00:00:00:00:00:00"){ ! icestring mac_msg; ! get_mac_message(c->mac,mac_msg); ! *out << mac_msg.c_str() << "\n\n"; ! } } |