[Javanetsim-cvs] IceScan TODO,1.12,1.13 udpscan.h,1.5,1.6
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2006-12-16 12:18:09
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13285 Modified Files: TODO udpscan.h Log Message: no message Index: TODO =================================================================== RCS file: /cvsroot/javanetsim/IceScan/TODO,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TODO 15 Dec 2006 17:46:18 -0000 1.12 --- TODO 16 Dec 2006 12:18:05 -0000 1.13 *************** *** 11,16 **** + UDP Ping (-PU [portlist]) [QweR] ! + TCP SYN Scan (-PS [portlist]) [Key] ! + ICMP Address Mask Ping (-PM) [QweR] + ARP/RAW Discovery --- 11,15 ---- + UDP Ping (-PU [portlist]) [QweR] ! + TCP SYN Ping (-PS [portlist]) [Key] + ARP/RAW Discovery *************** *** 24,26 **** --- 23,27 ---- -- Misc -- + + select right interface to scan + -- Bugs -- Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** udpscan.h 16 Dec 2006 11:39:17 -0000 1.5 --- udpscan.h 16 Dec 2006 12:18:05 -0000 1.6 *************** *** 9,18 **** #include <pthread.h> #include "portdef.h" - #include "icesockets/csocket.h" - #include "icesockets/sock_types.h" - #include "icesockets/sock_err.h" #include "csubtarget.h" - #define UDP_SCAN_ZSIZE 0 #define UDP_SCAN_RECVSIZE 150 --- 9,14 ---- *************** *** 41,45 **** if(ip->ip_p == SOL_UDP && ((char*)ip+hdrlen+sizeof(udphdr))-recvmsg<=recvbytes){ struct udphdr* udp = (struct udphdr *) ((char*)ip + hdrlen); ! port = ntohs(udp->uh_dport); if(par->verbose>0) out->line("Recieved icmp port unreachable."); --- 37,41 ---- 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>0) out->line("Recieved icmp port unreachable."); *************** *** 114,118 **** if(p){ struct udphdr* udp = (struct udphdr*) recvmsg; ! port = ntohs(udp->uh_sport); if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ scanning_ports[port].done = true; --- 110,114 ---- if(p){ struct udphdr* udp = (struct udphdr*) recvmsg; ! port = ntohs(udp->source); if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ scanning_ports[port].done = true; *************** *** 164,280 **** - bool udpscan2(icestring hostname2, icestring destname2, std::map <int, scanning_port> scanning_ports, const char *hostname, iceparams *par, iceoutput *out){ - #ifndef __CYGWIN__ - if(!getuid() || par->forceuid){ - #else - if(par->forceuid){ - #endif - //we're root, so can work with raw sockets - icestring hostname_(hostname); - - char *t_hostname = (char *) malloc(strlen(hostname) + 1); - strcpy(t_hostname, hostname); - - if(par->verbose>0) - out->line("Starting icmp ping host discovery..."); - - crawsocket r(AF_INET, SOCK_RAW, IPPROTO_ICMP); - - - int size = 60 * 1024; - int attempts = 0; - - - - r.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); - - r.nonblock(true); - - int at = 1; - int len; - - csocket sudp(AF_INET, SOCK_DGRAM); - sudp.bind(hostname, sudp.getMagicPort(), 0); - sudp.nonblock(true); - - while(attempts++ < 100){ - if(at++<=ATTEMPTS){ - short int msg_type = ICMP_ECHO; - char buf[sizeof(struct timeval) + 1]; - - - if(par->verbose>0) out->line("Sending icmp timestamp host discovery request..."); - bzero(buf, sizeof(struct timeval) + 1); - msg_type = ICMP_TSTAMP; - // r.send_icmp_packet(hostname, msg_type, 0, getpid(), at, 0, buf, sizeof(struct timeval)); - - char zmsg[UDP_SCAN_ZSIZE]; - - for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ - if(! (*i).second.done ){ - DBGOUTPUT((*i).first); - sudp.sendto(destname2.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); - iceusleep(10000); - } - } - - iceusleep(200000); - } - - char hostname[ICEMAXHOSTNAME]; - char buf[1500]; //1500 == standart IP Packet size - - do{ - len = recvfrom(r.get_socketid(), buf, sizeof(buf), 0, NULL, NULL); - - if(len > 0){ - - struct ip *ip = (struct ip *) buf; - int hdrlen = ip->ip_hl << 2; - - struct icmp *icmp = (struct icmp *) (buf + hdrlen); - - int icmplen = len - hdrlen; - - bool result = false; - - if(icmp->icmp_id == getpid() && icmplen > 16){ - if(icmp->icmp_type == ICMP_TSTAMPREPLY){ - result = true; - if(par->verbose>0) - out->line("Recieved icmp timestamp host discovery reply."); - - char *buf; - - uint32_t t = ntohl(icmp->icmp_rtime); - - DBGOUTPUT(t); - - DBGOUTPUT(make_uptime(t)); - } - if(result){ - free(t_hostname); - r.shutdown(); - r.close(); - return true; - } - } - - } - else iceusleep(50000); - }while(len > 0); - } - - r.shutdown(); - r.close(); - - free(t_hostname); - - }else out->line("UID isn't 0, so can't create raw socket => no UDP scan..."); - - - return false; - } - #endif /* _udpscan_H */ --- 160,163 ---- |