javanetsim-cvs Mailing List for javaNetSim (Page 16)
Status: Beta
Brought to you by:
darkkey
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(120) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(1) |
Feb
(69) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(76) |
Oct
(28) |
Nov
(77) |
Dec
(186) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(36) |
Oct
(61) |
Nov
(23) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(17) |
Oct
(105) |
Nov
(5) |
Dec
(1) |
2009 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(9) |
Nov
|
Dec
|
From: Alexander B. <da...@us...> - 2006-12-16 14:42:46
|
Update of /cvsroot/javanetsim/IceScan/nbproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1407/nbproject Modified Files: configurations.xml Log Message: no message Index: configurations.xml =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbproject/configurations.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** configurations.xml 16 Dec 2006 12:18:04 -0000 1.13 --- configurations.xml 16 Dec 2006 14:42:43 -0000 1.14 *************** *** 25,29 **** <itemPath>TODO</itemPath> </logicalFolder> - <itemPath>.#udpscan.h.1.h</itemPath> <itemPath>csubtarget.h</itemPath> <itemPath>ctarget.h</itemPath> --- 25,28 ---- *************** *** 122,128 **** <itemTool>3</itemTool> </item> - <item path=".#udpscan.h.1.h"> - <itemTool>3</itemTool> - </item> <item path="udpscan.h"> <itemTool>3</itemTool> --- 121,124 ---- |
From: QweR <qw...@us...> - 2006-12-16 12:37:35
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20729 Modified Files: udpscan.h Log Message: Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** udpscan.h 16 Dec 2006 12:18:05 -0000 1.6 --- udpscan.h 16 Dec 2006 12:37:31 -0000 1.7 *************** *** 51,61 **** void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out, csubtarget* subtarget){ - //char recvpackettest[56] = {0x45,0x00,0x00,0x38,0x36,0xd8,0x00,0x00,0xf2,0x01,0x0b,0x5e,0x52,0x8c,0x67,0x12, - // 0x57,0xed,0x75,0x03,0x03,0x03,0x83,0xa5,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x1c, - // 0x43,0x23,0x00,0x00,0x73,0x11,0x7e,0x1f,0x57,0xed,0x75,0x03,0x52,0x8c,0x67,0x12, - // 0x1a,0xf6,0x01,0xBC,0x00,0x08,0x5c,0xc9}; - //char recvpackettest2[8] = {0x01,0xBD,0x1a,0xf6,0x00,0x08,0x5c,0xc9}; - //bool alreadyscan = false; - //bool alreadyscan2 = false; #ifndef __CYGWIN__ --- 51,54 ---- *************** *** 87,110 **** sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); ! // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); ! for(repeats = 0; repeats < UDP_SCAN_REPEATS; repeats++){ ! // DBGOUTPUT("STARTING..."); 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(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); ! iceusleep(100000); ! //recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); } ! // alreadyscan = false; ! // alreadyscan2 = false; do{ recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); - // if((*i).first == 445 && !alreadyscan2){ - // recvbytes = 8; - // memcpy(recvmsg, recvpackettest2, 8); - // alreadyscan2 = true; - // } p = recvbytes > 0; if(p){ --- 80,92 ---- sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! for(repeats = 1; repeats <= UDP_SCAN_REPEATS; repeats++){ for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ if(! (*i).second.done ){ sudp.sendto(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); ! iceusleep(50000*repeats); } ! do{ recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); p = recvbytes > 0; if(p){ *************** *** 117,133 **** } else{ ! int att = 0; ! while(att++ < 5 && recvbytes <= 0){ recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); - iceusleep(100000); - } - - // if((*i).first == 444 && !alreadyscan){ - // recvbytes = 56; - // memcpy(recvmsg, recvpackettest, 56); - // alreadyscan = true; - // } - - // recvbytes = recvfrom(sicmp.get_socketid(), recvmsg, RECVSIZE, 0, NULL, NULL); if(recvbytes > 0){ port = parse_icmp_udp_packet(recvmsg, recvbytes, par, out); --- 99,108 ---- } 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); *************** *** 138,148 **** p = true; } ! else if(recvbytes != -1){ ! //DBGOUTPUT("NO DATA..."); ! //DBGOUTPUT(recvbytes); ! } ! if(!p) rep2++; } ! iceusleep(100000); }while(recvbytes > 0); } --- 113,119 ---- p = true; } ! // if(!p) rep2++; } ! iceusleep(50000*repeats); }while(recvbytes > 0); } |
From: Alexander B. <da...@us...> - 2006-12-16 12:18:09
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13285/icesockets Modified Files: sock_types.h Log Message: no message Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** sock_types.h 16 Dec 2006 11:39:17 -0000 1.12 --- sock_types.h 16 Dec 2006 12:18:05 -0000 1.13 *************** *** 32,38 **** #include <netinet/ip.h> #include <netinet/ip_icmp.h> - #include <netinet/udp.h> #define __FAVOR_BSD #include <netinet/tcp.h> #define my_uint16_t uint16_t --- 32,43 ---- #include <netinet/ip.h> #include <netinet/ip_icmp.h> #define __FAVOR_BSD #include <netinet/tcp.h> + #undef __FAVOR_BSD + + #ifndef __CYGWIN__ + #undef __FAVOR_BSD + #include <netinet/udp.h> + #endif #define my_uint16_t uint16_t *************** *** 238,249 **** char arp_dev[16]; }; ! /* UDP header as specified by RFC 768, August 1980. */ ! // struct udphdr { ! // u_short uh_sport; /* source port */ ! // u_short uh_dport; /* destination port */ ! // u_short uh_ulen; /* udp length */ ! // u_short uh_sum; /* udp checksum */ ! // }; #define SIOCGARP 0x8954 /* get ARP table entry */ #define SOL_UDP 17 --- 243,257 ---- char arp_dev[16]; }; ! /* UDP header as specified by RFC 768, August 1980. */ ! ! struct udphdr ! { ! u_int16_t source; ! u_int16_t dest; ! u_int16_t len; ! u_int16_t check; ! }; ! #define SIOCGARP 0x8954 /* get ARP table entry */ #define SOL_UDP 17 |
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 ---- |
From: Alexander B. <da...@us...> - 2006-12-16 12:18:08
|
Update of /cvsroot/javanetsim/IceScan/nbproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13285/nbproject Modified Files: configurations.xml Log Message: no message Index: configurations.xml =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbproject/configurations.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** configurations.xml 16 Dec 2006 10:02:50 -0000 1.12 --- configurations.xml 16 Dec 2006 12:18:04 -0000 1.13 *************** *** 25,28 **** --- 25,29 ---- <itemPath>TODO</itemPath> </logicalFolder> + <itemPath>.#udpscan.h.1.h</itemPath> <itemPath>csubtarget.h</itemPath> <itemPath>ctarget.h</itemPath> *************** *** 35,38 **** --- 36,40 ---- <itemPath>iceversion.h</itemPath> <itemPath>nbt_wrapper.h</itemPath> + <itemPath>portdef.h</itemPath> <itemPath>udpscan.h</itemPath> </logicalFolder> *************** *** 120,126 **** --- 122,134 ---- <itemTool>3</itemTool> </item> + <item path=".#udpscan.h.1.h"> + <itemTool>3</itemTool> + </item> <item path="udpscan.h"> <itemTool>3</itemTool> </item> + <item path="portdef.h"> + <itemTool>3</itemTool> + </item> </conf> </confs> |
From: QweR <qw...@us...> - 2006-12-16 11:39:24
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30153 Modified Files: csubtarget.h udpscan.h Log Message: Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** csubtarget.h 16 Dec 2006 10:39:10 -0000 1.31 --- csubtarget.h 16 Dec 2006 11:39:17 -0000 1.32 *************** *** 13,17 **** #include "nbt_wrapper.h" #include "iceprotocol.h" - #include "udpscan.h" #define CONNECT_TIMEOUT 14 --- 13,16 ---- *************** *** 25,28 **** --- 24,30 ---- #define MAX_CLOSED 7 + class csubtarget; + void udpscan(icestring, icestring, std::map <int, scanning_port>, iceparams*, iceoutput*, csubtarget*); + struct scan_socket{ int sid; *************** *** 164,168 **** local_hn.assign(local_hostname); ! udpscan(local_hn, hostname, scanning_ports); // udpscan2(local_hn, hostname, scanning_ports,hostname.c_str(), par, out); --- 166,170 ---- local_hn.assign(local_hostname); ! udpscan(local_hn, hostname, scanning_ports, par, out, this); // udpscan2(local_hn, hostname, scanning_ports,hostname.c_str(), par, out); *************** *** 207,317 **** } ! void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports){ ! //char recvpackettest[56] = {0x45,0x00,0x00,0x38,0x36,0xd8,0x00,0x00,0xf2,0x01,0x0b,0x5e,0x52,0x8c,0x67,0x12, ! // 0x57,0xed,0x75,0x03,0x03,0x03,0x83,0xa5,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x1c, ! // 0x43,0x23,0x00,0x00,0x73,0x11,0x7e,0x1f,0x57,0xed,0x75,0x03,0x52,0x8c,0x67,0x12, ! // 0x1a,0xf6,0x01,0xBC,0x00,0x08,0x5c,0xc9}; ! //char recvpackettest2[8] = {0x01,0xBD,0x1a,0xf6,0x00,0x08,0x5c,0xc9}; ! //bool alreadyscan = false; ! //bool alreadyscan2 = false; ! ! #ifndef __CYGWIN__ ! if(!getuid() || par->forceuid){ ! #else ! if(par->forceuid){ ! #endif ! #define UDP_SCAN_ZSIZE 0 ! #define UDP_SCAN_RECVSIZE 150 ! #define UDP_SCAN_REPEATS 5 ! int repeats; ! int rep2; ! csocket sudp(PF_INET, SOCK_DGRAM); ! crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); ! char zmsg[UDP_SCAN_ZSIZE]; ! char recvmsg[UDP_SCAN_RECVSIZE]; ! memset(zmsg, 0, UDP_SCAN_ZSIZE); ! int recvbytes; ! bool p; ! int port; ! ! int recvsize = UDP_SCAN_RECVSIZE; ! ! sudp.bind(hostname.c_str(), 0, 0); ! sudp.nonblock(true); ! sicmp.nonblock(true); ! ! int size = 60 * 1024; ! sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! ! //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); ! // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); ! for(repeats = 0; repeats < UDP_SCAN_REPEATS; repeats++){ ! // DBGOUTPUT("STARTING..."); ! 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(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); ! iceusleep(100000); ! //recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); ! } ! // alreadyscan = false; ! // alreadyscan2 = false; ! do{ ! recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); ! // if((*i).first == 445 && !alreadyscan2){ ! // recvbytes = 8; ! // memcpy(recvmsg, recvpackettest2, 8); ! // alreadyscan2 = true; ! // } ! p = recvbytes > 0; ! 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; ! set_port_status(port, PORT_OPEN, "udp"); ! } ! } ! else{ ! int att = 0; ! while(att++ < 5 && recvbytes <= 0){ ! recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); ! iceusleep(100000); ! } ! ! // if((*i).first == 444 && !alreadyscan){ ! // recvbytes = 56; ! // memcpy(recvmsg, recvpackettest, 56); ! // alreadyscan = true; ! // } ! ! // recvbytes = recvfrom(sicmp.get_socketid(), recvmsg, RECVSIZE, 0, NULL, 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())){ ! scanning_ports[port].done = true; ! set_port_status(port, PORT_CLOSED, "udp"); ! } ! p = true; ! } ! else if(recvbytes != -1){ ! //DBGOUTPUT("NO DATA..."); ! //DBGOUTPUT(recvbytes); ! } ! if(!p) rep2++; ! } ! iceusleep(100000); ! }while(recvbytes > 0); ! } ! } ! for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ ! if(! (*i).second.done ){ ! port = (*i).first; ! scanning_ports[port].done = true; ! set_port_status(port, PORT_OPEN_FILTERED, "udp"); ! } ! } ! }else out->line("UID isn't 0, so can't create raw socket => no UDP scan..."); ! } --- 209,218 ---- } ! void set_port_status(int port, enum port_status status, char* protocol){ ! struct scanned_port sp; ! sp.port_number = port; ! sp.status = status; ! subtarget_ports.push_back(sp); ! print_port_status(sp.port_number, status, protocol); } *************** *** 810,821 **** } - void set_port_status(int port, enum port_status status, char* protocol){ - struct scanned_port sp; - sp.port_number = port; - sp.status = status; - subtarget_ports.push_back(sp); - print_port_status(sp.port_number, status, protocol); - } - void show_ports(){ int filtered = 0, closed = 0, open = 0, total = 0; --- 711,714 ---- *************** *** 891,893 **** --- 784,788 ---- }; + #include "udpscan.h" + #endif Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** udpscan.h 16 Dec 2006 10:23:07 -0000 1.4 --- udpscan.h 16 Dec 2006 11:39:17 -0000 1.5 *************** *** 12,15 **** --- 12,16 ---- #include "icesockets/sock_types.h" #include "icesockets/sock_err.h" + #include "csubtarget.h" *************** *** 18,21 **** --- 19,23 ---- #define UDP_SCAN_REPEATS 5 + int parse_icmp_udp_packet(char* recvmsg, int recvbytes, iceparams *par, iceoutput *out){ int port = 0; *************** *** 39,43 **** 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."); --- 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."); *************** *** 52,55 **** --- 54,167 ---- } + void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out, csubtarget* subtarget){ + //char recvpackettest[56] = {0x45,0x00,0x00,0x38,0x36,0xd8,0x00,0x00,0xf2,0x01,0x0b,0x5e,0x52,0x8c,0x67,0x12, + // 0x57,0xed,0x75,0x03,0x03,0x03,0x83,0xa5,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x1c, + // 0x43,0x23,0x00,0x00,0x73,0x11,0x7e,0x1f,0x57,0xed,0x75,0x03,0x52,0x8c,0x67,0x12, + // 0x1a,0xf6,0x01,0xBC,0x00,0x08,0x5c,0xc9}; + //char recvpackettest2[8] = {0x01,0xBD,0x1a,0xf6,0x00,0x08,0x5c,0xc9}; + //bool alreadyscan = false; + //bool alreadyscan2 = false; + + #ifndef __CYGWIN__ + if(!getuid() || par->forceuid){ + #else + if(par->forceuid){ + #endif + #define UDP_SCAN_ZSIZE 0 + #define UDP_SCAN_RECVSIZE 150 + #define UDP_SCAN_REPEATS 5 + int repeats; + int rep2; + csocket sudp(PF_INET, SOCK_DGRAM); + crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); + char zmsg[UDP_SCAN_ZSIZE]; + char recvmsg[UDP_SCAN_RECVSIZE]; + memset(zmsg, 0, UDP_SCAN_ZSIZE); + int recvbytes; + bool p; + int port; + + int recvsize = UDP_SCAN_RECVSIZE; + + sudp.bind(hostname.c_str(), 0, 0); + sudp.nonblock(true); + sicmp.nonblock(true); + + int size = 60 * 1024; + sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + + //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); + // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); + for(repeats = 0; repeats < UDP_SCAN_REPEATS; repeats++){ + // DBGOUTPUT("STARTING..."); + 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(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); + iceusleep(100000); + //recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); + } + // alreadyscan = false; + // alreadyscan2 = false; + do{ + recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); + // if((*i).first == 445 && !alreadyscan2){ + // recvbytes = 8; + // memcpy(recvmsg, recvpackettest2, 8); + // alreadyscan2 = true; + // } + p = recvbytes > 0; + 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; + subtarget->set_port_status(port, PORT_OPEN, "udp"); + } + } + else{ + int att = 0; + while(att++ < 5 && recvbytes <= 0){ + recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); + iceusleep(100000); + } + + // if((*i).first == 444 && !alreadyscan){ + // recvbytes = 56; + // memcpy(recvmsg, recvpackettest, 56); + // alreadyscan = true; + // } + + // recvbytes = recvfrom(sicmp.get_socketid(), recvmsg, RECVSIZE, 0, NULL, 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())){ + scanning_ports[port].done = true; + subtarget->set_port_status(port, PORT_CLOSED, "udp"); + } + p = true; + } + else if(recvbytes != -1){ + //DBGOUTPUT("NO DATA..."); + //DBGOUTPUT(recvbytes); + } + if(!p) rep2++; + } + iceusleep(100000); + }while(recvbytes > 0); + } + } + for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ + if(! (*i).second.done ){ + port = (*i).first; + scanning_ports[port].done = true; + subtarget->set_port_status(port, PORT_OPEN_FILTERED, "udp"); + } + } + }else out->line("UID isn't 0, so can't create raw socket => no UDP scan..."); + + } + + bool udpscan2(icestring hostname2, icestring destname2, std::map <int, scanning_port> scanning_ports, const char *hostname, iceparams *par, iceoutput *out){ #ifndef __CYGWIN__ |
From: QweR <qw...@us...> - 2006-12-16 11:39:23
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30153/icesockets Modified Files: sock_types.h Log Message: Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sock_types.h 16 Dec 2006 10:02:50 -0000 1.11 --- sock_types.h 16 Dec 2006 11:39:17 -0000 1.12 *************** *** 240,250 **** /* UDP header as specified by RFC 768, August 1980. */ ! struct udphdr ! { ! my_uint16_t source; ! my_uint16_t dest; ! my_uint16_t len; ! my_uint16_t check; ! }; #define SIOCGARP 0x8954 /* get ARP table entry */ #define SOL_UDP 17 --- 240,249 ---- /* UDP header as specified by RFC 768, August 1980. */ ! // struct udphdr { ! // u_short uh_sport; /* source port */ ! // u_short uh_dport; /* destination port */ ! // u_short uh_ulen; /* udp length */ ! // u_short uh_sum; /* udp checksum */ ! // }; #define SIOCGARP 0x8954 /* get ARP table entry */ #define SOL_UDP 17 |
From: Alexander B. <da...@us...> - 2006-12-16 10:39:14
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6792 Modified Files: csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** csubtarget.h 16 Dec 2006 10:27:59 -0000 1.30 --- csubtarget.h 16 Dec 2006 10:39:10 -0000 1.31 *************** *** 145,323 **** } - void raw_tcp_scan(icestring scan_type){ - std::map <int, scanning_port> scanning_ports; - struct sockaddr_in saddress; - int len; - int MAGIC_PORT = 54678; //ugly, need to check - char local_hostname[80]; - - if(par->verbose > 0) - *out << "Starting TCP " << scan_type << " scan against " << hostname.c_str() << "...\n"; - - #ifdef __CYGWIN__ - if(par->forceuid){ - #else - if(getuid() || par->forceuid){ - #endif - out->line("UID isn't 0, so can't create raw socket => no RAW tcp scan..."); - return; - } - - - raw = true; - domain = (int) SOCK_RAW; - - len == make_sockname(saddress, hostname.c_str(), 0, domain); - - if(gethostname(local_hostname, 80)) exit(-1); - - icestring source(local_hostname); - - init_scanning_ports(hostname, par, (int) SOCK_RAW, scanning_ports); - - crawsocket rawsend(AF_INET, (int) SOCK_RAW, IPPROTO_RAW); - crawsocket rawrecv(AF_INET, (int) SOCK_RAW, IPPROTO_TCP); - - 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; - - while(attempts++ < 5){ - for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ - if(! (*i).second.done ){ - - switch(par->scan_type){ - case FIN_SCAN: - rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | par->tcpflags, 0, 0, 0); - break; - - case NULL_SCAN: - rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, par->tcpflags, 0, 0, 0); - break; - - case XMAS_SCAN: - rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | TH_URG | TH_PUSH | par->tcpflags, 0, 0, 0); - break; - - case WINDOW_SCAN: - case ACK_SCAN: - rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_ACK, 0, 0, 0); - break; - - case SYN_SCAN: - rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_SYN, 0, 0, 0); - break; - } - - - (*i).second.time = time(0); - - (*i).second.attempt++; - - iceusleep(1000); - } - } - - iceusleep(500000); - - 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) && (par->scan_type == FIN_SCAN || par->scan_type == NULL_SCAN || par->scan_type == XMAS_SCAN)) { - int closed_port = ntohs(tcp->th_sport); - - if(scanning_ports.find(closed_port) != scanning_ports.end()){ - if(!scanning_ports[closed_port].done){ - set_port_status(closed_port, PORT_CLOSED, "tcp"); - scanning_ports[closed_port].done = true; - } - } - }else if ((tcp->th_flags & TH_RST) && (par->scan_type == WINDOW_SCAN)) { - int port = ntohs(tcp->th_sport); - - if(scanning_ports.find(port) != scanning_ports.end()){ - if(!scanning_ports[port].done){ - scanning_ports[port].done = true; - if(tcp->th_win == 0){ - set_port_status(port, PORT_CLOSED, "tcp"); - }else{ - set_port_status(port, PORT_OPEN, "tcp"); - } - } - } - }else if ((tcp->th_flags & TH_RST) && (par->scan_type == ACK_SCAN)) { - int port = ntohs(tcp->th_sport); - - - if(scanning_ports.find(port) != scanning_ports.end()){ - if(!scanning_ports[port].done){ - set_port_status(port, PORT_UNFILTERED, "tcp"); - scanning_ports[port].done = true; - } - } - }else if ((tcp->th_flags & TH_RST) && (par->scan_type == SYN_SCAN)) { - int port = ntohs(tcp->th_sport); - - if(port != MAGIC_PORT){ - - if(scanning_ports.find(port) != scanning_ports.end()){ - if(!scanning_ports[port].done){ - scanning_ports[port].done = true; - set_port_status(port, PORT_CLOSED, "tcp"); - } - } - } - }else if ((tcp->th_flags & (TH_ACK|TH_SYN)) && (par->scan_type == SYN_SCAN)) { - int port = ntohs(tcp->th_sport); - - if(port != MAGIC_PORT){ - - if(scanning_ports.find(port) != scanning_ports.end()){ - if(!scanning_ports[port].done){ - set_port_status(port, PORT_OPEN, "tcp"); - rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, port, 0, 0, TH_RST, 0, 0, 0); - scanning_ports[port].done = true; - } - } - } - } - - - } - bzero(response, 65534); - } - iceusleep(1000); - } - } - - for(std::map <int, scanning_port>::iterator 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(), "tcp"); - } - } - - scanning_ports.clear(); - - show_ports(); - - if(par->verbose>0) - *out << "TCP " << scan_type << "scan finished.\n"; - } int udp_scan(){ --- 145,148 ---- *************** *** 614,617 **** --- 439,622 ---- } + /* This function implements any type of raw tcp scan, + * e.g. ACK, FIN and etc. + */ + void raw_tcp_scan(icestring scan_type){ + std::map <int, scanning_port> scanning_ports; + struct sockaddr_in saddress; + int len; + int MAGIC_PORT = 54678; //ugly, need to check + char local_hostname[80]; + + if(par->verbose > 0) + *out << "Starting TCP " << scan_type << " scan against " << hostname.c_str() << "...\n"; + + #ifdef __CYGWIN__ + if(par->forceuid){ + #else + if(getuid() || par->forceuid){ + #endif + out->line("UID isn't 0, so can't create raw socket => no RAW tcp scan..."); + return; + } + + + raw = true; + domain = (int) SOCK_RAW; + + len == make_sockname(saddress, hostname.c_str(), 0, domain); + + if(gethostname(local_hostname, 80)) exit(-1); + + icestring source(local_hostname); + + init_scanning_ports(hostname, par, (int) SOCK_RAW, scanning_ports); + + crawsocket rawsend(AF_INET, (int) SOCK_RAW, IPPROTO_RAW); + crawsocket rawrecv(AF_INET, (int) SOCK_RAW, IPPROTO_TCP); + + 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; + + while(attempts++ < 5){ + for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ + if(! (*i).second.done ){ + + switch(par->scan_type){ + case FIN_SCAN: + rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | par->tcpflags, 0, 0, 0); + break; + + case NULL_SCAN: + rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, par->tcpflags, 0, 0, 0); + break; + + case XMAS_SCAN: + rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | TH_URG | TH_PUSH | par->tcpflags, 0, 0, 0); + break; + + case WINDOW_SCAN: + case ACK_SCAN: + rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_ACK, 0, 0, 0); + break; + + case SYN_SCAN: + rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_SYN, 0, 0, 0); + break; + } + + + (*i).second.time = time(0); + + (*i).second.attempt++; + + iceusleep(1000); + } + } + + iceusleep(500000); + + 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) && (par->scan_type == FIN_SCAN || par->scan_type == NULL_SCAN || par->scan_type == XMAS_SCAN)) { + int closed_port = ntohs(tcp->th_sport); + + if(scanning_ports.find(closed_port) != scanning_ports.end()){ + if(!scanning_ports[closed_port].done){ + set_port_status(closed_port, PORT_CLOSED, "tcp"); + scanning_ports[closed_port].done = true; + } + } + }else if ((tcp->th_flags & TH_RST) && (par->scan_type == WINDOW_SCAN)) { + int port = ntohs(tcp->th_sport); + + if(scanning_ports.find(port) != scanning_ports.end()){ + if(!scanning_ports[port].done){ + scanning_ports[port].done = true; + if(tcp->th_win == 0){ + set_port_status(port, PORT_CLOSED, "tcp"); + }else{ + set_port_status(port, PORT_OPEN, "tcp"); + } + } + } + }else if ((tcp->th_flags & TH_RST) && (par->scan_type == ACK_SCAN)) { + int port = ntohs(tcp->th_sport); + + + if(scanning_ports.find(port) != scanning_ports.end()){ + if(!scanning_ports[port].done){ + set_port_status(port, PORT_UNFILTERED, "tcp"); + scanning_ports[port].done = true; + } + } + }else if ((tcp->th_flags & TH_RST) && (par->scan_type == SYN_SCAN)) { + int port = ntohs(tcp->th_sport); + + if(port != MAGIC_PORT){ + + if(scanning_ports.find(port) != scanning_ports.end()){ + if(!scanning_ports[port].done){ + scanning_ports[port].done = true; + set_port_status(port, PORT_CLOSED, "tcp"); + } + } + } + }else if ((tcp->th_flags & (TH_ACK|TH_SYN)) && (par->scan_type == SYN_SCAN)) { + int port = ntohs(tcp->th_sport); + + if(port != MAGIC_PORT){ + + if(scanning_ports.find(port) != scanning_ports.end()){ + if(!scanning_ports[port].done){ + set_port_status(port, PORT_OPEN, "tcp"); + rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, port, 0, 0, TH_RST, 0, 0, 0); + scanning_ports[port].done = true; + } + } + } + } + + + } + bzero(response, 65534); + } + iceusleep(1000); + } + } + + for(std::map <int, scanning_port>::iterator 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(), "tcp"); + } + } + + scanning_ports.clear(); + + show_ports(); + + if(par->verbose>0) + *out << "TCP " << scan_type << "scan finished.\n"; + } + + void shutdown_scansocket(int j){ csocket c(AF_INET, scan_sockets[j].domain, scan_sockets[j].sid); |
From: Alexander B. <da...@us...> - 2006-12-16 10:28:02
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2163 Modified Files: csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** csubtarget.h 16 Dec 2006 10:23:07 -0000 1.29 --- csubtarget.h 16 Dec 2006 10:27:59 -0000 1.30 *************** *** 417,423 **** int size = 60 * 1024; ! int attempts = 0; ! ! setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); --- 417,421 ---- int size = 60 * 1024; ! sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); *************** *** 466,470 **** 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()){ scanning_ports[port].done = true; set_port_status(port, PORT_CLOSED, "udp"); --- 464,468 ---- 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())){ scanning_ports[port].done = true; set_port_status(port, PORT_CLOSED, "udp"); |
From: Alexander B. <da...@us...> - 2006-12-16 10:23:10
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv529 Modified Files: icescan.cc udpscan.h icediscover.h csubtarget.h Log Message: no message Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** icescan.cc 16 Dec 2006 10:02:50 -0000 1.25 --- icescan.cc 16 Dec 2006 10:23:07 -0000 1.26 *************** *** 17,22 **** "\t-PA: ACK Ping host discovery\n" "\t-PR: ARP host discovery\n" ! "\t-PE: ICMP Echo (aka standart ping) host discovery\n" ! "\t-PT: ICMP Timestamp host discovery\n" "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" --- 17,21 ---- "\t-PA: ACK Ping host discovery\n" "\t-PR: ARP host discovery\n" ! "\t-PE/PT/PM: ICMP Echo/Timestamp/Mask host discovery\n" "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" *************** *** 201,204 **** --- 200,207 ---- par->icmp_timestamp_ping_discovery = true; break; + + case 'M': + par->icmp_mask_ping_discovery = true; + break; default: Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** csubtarget.h 16 Dec 2006 10:02:50 -0000 1.28 --- csubtarget.h 16 Dec 2006 10:23:07 -0000 1.29 *************** *** 412,418 **** int recvsize = UDP_SCAN_RECVSIZE; ! sudp.bind(hostname.c_str(), sudp.getMagicPort(), 0); sudp.nonblock(true); sicmp.nonblock(true); //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); --- 412,424 ---- int recvsize = UDP_SCAN_RECVSIZE; ! sudp.bind(hostname.c_str(), 0, 0); sudp.nonblock(true); sicmp.nonblock(true); + + int size = 60 * 1024; + int attempts = 0; + + setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** icediscover.h 16 Dec 2006 10:02:50 -0000 1.18 --- icediscover.h 16 Dec 2006 10:23:07 -0000 1.19 *************** *** 13,17 **** #define ATTEMPTS 5 ! enum Icmp_type {ECHO, TIMESTAMP}; bool tcp_ack_ping(const char *hostname, iceparams *par, iceoutput *out){ --- 13,17 ---- #define ATTEMPTS 5 ! enum Icmp_type {ECHO, TIMESTAMP, MASK}; bool tcp_ack_ping(const char *hostname, iceparams *par, iceoutput *out){ *************** *** 66,76 **** char buf[sizeof(struct timeval) + 1]; if(icmp_type == ECHO){ gettimeofday( ( struct timeval *) buf, NULL); if(par->verbose>0) out->line("Sending icmp ping host discovery request (echo_request)..."); }else if(icmp_type == TIMESTAMP){ ! if(par->verbose>0) out->line("Sending icmp timestamp host discovery request..."); ! bzero(buf, sizeof(struct timeval) + 1); msg_type = ICMP_TSTAMP; } --- 66,80 ---- char buf[sizeof(struct timeval) + 1]; + bzero(buf, sizeof(struct timeval) + 1); + if(icmp_type == ECHO){ gettimeofday( ( struct timeval *) buf, NULL); if(par->verbose>0) out->line("Sending icmp ping host discovery request (echo_request)..."); }else if(icmp_type == TIMESTAMP){ ! if(par->verbose>0) out->line("Sending icmp timestamp host discovery request..."); msg_type = ICMP_TSTAMP; + }else if(icmp_type == MASK){ + if(par->verbose>0) out->line("Sending icmp netmask host discovery request..."); + msg_type = ICMP_MASKREQ; } *************** *** 107,110 **** --- 111,121 ---- *out << "Recieved icmp timestamp host discovery reply: " << make_uptime(t) << ".\n"; } + }else if(icmp -> icmp_type == ICMP_MASKREPLY && icmp_type == MASK){ + result = true; + if(par->verbose>0){ + char netmask[24]; + sprintf(netmask, "%08x", ntohl(icmp->icmp_mask)); + *out << "Recieved icmp netmask host discovery reply: " << netmask << ".\n"; + } } if(result){ *************** *** 166,169 **** --- 177,182 ---- if(par->icmp_timestamp_ping_discovery) if( icmp_ping(hostname, par, out, TIMESTAMP) ) return true; + + if(par->icmp_mask_ping_discovery) if( icmp_ping(hostname, par, out, MASK) ) return true; if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** udpscan.h 16 Dec 2006 10:02:50 -0000 1.3 --- udpscan.h 16 Dec 2006 10:23:07 -0000 1.4 *************** *** 72,75 **** --- 72,77 ---- int size = 60 * 1024; int attempts = 0; + + r.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); |
From: Alexander B. <da...@us...> - 2006-12-16 10:02:54
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24917 Modified Files: icescan.cc udpscan.h icediscover.h csubtarget.h Log Message: no message Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** icescan.cc 16 Dec 2006 00:29:16 -0000 1.24 --- icescan.cc 16 Dec 2006 10:02:50 -0000 1.25 *************** *** 26,29 **** --- 26,30 ---- "\t-SI: IP Protocol scan\n" "\t-SN/SF/SX: stealth tcp Null/FIN/XMAS scan\n" + "\t-SU: udp scan.\n" "\t-S0: no scan\n" "\t--scanflags <flags>: Customize TCP scan flags (SF/SX/SN scans)\n" Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** csubtarget.h 16 Dec 2006 03:24:16 -0000 1.27 --- csubtarget.h 16 Dec 2006 10:02:50 -0000 1.28 *************** *** 415,419 **** sudp.nonblock(true); sicmp.nonblock(true); ! sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); for(repeats = 0; repeats < UDP_SCAN_REPEATS; repeats++){ --- 415,419 ---- sudp.nonblock(true); sicmp.nonblock(true); ! //sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); for(repeats = 0; repeats < UDP_SCAN_REPEATS; repeats++){ *************** *** 421,427 **** 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(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); iceusleep(100000); } // alreadyscan = false; --- 421,428 ---- 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(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); iceusleep(100000); + //recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); } // alreadyscan = false; *************** *** 443,448 **** } } ! else{ ! recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); // if((*i).first == 444 && !alreadyscan){ --- 444,453 ---- } } ! else{ ! int att = 0; ! while(att++ < 5 && recvbytes <= 0){ ! recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); ! iceusleep(100000); ! } // if((*i).first == 444 && !alreadyscan){ *************** *** 455,461 **** if(recvbytes > 0){ port = parse_icmp_udp_packet(recvmsg, recvbytes, par, out); - // DBGOUTPUT(port); if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ ! scanning_ports[port].done = true; set_port_status(port, PORT_CLOSED, "udp"); } --- 460,465 ---- 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()){ ! scanning_ports[port].done = true; set_port_status(port, PORT_CLOSED, "udp"); } *************** *** 463,468 **** } else if(recvbytes != -1){ ! // DBGOUTPUT("NO DATA..."); ! // DBGOUTPUT(recvbytes); } if(!p) rep2++; --- 467,472 ---- } else if(recvbytes != -1){ ! //DBGOUTPUT("NO DATA..."); ! //DBGOUTPUT(recvbytes); } if(!p) rep2++; Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** icediscover.h 16 Dec 2006 03:24:16 -0000 1.17 --- icediscover.h 16 Dec 2006 10:02:50 -0000 1.18 *************** *** 103,116 **** }else if(icmp -> icmp_type == ICMP_TSTAMPREPLY && icmp_type == TIMESTAMP){ 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){ --- 103,110 ---- }else if(icmp -> icmp_type == ICMP_TSTAMPREPLY && icmp_type == TIMESTAMP){ result = true; ! if(par->verbose>0){ ! uint32_t t = ntohl(icmp->icmp_rtime); ! *out << "Recieved icmp timestamp host discovery reply: " << make_uptime(t) << ".\n"; ! } } if(result){ Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** udpscan.h 16 Dec 2006 03:24:16 -0000 1.2 --- udpscan.h 16 Dec 2006 10:02:50 -0000 1.3 *************** *** 157,161 **** free(t_hostname); ! }else out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); --- 157,161 ---- free(t_hostname); ! }else out->line("UID isn't 0, so can't create raw socket => no UDP scan..."); |
From: Alexander B. <da...@us...> - 2006-12-16 10:02:54
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24917/icesockets Modified Files: csocket.h sock_types.h sock_time.h Log Message: no message Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sock_types.h 16 Dec 2006 03:24:16 -0000 1.10 --- sock_types.h 16 Dec 2006 10:02:50 -0000 1.11 *************** *** 32,35 **** --- 32,36 ---- #include <netinet/ip.h> #include <netinet/ip_icmp.h> + #include <netinet/udp.h> #define __FAVOR_BSD #include <netinet/tcp.h> Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** csocket.h 16 Dec 2006 00:29:16 -0000 1.13 --- csocket.h 16 Dec 2006 10:02:50 -0000 1.14 *************** *** 259,263 **** static int getMagicPort(){ ! return 0; } --- 259,263 ---- static int getMagicPort(){ ! return 33333; } Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sock_time.h 16 Dec 2006 00:29:16 -0000 1.6 --- sock_time.h 16 Dec 2006 10:02:50 -0000 1.7 *************** *** 42,52 **** int mins = t/1000/60 % (60); ! int hours = t/1000/60/60 % (24); ! int days = t/(1000*60*60*24); ! ! float fsecs = secs + msecs/1000; ! sprintf(buf, "%d days %d hours %d minutes %f seconds", days, hours, mins, fsecs); icestring ret(buf); --- 42,50 ---- int mins = t/1000/60 % (60); ! int hours = t/1000/60/60; ! double fsecs = secs + (double) msecs/1000; ! sprintf(buf, "%d hours %d minutes %.3f seconds", hours, mins, fsecs); icestring ret(buf); |
From: Alexander B. <da...@us...> - 2006-12-16 10:02:54
|
Update of /cvsroot/javanetsim/IceScan/nbproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24917/nbproject Modified Files: configurations.xml Log Message: no message Index: configurations.xml =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbproject/configurations.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** configurations.xml 15 Dec 2006 15:27:57 -0000 1.11 --- configurations.xml 16 Dec 2006 10:02:50 -0000 1.12 *************** *** 35,38 **** --- 35,39 ---- <itemPath>iceversion.h</itemPath> <itemPath>nbt_wrapper.h</itemPath> + <itemPath>udpscan.h</itemPath> </logicalFolder> <projectmakefile>Makefile</projectmakefile> *************** *** 119,122 **** --- 120,126 ---- <itemTool>3</itemTool> </item> + <item path="udpscan.h"> + <itemTool>3</itemTool> + </item> </conf> </confs> |
From: QweR <qw...@us...> - 2006-12-16 03:24:19
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1857/icesockets Modified Files: sock_types.h Log Message: Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sock_types.h 16 Dec 2006 00:29:16 -0000 1.9 --- sock_types.h 16 Dec 2006 03:24:16 -0000 1.10 *************** *** 204,207 **** --- 204,231 ---- }; + // struct ip + // { + // #if __BYTE_ORDER == __LITTLE_ENDIAN + // unsigned int ip_hl:4; /* header length */ + // unsigned int ip_v:4; /* version */ + // #endif + // #if __BYTE_ORDER == __BIG_ENDIAN + // unsigned int ip_v:4; /* version */ + // unsigned int ip_hl:4; /* header length */ + // #endif + // u_int8_t ip_tos; /* type of service */ + // u_short ip_len; /* total length */ + // u_short ip_id; /* identification */ + // u_short ip_off; /* fragment offset field */ + // #define IP_RF 0x8000 /* reserved fragment flag */ + // #define IP_DF 0x4000 /* dont fragment flag */ + // #define IP_MF 0x2000 /* more fragments flag */ + // #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + // u_int8_t ip_ttl; /* time to live */ + // u_int8_t ip_p; /* protocol */ + // u_short ip_sum; /* checksum */ + // struct in_addr ip_src, ip_dst; /* source and dest address */ + // }; + /* ARP ioctl request. */ struct arpreq *************** *** 213,218 **** char arp_dev[16]; }; #define SIOCGARP 0x8954 /* get ARP table entry */ ! #endif --- 237,252 ---- char arp_dev[16]; }; + + /* UDP header as specified by RFC 768, August 1980. */ + struct udphdr + { + my_uint16_t source; + my_uint16_t dest; + my_uint16_t len; + my_uint16_t check; + }; #define SIOCGARP 0x8954 /* get ARP table entry */ ! #define SOL_UDP 17 ! #define SOL_TCP 6 #endif |
From: QweR <qw...@us...> - 2006-12-16 03:24:19
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1857 Modified Files: csubtarget.h icediscover.h udpscan.h Log Message: Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** csubtarget.h 16 Dec 2006 00:29:15 -0000 1.26 --- csubtarget.h 16 Dec 2006 03:24:16 -0000 1.27 *************** *** 244,248 **** if(scanning_ports.find(closed_port) != scanning_ports.end()){ if(!scanning_ports[closed_port].done){ ! set_port_status(closed_port, PORT_CLOSED); scanning_ports[closed_port].done = true; } --- 244,248 ---- if(scanning_ports.find(closed_port) != scanning_ports.end()){ if(!scanning_ports[closed_port].done){ ! set_port_status(closed_port, PORT_CLOSED, "tcp"); scanning_ports[closed_port].done = true; } *************** *** 255,261 **** scanning_ports[port].done = true; if(tcp->th_win == 0){ ! set_port_status(port, PORT_CLOSED); }else{ ! set_port_status(port, PORT_OPEN); } } --- 255,261 ---- scanning_ports[port].done = true; if(tcp->th_win == 0){ ! set_port_status(port, PORT_CLOSED, "tcp"); }else{ ! set_port_status(port, PORT_OPEN, "tcp"); } } *************** *** 267,271 **** if(scanning_ports.find(port) != scanning_ports.end()){ if(!scanning_ports[port].done){ ! set_port_status(port, PORT_UNFILTERED); scanning_ports[port].done = true; } --- 267,271 ---- if(scanning_ports.find(port) != scanning_ports.end()){ if(!scanning_ports[port].done){ ! set_port_status(port, PORT_UNFILTERED, "tcp"); scanning_ports[port].done = true; } *************** *** 279,283 **** if(!scanning_ports[port].done){ scanning_ports[port].done = true; ! set_port_status(port, PORT_CLOSED); } } --- 279,283 ---- if(!scanning_ports[port].done){ scanning_ports[port].done = true; ! set_port_status(port, PORT_CLOSED, "tcp"); } } *************** *** 290,294 **** if(scanning_ports.find(port) != scanning_ports.end()){ if(!scanning_ports[port].done){ ! set_port_status(port, PORT_OPEN); rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, port, 0, 0, TH_RST, 0, 0, 0); scanning_ports[port].done = true; --- 290,294 ---- if(scanning_ports.find(port) != scanning_ports.end()){ if(!scanning_ports[port].done){ ! set_port_status(port, PORT_OPEN, "tcp"); rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, port, 0, 0, TH_RST, 0, 0, 0); scanning_ports[port].done = true; *************** *** 309,313 **** if(! (*i).second.done){ (*i).second.done = true; ! set_port_status((*i).first, get_no_response_status()); } } --- 309,313 ---- if(! (*i).second.done){ (*i).second.done = true; ! set_port_status((*i).first, get_no_response_status(), "tcp"); } } *************** *** 339,343 **** local_hn.assign(local_hostname); ! udpscan(local_hn, hostname, scanning_ports, par, out); // udpscan2(local_hn, hostname, scanning_ports,hostname.c_str(), par, out); --- 339,343 ---- local_hn.assign(local_hostname); ! udpscan(local_hn, hostname, scanning_ports); // udpscan2(local_hn, hostname, scanning_ports,hostname.c_str(), par, out); *************** *** 381,384 **** --- 381,485 ---- scanning_ports.clear(); } + + void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports){ + //char recvpackettest[56] = {0x45,0x00,0x00,0x38,0x36,0xd8,0x00,0x00,0xf2,0x01,0x0b,0x5e,0x52,0x8c,0x67,0x12, + // 0x57,0xed,0x75,0x03,0x03,0x03,0x83,0xa5,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x1c, + // 0x43,0x23,0x00,0x00,0x73,0x11,0x7e,0x1f,0x57,0xed,0x75,0x03,0x52,0x8c,0x67,0x12, + // 0x1a,0xf6,0x01,0xBC,0x00,0x08,0x5c,0xc9}; + //char recvpackettest2[8] = {0x01,0xBD,0x1a,0xf6,0x00,0x08,0x5c,0xc9}; + //bool alreadyscan = false; + //bool alreadyscan2 = false; + + #ifndef __CYGWIN__ + if(!getuid() || par->forceuid){ + #else + if(par->forceuid){ + #endif + #define UDP_SCAN_ZSIZE 0 + #define UDP_SCAN_RECVSIZE 150 + #define UDP_SCAN_REPEATS 5 + int repeats; + int rep2; + csocket sudp(PF_INET, SOCK_DGRAM); + crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); + char zmsg[UDP_SCAN_ZSIZE]; + char recvmsg[UDP_SCAN_RECVSIZE]; + memset(zmsg, 0, UDP_SCAN_ZSIZE); + int recvbytes; + bool p; + int port; + + int recvsize = UDP_SCAN_RECVSIZE; + + sudp.bind(hostname.c_str(), sudp.getMagicPort(), 0); + sudp.nonblock(true); + sicmp.nonblock(true); + sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); + // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); + for(repeats = 0; repeats < UDP_SCAN_REPEATS; repeats++){ + // DBGOUTPUT("STARTING..."); + 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(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); + iceusleep(100000); + } + // alreadyscan = false; + // alreadyscan2 = false; + do{ + recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); + // if((*i).first == 445 && !alreadyscan2){ + // recvbytes = 8; + // memcpy(recvmsg, recvpackettest2, 8); + // alreadyscan2 = true; + // } + p = recvbytes > 0; + 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; + set_port_status(port, PORT_OPEN, "udp"); + } + } + else{ + recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); + + // if((*i).first == 444 && !alreadyscan){ + // recvbytes = 56; + // memcpy(recvmsg, recvpackettest, 56); + // alreadyscan = true; + // } + + // recvbytes = recvfrom(sicmp.get_socketid(), recvmsg, RECVSIZE, 0, NULL, NULL); + if(recvbytes > 0){ + port = parse_icmp_udp_packet(recvmsg, recvbytes, par, out); + // DBGOUTPUT(port); + if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ + scanning_ports[port].done = true; + set_port_status(port, PORT_CLOSED, "udp"); + } + p = true; + } + else if(recvbytes != -1){ + // DBGOUTPUT("NO DATA..."); + // DBGOUTPUT(recvbytes); + } + if(!p) rep2++; + } + iceusleep(100000); + }while(recvbytes > 0); + } + } + for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ + if(! (*i).second.done ){ + port = (*i).first; + scanning_ports[port].done = true; + set_port_status(port, PORT_OPEN_FILTERED, "udp"); + } + } + }else out->line("UID isn't 0, so can't create raw socket => no UDP scan..."); + + } private: *************** *** 561,581 **** } ! void print_port_status(int port, enum port_status ps){ char output_buf[255]; if(ps == PORT_OPEN && par->verbose >= 1){ ! sprintf(output_buf, "Discovered open port %d/tcp on %s.", port, hostname.c_str()); out->line(output_buf); }else if(ps == PORT_CLOSED && par->verbose > 1){ ! sprintf(output_buf, "Discovered closed port %d/tcp on %s.", port, hostname.c_str()); out->line(output_buf); }else if(ps == PORT_FILTERED && par->verbose > 2){ ! 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); }else if(ps == PORT_UNFILTERED && par->verbose > 1){ ! sprintf(output_buf, "Discovered unfiltered port %d/tcp on %s.", port, hostname.c_str()); out->line(output_buf); } --- 662,682 ---- } ! void print_port_status(int port, enum port_status ps, char* protocol){ char output_buf[255]; if(ps == PORT_OPEN && par->verbose >= 1){ ! sprintf(output_buf, "Discovered open port %d/%s on %s.", port, protocol, hostname.c_str()); out->line(output_buf); }else if(ps == PORT_CLOSED && par->verbose > 1){ ! sprintf(output_buf, "Discovered closed port %d/%s on %s.", port, protocol, hostname.c_str()); out->line(output_buf); }else if(ps == PORT_FILTERED && par->verbose > 2){ ! sprintf(output_buf, "Discovered filtered port %d/%s on %s.", port, protocol, hostname.c_str()); out->line(output_buf); }else if(ps == PORT_OPEN_FILTERED && par->verbose > 2){ ! sprintf(output_buf, "Discovered open|filtered port %d/%s on %s.", port, protocol, hostname.c_str()); out->line(output_buf); }else if(ps == PORT_UNFILTERED && par->verbose > 1){ ! sprintf(output_buf, "Discovered unfiltered port %d/%s on %s.", port, protocol, hostname.c_str()); out->line(output_buf); } *************** *** 674,678 **** ! set_port_status((*i).first, status); (*i).second.done = true; shutdown_scansocket((*i).second.socket_ptr); --- 775,779 ---- ! set_port_status((*i).first, status, "tcp"); (*i).second.done = true; shutdown_scansocket((*i).second.socket_ptr); *************** *** 683,687 **** status = PORT_FILTERED; ! set_port_status((*i).first, status); (*i).second.done = true; shutdown_scansocket((*i).second.socket_ptr); --- 784,788 ---- status = PORT_FILTERED; ! set_port_status((*i).first, status, "tcp"); (*i).second.done = true; shutdown_scansocket((*i).second.socket_ptr); *************** *** 696,705 **** } ! void set_port_status(int port, enum port_status status){ struct scanned_port sp; sp.port_number = port; sp.status = status; subtarget_ports.push_back(sp); ! print_port_status(sp.port_number, status); } --- 797,806 ---- } ! void set_port_status(int port, enum port_status status, char* protocol){ struct scanned_port sp; sp.port_number = port; sp.status = status; subtarget_ports.push_back(sp); ! print_port_status(sp.port_number, status, protocol); } Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** icediscover.h 16 Dec 2006 00:29:16 -0000 1.16 --- icediscover.h 16 Dec 2006 03:24:16 -0000 1.17 *************** *** 158,161 **** --- 158,165 ---- } + bool udp_discovery(const char *hostname, iceparams *par, iceoutput *out){ + return false; + } + bool host_discover(const char *hostname, iceparams *par, iceoutput *out){ Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** udpscan.h 16 Dec 2006 00:29:16 -0000 1.1 --- udpscan.h 16 Dec 2006 03:24:16 -0000 1.2 *************** *** 12,108 **** #include "icesockets/sock_types.h" #include "icesockets/sock_err.h" - #define ZSIZE 0 - #define RECVSIZE 150 - char recvpackettest[70] = {0x00,0x11,0xd8,0x5e,0xea,0x44,0x00,0x17,0x95,0xee,0x26,0x1a,0x08,0x00,0x45,0x00, - 0x00,0x38,0x36,0xd8,0x00,0x00,0xf2,0x01,0x0b,0x5e,0x52,0x8c,0x67,0x12,0x57,0xed, - 0x75,0x03,0x03,0x03,0x83,0xa5,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x1c,0x43,0x23, - 0x00,0x00,0x73,0x11,0x7e,0x1f,0x57,0xed,0x75,0x03,0x52,0x8c,0x67,0x12,0x1a,0xf6, - 0x01,0x90,0x00,0x08,0x5c,0xc9}; ! void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out){ ! #ifndef __CYGWIN__ ! if(!getuid() || par->forceuid){ ! #else ! if(par->forceuid){ ! #endif ! int repeats; ! int rep2; ! csocket sudp(PF_INET, SOCK_DGRAM); ! crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); ! char zmsg[ZSIZE]; ! char recvmsg[RECVSIZE]; ! memset(zmsg, 0, ZSIZE); ! int recvbytes; ! struct icmp* icmppacket; ! // struct ip *ip ! bool p; ! int recvsize = RECVSIZE; ! sudp.bind(hostname.c_str(), sudp.getMagicPort(), 0); ! sudp.nonblock(true); ! sicmp.nonblock(true); ! sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); ! // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); ! for(repeats = 0; repeats < 10; repeats++){ ! DBGOUTPUT("STARTING..."); ! 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(destname.c_str(), (*i).first, zmsg, ZSIZE, 0); ! iceusleep(10000); ! } ! } ! for(rep2 = 0; rep2 < 10; ){ ! recvbytes = sudp.recvfrom(recvmsg, RECVSIZE, 0, NULL, NULL); ! p = recvbytes > 0; ! recvbytes = sicmp.recvfrom(recvmsg, RECVSIZE, 0, NULL); ! // recvbytes = recvfrom(sicmp.get_socketid(), recvmsg, RECVSIZE, 0, NULL, NULL); ! if(recvbytes > 0){ ! DBGOUTPUT("Data portion:\n"); ! for(int i=0; i < recvbytes; i++) printf("%2X%c", recvmsg[i], (++i%16)? ' ' : '\n'); ! printf("\n"); ! ! // ip = (struct ip *) buf; ! // int hdrlen = ip->ip_hl << 2; ! // icmppacket = (struct icmp *) (buf + hdrlen); ! // int icmplen = len - hdrlen; ! // ! // bool result = false; ! // ! // if(icmp->icmp_type == ICMP_UNREACH && icmp->icmp_code == ICMP_UNREACH_PORT){ ! // result = true; ! // if(par->verbose>0) ! // out->line("Recieved icmp port unreachable."); ! // ! // 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; ! // } ! ! ! p = true; ! } ! else if(recvbytes != -1){ ! DBGOUTPUT("NO DATA..."); ! DBGOUTPUT(recvbytes); ! } ! iceusleep(10000); ! if(!p) rep2++; ! } } ! }else out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); ! } --- 12,53 ---- #include "icesockets/sock_types.h" #include "icesockets/sock_err.h" ! #define UDP_SCAN_ZSIZE 0 ! #define UDP_SCAN_RECVSIZE 150 ! #define UDP_SCAN_REPEATS 5 ! int parse_icmp_udp_packet(char* recvmsg, int recvbytes, iceparams *par, iceoutput *out){ ! int port = 0; ! // DBGOUTPUT("Data portion:\n"); ! // for(int i=0; i < recvbytes; i++){ ! // char a = recvmsg[i]; ! // printf("%02X%c", a & 0xFF, (++i%16)? ' ' : '\n'); ! // } ! // printf("\n"); ! ! struct ip* ip = (struct ip*) recvmsg; ! int hdrlen = ip->ip_hl << 2; ! struct icmp* icmppacket = (struct icmp *) (recvmsg + hdrlen); ! int icmplen = recvbytes - hdrlen; ! ! 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>0) out->line("Recieved icmp port unreachable."); ! ! return port; } ! else{ ! DBGOUTPUT("incorrect length of packet"); ! } ! } ! return 0; } *************** *** 150,159 **** // r.send_icmp_packet(hostname, msg_type, 0, getpid(), at, 0, buf, sizeof(struct timeval)); ! char zmsg[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, ZSIZE, 0); iceusleep(10000); } --- 95,104 ---- // 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); } |
From: QweR <qw...@us...> - 2006-12-16 00:37:09
|
Update of /cvsroot/javanetsim/IceScan/nbproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30781/nbproject Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbproject/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 28 Nov 2006 18:00:23 -0000 1.1 --- .cvsignore 16 Dec 2006 00:37:06 -0000 1.2 *************** *** 1 **** --- 1,2 ---- private + configurations.xml \ No newline at end of file |
From: QweR <qw...@us...> - 2006-12-16 00:35:56
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30017 Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/javanetsim/IceScan/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 30 Nov 2006 15:36:33 -0000 1.2 --- .cvsignore 16 Dec 2006 00:35:52 -0000 1.3 *************** *** 1 **** --- 1,2 ---- icescan icescan.o Makefile + icescan.exe \ No newline at end of file |
From: QweR <qw...@us...> - 2006-12-16 00:29:21
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27015 Modified Files: csubtarget.h icediscover.h iceparams.h icescan.cc Added Files: portdef.h udpscan.h Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** icescan.cc 15 Dec 2006 21:04:55 -0000 1.23 --- icescan.cc 16 Dec 2006 00:29:16 -0000 1.24 *************** *** 163,166 **** --- 163,170 ---- break; + case 'U': + par->scan_type = UDP_SCAN; + break; + default: std::cout << "Invalid scan type: -S" << argv[i][2] << std::endl; *************** *** 215,225 **** }else{ IceRegex re("(\\d+(-\\d+)?),?"); icestring var = "", var2 = ""; ! re.match(argv[i+1]); re.findReset(); //re.Consume(&input, &var, &var2) while(re.findNext()){ var2 = ""; var = ""; re.group(1,var); --- 219,231 ---- }else{ IceRegex re("(\\d+(-\\d+)?),?"); + icestring var = "", var2 = ""; ! re.match(argv[i+1]); re.findReset(); //re.Consume(&input, &var, &var2) while(re.findNext()){ + var2 = ""; var = ""; re.group(1,var); Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** csubtarget.h 15 Dec 2006 17:46:18 -0000 1.25 --- csubtarget.h 16 Dec 2006 00:29:15 -0000 1.26 *************** *** 7,10 **** --- 7,11 ---- #include <vector> #include <errno.h> + #include "portdef.h" #include "iceoutput.h" #include "iceparams.h" *************** *** 12,15 **** --- 13,17 ---- #include "nbt_wrapper.h" #include "iceprotocol.h" + #include "udpscan.h" #define CONNECT_TIMEOUT 14 *************** *** 23,34 **** #define MAX_CLOSED 7 - enum port_status { PORT_UNKNOWN = -1, PORT_OPEN = 0, PORT_CLOSED = 1, PORT_FILTERED = 2, PORT_OPEN_FILTERED = 3, PORT_UNFILTERED = 4 }; - - class scanned_port{ - public: - int port_number; - enum port_status status; - }; - struct scan_socket{ int sid; --- 25,28 ---- *************** *** 37,49 **** }; - class scanning_port{ - public: - int port_number; - bool done; - long time; - int socket_ptr; - int attempt; - }; - class csubtarget{ --- 31,34 ---- *************** *** 108,111 **** --- 93,97 ---- if(par->scan_type == ACK_SCAN) raw_tcp_scan("ACK"); if(par->scan_type == SYN_SCAN) raw_tcp_scan("SYN"); + if(par->scan_type == UDP_SCAN) udp_scan(); } *************** *** 191,195 **** crawsocket rawsend(AF_INET, (int) SOCK_RAW, IPPROTO_RAW); ! crawsocket rawrecv(AF_INET, (int) SOCK_RAW, IPPROTO_TCP); rawrecv.nonblock(true); --- 177,181 ---- crawsocket rawsend(AF_INET, (int) SOCK_RAW, IPPROTO_RAW); ! crawsocket rawrecv(AF_INET, (int) SOCK_RAW, IPPROTO_TCP); rawrecv.nonblock(true); *************** *** 335,339 **** } ! int connect_scan(){ --- 321,352 ---- } ! int udp_scan(){ ! // connect scan, -SU ! ! char output_buf[255]; ! char local_hostname[80]; ! icestring local_hn; ! ! std::map <int, scanning_port> scanning_ports; ! init_scanning_ports(hostname, par, (int) SOCK_DGRAM, scanning_ports); ! ! if(par->verbose>0){ ! sprintf(output_buf, "Starting UDP scan against %s...", hostname.c_str()); ! out->line(output_buf); ! } ! ! if(gethostname(local_hostname,79)) exit(-1); ! local_hn.assign(local_hostname); ! ! udpscan(local_hn, hostname, scanning_ports, par, out); ! // udpscan2(local_hn, hostname, scanning_ports,hostname.c_str(), par, out); ! ! show_ports(); ! ! if(par->verbose>0) ! out->line("UDP scan finished."); ! ! scanning_ports.clear(); ! } int connect_scan(){ *************** *** 359,362 **** --- 372,377 ---- while( ! do_select_round_connect(scanning_ports, subtarget_ports) ) iceusleep(1000); + // DBGOUTPUT("end do_select_round"); + show_ports(); *************** *** 593,598 **** int curtime = time(0); ! for(i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ if((*i).second.done) continue; if( (*i).second.socket_ptr == -1){ --- 608,616 ---- int curtime = time(0); ! // DBGOUTPUT(" 509 "); + for(i = scanning_ports.begin(); i!= scanning_ports.end(); ++i){ + // DBGOUTPUT(" 512 "); + if((*i).second.done) continue; if( (*i).second.socket_ptr == -1){ *************** *** 601,605 **** continue; } ! enum port_status status = PORT_UNKNOWN; if(s >= 0 && (FD_ISSET(scan_sockets[(*i).second.socket_ptr].sid, &fd_rtmp) || --- 619,626 ---- continue; } ! ! // DBGOUTPUT( (*i).second.socket_ptr); ! // DBGOUTPUT(" 522 "); ! enum port_status status = PORT_UNKNOWN; if(s >= 0 && (FD_ISSET(scan_sockets[(*i).second.socket_ptr].sid, &fd_rtmp) || *************** *** 607,611 **** FD_ISSET(scan_sockets[(*i).second.socket_ptr].sid, &fd_xtmp))){ ! //DBGOUTPUT( (*i).second.socket_ptr); csocket c(AF_INET, (int) domain, scan_sockets[(*i).second.socket_ptr].sid); --- 628,632 ---- FD_ISSET(scan_sockets[(*i).second.socket_ptr].sid, &fd_xtmp))){ ! // DBGOUTPUT( (*i).second.socket_ptr); csocket c(AF_INET, (int) domain, scan_sockets[(*i).second.socket_ptr].sid); *************** *** 670,675 **** done &= true; } ! ! //DBGOUTPUT(done); return done; } --- 691,696 ---- done &= true; } ! // DBGOUTPUT("done"); ! // DBGOUTPUT(done); return done; } Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** icediscover.h 15 Dec 2006 21:04:55 -0000 1.15 --- icediscover.h 16 Dec 2006 00:29:16 -0000 1.16 *************** *** 34,38 **** } ! bool icmp_ping(const char *hostname, iceparams *par, iceoutput *out, enum Icmp_type icmp_type){ #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ --- 34,38 ---- } ! bool icmp_ping(const char *hostname, iceparams *par, iceoutput *out, enum Icmp_type icmp_type){ #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ *************** *** 45,49 **** char *t_hostname = (char *) malloc(strlen(hostname) + 1); strcpy(t_hostname, hostname); ! if(par->verbose>0) out->line("Starting icmp ping host discovery..."); --- 45,49 ---- char *t_hostname = (char *) malloc(strlen(hostname) + 1); strcpy(t_hostname, hostname); ! if(par->verbose>0) out->line("Starting icmp ping host discovery..."); Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** iceparams.h 15 Dec 2006 17:46:18 -0000 1.10 --- iceparams.h 16 Dec 2006 00:29:16 -0000 1.11 *************** *** 12,17 **** }; ! enum Scan_type {NO_SCAN, TCP_CONNECT_SCAN, NBT_SCAN, PROT_SCAN, FIN_SCAN, NULL_SCAN, XMAS_SCAN, WINDOW_SCAN, ACK_SCAN, SYN_SCAN}; ! // -S0 -ST -SB -SI -SF -SN -SX -SW -SA -SS --- 12,17 ---- }; ! enum Scan_type {NO_SCAN, TCP_CONNECT_SCAN, NBT_SCAN, PROT_SCAN, FIN_SCAN, NULL_SCAN, XMAS_SCAN, WINDOW_SCAN, ACK_SCAN, SYN_SCAN, UDP_SCAN}; ! // -S0 -ST -SB -SI -SF -SN -SX -SW -SA -SS -SU *************** *** 125,129 **** const int ranges_cnt = 2; ! int ranges[ranges_cnt][2] = { {20, 25}, {135, 136} }; //int ranges[ranges_cnt][2] = { {1, 1024}, {3388, 3390} }; --- 125,129 ---- const int ranges_cnt = 2; ! int ranges[ranges_cnt][2] = { {20, 25}, {130, 200} }; //int ranges[ranges_cnt][2] = { {1, 1024}, {3388, 3390} }; --- NEW FILE: udpscan.h --- #ifndef _udpscan_H #define _udpscan_H #include <cstdio> #include <cstdlib> #include <map> #include <vector> #include <errno.h> #include <pthread.h> #include "portdef.h" #include "icesockets/csocket.h" #include "icesockets/sock_types.h" #include "icesockets/sock_err.h" #define ZSIZE 0 #define RECVSIZE 150 char recvpackettest[70] = {0x00,0x11,0xd8,0x5e,0xea,0x44,0x00,0x17,0x95,0xee,0x26,0x1a,0x08,0x00,0x45,0x00, 0x00,0x38,0x36,0xd8,0x00,0x00,0xf2,0x01,0x0b,0x5e,0x52,0x8c,0x67,0x12,0x57,0xed, 0x75,0x03,0x03,0x03,0x83,0xa5,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x1c,0x43,0x23, 0x00,0x00,0x73,0x11,0x7e,0x1f,0x57,0xed,0x75,0x03,0x52,0x8c,0x67,0x12,0x1a,0xf6, 0x01,0x90,0x00,0x08,0x5c,0xc9}; void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out){ #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ #else if(par->forceuid){ #endif int repeats; int rep2; csocket sudp(PF_INET, SOCK_DGRAM); crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); char zmsg[ZSIZE]; char recvmsg[RECVSIZE]; memset(zmsg, 0, ZSIZE); int recvbytes; struct icmp* icmppacket; // struct ip *ip bool p; int recvsize = RECVSIZE; sudp.bind(hostname.c_str(), sudp.getMagicPort(), 0); sudp.nonblock(true); sicmp.nonblock(true); sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); // sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &recvsize, sizeof(recvsize)); for(repeats = 0; repeats < 10; repeats++){ DBGOUTPUT("STARTING..."); 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(destname.c_str(), (*i).first, zmsg, ZSIZE, 0); iceusleep(10000); } } for(rep2 = 0; rep2 < 10; ){ recvbytes = sudp.recvfrom(recvmsg, RECVSIZE, 0, NULL, NULL); p = recvbytes > 0; recvbytes = sicmp.recvfrom(recvmsg, RECVSIZE, 0, NULL); // recvbytes = recvfrom(sicmp.get_socketid(), recvmsg, RECVSIZE, 0, NULL, NULL); if(recvbytes > 0){ DBGOUTPUT("Data portion:\n"); for(int i=0; i < recvbytes; i++) printf("%2X%c", recvmsg[i], (++i%16)? ' ' : '\n'); printf("\n"); // ip = (struct ip *) buf; // int hdrlen = ip->ip_hl << 2; // icmppacket = (struct icmp *) (buf + hdrlen); // int icmplen = len - hdrlen; // // bool result = false; // // if(icmp->icmp_type == ICMP_UNREACH && icmp->icmp_code == ICMP_UNREACH_PORT){ // result = true; // if(par->verbose>0) // out->line("Recieved icmp port unreachable."); // // 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; // } p = true; } else if(recvbytes != -1){ DBGOUTPUT("NO DATA..."); DBGOUTPUT(recvbytes); } iceusleep(10000); if(!p) rep2++; } } }else out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); } 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[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, 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 ICMP ping..."); return false; } #endif /* _udpscan_H */ --- NEW FILE: portdef.h --- #ifndef _portdef_H #define _portdef_H enum port_status { PORT_UNKNOWN = -1, PORT_OPEN = 0, PORT_CLOSED = 1, PORT_FILTERED = 2, PORT_OPEN_FILTERED = 3, PORT_UNFILTERED = 4 }; class scanned_port{ public: int port_number; enum port_status status; }; class scanning_port{ public: int port_number; bool done; long time; int socket_ptr; int attempt; }; #endif /* _portdef_H */ |
From: QweR <qw...@us...> - 2006-12-16 00:29:21
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27015/icesockets Modified Files: csocket.h sock_time.h sock_types.h Log Message: Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sock_types.h 15 Dec 2006 15:27:57 -0000 1.8 --- sock_types.h 16 Dec 2006 00:29:16 -0000 1.9 *************** *** 15,19 **** --- 15,23 ---- #include <sys/socket.h> #include <arpa/inet.h> + + #ifndef __CYGWIN__ #include <net/if_arp.h> + #endif + #include <netinet/in.h> #include <netinet/ip.h> *************** *** 177,210 **** int icmp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); #endif - - #endif ! // IP Header structure for cygwin ! #ifdef __CYGWIN__ ! struct iphdr ! { ! #if __BYTE_ORDER == __LITTLE_ENDIAN ! unsigned int ihl:4; ! unsigned int version:4; ! #elif __BYTE_ORDER == __BIG_ENDIAN ! unsigned int version:4; ! unsigned int ihl:4; ! #else ! # error "Please fix <bits/endian.h>" ! #endif ! my_uint8_t tos; ! my_uint16_t tot_len; ! my_uint16_t id; ! my_uint16_t frag_off; ! my_uint8_t ttl; ! my_uint8_t protocol; ! my_uint16_t check; ! my_uint32_t saddr; ! my_uint32_t daddr; ! /*The options start here. */ ! }; #endif ! #endif --- 181,220 ---- int icmp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); #endif + struct iphdr + { + #if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ihl:4; + unsigned int version:4; + #elif __BYTE_ORDER == __BIG_ENDIAN + unsigned int version:4; + unsigned int ihl:4; + #else + # error "Please fix <bits/endian.h>" + #endif + my_uint8_t tos; + my_uint16_t tot_len; + my_uint16_t id; + my_uint16_t frag_off; + my_uint8_t ttl; + my_uint8_t protocol; + my_uint16_t check; + my_uint32_t saddr; + my_uint32_t daddr; + }; ! /* ARP ioctl request. */ ! struct arpreq ! { ! struct sockaddr arp_pa; /* Protocol address. */ ! struct sockaddr arp_ha; /* Hardware address. */ ! int arp_flags; /* Flags. */ ! struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */ ! char arp_dev[16]; ! }; ! #define SIOCGARP 0x8954 /* get ARP table entry */ #endif ! ! #endif Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** csocket.h 15 Dec 2006 15:27:57 -0000 1.12 --- csocket.h 16 Dec 2006 00:29:16 -0000 1.13 *************** *** 258,261 **** --- 258,265 ---- } + static int getMagicPort(){ + return 0; + } + }; Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sock_time.h 15 Dec 2006 21:04:55 -0000 1.5 --- sock_time.h 16 Dec 2006 00:29:16 -0000 1.6 *************** *** 36,46 **** char buf[1024]; ! int msecs = t % (1000*60*60*24); ! int secs = t % (60*60*24); ! int mins = t % (60*24); ! int hours = t%(24); int days = t/(1000*60*60*24); --- 36,46 ---- char buf[1024]; ! int msecs = t % (1000); ! int secs = t/1000 % (60); ! int mins = t/1000/60 % (60); ! int hours = t/1000/60/60 % (24); int days = t/(1000*60*60*24); |
From: Alexander B. <da...@us...> - 2006-12-15 21:04:58
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10589/icesockets Modified Files: sock_time.h Log Message: no message Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sock_time.h 15 Dec 2006 16:35:29 -0000 1.4 --- sock_time.h 15 Dec 2006 21:04:55 -0000 1.5 *************** *** 33,35 **** --- 33,57 ---- } + icestring make_uptime(long t){ + char buf[1024]; + + int msecs = t % (1000*60*60*24); + + int secs = t % (60*60*24); + + int mins = t % (60*24); + + int hours = t%(24); + + int days = t/(1000*60*60*24); + + float fsecs = secs + msecs/1000; + + sprintf(buf, "%d days %d hours %d minutes %f seconds", days, hours, mins, fsecs); + + icestring ret(buf); + + return ret; + } + #endif |
From: Alexander B. <da...@us...> - 2006-12-15 21:04:58
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10589 Modified Files: icescan.cc icediscover.h Log Message: no message Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** icescan.cc 15 Dec 2006 17:46:18 -0000 1.22 --- icescan.cc 15 Dec 2006 21:04:55 -0000 1.23 *************** *** 8,28 **** void print_help(char *name){ ! printf("\nUSAGE: %s [options] [Scan type] target\n" "\t target can be hostname or IP address.\n" "WHOLE PROGRAM:\n" "\t-v[v[v[v]]]]: verbose levels\n" "HOST DISCOVERY:\n" "\t-P0: skip host discovery\n" "\t-PA: ACK Ping host discovery\n" ! "\t-PM: ARP host discovery\n" "\t-PE: ICMP Echo (aka standart ping) host discovery\n" "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" "\t-ST/SA/SS/SW: tcp connect()/ACK/SYN/Window scan\n" "\t-SB: udp NetBIOS scan\n" "\t-SI: IP Protocol scan\n" ! "\t-SN/SF/SX: stealth Null/FIN/XMAS scan\n" "\t-S0: no scan\n" ! "\t--scanflags <flags>: Customize TCP scan flags (SF/SX/SN scans)" "PORTS SPECIFICATION:\n" "\t-p <port range>: specify port range to scan (default 1-1024).\n" --- 8,31 ---- void print_help(char *name){ ! printf("\nUSAGE: %s [options] [scan type] target\n" "\t target can be hostname or IP address.\n" "WHOLE PROGRAM:\n" "\t-v[v[v[v]]]]: verbose levels\n" "HOST DISCOVERY:\n" + "\t default is PA and PE.\n" "\t-P0: skip host discovery\n" "\t-PA: ACK Ping host discovery\n" ! "\t-PR: ARP host discovery\n" "\t-PE: ICMP Echo (aka standart ping) host discovery\n" + "\t-PT: ICMP Timestamp host discovery\n" "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" + "\t default id tcp connect()\n" "\t-ST/SA/SS/SW: tcp connect()/ACK/SYN/Window scan\n" "\t-SB: udp NetBIOS scan\n" "\t-SI: IP Protocol scan\n" ! "\t-SN/SF/SX: stealth tcp Null/FIN/XMAS scan\n" "\t-S0: no scan\n" ! "\t--scanflags <flags>: Customize TCP scan flags (SF/SX/SN scans)\n" "PORTS SPECIFICATION:\n" "\t-p <port range>: specify port range to scan (default 1-1024).\n" *************** *** 186,192 **** break; ! case 'M': par->arp_discovery = true; break; default: --- 189,199 ---- break; ! case 'R': par->arp_discovery = true; break; + + case 'T': + par->icmp_timestamp_ping_discovery = true; + break; default: Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** icediscover.h 15 Dec 2006 17:46:18 -0000 1.14 --- icediscover.h 15 Dec 2006 21:04:55 -0000 1.15 *************** *** 11,15 **** #define ACK_PING_STANDART_PORT 80 #define ARP_PING_STANDART_PORT 138 ! #define ECHO_ATTEMPTS 5 bool tcp_ack_ping(const char *hostname, iceparams *par, iceoutput *out){ --- 11,17 ---- #define ACK_PING_STANDART_PORT 80 #define ARP_PING_STANDART_PORT 138 ! #define ATTEMPTS 5 ! ! enum Icmp_type {ECHO, TIMESTAMP}; bool tcp_ack_ping(const char *hostname, iceparams *par, iceoutput *out){ *************** *** 32,38 **** } ! bool icmp_echo_ping(const char *hostname, iceparams *par, iceoutput *out){ ! //pthread_t send_thread; ! #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ --- 34,38 ---- } ! bool icmp_ping(const char *hostname, iceparams *par, iceoutput *out, enum Icmp_type icmp_type){ #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ *************** *** 62,74 **** while(attempts++ < 100){ ! if(at++<=ECHO_ATTEMPTS){ ! if(par->verbose>0) ! out->line("Sending icmp ping host discovery request (echo_request)..."); ! char buf[sizeof(struct timeval) + 1]; ! gettimeofday( ( struct timeval *) buf, NULL); ! ! r.send_icmp_packet(hostname, ICMP_ECHO, 0, getpid(), at, 0, buf, sizeof(struct timeval)); iceusleep(200000); --- 62,79 ---- while(attempts++ < 100){ ! if(at++<=ATTEMPTS){ ! short int msg_type = ICMP_ECHO; char buf[sizeof(struct timeval) + 1]; + + if(icmp_type == ECHO){ + gettimeofday( ( struct timeval *) buf, NULL); + if(par->verbose>0) out->line("Sending icmp ping host discovery request (echo_request)..."); + }else if(icmp_type == TIMESTAMP){ + 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)); iceusleep(200000); *************** *** 89,99 **** int icmplen = len - hdrlen; ! if(icmp -> icmp_type == ICMP_ECHOREPLY && icmp->icmp_id == getpid() && icmplen > 16){ if(par->verbose>0) out->line("Recieved icmp ping host discovery reply (echo_reply)."); free(t_hostname); r.shutdown(); r.close(); return true; } --- 94,123 ---- int icmplen = len - hdrlen; ! bool result = false; ! ! if(icmp->icmp_id == getpid() && icmplen > 16){ ! if(icmp -> icmp_type == ICMP_ECHOREPLY && icmp_type == ECHO){ ! result = true; if(par->verbose>0) out->line("Recieved icmp ping host discovery reply (echo_reply)."); + }else if(icmp -> icmp_type == ICMP_TSTAMPREPLY && icmp_type == TIMESTAMP){ + 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; + } } *************** *** 141,149 **** if(par->ack_ping_discovery) if( tcp_ack_ping(hostname, par, out) ) return true; ! if(par->icmp_echo_ping_discovery) if( icmp_echo_ping(hostname, par, out) ) return true; if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; ! if(par->verbose>0) *out << "Ack host discovery failed!" << iceoutput::endl; return false; --- 165,175 ---- if(par->ack_ping_discovery) if( tcp_ack_ping(hostname, par, out) ) return true; ! if(par->icmp_echo_ping_discovery) if( icmp_ping(hostname, par, out, ECHO) ) return true; ! ! if(par->icmp_timestamp_ping_discovery) if( icmp_ping(hostname, par, out, TIMESTAMP) ) return true; if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; ! if(par->verbose>0) *out << "Host discovery failed!" << iceoutput::endl; return false; |
From: Alexander B. <da...@us...> - 2006-12-15 17:46:25
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv31353 Modified Files: iceparams.h icescan.cc ctarget.h TODO icediscover.h csubtarget.h Log Message: no message Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** icescan.cc 15 Dec 2006 17:15:12 -0000 1.21 --- icescan.cc 15 Dec 2006 17:46:18 -0000 1.22 *************** *** 15,18 **** --- 15,19 ---- "\t-P0: skip host discovery\n" "\t-PA: ACK Ping host discovery\n" + "\t-PM: ARP host discovery\n" "\t-PE: ICMP Echo (aka standart ping) host discovery\n" "\t-r: no reverse-dns lookups\n" *************** *** 28,31 **** --- 29,33 ---- "\t You can use: 1-10; 1; 1-10,12-14; etc.\n" "MISC:\n" + "\t--uid0: assume that the current user is fully privileged.\n" "\t-V: print version and exit\n" "\t-?: this message\n\n", name); *************** *** 74,77 **** --- 76,85 ---- exit(1); } + }else if(!strcmp(argv[i], "--uid0")){ + par->forceuid = true; + }else{ + std::cout << "Invalid option: -" << argv[i][1] << std::endl; + print_help(argv[0]); + exit(1); } *************** *** 177,180 **** --- 185,192 ---- par->icmp_echo_ping_discovery = true; break; + + case 'M': + par->arp_discovery = true; + break; default: Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** csubtarget.h 15 Dec 2006 17:15:12 -0000 1.24 --- csubtarget.h 15 Dec 2006 17:46:18 -0000 1.25 *************** *** 169,178 **** *out << "Starting TCP " << scan_type << " scan against " << hostname.c_str() << "...\n"; ! #ifndef __CYGWIN__ ! if(getuid()){ out->line("UID isn't 0, so can't create raw socket => no RAW tcp scan..."); return; } ! #endif raw = true; --- 169,181 ---- *out << "Starting TCP " << scan_type << " scan against " << hostname.c_str() << "...\n"; ! #ifdef __CYGWIN__ ! if(par->forceuid){ ! #else ! if(getuid() || par->forceuid){ ! #endif out->line("UID isn't 0, so can't create raw socket => no RAW tcp scan..."); return; } ! raw = true; Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** icediscover.h 15 Dec 2006 16:35:29 -0000 1.13 --- icediscover.h 15 Dec 2006 17:46:18 -0000 1.14 *************** *** 10,13 **** --- 10,14 ---- #define ACK_PING_STANDART_PORT 80 + #define ARP_PING_STANDART_PORT 138 #define ECHO_ATTEMPTS 5 *************** *** 26,31 **** if(par->verbose>0) *out << "Ack host discovery successfull!" << iceoutput::endl; return true; ! }else if(par->verbose>0) *out << "Ack host discovery failed!" << iceoutput::endl; ! return false; } --- 27,32 ---- if(par->verbose>0) *out << "Ack host discovery successfull!" << iceoutput::endl; return true; ! } ! return false; } *************** *** 35,41 **** #ifndef __CYGWIN__ ! if(!getuid()){ #else ! if(1){ #endif //we're root, so can work with raw sockets --- 36,42 ---- #ifndef __CYGWIN__ ! if(!getuid() || par->forceuid){ #else ! if(par->forceuid){ #endif //we're root, so can work with raw sockets *************** *** 90,94 **** if(icmp -> icmp_type == ICMP_ECHOREPLY && icmp->icmp_id == getpid() && icmplen > 16){ if(par->verbose>0) ! out->line("Recieved icmp ping host discovery reply (echo_reply)..."); free(t_hostname); r.shutdown(); --- 91,95 ---- if(icmp -> icmp_type == ICMP_ECHOREPLY && icmp->icmp_id == getpid() && icmplen > 16){ if(par->verbose>0) ! out->line("Recieved icmp ping host discovery reply (echo_reply)."); free(t_hostname); r.shutdown(); *************** *** 107,115 **** }else out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); ! return false; } ! bool host_discover(const char *hostname, iceparams *par, iceoutput *out){ --- 108,136 ---- }else out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); ! ! return false; } ! bool arp_discovery(const char *hostname, iceparams *par, iceoutput *out){ ! ! icestring ip(hostname); ! ! csocket c(AF_INET, SOCK_DGRAM); ! ! if(par->verbose>0) ! out->line("Sending upd packet for unprivileged arp host discovery..."); ! ! c.sendto(hostname, ARP_PING_STANDART_PORT, " ", 1, 0); ! ! icestring mac = get_arp_from_cache(ip); ! ! if(mac != ""){ ! if(par->verbose>0) ! *out << "Recieved ARP host discovery reply: " << hostname << "'s MAC is " << mac << ".\n"; ! return true; ! }else ! return false; ! } bool host_discover(const char *hostname, iceparams *par, iceoutput *out){ *************** *** 121,125 **** if(par->icmp_echo_ping_discovery) if( icmp_echo_ping(hostname, par, out) ) return true; ! return false; } --- 142,150 ---- if(par->icmp_echo_ping_discovery) if( icmp_echo_ping(hostname, par, out) ) return true; ! ! if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; ! ! if(par->verbose>0) *out << "Ack host discovery failed!" << iceoutput::endl; ! return false; } Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** iceparams.h 15 Dec 2006 17:15:12 -0000 1.9 --- iceparams.h 15 Dec 2006 17:46:18 -0000 1.10 *************** *** 24,28 **** int verbose; //-v -vv -vvv - Verbose params ! int UID; // we're root or not? // Target --- 24,28 ---- int verbose; //-v -vv -vvv - Verbose params ! bool forceuid; // Target *************** *** 44,47 **** --- 44,50 ---- std::vector <int> ps_ports; + bool arp_discovery; // -PM, ARP Ping + std::vector <int> pm_ports; + bool icmp_echo_ping_discovery; // -PE, ICMP Echo (standart) Ping bool icmp_mask_ping_discovery; // -PM, ICMP GetNetMask Ping *************** *** 88,91 **** --- 91,95 ---- icmp_timestamp_ping_discovery = false; udp_ping_discovery = false; + arp_discovery = false; scan_type = TCP_CONNECT_SCAN; *************** *** 95,98 **** --- 99,103 ---- tcpflags = 0; + forceuid = false; } *************** *** 109,113 **** void by_default_init(){ 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) ){ ack_ping_discovery = true; icmp_echo_ping_discovery = true; --- 114,118 ---- void by_default_init(){ 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) ){ ack_ping_discovery = true; icmp_echo_ping_discovery = true; Index: ctarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/ctarget.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ctarget.h 14 Dec 2006 19:45:40 -0000 1.10 --- ctarget.h 15 Dec 2006 17:46:18 -0000 1.11 *************** *** 30,33 **** --- 30,35 ---- if(subtargets[i]->discovered) up++; } + + return up; } Index: TODO =================================================================== RCS file: /cvsroot/javanetsim/IceScan/TODO,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TODO 15 Dec 2006 17:15:12 -0000 1.11 --- TODO 15 Dec 2006 17:46:18 -0000 1.12 *************** *** 7,11 **** + add multiple targets handling; * fix reading port range for ack/udp/syn pings; - + add uid option -- Discovering -- --- 7,10 ---- *************** *** 14,19 **** + TCP SYN Scan (-PS [portlist]) [Key] + ICMP Address Mask Ping (-PM) [QweR] ! + ARP/UDP Discovery ! + ARP Discovery -- Scanning -- --- 13,17 ---- + TCP SYN Scan (-PS [portlist]) [Key] + ICMP Address Mask Ping (-PM) [QweR] ! + ARP/RAW Discovery -- Scanning -- |
From: Alexander B. <da...@us...> - 2006-12-15 17:15:18
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18981 Modified Files: iceparams.h icescan.cc TODO csubtarget.h Log Message: no message Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** icescan.cc 14 Dec 2006 19:45:40 -0000 1.20 --- icescan.cc 15 Dec 2006 17:15:12 -0000 1.21 *************** *** 18,30 **** "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" ! "\t-ST: tcp connect() scan\n" "\t-SB: udp NetBIOS scan\n" "\t-SI: IP Protocol scan\n" ! "\t-SN: Null scan\n" ! "\t-SF: Fin scan\n" ! "\t-SW: window scan\n" ! "\t-SA: ACK scan\n" ! "\t-SS: SYN scan\n" ! "\t-S0: skip scan\n" "PORTS SPECIFICATION:\n" "\t-p <port range>: specify port range to scan (default 1-1024).\n" --- 18,27 ---- "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" ! "\t-ST/SA/SS/SW: tcp connect()/ACK/SYN/Window scan\n" "\t-SB: udp NetBIOS scan\n" "\t-SI: IP Protocol scan\n" ! "\t-SN/SF/SX: stealth Null/FIN/XMAS scan\n" ! "\t-S0: no scan\n" ! "\t--scanflags <flags>: Customize TCP scan flags (SF/SX/SN scans)" "PORTS SPECIFICATION:\n" "\t-p <port range>: specify port range to scan (default 1-1024).\n" *************** *** 45,49 **** if(strlen(argv[i]) >= 2){ if(argv[i][1] == '-'){ ! //DBGOUTPUT("Long option is :" << argv[i]); }else{ //DBGOUTPUT("Option is :" << argv[i]); --- 42,79 ---- if(strlen(argv[i]) >= 2){ if(argv[i][1] == '-'){ ! //DBGOUTPUT("Long option is :" << argv[i]); ! ! if(!strcmp(argv[i], "--scanflags")){ ! if(i+1 < argc){ ! IceRegex re1("(URG|ACK|PSH|RST|SYN|FIN)+"); ! IceRegex re2("(\\d+)"); ! if(re1.match(argv[i+1])){ ! short int tcpflags = 0; ! icestring flags(argv[i+1]); ! ! if(flags.find("URG", 0) != icestring::npos) tcpflags |= TH_URG; ! if(flags.find("PSH", 0) != icestring::npos) tcpflags |= TH_PUSH; ! if(flags.find("ACK", 0) != icestring::npos) tcpflags |= TH_ACK; ! if(flags.find("SYN", 0) != icestring::npos) tcpflags |= TH_SYN; ! if(flags.find("RST", 0) != icestring::npos) tcpflags |= TH_RST; ! if(flags.find("FIN", 0) != icestring::npos) tcpflags |= TH_FIN; ! ! par->tcpflags = tcpflags; ! ! }else if(re2.match(argv[i+1])){ ! par->tcpflags = atoi(argv[i+1]); ! }else{ ! std::cout << "Invalid option format: " << argv[i] << " " << argv[i+1] << std::endl; ! print_help(argv[0]); ! exit(1); ! } ! ! i++; ! } else { std::cout << "Invalid option format: " << argv[i] << std::endl; ! print_help(argv[0]); ! exit(1); ! } ! } ! }else{ //DBGOUTPUT("Option is :" << argv[i]); *************** *** 155,163 **** break; ! case 'p': if(i+1 < argc){ - // IceRegex re1("(\\d|\\,|\\-)+"); IceRegex re1("((\\d+(-\\d+)?),?)+"); if(! re1.match(argv[i+1]) ){ --- 185,192 ---- break; ! case 'p': if(i+1 < argc){ IceRegex re1("((\\d+(-\\d+)?),?)+"); if(! re1.match(argv[i+1]) ){ *************** *** 228,232 **** int main(int argc, char *argv[]){ ! ice_service_name_database isnd("services"); ice_mac_name_database ismd("ieee-oui.txt"); --- 257,261 ---- int main(int argc, char *argv[]){ ! ice_service_name_database isnd("services"); ice_mac_name_database ismd("ieee-oui.txt"); Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** iceparams.h 14 Dec 2006 19:45:40 -0000 1.8 --- iceparams.h 15 Dec 2006 17:15:12 -0000 1.9 *************** *** 58,61 **** --- 58,63 ---- int netbios_port; + + unsigned char tcpflags; // Scan Port Range *************** *** 91,94 **** --- 93,98 ---- sim_connects = 25; netbios_port = NBT_PORT + 10000; + + tcpflags = 0; } Index: TODO =================================================================== RCS file: /cvsroot/javanetsim/IceScan/TODO,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TODO 15 Dec 2006 16:24:58 -0000 1.10 --- TODO 15 Dec 2006 17:15:12 -0000 1.11 *************** *** 23,31 **** * do setting random window/seq(ack and seg) for raw scanning + ARP Scan + Fingerprint (??) - + --tcpflags NUMBER || FLAGS -- set specific tcp flags when raw tcp scan + iceparams::check_right_params() -- Misc -- - + add 'send_icmp_packet' function to crawsocket. - -- Bugs -- --- 23,28 ---- Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** csubtarget.h 15 Dec 2006 16:35:29 -0000 1.23 --- csubtarget.h 15 Dec 2006 17:15:12 -0000 1.24 *************** *** 205,217 **** switch(par->scan_type){ case FIN_SCAN: ! rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN, 0, 0, 0); break; case NULL_SCAN: ! rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, 0, 0, 0, 0); break; case XMAS_SCAN: ! rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | TH_URG | TH_PUSH, 0, 0, 0); break; --- 205,217 ---- switch(par->scan_type){ case FIN_SCAN: ! rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | par->tcpflags, 0, 0, 0); break; case NULL_SCAN: ! rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, par->tcpflags, 0, 0, 0); break; case XMAS_SCAN: ! rawsend.send_tcp_raw(source, hostname, MAGIC_PORT, (*i).first, 0, 0, TH_FIN | TH_URG | TH_PUSH | par->tcpflags, 0, 0, 0); break; |
From: Alexander B. <da...@us...> - 2006-12-15 16:35:36
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4778/icesockets Modified Files: sock_time.h Log Message: no message Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sock_time.h 15 Dec 2006 15:27:57 -0000 1.3 --- sock_time.h 15 Dec 2006 16:35:29 -0000 1.4 *************** *** 4,9 **** #include "sock_types.h" ! void icesleep(int secs, int nsecs){ ! struct timespec ts; ts.tv_sec = secs; --- 4,13 ---- #include "sock_types.h" ! void iceusleep(unsigned long usec){ ! usleep(usec); ! } ! ! void icesleep(int secs, int nsecs = 0){ ! struct timespec ts; ts.tv_sec = secs; |
From: Alexander B. <da...@us...> - 2006-12-15 16:35:34
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4778 Modified Files: icediscover.h csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** csubtarget.h 15 Dec 2006 15:48:51 -0000 1.22 --- csubtarget.h 15 Dec 2006 16:35:29 -0000 1.23 *************** *** 231,239 **** (*i).second.attempt++; ! usleep(1000); } } ! usleep(500000); int bytes; --- 231,239 ---- (*i).second.attempt++; ! iceusleep(1000); } } ! iceusleep(500000); int bytes; *************** *** 313,317 **** bzero(response, 65534); } ! usleep(1000); } } --- 313,317 ---- bzero(response, 65534); } ! iceusleep(1000); } } *************** *** 354,358 **** int j = initiate_connect(scanning_ports); //DBGOUTPUT(j); ! while( ! do_select_round_connect(scanning_ports, subtarget_ports) ) usleep(1000); show_ports(); --- 354,358 ---- int j = initiate_connect(scanning_ports); //DBGOUTPUT(j); ! while( ! do_select_round_connect(scanning_ports, subtarget_ports) ) iceusleep(1000); show_ports(); *************** *** 539,543 **** //DBGOUTPUT("Connecting to " << prt << " using socket id " << scanning_ports[prt].c->get_socketid()); //DBGOUTPUT("!!!"); ! //usleep(10000); } } --- 539,543 ---- //DBGOUTPUT("Connecting to " << prt << " using socket id " << scanning_ports[prt].c->get_socketid()); //DBGOUTPUT("!!!"); ! //iceusleep(10000); } } *************** *** 622,626 **** }else{ //DBGOUTPUT("WRITE"); ! usleep(20000); res = c.write("", 0, 0); //DBGOUTPUT("/WRITE" << res); --- 622,626 ---- }else{ //DBGOUTPUT("WRITE"); ! iceusleep(20000); res = c.write("", 0, 0); //DBGOUTPUT("/WRITE" << res); Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** icediscover.h 15 Dec 2006 16:24:58 -0000 1.12 --- icediscover.h 15 Dec 2006 16:35:29 -0000 1.13 *************** *** 71,78 **** r.send_icmp_packet(hostname, ICMP_ECHO, 0, getpid(), at, 0, buf, sizeof(struct timeval)); ! usleep(200000); } ! char hostname[1024]; char buf[1500]; //1500 == standart IP Packet size --- 71,78 ---- r.send_icmp_packet(hostname, ICMP_ECHO, 0, getpid(), at, 0, buf, sizeof(struct timeval)); ! iceusleep(200000); } ! char hostname[ICEMAXHOSTNAME]; char buf[1500]; //1500 == standart IP Packet size *************** *** 97,101 **** } ! }else usleep(50000); } --- 97,101 ---- } ! }else iceusleep(50000); } |