javanetsim-cvs Mailing List for javaNetSim (Page 15)
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-17 09:59:45
|
Update of /cvsroot/javanetsim/IceScan/vccproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19563/vccproject Modified Files: IceScan.suo Log Message: Index: IceScan.suo =================================================================== RCS file: /cvsroot/javanetsim/IceScan/vccproject/IceScan.suo,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsmdTYp4 and /tmp/cvsVgoJgj differ |
From: Alexander B. <da...@us...> - 2006-12-17 09:59:45
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19563/icesockets Modified Files: crawsocket.h csocket.h sock_err.h sock_pcap.h sock_types.h sock_win.h Log Message: Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** sock_types.h 16 Dec 2006 20:44:19 -0000 1.16 --- sock_types.h 17 Dec 2006 09:59:40 -0000 1.17 *************** *** 14,18 **** #include <signal.h> ! #include <pcap.h> #include <errno.h> --- 14,20 ---- #include <signal.h> ! #ifndef __CYGWIN__ ! #include <pcap.h> ! #endif #include <errno.h> *************** *** 22,26 **** #define __NO_LIBPCRE__ #else ! #include <netinet/if_ether.h> #include <sys/socket.h> --- 24,31 ---- #define __NO_LIBPCRE__ #else ! ! #ifndef __CYGWIN__ ! #include <netinet/if_ether.h> ! #endif #include <sys/socket.h> *************** *** 64,67 **** --- 69,76 ---- typedef int SOCKET; + typedef uint16_t my_uint16_t; + typedef uint32_t my_uint32_t; + typedef uint8_t my_uint8_t; + #define Bzero(a,b) bzero(a, b) #else Index: crawsocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** crawsocket.h 16 Dec 2006 21:05:28 -0000 1.12 --- crawsocket.h 17 Dec 2006 09:59:40 -0000 1.13 *************** *** 87,92 **** } ! int sendto(const char *hostname, const void *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, (sockbuf_type) msg, len, flags); } --- 87,92 ---- } ! int sendto(const char *hostname, const char *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, msg, len, flags); } Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** csocket.h 16 Dec 2006 21:05:28 -0000 1.18 --- csocket.h 17 Dec 2006 09:59:40 -0000 1.19 *************** *** 121,152 **** } }else{ ! fd_set sset; ! struct timeval tv; ! ! nonblock(true); ! ! ::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)); ! FD_ZERO(&sset); ! FD_SET(sid, &sset); ! tv.tv_sec = timeout; ! tv.tv_usec = 0; ! SOCKET ndfs = sid + 1; ! ! #ifdef WIN32 ! int res = select(0, NULL, &sset, NULL, &tv); ! #else ! int res = select(ndfs, NULL, &sset, NULL, &tv); ! #endif ! if (res == SOCKET_ERROR && errno != EINTR){ ! nonblock(false); return ICESOCK_ERRNO; ! } else if (res == 0){ ! nonblock(false); return ICESOCK_TIMEOUT; ! } else nonblock(false); } ! return 0; } --- 121,162 ---- } }else{ ! fd_set sset; ! struct timeval tv; ! ! nonblock(true); ! ! ::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)); ! FD_ZERO(&sset); ! FD_SET(sid, &sset); ! tv.tv_sec = timeout; ! tv.tv_usec = 0; ! SOCKET ndfs = sid + 1; ! ! #ifdef WIN32 ! int res = select(0, NULL, &sset, NULL, &tv); ! #else ! int res = select(ndfs, NULL, &sset, NULL, &tv); ! #endif ! nonblock(false); ! ! if (res == SOCKET_ERROR && errno != EINTR){ ! return ICESOCK_ERRNO; ! } else if (res == 0){ ! int sopt, soptlen; ! getsockopt(SOL_SOCKET, SO_ERROR, (char *) &sopt, (socklen_t *) &soptlen); ! ! DBGOUTPUT(sopt); ! ! if(sopt == ECONNREFUSED) ! return ICESOCK_CONNREF; ! else ! return ICESOCK_TIMEOUT; ! } } ! return 0; } *************** *** 201,205 **** } ! int recvfrom(sockbuf_type buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; --- 211,215 ---- } ! int recvfrom(sockbuf_type buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; *************** *** 216,220 **** } ! int sendto(const char *hostname, int port, const sockbuf_type msg, int len, unsigned int flags){ struct sockaddr_in saddress; int slen; --- 226,230 ---- } ! int sendto(const char *hostname, int port, const char* msg, int len, unsigned int flags){ struct sockaddr_in saddress; int slen; Index: sock_err.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_err.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sock_err.h 15 Dec 2006 15:27:57 -0000 1.2 --- sock_err.h 17 Dec 2006 09:59:40 -0000 1.3 *************** *** 5,8 **** --- 5,9 ---- #define ICESOCK_TIMEOUT 10 // timeout in when connecting or recieving + #define ICESOCK_CONNREF 15 // connection refused #define ICESOCK_PERROR -1 // socket operation error, see perror() #define ICESOCK_ERRNO -2 // socket operation error, see ERRNO Index: sock_win.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_win.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sock_win.h 16 Dec 2006 20:44:19 -0000 1.2 --- sock_win.h 17 Dec 2006 09:59:40 -0000 1.3 *************** *** 32,36 **** } ! void stop_sockets(){} int getpid(){ --- 32,38 ---- } ! void stop_sockets(){ ! WSACleanup(); ! } int getpid(){ *************** *** 43,47 **** #else ! typedef int WSA_DATA; int start_sockets(){ } --- 45,49 ---- #else ! typedef int WSADATA; int start_sockets(){ } Index: sock_pcap.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_pcap.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sock_pcap.h 16 Dec 2006 20:44:19 -0000 1.4 --- sock_pcap.h 17 Dec 2006 09:59:40 -0000 1.5 *************** *** 9,18 **** #define _sock_pcap_H ! #ifdef __CYGWIN__ typedef int pcap_t; ! pcap_t* init_pcap(){ return NULL; } char* readip_pcap(pcap_t* pd, unsigned int *len, struct timeval *rcvd_time){ return NULL; --- 9,22 ---- #define _sock_pcap_H ! #ifdef __CYGWIN__ //There's no pcap in Cygwin :( typedef int pcap_t; ! pcap_t* init_pcap(int index = 0){ return NULL; } + + void listdev_pcap(){ + } + char* readip_pcap(pcap_t* pd, unsigned int *len, struct timeval *rcvd_time){ return NULL; *************** *** 28,32 **** #include "sock_types.h" ! pcap_t* init_pcap(){ int i; char *dev; --- 32,36 ---- #include "sock_types.h" ! pcap_t* init_pcap(int index = 0){ int i; char *dev; *************** *** 34,67 **** pcap_t* descr; ! u_char *ptr; /* printing out hardware header info */ ! /* grab a device to peak into... */ ! dev = pcap_lookupdev(errbuf); ! if(dev == NULL) ! { ! return NULL; ! } ! //printf("DEV: %s\n",dev); ! /* open the device for sniffing. ! pcap_t *pcap_open_live(char *device,int snaplen, int prmisc,int to_ms, ! char *ebuf) ! snaplen - maximum size of packets to capture in bytes ! promisc - set card in promiscuous mode? ! to_ms - time to wait for packets in miliseconds before read ! times out ! errbuf - if something happens, place error string here ! Note if you change "prmisc" param to anything other than zero, you will ! get all packets your device sees, whether they are intendeed for you or ! not!! Be sure you know the rules of the network you are running on ! before you set your card in promiscuous mode!! */ ! return pcap_open_live(dev,BUFSIZ,0,-1,errbuf); ! } --- 38,110 ---- pcap_t* descr; ! if(index){ ! pcap_if_t *alldevs; ! pcap_if_t *d; ! int i=0; ! if(pcap_findalldevs(&alldevs, errbuf) == -1) ! { ! printf("Error in pcap_findalldevs: %s\n", errbuf); ! exit(1); ! } ! ! for(d=alldevs; d; d=d->next) ! i++; ! ! if(i==0) ! { ! printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); ! return NULL; ! } ! for(d=alldevs, i=0; i< index-1 ;d=d->next, i++); ! pcap_t *dev = pcap_open_live(d->name,BUFSIZ,0,-1,errbuf); ! pcap_freealldevs(alldevs); ! return dev; ! }else{ ! dev = pcap_lookupdev(errbuf); ! if(dev == NULL) ! { ! return NULL; ! } ! return pcap_open_live(dev,BUFSIZ,0,-1,errbuf); ! } ! return NULL; ! } ! ! void listdev_pcap(){ ! pcap_if_t *alldevs; ! pcap_if_t *d; ! int i=0; ! char errbuf[PCAP_ERRBUF_SIZE]; ! ! if(pcap_findalldevs(&alldevs, errbuf) == -1) ! { ! printf("Error in pcap_findalldevs: %s\n", errbuf); ! exit(1); ! } ! ! for(d=alldevs; d; d=d->next) ! { ! printf("%d. %s", ++i, d->name); ! if (d->description) ! printf(" (%s)\n", d->description); ! else ! printf(" (No description available)\n"); ! } ! ! pcap_freealldevs(alldevs); ! ! if(i==0) ! { ! printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); ! return; ! } } |
From: Alexander B. <da...@us...> - 2006-12-17 09:59:45
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19563 Modified Files: csubtarget.h icedbs.h icediscover.h iceparams.h icescan.cc Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** icescan.cc 16 Dec 2006 20:44:18 -0000 1.32 --- icescan.cc 17 Dec 2006 09:59:39 -0000 1.33 *************** *** 14,38 **** "\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/PT/PM: ICMP Echo/Timestamp/Mask host discovery\n" "\t-PU: UDP Ping 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-SU: udp 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" "\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); --- 14,41 ---- "\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/PT/PM: ICMP Echo/Timestamp/Mask host discovery\n" "\t-PU: UDP Ping 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-SU: udp 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" "\t You can use: 1-10; 1; 1-10,12-14; etc.\n" + "INTERFACES AND SPOOFING:\n" + "\t--list-interfaces: list all interfaces\n" + "\t-i <iface-number>: use interface <iface-number> for pcap/source interface.\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); *************** *** 127,130 **** --- 130,137 ---- }else if(!strcmp(argv[i], "--uid0")){ par->forceuid = true; + }else if(!strcmp(argv[i], "--list-interfaces")){ + listdev_pcap(); + std::cout << std::endl; + exit(0); }else{ std::cout << "Invalid option: -" << argv[i][1] << std::endl; *************** *** 161,164 **** --- 168,178 ---- break; + case 'i': + if(i+1 < argc){ //UGLY, need more check!!! + par->source_iface = atoi(argv[i+1]); + } + i++; + break; + case 'S': *************** *** 301,304 **** --- 315,320 ---- int main(int argc, char *argv[]){ + //listdev_pcap(); + ice_service_name_database isnd("services"); ice_mac_name_database ismd("ieee-oui.txt"); Index: icedbs.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icedbs.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** icedbs.h 15 Dec 2006 15:48:51 -0000 1.4 --- icedbs.h 17 Dec 2006 09:59:39 -0000 1.5 *************** *** 20,24 **** if(!in){ ! std::cout << "Can't open service names database!" << std::endl; } else { while(!in.eof()){ --- 20,24 ---- if(!in){ ! std::cout << "Warning: Can't open service names database!" << std::endl; } else { while(!in.eof()){ *************** *** 78,82 **** if(!in){ ! std::cout << "Can't open service names database!" << std::endl; } else { while(!in.eof()){ --- 78,82 ---- if(!in){ ! std::cout << "Warning: Can't open MAC vendors database!" << std::endl; } else { while(!in.eof()){ Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** iceparams.h 16 Dec 2006 21:05:28 -0000 1.14 --- iceparams.h 17 Dec 2006 09:59:39 -0000 1.15 *************** *** 26,29 **** --- 26,31 ---- bool forceuid; + int source_iface; + // Target Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** icediscover.h 16 Dec 2006 21:05:28 -0000 1.25 --- icediscover.h 17 Dec 2006 09:59:39 -0000 1.26 *************** *** 12,16 **** #define ACK_PING_STANDART_PORT 80 #else ! #define ACK_PING_STANDART_PORT 135 #endif --- 12,16 ---- #define ACK_PING_STANDART_PORT 80 #else ! #define ACK_PING_STANDART_PORT 80 #endif *************** *** 31,35 **** --- 31,39 ---- s.shutdown(); + #ifdef WIN32 + if(rc != SOCKET_ERROR && rc != ICESOCK_TIMEOUT){ + #else if(!rc){ + #endif if(par->verbose>0) *out << "Ack host discovery successfull!" << iceoutput::endl; return true; *************** *** 90,100 **** } ! char hostname[ICEMAXHOSTNAME]; char buf[1500]; //1500 == standart IP Packet size ! int 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; --- 94,108 ---- } ! char hostname[ICEMAXHOSTNAME]; char buf[1500]; //1500 == standart IP Packet size ! sockaddr_in source; ! int fromlen = sizeof(source); ! ! int len = recvfrom(r.get_socketid(), buf, sizeof(buf), 0, (sockaddr*)&source, &fromlen); if(len > 0){ ! //DBGOUTPUT("!!!!"); ! struct ip *ip = (struct ip *) buf; int hdrlen = ip->ip_hl << 2; Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** csubtarget.h 16 Dec 2006 21:05:28 -0000 1.37 --- csubtarget.h 17 Dec 2006 09:59:39 -0000 1.38 *************** *** 352,593 **** return max; ! } ! ! /* 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"; ! ! #if (__CYGWIN__ || WIN32) //UGLY!!! ! if(par->forceuid){ ! #else ! if(getuid() || par->forceuid){ ! #endif ! out->line("UID isn't 0, so can't create raw socket/load pcap => no RAW tcp scan..."); ! return; ! } ! ! pcap_t* p = init_pcap(); //check for NULL ! ! if(p == NULL){ ! out->line("Can't open pcap: no raw tcp scan. Exitting."); ! 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 l = scanning_ports.size()/MAX_PACKETS; ! if(scanning_ports.size() % MAX_PACKETS != 0) l++; ! ! char filter_exp[256]; ! ! sprintf(filter_exp, "port %d host %s tcp", MAGIC_PORT, hostname.c_str()); ! ! pcap_filter(p, filter_exp); ! ! int maxat; ! ! int covar = 10000; ! ! int attempts = 0; ! while(attempts++ < 5){ ! int j = 0; ! while(j < l){ ! std::map <int, scanning_port>::iterator i = scanning_ports.begin(); ! //DBGOUTPUT(attempts); ! maxat = 0; ! for(int k=0; k < MAX_PACKETS*j; k++) i++; ! for(int k = j*MAX_PACKETS; (k < (j+1)*MAX_PACKETS) && i!= scanning_ports.end(); ++i, k++){ ! 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; ! } ! gettimeofday(&((*i).second.tv), 0); - //DBGOUTPUT("Sending:" << (*i).second.attempt); ! (*i).second.attempt++; ! ! maxat++; ! recieve_tcp_raw(p, rawsend, source, saddress, scanning_ports, MAGIC_PORT, 10, 0); ! } ! } ! j++; ! //iceusleep(1000); ! recieve_tcp_raw(p, rawsend, source, saddress, scanning_ports, MAGIC_PORT, (maxat) * covar + 10000, maxat); ! ! //DBGOUTPUT(covar); } ! } ! 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"; ! close_pcap(p); } ! int recieve_tcp_raw(pcap_t* p, crawsocket &rawsend, icestring &source, struct sockaddr_in &saddress, std::map <int, scanning_port> &scanning_ports, int MAGIC_PORT, int timeout, int packets){ ! int bytes; ! char *response; ! struct iphdr *ip; ! struct tcphdr *tcp; ! unsigned int len; ! int maxtimeval = 0; ! struct timeval tv1, tv2, tv3; ! gettimeofday(&tv1, 0); ! bool stop = false; ! int port; ! ! //DBGOUTPUT("!!!!!"); ! //while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ ! while(!stop){ ! response = readip_pcap(p, &len, NULL); ! port = 0; ! if(response){ ! ip = (struct iphdr *) response; ! if(ip->saddr = saddress.sin_addr.s_addr && ip->protocol == IPPROTO_TCP){ ! 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)) { ! port = ntohs(tcp->th_sport); ! if(scanning_ports.find(port) != scanning_ports.end()){ ! if(!scanning_ports[port].done){ ! set_port_status(port, PORT_CLOSED, "tcp"); ! scanning_ports[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); ! } } ! gettimeofday(&tv2, 0); ! ! if(port){ ! if(SUB_TIMEVALS(tv2,scanning_ports[port].tv) > maxtimeval) ! maxtimeval = SUB_TIMEVALS(tv2,scanning_ports[port].tv); ! } ! ! if(SUB_TIMEVALS(tv2,tv1) >= timeout || SUB_TIMEVALS(tv2,tv1) > MAX_RAW_WAIT + packets * 500) ! stop = true; ! } ! ! return maxtimeval; } void shutdown_scansocket(int j){ --- 352,592 ---- return max; ! } ! /* 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"; ! ! #if (__CYGWIN__ || WIN32) //UGLY!!! ! if(!par->forceuid){ ! #else ! if(!getuid() || !par->forceuid){ ! #endif ! out->line("UID isn't 0, so can't create raw socket/load pcap => no RAW tcp scan..."); ! return; ! } ! ! pcap_t* p = init_pcap(par->source_iface); //check for NULL ! ! if(p == NULL){ ! out->line("Can't open pcap: no raw tcp scan. Exitting."); ! return; ! } ! ! 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 l = scanning_ports.size()/MAX_PACKETS; ! if(scanning_ports.size() % MAX_PACKETS != 0) l++; ! ! char filter_exp[256]; ! ! sprintf(filter_exp, "port %d host %s tcp", MAGIC_PORT, hostname.c_str()); ! ! pcap_filter(p, filter_exp); ! ! int maxat; ! ! int covar = 10000; ! ! int attempts = 0; ! while(attempts++ < 5){ ! int j = 0; ! while(j < l){ ! std::map <int, scanning_port>::iterator i = scanning_ports.begin(); ! //DBGOUTPUT(attempts); ! maxat = 0; ! for(int k=0; k < MAX_PACKETS*j; k++) i++; ! for(int k = j*MAX_PACKETS; (k < (j+1)*MAX_PACKETS) && i!= scanning_ports.end(); ++i, k++){ ! 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; ! } ! gettimeofday(&((*i).second.tv), 0); ! //DBGOUTPUT("Sending:" << (*i).second.attempt); ! (*i).second.attempt++; ! maxat++; ! recieve_tcp_raw(p, rawsend, source, saddress, scanning_ports, MAGIC_PORT, 10, 0); } ! } ! j++; ! //iceusleep(1000); ! ! recieve_tcp_raw(p, rawsend, source, saddress, scanning_ports, MAGIC_PORT, (maxat) * covar + 10000, maxat); ! //DBGOUTPUT(covar); ! } } + + 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"; ! ! close_pcap(p); ! } ! ! int recieve_tcp_raw(pcap_t* p, crawsocket &rawsend, icestring &source, struct sockaddr_in &saddress, std::map <int, scanning_port> &scanning_ports, int MAGIC_PORT, int timeout, int packets){ ! int bytes; ! char *response; ! struct iphdr *ip; ! struct tcphdr *tcp; ! unsigned int len; ! int maxtimeval = 0; ! struct timeval tv1, tv2, tv3; ! gettimeofday(&tv1, 0); ! bool stop = false; ! int port; ! ! //DBGOUTPUT("!!!!!"); ! //while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ ! while(!stop){ ! response = readip_pcap(p, &len, NULL); ! port = 0; ! if(response){ ! ip = (struct iphdr *) response; ! if(ip->saddr = saddress.sin_addr.s_addr && ip->protocol == IPPROTO_TCP){ ! 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)) { ! port = ntohs(tcp->th_sport); ! if(scanning_ports.find(port) != scanning_ports.end()){ ! if(!scanning_ports[port].done){ ! set_port_status(port, PORT_CLOSED, "tcp"); ! scanning_ports[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); ! } } + gettimeofday(&tv2, 0); + + if(port){ + if(SUB_TIMEVALS(tv2,scanning_ports[port].tv) > maxtimeval) + maxtimeval = SUB_TIMEVALS(tv2,scanning_ports[port].tv); + } + + if(SUB_TIMEVALS(tv2,tv1) >= timeout || SUB_TIMEVALS(tv2,tv1) > MAX_RAW_WAIT + packets * 500) + stop = true; + } + + return maxtimeval; + } void shutdown_scansocket(int j){ *************** *** 723,729 **** switch(sopt){ case 0: ! #ifdef __CYGWIN__ ! //case 1: ! if(false){ #else if(FD_ISSET(scan_sockets[(*i).second.socket_ptr].sid, &fd_r)){ --- 722,727 ---- switch(sopt){ case 0: ! #ifdef __CYGWIN__ ! if(false){ #else if(FD_ISSET(scan_sockets[(*i).second.socket_ptr].sid, &fd_r)){ |
From: Alexander B. <da...@us...> - 2006-12-16 21:05:32
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21036 Modified Files: csubtarget.h icediscover.h iceparams.h Log Message: Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** iceparams.h 16 Dec 2006 17:29:16 -0000 1.13 --- iceparams.h 16 Dec 2006 21:05:28 -0000 1.14 *************** *** 125,129 **** const int ranges_cnt = 2; ! int ranges[ranges_cnt][2] = { {20, 25}, {130, 140} }; //int ranges[ranges_cnt][2] = { {1, 1024}, {3388, 3390} }; --- 125,129 ---- const int ranges_cnt = 2; ! int ranges[ranges_cnt][2] = { {20, 25}, {134, 135} }; //int ranges[ranges_cnt][2] = { {1, 1024}, {3388, 3390} }; Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** icediscover.h 16 Dec 2006 20:44:18 -0000 1.24 --- icediscover.h 16 Dec 2006 21:05:28 -0000 1.25 *************** *** 9,13 **** #include "iceoutput.h" ! #define ACK_PING_STANDART_PORT 80 #define ARP_PING_STANDART_PORT 138 #define ATTEMPTS 5 --- 9,18 ---- #include "iceoutput.h" ! #ifndef WIN32 ! #define ACK_PING_STANDART_PORT 80 ! #else ! #define ACK_PING_STANDART_PORT 135 ! #endif ! #define ARP_PING_STANDART_PORT 138 #define ATTEMPTS 5 Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** csubtarget.h 16 Dec 2006 20:44:18 -0000 1.36 --- csubtarget.h 16 Dec 2006 21:05:28 -0000 1.37 *************** *** 365,371 **** if(par->verbose > 0) ! *out << "Starting TCP " << scan_type << " scan against " << hostname.c_str() << "...\n"; ! #ifdef __CYGWIN__ if(par->forceuid){ #else --- 365,371 ---- if(par->verbose > 0) ! *out << "Starting TCP " << scan_type << " scan against " << hostname.c_str() << "...\n"; ! #if (__CYGWIN__ || WIN32) //UGLY!!! if(par->forceuid){ #else *************** *** 386,390 **** domain = (int) SOCK_RAW; ! len == make_sockname(saddress, hostname.c_str(), 0, domain); if(gethostname(local_hostname, 80)) exit(-1); --- 386,390 ---- domain = (int) SOCK_RAW; ! len = make_sockname(saddress, hostname.c_str(), 0, domain); if(gethostname(local_hostname, 80)) exit(-1); |
From: Alexander B. <da...@us...> - 2006-12-16 21:05:32
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21036/icesockets Modified Files: crawsocket.h csocket.h Log Message: Index: crawsocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** crawsocket.h 16 Dec 2006 20:44:18 -0000 1.11 --- crawsocket.h 16 Dec 2006 21:05:28 -0000 1.12 *************** *** 146,151 **** int slen, dlen; ! slen == make_sockname(saddress, source.c_str(), 0, domain); ! dlen == make_sockname(daddress, destination.c_str(), 0, domain); Bzero(packet, sizeof(iphdr) + sizeof(tcphdr)); --- 146,151 ---- int slen, dlen; ! slen = make_sockname(saddress, source.c_str(), 0, domain); ! dlen = make_sockname(daddress, destination.c_str(), 0, domain); Bzero(packet, sizeof(iphdr) + sizeof(tcphdr)); Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** csocket.h 16 Dec 2006 20:44:18 -0000 1.17 --- csocket.h 16 Dec 2006 21:05:28 -0000 1.18 *************** *** 103,113 **** int len; ! if((len == make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); if(!timeout){ if(block){ if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) == SOCKET_ERROR) ! return sockerror("connect"); }else{ if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) != SOCKET_ERROR) --- 103,118 ---- int len; ! if(!(len = make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); if(!timeout){ if(block){ + if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) == SOCKET_ERROR) ! #ifndef WIN32 //UGLY!!!! ! return sockerror("connect"); ! #else ! ; ! #endif }else{ if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) != SOCKET_ERROR) *************** *** 116,123 **** } }else{ ! fd_set sset; struct timeval tv; ! nonblock(true); ::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)); --- 121,128 ---- } }else{ ! fd_set sset; struct timeval tv; ! nonblock(true); ::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)); *************** *** 151,155 **** int len; ! if((len == make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); --- 156,160 ---- int len; ! if(!(len = make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); *************** *** 167,171 **** int len; ! if((len == make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); --- 172,176 ---- int len; ! if(!(len = make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); *************** *** 214,218 **** struct sockaddr_in saddress; int slen; ! if((slen == make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); --- 219,223 ---- struct sockaddr_in saddress; int slen; ! if(!(slen = make_sockname(saddress, hostname, port, domain))) return sockerror("sockname"); |
From: Alexander B. <da...@us...> - 2006-12-16 21:05:32
|
Update of /cvsroot/javanetsim/IceScan/vccproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21036/vccproject Modified Files: IceScan.suo IceScan.vcproj.ACER.85672.user Log Message: Index: IceScan.suo =================================================================== RCS file: /cvsroot/javanetsim/IceScan/vccproject/IceScan.suo,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsARInt8 and /tmp/cvsZt9QyY differ Index: IceScan.vcproj.ACER.85672.user =================================================================== RCS file: /cvsroot/javanetsim/IceScan/vccproject/IceScan.vcproj.ACER.85672.user,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IceScan.vcproj.ACER.85672.user 16 Dec 2006 20:44:19 -0000 1.1 --- IceScan.vcproj.ACER.85672.user 16 Dec 2006 21:05:28 -0000 1.2 *************** *** 11,16 **** <DebugSettings Command="$(TargetPath)" ! WorkingDirectory="" ! CommandArguments="" Attach="false" DebuggerType="3" --- 11,16 ---- <DebugSettings Command="$(TargetPath)" ! WorkingDirectory="C:\IceScan" ! CommandArguments="-SF -PA -v 80.70.228.177" Attach="false" DebuggerType="3" *************** *** 23,27 **** Environment="" EnvironmentMerge="true" ! DebuggerFlavor="" MPIRunCommand="" MPIRunArguments="" --- 23,27 ---- Environment="" EnvironmentMerge="true" ! DebuggerFlavor="0" MPIRunCommand="" MPIRunArguments="" |
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12835/icesockets Modified Files: crawsocket.h csocket.h iceregex.h sock_arp.h sock_name.h sock_pcap.h sock_time.h sock_types.h sock_win.h Log Message: Index: sock_arp.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_arp.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sock_arp.h 15 Dec 2006 15:27:57 -0000 1.3 --- sock_arp.h 16 Dec 2006 20:44:18 -0000 1.4 *************** *** 13,17 **** icestring get_arp_from_cache(icestring &ip) { ! #ifdef __CYGWIN__ return ""; #else --- 13,17 ---- icestring get_arp_from_cache(icestring &ip) { ! #if (__CYGWIN__ || WIN32) return ""; #else Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** sock_types.h 16 Dec 2006 17:29:16 -0000 1.15 --- sock_types.h 16 Dec 2006 20:44:19 -0000 1.16 *************** *** 12,28 **** #include <time.h> #include <sys/timeb.h> #include <errno.h> ! #include <sys/socket.h> ! #include <arpa/inet.h> ! #ifndef __CYGWIN__ ! #include <net/if_arp.h> #endif ! #include <netinet/in.h> ! #include <netinet/ip.h> ! #include <netdb.h> #include <cstdio> --- 12,54 ---- #include <time.h> #include <sys/timeb.h> + #include <signal.h> + #include <pcap.h> + #include <errno.h> ! #ifdef WIN32 ! #define __WIN32__ ! #define __NO_LIBPCRE__ ! #else ! #include <netinet/if_ether.h> ! #include <sys/socket.h> ! #include <arpa/inet.h> ! ! #ifndef __CYGWIN__ ! #include <net/if_arp.h> ! #endif ! ! #include <netinet/in.h> ! #include <netinet/ip.h> ! #include <netdb.h> ! ! #include <sys/ioctl.h> ! ! #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 ! ! #include <pthread.h> #endif ! #include <cstdio> *************** *** 30,45 **** #include <fcntl.h> - #include <sys/ioctl.h> - - #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 --- 56,59 ---- *************** *** 50,65 **** typedef int SOCKET; #endif ! #define my_uint16_t uint16_t ! #define my_uint32_t uint32_t ! #define my_uint8_t uint8_t struct pseudo_header { ! my_uint32_t s_addr; ! my_uint32_t d_addr; ! my_uint8_t zero; ! my_uint8_t protocol; ! my_uint16_t length; }; --- 64,97 ---- typedef int SOCKET; + #define Bzero(a,b) bzero(a, b) + #else + #define Bzero(a,b) memset(a,0,b); + + typedef UINT16 uint16_t; + typedef UINT32 uint32_t; + typedef UINT8 uint8_t; + + typedef UINT16 my_uint16_t; + typedef UINT32 my_uint32_t; + typedef UINT8 my_uint8_t; + + typedef UINT16 u_int16_t; //UGLY + typedef UINT8 u_int8_t; + + typedef UINT16 n_short; + typedef UINT32 n_long; + + typedef long n_time; //UGLY, need to check... + #endif ! struct pseudo_header { ! uint32_t src_addr; ! uint32_t dst_addr; ! uint8_t zero; ! uint8_t protocol; ! uint16_t length; }; *************** *** 73,81 **** --- 105,208 ---- // Structure and constants for icmp packets + #ifdef __CYGWIN__ #include <sys/param.h> #include <sys/file.h> #include <netinet/in_systm.h> + #endif + + #ifdef WIN32 + //#define _CRT_SECURE_NO_DEPRECATE + #define EWOULDBLOCK WSAEWOULDBLOCK + #define EINPROGRESS WSAEINPROGRESS + #define EALREADY WSAEALREADY + #define ENOTSOCK WSAENOTSOCK + #define EDESTADDRREQ WSAEDESTADDRREQ + #define EMSGSIZE WSAEMSGSIZE + #define EPROTOTYPE WSAEPROTOTYPE + #define ENOPROTOOPT WSAENOPROTOOPT + #define EPROTONOSUPPORT WSAEPROTONOSUPPORT + #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT + #define EOPNOTSUPP WSAEOPNOTSUPP + #define EPFNOSUPPORT WSAEPFNOSUPPORT + #define EAFNOSUPPORT WSAEAFNOSUPPORT + #define EADDRINUSE WSAEADDRINUSE + #define EADDRNOTAVAIL WSAEADDRNOTAVAIL + #define ENETDOWN WSAENETDOWN + #define ENETUNREACH WSAENETUNREACH + #define ENETRESET WSAENETRESET + #define ECONNABORTED WSAECONNABORTED + #define ECONNRESET WSAECONNRESET + #define ENOBUFS WSAENOBUFS + #define EISCONN WSAEISCONN + #define ENOTCONN WSAENOTCONN + #define ESHUTDOWN WSAESHUTDOWN + #define ETOOMANYREFS WSAETOOMANYREFS + #define ETIMEDOUT WSAETIMEDOUT + #define ECONNREFUSED WSAECONNREFUSED + #define ELOOP WSAELOOP + #define EHOSTDOWN WSAEHOSTDOWN + #define EHOSTUNREACH WSAEHOSTUNREACH + #define EPROCLIM WSAEPROCLIM + #define EUSERS WSAEUSERS + #define EDQUOT WSAEDQUOT + #define ESTALE WSAESTALE + #define EREMOTE WSAEREMOTE + + #define tcp_seq unsigned int + + #define TH_FIN 0x01 + #define TH_SYN 0x02 + #define TH_RST 0x04 + #define TH_PUSH 0x08 + #define TH_ACK 0x10 + #define TH_URG 0x20 + + //UGLY, Copy from linux!!! + struct ip{ + u_int8_t ip_hv; /* header and version */ + 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 */ + 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 */ + }; + + #define ip_hl ip_hv&0x0f + #define ip_v ip_hv>>4 + + struct tcphdr { + u_short th_sport; /* source port */ + u_short th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ + #if BYTE_ORDER == LITTLE_ENDIAN + u_int th_x2:4, /* (unused) */ + th_off:4; /* data offset */ + #else if BYTE_ORDER == BIG_ENDIAN + u_int th_off:4, /* data offset */ + th_x2:4; /* (unused) */ + #endif + u_char th_flags; + #define TH_FIN 0x01 + #define TH_SYN 0x02 + #define TH_RST 0x04 + #define TH_PUSH 0x08 + #define TH_ACK 0x10 + #define TH_URG 0x20 + #define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + + u_short th_win; /* window */ + u_short th_sum; /* checksum */ + u_short th_urp; /* urgent pointer */ + }; + + #endif + + #if (__CYGWIN__ || WIN32) /* * Structure of an icmp header. Index: sock_name.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_name.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sock_name.h 15 Dec 2006 15:27:57 -0000 1.9 --- sock_name.h 16 Dec 2006 20:44:18 -0000 1.10 *************** *** 79,83 **** strncpy(hname, nisname, len); ! bzero(&hints, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; --- 79,83 ---- strncpy(hname, nisname, len); ! Bzero(&hints, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sock_time.h 16 Dec 2006 17:18:28 -0000 1.8 --- sock_time.h 16 Dec 2006 20:44:19 -0000 1.9 *************** *** 6,9 **** --- 6,45 ---- #define SUB_TIMEVALS(a,b) (((a).tv_sec - (b).tv_sec) * 1000000 + (a).tv_usec - (b).tv_usec) + #ifdef WIN32 + #define usleep(t) Sleep((t) / 1000) + + #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) || defined(__WATCOMC__) + #define DELTA_EPOCH_IN_USEC 11644473600000000Ui64 + #else + #define DELTA_EPOCH_IN_USEC 11644473600000000ULL + #endif + + static u_int64_t filetime_to_unix_epoch (const FILETIME *ft) + { + u_int64_t res = (u_int64_t) ft->dwHighDateTime << 32; + + res |= ft->dwLowDateTime; + res /= 10; + res -= DELTA_EPOCH_IN_USEC; + return (res); + } + + int gettimeofday (struct timeval *tv, void *tz_U_) + { + FILETIME ft; + u_int64_t tim; + + if (!tv) { + errno = EINVAL; + return (-1); + } + GetSystemTimeAsFileTime (&ft); + tim = filetime_to_unix_epoch (&ft); + tv->tv_sec = (long) (tim / 1000000L); + tv->tv_usec = (long) (tim % 1000000L); + return (0); + } + #endif + void iceusleep(unsigned long usec){ usleep(usec); *************** *** 11,20 **** void icesleep(int secs, int nsecs = 0){ ! struct timespec ts; ts.tv_sec = secs; ts.tv_nsec = nsecs; nanosleep (&ts, NULL); ! } --- 47,59 ---- void icesleep(int secs, int nsecs = 0){ ! #ifndef WIN32 ! struct timespec ts; ts.tv_sec = secs; ts.tv_nsec = nsecs; nanosleep (&ts, NULL); ! #else ! usleep(secs + nsecs * 1000); ! #endif } Index: crawsocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** crawsocket.h 16 Dec 2006 14:42:42 -0000 1.10 --- crawsocket.h 16 Dec 2006 20:44:18 -0000 1.11 *************** *** 81,85 **** int rc = 0; ! if( rc = ::setsockopt(sid, level, opname, optval, optlen) > 0 ) sockerror("setsockopt"); --- 81,85 ---- int rc = 0; ! if( rc = ::setsockopt(sid, level, opname, (sockbuf_type) optval, optlen) > 0 ) sockerror("setsockopt"); *************** *** 88,101 **** int sendto(const char *hostname, const void *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, msg, len, flags); } int recvfrom(void *buf, int len, unsigned int flags, char *srchostname){ ! return csocket::recvfrom(buf, len, flags, srchostname, NULL); } ! void nonblock(bool lck){ ! csocket::nonblock(lck); ! } bool state(){ --- 88,101 ---- int sendto(const char *hostname, const void *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, (sockbuf_type) msg, len, flags); } int recvfrom(void *buf, int len, unsigned int flags, char *srchostname){ ! return csocket::recvfrom((sockbuf_type) buf, len, flags, srchostname, NULL); } ! void nonblock(bool lck){ ! csocket::nonblock(lck); ! } bool state(){ *************** *** 103,107 **** } ! int get_socketid(){ return sid; } --- 103,107 ---- } ! SOCKET get_socketid(){ return sid; } *************** *** 127,230 **** } ! int send_tcp_raw( icestring source, icestring destination, unsigned short sport, unsigned short dport, unsigned long seq, ! unsigned long ack, unsigned char flags, unsigned short window, char *data, unsigned short datalen) ! { ! ! ! char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen]; ! struct iphdr *ip = (struct iphdr *) packet; ! struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); ! struct pseudo_header *pseudo = (struct pseudo_header *) (packet + sizeof(struct iphdr) - sizeof(struct pseudo_header)); ! int res; ! char myname[ICEMAXHOSTNAME + 1]; ! struct sockaddr_in saddress, daddress; ! int slen, dlen; ! slen == make_sockname(saddress, source.c_str(), 0, domain); ! dlen == make_sockname(daddress, destination.c_str(), 0, domain); ! bzero(packet, sizeof(iphdr) + sizeof(tcphdr)); ! pseudo->s_addr = saddress.sin_addr.s_addr; ! pseudo->d_addr = daddress.sin_addr.s_addr; ! pseudo->protocol = IPPROTO_TCP; ! pseudo->length = htons(sizeof(struct tcphdr) + datalen); ! tcp->th_sport = htons(sport); ! tcp->th_dport = htons(dport); ! if (seq) ! tcp->th_seq = htonl(seq); ! else tcp->th_seq = rand() + rand(); ! if (flags & TH_ACK && ack) ! tcp->th_ack = htonl(seq); ! else if (flags & TH_ACK) ! tcp->th_ack = rand() + rand(); ! tcp->th_off = 5; ! tcp->th_flags = flags; ! unsigned short ttl = 121; ! ! if (window) ! tcp->th_win = window; ! else tcp->th_win = htons(1024 * (ttl % 4 + 1)); ! tcp->th_sum = in_chksum((unsigned short *)pseudo, sizeof(struct tcphdr) + ! sizeof(struct pseudo_header) + datalen); ! bzero(packet, sizeof(struct iphdr)); ! ip->version = 4; ! ip->ihl = 5; ! ip->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen); ! ip->id = rand(); ! ip->ttl = ttl; ! ip->protocol = IPPROTO_TCP; ! ip->saddr = saddress.sin_addr.s_addr; ! ip->daddr = daddress.sin_addr.s_addr; ! ip->check = in_chksum((unsigned short *)ip, sizeof(struct iphdr)); ! //print_tcppacket(packet,ntohs(ip->tot_len)); ! if ((res = sendto(destination.c_str(), packet, ntohs(ip->tot_len), 0)) == -1) ! { ! perror("sendto in send_tcp_raw"); ! return -1; ! } ! return res; } - - int send_icmp_packet(icestring Hostname, int Icmp_type, int Icmp_code, int Icmp_id, - int Icmp_seq, int Icmp_checksum, void* Icmp_data, int Icmp_data_len){ - - char buftosend[1500]; ! const char *hostname = Hostname.c_str(); ! bzero(buftosend, 1500); ! struct icmp *icmp = (struct icmp *) buftosend; ! icmp->icmp_type = Icmp_type; ! icmp->icmp_code = Icmp_code; ! icmp->icmp_id = Icmp_id; ! memcpy(icmp->icmp_data, Icmp_data, Icmp_data_len); ! icmp->icmp_seq = Icmp_seq; ! int len = 8 + 56; // icmp header + icmp data ! if(!Icmp_checksum) ! icmp->icmp_cksum = crawsocket::in_chksum( (unsigned short * ) icmp, len); ! else ! icmp->icmp_cksum = Icmp_checksum; ! return sendto(hostname, buftosend, len, 0); ! } // from Fyodor's "The Art of Port Scanning" ! static int print_tcppacket(char *packet, int readdata) { struct iphdr *ip = (struct iphdr *) packet; struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); --- 127,235 ---- } ! int send_tcp_raw( icestring source, icestring destination, unsigned short sport, unsigned short dport, unsigned long seq, ! unsigned long ack, unsigned char flags, unsigned short window, char *data, const unsigned short datalen) ! { ! #ifdef WIN32 ! char *packet = (char *) malloc(sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen); ! #else ! char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen]; ! #endif ! struct iphdr *ip = (struct iphdr *) packet; ! struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); ! struct pseudo_header *pseudo = (struct pseudo_header *) (packet + sizeof(struct iphdr) - sizeof(struct pseudo_header)); ! int res; ! char myname[ICEMAXHOSTNAME + 1]; ! struct sockaddr_in saddress, daddress; ! int slen, dlen; ! slen == make_sockname(saddress, source.c_str(), 0, domain); ! dlen == make_sockname(daddress, destination.c_str(), 0, domain); ! Bzero(packet, sizeof(iphdr) + sizeof(tcphdr)); ! pseudo->src_addr = saddress.sin_addr.s_addr; ! pseudo->dst_addr = daddress.sin_addr.s_addr; ! pseudo->protocol = IPPROTO_TCP; ! pseudo->length = htons(sizeof(struct tcphdr) + datalen); ! tcp->th_sport = htons(sport); ! tcp->th_dport = htons(dport); ! if (seq) ! tcp->th_seq = htonl(seq); ! else tcp->th_seq = rand() + rand(); ! if (flags & TH_ACK && ack) ! tcp->th_ack = htonl(seq); ! else if (flags & TH_ACK) ! tcp->th_ack = rand() + rand(); ! tcp->th_off = 5; ! tcp->th_flags = flags; ! unsigned short ttl = 121; ! ! if (window) ! tcp->th_win = window; ! else tcp->th_win = htons(1024 * (ttl % 4 + 1)); ! tcp->th_sum = in_chksum((unsigned short *)pseudo, sizeof(struct tcphdr) + ! sizeof(struct pseudo_header) + datalen); ! Bzero(packet, sizeof(struct iphdr)); ! ip->version = 4; ! ip->ihl = 5; ! ip->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen); ! ip->id = rand(); ! ip->ttl = ttl; ! ip->protocol = IPPROTO_TCP; ! ip->saddr = saddress.sin_addr.s_addr; ! ip->daddr = daddress.sin_addr.s_addr; ! ip->check = in_chksum((unsigned short *)ip, sizeof(struct iphdr)); ! //print_tcppacket(packet,ntohs(ip->tot_len)); ! if ((res = sendto(destination.c_str(), packet, ntohs(ip->tot_len), 0)) == -1) ! { ! perror("sendto in send_tcp_raw"); ! free(packet); ! return -1; } ! free(packet); ! return res; ! } ! ! int send_icmp_packet(icestring Hostname, int Icmp_type, int Icmp_code, int Icmp_id, ! int Icmp_seq, int Icmp_checksum, void* Icmp_data, int Icmp_data_len){ ! ! char buftosend[1500]; ! const char *hostname = Hostname.c_str(); ! Bzero(buftosend, 1500); ! struct icmp *icmp = (struct icmp *) buftosend; ! icmp->icmp_type = Icmp_type; ! icmp->icmp_code = Icmp_code; ! icmp->icmp_id = Icmp_id; ! memcpy(icmp->icmp_data, Icmp_data, Icmp_data_len); ! icmp->icmp_seq = Icmp_seq; ! int len = 8 + 56; // icmp header + icmp data ! if(!Icmp_checksum) ! icmp->icmp_cksum = crawsocket::in_chksum( (unsigned short * ) icmp, len); ! else ! icmp->icmp_cksum = Icmp_checksum; ! ! return sendto(hostname, buftosend, len, 0); ! } // from Fyodor's "The Art of Port Scanning" ! /*static int print_tcppacket(char *packet, int readdata) { struct iphdr *ip = (struct iphdr *) packet; struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); *************** *** 274,278 **** return 0; ! } }; --- 279,283 ---- return 0; ! } */ }; Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** csocket.h 16 Dec 2006 20:25:13 -0000 1.16 --- csocket.h 16 Dec 2006 20:44:18 -0000 1.17 *************** *** 9,12 **** --- 9,18 ---- #include "sock_arp.h" + #ifdef WIN32 + typedef char* sockbuf_type; + #else + typedef void* sockbuf_type; + #endif + #define MIN_MAGIC_PORT 20000 #define MAX_MAGIC_PORT 65535 *************** *** 82,86 **** void close(){ ! ::close(sid); } --- 88,96 ---- void close(){ ! #ifndef WIN32 ! ::close(sid); ! #else ! ::closesocket(sid); ! #endif } *************** *** 119,123 **** tv.tv_usec = 0; ! int ndfs = sid + 1; #ifdef WIN32 --- 129,133 ---- tv.tv_usec = 0; ! SOCKET ndfs = sid + 1; #ifdef WIN32 *************** *** 169,173 **** struct sockaddr_in sraddress; socklen_t size = sizeof(sraddress); ! int resultid = ::accept( sid, (struct sockaddr *) &sraddress, &size); if(resultid > -1){ if (remotehost) strcpy(remotehost, iptohost(sraddress.sin_addr)); --- 179,183 ---- struct sockaddr_in sraddress; socklen_t size = sizeof(sraddress); ! SOCKET resultid = ::accept( sid, (struct sockaddr *) &sraddress, &size); if(resultid > -1){ if (remotehost) strcpy(remotehost, iptohost(sraddress.sin_addr)); *************** *** 180,184 **** int rc = 0; ! if( rc = ::getsockopt(sid, level, opname, optval, optlen) > 0 ) sockerror("getsockopt"); --- 190,194 ---- int rc = 0; ! if( rc = ::getsockopt(sid, level, opname, (sockbuf_type) optval, optlen) > 0 ) sockerror("getsockopt"); *************** *** 186,190 **** } ! int recvfrom(void *buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; --- 196,200 ---- } ! int recvfrom(sockbuf_type buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; *************** *** 201,225 **** } ! int sendto(const char *hostname, int port, const void *msg, int len, unsigned int flags){ ! ! // struct addrinfo hints, *res; ! // int salen; ! // char cportbuf[8]; ! // char *cport = cportbuf; ! // ! // if(port == 0) cport = NULL; ! // else sprintf(cport, "%d", port); ! // ! // bzero(&hints, sizeof(struct addrinfo)); ! // ! // hints.ai_flags = AI_CANONNAME; ! // hints.ai_family = domain; ! // hints.ai_socktype = type; ! ! // if( getaddrinfo(hostname, cport, &hints, &res) != 0 ) ! // return sockerror("getaddrinfo"); ! ! // return ::sendto(sid, msg, len, flags, (const sockaddr *) res->ai_addr, res->ai_addrlen); ! struct sockaddr_in saddress; int slen; --- 211,215 ---- } ! int sendto(const char *hostname, int port, const sockbuf_type msg, int len, unsigned int flags){ struct sockaddr_in saddress; int slen; *************** *** 239,243 **** } ! int get_socketid(){ return sid; } --- 229,233 ---- } ! SOCKET get_socketid(){ return sid; } *************** *** 252,255 **** --- 242,246 ---- void nonblock(bool lck){ + #ifndef WIN32 int arg = fcntl(sid, F_GETFL, NULL); *************** *** 265,268 **** --- 256,272 ---- if( fcntl(sid, F_SETFL, arg) < 0 ){ perror("Error in fcntl(.., F_GETFL, ...)."); throw "Error in fcntl(.., F_SETFL, ...)."; } + #else + ULONG NonBlock; + if(lck) + NonBlock = 1; + else + NonBlock = 0; + + if (ioctlsocket(sid, FIONBIO, &NonBlock) == SOCKET_ERROR) + { + perror("ioctlsocket() failed"); + exit(-1); + } + #endif } Index: sock_win.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_win.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sock_win.h 16 Dec 2006 17:29:16 -0000 1.1 --- sock_win.h 16 Dec 2006 20:44:19 -0000 1.2 *************** *** 15,23 **** #pragma comment(lib, "ws2_32.lib") ! #include <winsock2.h> ! WSA_DATA start_sockets(){ ! WSA_DATA wsa; if(WSAStartup(MAKEWORD(2,0), &wsa) != 0x0){ --- 15,26 ---- #pragma comment(lib, "ws2_32.lib") ! #pragma comment(lib, "wpcap.lib") ! #include <winsock2.h> + #include <ws2tcpip.h> + #include <process.h> ! WSADATA start_sockets(){ ! WSADATA wsa; if(WSAStartup(MAKEWORD(2,0), &wsa) != 0x0){ *************** *** 30,34 **** void stop_sockets(){} ! #else --- 33,44 ---- void stop_sockets(){} ! ! int getpid(){ ! return _getpid(); ! } ! ! int getuid(){ ! return 1; //UGLY, FIXIT! ! } #else Index: sock_pcap.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_pcap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sock_pcap.h 16 Dec 2006 20:25:13 -0000 1.3 --- sock_pcap.h 16 Dec 2006 20:44:19 -0000 1.4 *************** *** 10,15 **** #ifdef __CYGWIN__ ! //typedef int pcap_t ! #define pcap_t int pcap_t* init_pcap(){ return NULL; --- 10,15 ---- #ifdef __CYGWIN__ ! typedef int pcap_t; ! pcap_t* init_pcap(){ return NULL; *************** *** 26,31 **** #else /* __CYGWIN__ */ - #include <pcap.h> - #include <netinet/if_ether.h> #include "sock_types.h" --- 26,29 ---- *************** *** 152,155 **** --- 150,155 ---- if (rcvd_time) { #if defined(WIN32) + struct timeval tv_end; + gettimeofday(&tv_end, NULL); *rcvd_time = tv_end; Index: iceregex.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/iceregex.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** iceregex.h 15 Dec 2006 15:27:57 -0000 1.9 --- iceregex.h 16 Dec 2006 20:44:18 -0000 1.10 *************** *** 9,16 **** #define _ICEREGEX_H - #include <pcre.h> - #include "sock_types.h" class IceRegex { public: --- 9,79 ---- #define _ICEREGEX_H #include "sock_types.h" + #ifdef __NO_LIBPCRE__ + + class IceRegex { + public: + IceRegex (const icestring pattern){ + + } + + IceRegex (const char pattern[]){ + + } + + ~IceRegex(){ + + } + + void init_regex(){ + + } + + bool match(icestring const& s, std::vector<icestring> &v){ + return false; + } + + bool match(icestring const& s){ + return false; + } + + bool match(const char s[]){ + return false; + } + + bool findNext(){ + return false; + } + + bool findNextMin(){ + return false; + } + + void findReset(){ + } + + int groups(){ + return 0; + } + + bool group(int i, char *str, int strsize){ + return false; + } + + bool group(int i, icestring &str){ + return false; + } + + private: + bool find(icestring const& s, std::vector<icestring> &v, int start){ + return false; + } + }; + + #else + + #include <pcre.h> + class IceRegex { public: *************** *** 184,187 **** --- 247,252 ---- }; + #endif /* WIN32 */ + #endif /* _ICEREGEX_H */ |
From: Alexander B. <da...@us...> - 2006-12-16 20:44:22
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12835 Modified Files: Makefile csubtarget.h icediscover.h iceoutput.h icescan.cc nbt_wrapper.h udpscan.h Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** icescan.cc 16 Dec 2006 20:25:13 -0000 1.31 --- icescan.cc 16 Dec 2006 20:44:18 -0000 1.32 *************** *** 315,319 **** time_t rawtime; ! WSA_DATA wsa; wsa = start_sockets(); --- 315,319 ---- time_t rawtime; ! WSADATA wsa; wsa = start_sockets(); Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** csubtarget.h 16 Dec 2006 17:18:28 -0000 1.35 --- csubtarget.h 16 Dec 2006 20:44:18 -0000 1.36 *************** *** 10,14 **** #include "iceoutput.h" #include "iceparams.h" ! #include "nbt_wrapper.h" #include "iceprotocol.h" #include "icesockets/sock_pcap.h" --- 10,18 ---- #include "iceoutput.h" #include "iceparams.h" ! ! #ifndef WIN32 ! #include "nbt_wrapper.h" ! #endif ! #include "iceprotocol.h" #include "icesockets/sock_pcap.h" *************** *** 130,158 **** // cps.test(hostname.c_str()); } int nbt_scan(){ // NetBIOS scan, -SB ! char output_buf[255]; ! if(par->verbose>0){ sprintf(output_buf, "Starting NetBIOS scan against %s...", hostname.c_str()); out->line(output_buf); } cnbtwrapper wrap(par); ! wrap.test(hostname.c_str(), 137); ! if(par->verbose>0){ ! bzero(output_buf, 255); sprintf(output_buf, "NetBIOS scan finished.", hostname.c_str()); out->line(output_buf); } ! } ! int udp_scan(){ ! // connect scan, -SU char output_buf[255]; --- 134,166 ---- // cps.test(hostname.c_str()); + return 0; } int nbt_scan(){ // NetBIOS scan, -SB ! char output_buf[255]; ! if(par->verbose>0){ sprintf(output_buf, "Starting NetBIOS scan against %s...", hostname.c_str()); out->line(output_buf); } + #ifndef WIN32 cnbtwrapper wrap(par); ! wrap.test(hostname.c_str(), 137); ! #endif ! if(par->verbose>0){ ! Bzero(output_buf, 255); sprintf(output_buf, "NetBIOS scan finished.", hostname.c_str()); out->line(output_buf); } ! return 0; ! } ! int udp_scan(){ ! //udp scan, -SU char output_buf[255]; *************** *** 177,180 **** --- 185,190 ---- scanning_ports.clear(); + + return 0; } *************** *** 209,212 **** --- 219,224 ---- scanning_ports.clear(); + + return 0; } *************** *** 332,336 **** } ! int get_max_fd(){ int max = -1; --- 344,348 ---- } ! int get_max_fd(){ int max = -1; *************** *** 798,802 **** ! bzero(output_buf, 255); if(filtered > 0){ if(show_closed){ --- 810,814 ---- ! Bzero(output_buf, 255); if(filtered > 0){ if(show_closed){ *************** *** 816,820 **** for(int j = 0; j < subtarget_ports.size(); j++){ ! bzero(output_buf, 255); if(subtarget_ports[j].status == PORT_OPEN){ sprintf(output_buf, "%5d/tcp open %s", subtarget_ports[j].port_number, par->isnd->get_tcp_service(subtarget_ports[j].port_number).c_str()); --- 828,832 ---- for(int j = 0; j < subtarget_ports.size(); j++){ ! Bzero(output_buf, 255); if(subtarget_ports[j].status == PORT_OPEN){ sprintf(output_buf, "%5d/tcp open %s", subtarget_ports[j].port_number, par->isnd->get_tcp_service(subtarget_ports[j].port_number).c_str()); Index: nbt_wrapper.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbt_wrapper.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** nbt_wrapper.h 16 Dec 2006 17:29:16 -0000 1.5 --- nbt_wrapper.h 16 Dec 2006 20:44:18 -0000 1.6 *************** *** 3,7 **** #include <sys/types.h> ! #include <sys/time.h> #define NBT_MSGSIZE 1024 --- 3,10 ---- #include <sys/types.h> ! ! #ifndef WIN32 ! #include <sys/time.h> ! #endif #define NBT_MSGSIZE 1024 Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** icediscover.h 16 Dec 2006 17:18:28 -0000 1.23 --- icediscover.h 16 Dec 2006 20:44:18 -0000 1.24 *************** *** 2,8 **** #define ICEDISCOVER_H ! #include <signal.h> ! #include <sys/time.h> ! #include <stdlib.h> #include "icesockets/ice_rand.h" #include "icesockets/csocket.h" --- 2,6 ---- #define ICEDISCOVER_H ! #include "icesockets/ice_rand.h" #include "icesockets/csocket.h" *************** *** 43,51 **** #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) --- 41,49 ---- #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) *************** *** 60,66 **** r.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! r.nonblock(true); ! ! int at = 1; while(attempts++ < 100){ --- 58,64 ---- r.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! r.nonblock(true); ! ! int at = 1; while(attempts++ < 100){ *************** *** 69,73 **** char buf[sizeof(struct timeval) + 1]; ! bzero(buf, sizeof(struct timeval) + 1); if(icmp_type == ECHO){ --- 67,71 ---- char buf[sizeof(struct timeval) + 1]; ! Bzero(buf, sizeof(struct timeval) + 1); if(icmp_type == ECHO){ Index: Makefile =================================================================== RCS file: /cvsroot/javanetsim/IceScan/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 30 Nov 2006 15:25:48 -0000 1.2 --- Makefile 16 Dec 2006 20:44:18 -0000 1.3 *************** *** 1,4 **** ! CXXFLAGS=-g -lpthread -lpcrecpp -lpcre ! LDFLAGS=-g -lpthread -lpcrecpp -lpcre all: icescan --- 1,4 ---- ! CXXFLAGS= ! LDFLAGS=-g -lpthread -lpcre -lpcrecpp -lpcap all: icescan Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** udpscan.h 16 Dec 2006 20:25:13 -0000 1.11 --- udpscan.h 16 Dec 2006 20:44:18 -0000 1.12 *************** *** 58,62 **** --- 58,64 ---- if(par->forceuid){ #endif + #define UDP_SCAN_ZSIZE 0 + #define UDP_SCAN_RECVSIZE 150 #define UDP_SCAN_REPEATS 5 *************** *** 64,68 **** --- 66,74 ---- csocket sudp(PF_INET, SOCK_DGRAM); crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); + #ifdef WIN32 + char *zmsg; + #else char zmsg[UDP_SCAN_ZSIZE]; + #endif char recvmsg[UDP_SCAN_RECVSIZE]; memset(zmsg, 0, UDP_SCAN_ZSIZE); Index: iceoutput.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceoutput.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** iceoutput.h 30 Nov 2006 12:27:35 -0000 1.3 --- iceoutput.h 16 Dec 2006 20:44:18 -0000 1.4 *************** *** 6,10 **** #include <iostream> #include <vector> - #include <pthread.h> class iceoutput{ --- 6,9 ---- *************** *** 17,25 **** static const char endl[]; ! iceoutput(){ ! text_output = true; ! xml_output = false; ! binary_output = false; } --- 16,23 ---- static const char endl[]; ! iceoutput(){ text_output = true; ! xml_output = false; ! binary_output = false; } *************** *** 42,61 **** --- 40,69 ---- iceoutput &operator<<(const int &i){ std::cout << i; + + return *this; } iceoutput &operator<<(const char *buf){ std::cout << buf; + + return *this; } iceoutput &operator<<(const icestring &str){ std::cout << str; + + return *this; } iceoutput &operator<<(const double &d){ std::cout << d; + + return *this; } }; + #ifndef WIN32 + void block_output(pthread_mutex_t *output_mutex, char *str, iceoutput *out){ pthread_mutex_lock(output_mutex); *************** *** 65,66 **** --- 73,76 ---- #endif + + #endif |
From: Alexander B. <da...@us...> - 2006-12-16 20:44:22
|
Update of /cvsroot/javanetsim/IceScan/vccproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12835/vccproject Added Files: IceScan.sln IceScan.suo IceScan.vcproj IceScan.vcproj.ACER.85672.user IceScan.vcproj.user Log Message: --- NEW FILE: IceScan.suo --- (This appears to be a binary file; contents omitted.) --- NEW FILE: IceScan.vcproj.ACER.85672.user --- <?xml version="1.0" encoding="windows-1251"?> <VisualStudioUserFile ProjectType="Visual C++" Version="8,00" ShowAllFiles="true" > <Configurations> <Configuration Name="Debug|Win32" > <DebugSettings Command="$(TargetPath)" WorkingDirectory="" CommandArguments="" Attach="false" DebuggerType="3" Remote="1" RemoteMachine="ACER" RemoteCommand="" HttpUrl="" PDBPath="" SQLDebugging="" Environment="" EnvironmentMerge="true" DebuggerFlavor="" MPIRunCommand="" MPIRunArguments="" MPIRunWorkingDirectory="" ApplicationCommand="" ApplicationArguments="" ShimCommand="" MPIAcceptMode="" MPIAcceptFilter="" /> </Configuration> <Configuration Name="Release|Win32" > <DebugSettings Command="$(TargetPath)" WorkingDirectory="" CommandArguments="" Attach="false" DebuggerType="3" Remote="1" RemoteMachine="ACER" RemoteCommand="" HttpUrl="" PDBPath="" SQLDebugging="" Environment="" EnvironmentMerge="true" DebuggerFlavor="" MPIRunCommand="" MPIRunArguments="" MPIRunWorkingDirectory="" ApplicationCommand="" ApplicationArguments="" ShimCommand="" MPIAcceptMode="" MPIAcceptFilter="" /> </Configuration> </Configurations> </VisualStudioUserFile> --- NEW FILE: IceScan.sln --- (This appears to be a binary file; contents omitted.) --- NEW FILE: IceScan.vcproj.user --- <?xml version="1.0" encoding="utf-8"?><VisualStudioUserFile ProjectType="Visual C++" Version="8.00" ShowAllFiles="true"></VisualStudioUserFile> --- NEW FILE: IceScan.vcproj --- <?xml version="1.0" encoding="windows-1251"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="IceScan" ProjectGUID="{80800AA3-4A13-4902-9541-CC7C5EC31DCC}" Keyword="Win32Proj" > <Platforms> <Platform Name="Win32" /> </Platforms> <ToolFiles> </ToolFiles> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="1" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="0" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="0" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" LinkIncremental="2" GenerateDebugInformation="true" SubSystem="1" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="1" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="true" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" LinkIncremental="2" GenerateDebugInformation="true" SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File RelativePath="..\icesockets\crawsocket.h" > </File> <File RelativePath="..\icesockets\csocket.h" > </File> <File RelativePath="..\csubtarget.h" > </File> <File RelativePath="..\ctarget.h" > </File> <File RelativePath="..\icesockets\getaddrinfo.h" > </File> <File RelativePath="..\icesockets\ice_rand.h" > </File> <File RelativePath="..\icedbs.h" > </File> <File RelativePath="..\icediscover.h" > </File> <File RelativePath="..\iceoutput.h" > </File> <File RelativePath="..\iceparams.h" > </File> <File RelativePath="..\iceprotocol.h" > </File> <File RelativePath="..\icesockets\iceregex.h" > </File> <File RelativePath="..\iceversion.h" > </File> <File RelativePath="..\nbt_wrapper.h" > </File> <File RelativePath="..\portdef.h" > </File> <File RelativePath="..\icesockets\sock_arp.h" > </File> <File RelativePath="..\icesockets\sock_err.h" > </File> <File RelativePath="..\icesockets\sock_name.h" > </File> <File RelativePath="..\icesockets\sock_pcap.h" > </File> <File RelativePath="..\icesockets\sock_time.h" > </File> <File RelativePath="..\icesockets\sock_types.h" > </File> <File RelativePath="..\icesockets\sock_win.h" > </File> <File RelativePath="..\udpscan.h" > </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > </Filter> <Filter Name="Source Files" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File RelativePath="..\icescan.cc" > </File> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> |
From: Alexander B. <da...@us...> - 2006-12-16 20:42:23
|
Update of /cvsroot/javanetsim/IceScan/vccproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11809/vccproject Log Message: Directory /cvsroot/javanetsim/IceScan/vccproject added to the repository |
From: QweR <qw...@us...> - 2006-12-16 20:25:16
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5160/icesockets Modified Files: csocket.h sock_pcap.h Log Message: Index: sock_pcap.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_pcap.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sock_pcap.h 16 Dec 2006 17:29:16 -0000 1.2 --- sock_pcap.h 16 Dec 2006 20:25:13 -0000 1.3 *************** *** 9,12 **** --- 9,29 ---- #define _sock_pcap_H + #ifdef __CYGWIN__ + //typedef int pcap_t + #define pcap_t int + pcap_t* init_pcap(){ + return NULL; + } + char* readip_pcap(pcap_t* pd, unsigned int *len, struct timeval *rcvd_time){ + return NULL; + } + bool pcap_filter(pcap_t *p, char *filter_exp){ + return true; + } + + void close_pcap(pcap_t *p){ + } + #else /* __CYGWIN__ */ + #include <pcap.h> #include <netinet/if_ether.h> *************** *** 163,166 **** --- 180,184 ---- pcap_close(p); } + #endif /* __CYGWIN__ */ #endif /* _sock_pcap_H */ Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** csocket.h 16 Dec 2006 14:42:42 -0000 1.15 --- csocket.h 16 Dec 2006 20:25:13 -0000 1.16 *************** *** 9,12 **** --- 9,15 ---- #include "sock_arp.h" + #define MIN_MAGIC_PORT 20000 + #define MAX_MAGIC_PORT 65535 + class csocket{ int cs_id; *************** *** 264,269 **** } ! static int getMagicPort(){ ! return 33333; } --- 267,295 ---- } ! static int getMagicPort(int type, int tries){ ! int mp; ! int i; ! bool p; ! csocket s(PF_INET, type); ! char hostname[80]; ! ! if(gethostname(hostname,79)){ ! printf("\ngethostname() returned error!\n"); ! exit(-1); ! } ! if(tries <= 0){ ! tries = MAX_MAGIC_PORT - MIN_MAGIC_PORT + 1; ! } ! ! for(i = 0, p = false; i < tries && !p; i++){ ! mp = (unsigned)rand() % (MAX_MAGIC_PORT - MIN_MAGIC_PORT + 1) + MIN_MAGIC_PORT; ! p = s.bind(hostname, mp, 0) == 0; ! if(p){ ! s.shutdown(); ! s.close(); ! } ! } ! ! return (p==false ? 0 : mp); } |
From: QweR <qw...@us...> - 2006-12-16 20:25:16
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5160 Modified Files: icescan.cc udpscan.h Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** icescan.cc 16 Dec 2006 17:29:16 -0000 1.30 --- icescan.cc 16 Dec 2006 20:25:13 -0000 1.31 *************** *** 41,45 **** bool parse_ports(int i, int argc, char *argv[], std::vector <port_range>& ports, bool isexit){ if(i+1 < argc){ ! IceRegex re1("$((\\d+(-\\d+)?),?)+^"); if(! re1.match(argv[i+1]) ){ if(isexit){ --- 41,45 ---- bool parse_ports(int i, int argc, char *argv[], std::vector <port_range>& ports, bool isexit){ if(i+1 < argc){ ! IceRegex re1("^((\\d+(-\\d+)?),?)+$"); if(! re1.match(argv[i+1]) ){ if(isexit){ Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** udpscan.h 16 Dec 2006 16:06:06 -0000 1.10 --- udpscan.h 16 Dec 2006 20:25:13 -0000 1.11 *************** *** 76,80 **** if(gethostname(hostname,79)) exit(-1); ! sudp.bind(hostname, 0, 0); sudp.nonblock(true); sicmp.nonblock(true); --- 76,81 ---- if(gethostname(hostname,79)) exit(-1); ! int pppp = sudp.getMagicPort(SOCK_DGRAM, 100); ! sudp.bind(hostname, pppp, 0); sudp.nonblock(true); sicmp.nonblock(true); *************** *** 140,143 **** --- 141,148 ---- } } + sudp.shutdown(); + sicmp.shutdown(); + sudp.close(); + sicmp.close(); } else{ |
From: Alexander B. <da...@us...> - 2006-12-16 17:29:21
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1926/icesockets Modified Files: sock_pcap.h sock_types.h Added Files: sock_win.h Log Message: no message Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** sock_types.h 16 Dec 2006 14:42:42 -0000 1.14 --- sock_types.h 16 Dec 2006 17:29:16 -0000 1.15 *************** *** 2,5 **** --- 2,7 ---- #define ICESOCK_SOCK_TYPES_H + #include "sock_win.h" + #include <vector> #include <string> Index: sock_pcap.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_pcap.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sock_pcap.h 16 Dec 2006 17:18:28 -0000 1.1 --- sock_pcap.h 16 Dec 2006 17:29:16 -0000 1.2 *************** *** 29,33 **** } ! printf("DEV: %s\n",dev); /* open the device for sniffing. --- 29,33 ---- } ! //printf("DEV: %s\n",dev); /* open the device for sniffing. --- NEW FILE: sock_win.h --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2006-12-16 17:29:20
|
Update of /cvsroot/javanetsim/IceScan/nbproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1926/nbproject Modified Files: configurations.xml Log Message: no message Index: configurations.xml =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbproject/configurations.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** configurations.xml 16 Dec 2006 17:18:28 -0000 1.15 --- configurations.xml 16 Dec 2006 17:29:16 -0000 1.16 *************** *** 5,10 **** --- 5,12 ---- <itemPath>icesockets/crawsocket.h</itemPath> <itemPath>icesockets/csocket.h</itemPath> + <itemPath>csubtarget.h</itemPath> <itemPath>icesockets/getaddrinfo.h</itemPath> <itemPath>icesockets/ice_rand.h</itemPath> + <itemPath>icediscover.h</itemPath> <itemPath>icesockets/iceregex.h</itemPath> <itemPath>icesockets/sock_arp.h</itemPath> *************** *** 14,17 **** --- 16,20 ---- <itemPath>icesockets/sock_time.h</itemPath> <itemPath>icesockets/sock_types.h</itemPath> + <itemPath>icesockets/sock_win.h</itemPath> </logicalFolder> <logicalFolder name="ExternalFiles" *************** *** 26,33 **** <itemPath>TODO</itemPath> </logicalFolder> - <itemPath>csubtarget.h</itemPath> <itemPath>ctarget.h</itemPath> <itemPath>icedbs.h</itemPath> - <itemPath>icediscover.h</itemPath> <itemPath>iceoutput.h</itemPath> <itemPath>iceparams.h</itemPath> --- 29,34 ---- *************** *** 63,69 **** <itemTool>3</itemTool> </item> - <item path="icediscover.h"> - <itemTool>3</itemTool> - </item> <item path="iceversion.h"> <itemTool>3</itemTool> --- 64,67 ---- *************** *** 110,116 **** <itemTool>3</itemTool> </item> - <item path="csubtarget.h"> - <itemTool>3</itemTool> - </item> <item path="icesockets/ice_rand.h"> <itemTool>3</itemTool> --- 108,111 ---- *************** *** 131,134 **** --- 126,138 ---- <itemTool>3</itemTool> </item> + <item path="csubtarget.h"> + <itemTool>3</itemTool> + </item> + <item path="icediscover.h"> + <itemTool>3</itemTool> + </item> + <item path="icesockets/sock_win.h"> + <itemTool>3</itemTool> + </item> </conf> </confs> |
From: Alexander B. <da...@us...> - 2006-12-16 17:29:20
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1926 Modified Files: iceparams.h nbt_wrapper.h icescan.cc Log Message: no message Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** icescan.cc 16 Dec 2006 17:14:15 -0000 1.29 --- icescan.cc 16 Dec 2006 17:29:16 -0000 1.30 *************** *** 300,305 **** int main(int argc, char *argv[]){ - - init_rand(); ice_service_name_database isnd("services"); --- 300,303 ---- *************** *** 317,320 **** --- 315,324 ---- time_t rawtime; + WSA_DATA wsa; + + wsa = start_sockets(); + + init_rand(); + time(&rawtime); *************** *** 352,355 **** --- 356,361 ---- out << "IceScan finished: " << ts.subtargets_count() << " IP address(es) (" << ts.up_subtargets_count() << " host(s) up) processed in " << timeb_diff(tp1, tp2) << " seconds." << iceoutput::endl; + stop_sockets(); + return 0; } Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** iceparams.h 16 Dec 2006 14:44:56 -0000 1.12 --- iceparams.h 16 Dec 2006 17:29:16 -0000 1.13 *************** *** 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} }; --- 125,129 ---- const int ranges_cnt = 2; ! int ranges[ranges_cnt][2] = { {20, 25}, {130, 140} }; //int ranges[ranges_cnt][2] = { {1, 1024}, {3388, 3390} }; Index: nbt_wrapper.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbt_wrapper.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** nbt_wrapper.h 15 Dec 2006 16:24:58 -0000 1.4 --- nbt_wrapper.h 16 Dec 2006 17:29:16 -0000 1.5 *************** *** 3,6 **** --- 3,7 ---- #include <sys/types.h> + #include <sys/time.h> #define NBT_MSGSIZE 1024 |
From: Alexander B. <da...@us...> - 2006-12-16 17:18:33
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30073 Modified Files: portdef.h icediscover.h csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** csubtarget.h 16 Dec 2006 14:44:56 -0000 1.34 --- csubtarget.h 16 Dec 2006 17:18:28 -0000 1.35 *************** *** 12,19 **** #include "nbt_wrapper.h" #include "iceprotocol.h" #define CONNECT_TIMEOUT 14 ! #define MAX_PACKETS 512 #ifdef __CYGWIN__ --- 12,21 ---- #include "nbt_wrapper.h" #include "iceprotocol.h" + #include "icesockets/sock_pcap.h" #define CONNECT_TIMEOUT 14 ! #define MAX_PACKETS 2048 ! #define MAX_RAW_WAIT 1000000 #ifdef __CYGWIN__ *************** *** 358,365 **** if(getuid() || par->forceuid){ #endif ! out->line("UID isn't 0, so can't create raw socket => no RAW tcp scan..."); return; } raw = true; --- 360,373 ---- if(getuid() || par->forceuid){ #endif ! out->line("UID isn't 0, so can't create raw socket/load pcap => no RAW tcp scan..."); return; } + pcap_t* p = init_pcap(); //check for NULL + + if(p == NULL){ + out->line("Can't open pcap: no raw tcp scan. Exitting."); + return; + } raw = true; *************** *** 384,447 **** perror("Setsockopt HDRINCL:"); - - int l = scanning_ports.size()/MAX_PACKETS; if(scanning_ports.size() % MAX_PACKETS != 0) l++; ! int j = 0; ! while(j < l){ ! int attempts = 0; ! while(attempts++ < 10){ ! std::map <int, scanning_port>::iterator i = scanning_ports.begin(); ! ! DBGOUTPUT(attempts); ! ! for(int k=0; k < MAX_PACKETS*j; k++) i++; ! j++; ! ! for(int k = j*MAX_PACKETS; (k < (j+1)*MAX_PACKETS) && i!= scanning_ports.end(); ++i, k++){ ! 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++; ! recieve_tcp_raw(rawrecv, rawsend, source, saddress, scanning_ports, MAGIC_PORT); ! } ! } ! ! usleep(1000000); ! int at = 0; ! ! while(at++<100){ ! recieve_tcp_raw(rawrecv, rawsend, source, saddress, scanning_ports, MAGIC_PORT); ! iceusleep(1000); } - } } --- 392,465 ---- perror("Setsockopt HDRINCL:"); int l = scanning_ports.size()/MAX_PACKETS; if(scanning_ports.size() % MAX_PACKETS != 0) l++; + char filter_exp[256]; ! sprintf(filter_exp, "port %d host %s tcp", MAGIC_PORT, hostname.c_str()); ! ! pcap_filter(p, filter_exp); ! ! int maxat; ! ! int covar = 10000; ! ! int attempts = 0; ! while(attempts++ < 5){ ! int j = 0; ! while(j < l){ ! std::map <int, scanning_port>::iterator i = scanning_ports.begin(); ! ! //DBGOUTPUT(attempts); ! maxat = 0; ! ! for(int k=0; k < MAX_PACKETS*j; k++) i++; ! ! for(int k = j*MAX_PACKETS; (k < (j+1)*MAX_PACKETS) && i!= scanning_ports.end(); ++i, k++){ ! 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; ! } ! ! ! gettimeofday(&((*i).second.tv), 0); ! ! //DBGOUTPUT("Sending:" << (*i).second.attempt); ! ! (*i).second.attempt++; ! maxat++; ! ! recieve_tcp_raw(p, rawsend, source, saddress, scanning_ports, MAGIC_PORT, 10, 0); } ! } ! j++; ! ! //iceusleep(1000); ! recieve_tcp_raw(p, rawsend, source, saddress, scanning_ports, MAGIC_PORT, (maxat) * covar + 10000, maxat); ! ! //DBGOUTPUT(covar); } } *************** *** 458,535 **** if(par->verbose>0) ! *out << "TCP " << scan_type << "scan finished.\n"; } ! void recieve_tcp_raw(crawsocket &rawrecv, crawsocket &rawsend, icestring &source, struct sockaddr_in &saddress, std::map <int, scanning_port> &scanning_ports, int MAGIC_PORT){ int bytes; ! char response[65535]; ! struct iphdr *ip = (struct iphdr *) response; struct tcphdr *tcp; ! while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ ! if(ip->saddr = saddress.sin_addr.s_addr){ ! tcp = (struct tcphdr *) (response + 4 * ip->ihl); ! ! if ((tcp->th_flags & TH_RST) && (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); ! } } } --- 476,580 ---- if(par->verbose>0) ! *out << "TCP " << scan_type << " scan finished.\n"; ! ! close_pcap(p); } ! int recieve_tcp_raw(pcap_t* p, crawsocket &rawsend, icestring &source, struct sockaddr_in &saddress, std::map <int, scanning_port> &scanning_ports, int MAGIC_PORT, int timeout, int packets){ int bytes; ! char *response; ! struct iphdr *ip; struct tcphdr *tcp; + unsigned int len; + int maxtimeval = 0; + struct timeval tv1, tv2, tv3; + gettimeofday(&tv1, 0); + bool stop = false; + int port; ! //DBGOUTPUT("!!!!!"); ! //while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ ! while(!stop){ ! response = readip_pcap(p, &len, NULL); ! port = 0; + if(response){ + ip = (struct iphdr *) response; + if(ip->saddr = saddress.sin_addr.s_addr && ip->protocol == IPPROTO_TCP){ + 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)) { ! port = ntohs(tcp->th_sport); ! if(scanning_ports.find(port) != scanning_ports.end()){ ! if(!scanning_ports[port].done){ ! set_port_status(port, PORT_CLOSED, "tcp"); ! scanning_ports[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); ! } ! } ! gettimeofday(&tv2, 0); ! ! if(port){ ! if(SUB_TIMEVALS(tv2,scanning_ports[port].tv) > maxtimeval) ! maxtimeval = SUB_TIMEVALS(tv2,scanning_ports[port].tv); ! } ! ! if(SUB_TIMEVALS(tv2,tv1) >= timeout || SUB_TIMEVALS(tv2,tv1) > MAX_RAW_WAIT + packets * 500) ! stop = true; } + + return maxtimeval; } Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** icediscover.h 16 Dec 2006 16:06:06 -0000 1.22 --- icediscover.h 16 Dec 2006 17:18:28 -0000 1.23 *************** *** 42,45 **** --- 42,46 ---- if(par->forceuid){ #endif + //we're root, so can work with raw sockets icestring hostname_(hostname); Index: portdef.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/portdef.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** portdef.h 16 Dec 2006 00:29:16 -0000 1.1 --- portdef.h 16 Dec 2006 17:18:28 -0000 1.2 *************** *** 15,18 **** --- 15,19 ---- bool done; long time; + struct timeval tv; int socket_ptr; int attempt; |
From: Alexander B. <da...@us...> - 2006-12-16 17:18:32
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30073/icesockets Modified Files: sock_time.h Added Files: sock_pcap.h Log Message: no message --- NEW FILE: sock_pcap.h --- (This appears to be a binary file; contents omitted.) Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sock_time.h 16 Dec 2006 10:02:50 -0000 1.7 --- sock_time.h 16 Dec 2006 17:18:28 -0000 1.8 *************** *** 4,7 **** --- 4,9 ---- #include "sock_types.h" + #define SUB_TIMEVALS(a,b) (((a).tv_sec - (b).tv_sec) * 1000000 + (a).tv_usec - (b).tv_usec) + void iceusleep(unsigned long usec){ usleep(usec); |
From: Alexander B. <da...@us...> - 2006-12-16 17:18:32
|
Update of /cvsroot/javanetsim/IceScan/nbproject In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30073/nbproject Modified Files: configurations.xml Log Message: no message Index: configurations.xml =================================================================== RCS file: /cvsroot/javanetsim/IceScan/nbproject/configurations.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** configurations.xml 16 Dec 2006 14:42:43 -0000 1.14 --- configurations.xml 16 Dec 2006 17:18:28 -0000 1.15 *************** *** 11,14 **** --- 11,15 ---- <itemPath>icesockets/sock_err.h</itemPath> <itemPath>icesockets/sock_name.h</itemPath> + <itemPath>icesockets/sock_pcap.h</itemPath> <itemPath>icesockets/sock_time.h</itemPath> <itemPath>icesockets/sock_types.h</itemPath> *************** *** 127,130 **** --- 128,134 ---- <itemTool>3</itemTool> </item> + <item path="icesockets/sock_pcap.h"> + <itemTool>3</itemTool> + </item> </conf> </confs> |
From: QweR <qw...@us...> - 2006-12-16 17:14:18
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28471 Modified Files: icescan.cc Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** icescan.cc 16 Dec 2006 16:06:06 -0000 1.28 --- icescan.cc 16 Dec 2006 17:14:15 -0000 1.29 *************** *** 250,254 **** case 'M': par->icmp_mask_ping_discovery = true; - parse_ports(i, argc, argv, par->pm_ports, false); break; --- 250,253 ---- |
From: QweR <qw...@us...> - 2006-12-16 16:06:10
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1643/icesockets Modified Files: ice_rand.h Log Message: Index: ice_rand.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/ice_rand.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ice_rand.h 14 Dec 2006 19:23:32 -0000 1.2 --- ice_rand.h 16 Dec 2006 16:06:06 -0000 1.3 *************** *** 11,14 **** --- 11,15 ---- #include <string.h> #include <stdio.h> + #include <stdlib.h> #if HAVE_SYS_TIME_H #include <sys/time.h> *************** *** 69,72 **** --- 70,78 ---- } + void init_rand(){ + unsigned i; + get_random_bytes(&i, sizeof(i)); + srand(i); + } #endif /* _ice_rand_H */ |
From: QweR <qw...@us...> - 2006-12-16 16:06:10
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1643 Modified Files: icediscover.h icescan.cc udpscan.h Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** icescan.cc 16 Dec 2006 14:44:56 -0000 1.27 --- icescan.cc 16 Dec 2006 16:06:06 -0000 1.28 *************** *** 6,9 **** --- 6,10 ---- #include "icedbs.h" #include "ctarget.h" + #include "icesockets/ice_rand.h" void print_help(char *name){ *************** *** 38,48 **** } ! bool parse_ports(int i, int argc, char *argv[], std::vector <port_range>& ports){ ! if(i+1 < argc){ ! IceRegex re1("((\\d+(-\\d+)?),?)+"); if(! re1.match(argv[i+1]) ){ ! std::cout << "Invalid port range definition format." << std::endl; ! print_help(argv[0]); ! exit(1); }else{ IceRegex re("(\\d+(-\\d+)?),?"); --- 39,54 ---- } ! bool parse_ports(int i, int argc, char *argv[], std::vector <port_range>& ports, bool isexit){ ! if(i+1 < argc){ ! IceRegex re1("$((\\d+(-\\d+)?),?)+^"); if(! re1.match(argv[i+1]) ){ ! if(isexit){ ! std::cout << "Invalid port range definition format." << std::endl; ! print_help(argv[0]); ! exit(1); ! } ! else{ ! return false; ! } }else{ IceRegex re("(\\d+(-\\d+)?),?"); *************** *** 74,77 **** --- 80,84 ---- exit(1); } + return true; } *************** *** 226,230 **** case 'A': par->ack_ping_discovery = true; ! parse_ports(i, argc, argv, par->pa_ports); break; --- 233,237 ---- case 'A': par->ack_ping_discovery = true; ! parse_ports(i, argc, argv, par->pa_ports, false); break; *************** *** 243,252 **** case 'M': par->icmp_mask_ping_discovery = true; ! parse_ports(i, argc, argv, par->pm_ports); break; case 'U': par->udp_ping_discovery = true; ! parse_ports(i, argc, argv, par->pu_ports); break; --- 250,259 ---- case 'M': par->icmp_mask_ping_discovery = true; ! parse_ports(i, argc, argv, par->pm_ports, false); break; case 'U': par->udp_ping_discovery = true; ! parse_ports(i, argc, argv, par->pu_ports, false); break; *************** *** 260,264 **** case 'p': ! parse_ports(i, argc, argv, par->ports); break; --- 267,271 ---- case 'p': ! parse_ports(i, argc, argv, par->ports, true); break; *************** *** 295,298 **** --- 302,307 ---- int main(int argc, char *argv[]){ + init_rand(); + ice_service_name_database isnd("services"); ice_mac_name_database ismd("ieee-oui.txt"); Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** icediscover.h 16 Dec 2006 15:24:57 -0000 1.21 --- icediscover.h 16 Dec 2006 16:06:06 -0000 1.22 *************** *** 4,7 **** --- 4,9 ---- #include <signal.h> #include <sys/time.h> + #include <stdlib.h> + #include "icesockets/ice_rand.h" #include "icesockets/csocket.h" #include "icesockets/crawsocket.h" *************** *** 166,182 **** std::map <int, scanning_port> scanning_ports; ! for(int j = 0; j < par->pu_ports.size(); j++){ ! port_range pr = par->pu_ports[j]; ! for(int i = pr.lower_port; i <= pr.upper_port; i++){ ! if(scanning_ports.find(i) == scanning_ports.end()){ ! struct scanning_port sp; ! sp.port_number = i; ! scanning_ports[i] = sp; ! scanning_ports[i].attempt = 0; ! scanning_ports[i].done = false; } } } return udpscan(hostname,scanning_ports,par,out,NULL,false); } --- 168,197 ---- std::map <int, scanning_port> scanning_ports; ! if(par->pu_ports.size() > 0){ ! for(int j = 0; j < par->pu_ports.size(); j++){ ! port_range pr = par->pu_ports[j]; ! for(int i = pr.lower_port; i <= pr.upper_port; i++){ ! if(scanning_ports.find(i) == scanning_ports.end()){ ! struct scanning_port sp; ! sp.port_number = i; ! scanning_ports[i] = sp; ! scanning_ports[i].attempt = 0; ! scanning_ports[i].done = false; ! } } } } + else{ + struct scanning_port sp; + unsigned i; + get_random_bytes(&i, sizeof(i)); + i = ((unsigned)rand() % 35536) + 30000; // return "random" number [30000, 65535] + + sp.port_number = i; + scanning_ports[i] = sp; + scanning_ports[i].attempt = 0; + scanning_ports[i].done = false; + } return udpscan(hostname,scanning_ports,par,out,NULL,false); } Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** udpscan.h 16 Dec 2006 15:24:57 -0000 1.9 --- udpscan.h 16 Dec 2006 16:06:06 -0000 1.10 *************** *** 88,92 **** sudp.sendto(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); iceusleep(50000*repeats); - DBGOUTPUT((*i).first); } --- 88,91 ---- |
From: QweR <qw...@us...> - 2006-12-16 15:25:01
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17743 Modified Files: icediscover.h udpscan.h Log Message: Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** icediscover.h 16 Dec 2006 14:44:56 -0000 1.20 --- icediscover.h 16 Dec 2006 15:24:57 -0000 1.21 *************** *** 196,200 **** if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; ! // if(par->udp_ping_discovery) if( udp_discovery(hostname, par, out) ) return true; if(par->verbose>0) *out << "Host discovery failed!" << iceoutput::endl; --- 196,200 ---- if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; ! if(par->udp_ping_discovery) if( udp_discovery(hostname, par, out) ) return true; if(par->verbose>0) *out << "Host discovery failed!" << iceoutput::endl; Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** udpscan.h 16 Dec 2006 14:44:56 -0000 1.8 --- udpscan.h 16 Dec 2006 15:24:57 -0000 1.9 *************** *** 70,73 **** --- 70,74 ---- int port; char hostname[80]; + bool next = true; int recvsize = UDP_SCAN_RECVSIZE; *************** *** 82,87 **** sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! for(repeats = 1; repeats <= UDP_SCAN_REPEATS && !(result ^ isscan); repeats++){ //exit if( isscan = false && result = true ) ! for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end() && !(result ^ isscan); ++i){ if(! (*i).second.done ){ sudp.sendto(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); --- 83,88 ---- sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! for(repeats = 1; repeats <= UDP_SCAN_REPEATS && next; repeats++){ ! for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end() && next; ++i){ if(! (*i).second.done ){ sudp.sendto(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); *************** *** 102,105 **** --- 103,107 ---- else{ result = true; + next = false; } } *************** *** 121,124 **** --- 123,127 ---- else{ result = true; + next = false; } } *************** *** 126,130 **** } iceusleep(50000*repeats); ! }while(recvbytes > 0 && !(result ^ isscan)); } } --- 129,133 ---- } iceusleep(50000*repeats); ! }while(recvbytes > 0 && next); } } |
From: QweR <qw...@us...> - 2006-12-16 14:45:00
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2210 Modified Files: csubtarget.h icediscover.h iceparams.h icescan.cc udpscan.h Log Message: Index: icescan.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icescan.cc,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** icescan.cc 16 Dec 2006 10:23:07 -0000 1.26 --- icescan.cc 16 Dec 2006 14:44:56 -0000 1.27 *************** *** 18,21 **** --- 18,22 ---- "\t-PR: ARP host discovery\n" "\t-PE/PT/PM: ICMP Echo/Timestamp/Mask host discovery\n" + "\t-PU: UDP Ping discovery\n" "\t-r: no reverse-dns lookups\n" "SCAN TYPES:\n" *************** *** 37,40 **** --- 38,79 ---- } + bool parse_ports(int i, int argc, char *argv[], std::vector <port_range>& ports){ + if(i+1 < argc){ + IceRegex re1("((\\d+(-\\d+)?),?)+"); + if(! re1.match(argv[i+1]) ){ + std::cout << "Invalid port range definition format." << std::endl; + print_help(argv[0]); + exit(1); + }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); + if(re.groups() > 2) re.group(2,var2); + struct port_range pr; + + if(var2 == ""){ + sscanf(var.c_str(), "%d", &pr.lower_port); + pr.upper_port = pr.lower_port; + }else{ + sscanf(var.c_str(), "%d-%d", &pr.lower_port, &pr.upper_port); + } + ports.push_back(pr); + } + i++; + } + }else{ + std::cout << "Invalid port range definition format." << std::endl; + print_help(argv[0]); + exit(1); + } + } + bool parse_input(int argc, char *argv[], iceparams *par){ int c; *************** *** 187,190 **** --- 226,230 ---- case 'A': par->ack_ping_discovery = true; + parse_ports(i, argc, argv, par->pa_ports); break; *************** *** 203,208 **** --- 243,254 ---- case 'M': par->icmp_mask_ping_discovery = true; + parse_ports(i, argc, argv, par->pm_ports); break; + case 'U': + par->udp_ping_discovery = true; + parse_ports(i, argc, argv, par->pu_ports); + break; + default: std::cout << "Invalid discovery type: -P" << argv[i][2] << std::endl; *************** *** 214,256 **** case 'p': ! ! if(i+1 < argc){ ! IceRegex re1("((\\d+(-\\d+)?),?)+"); ! if(! re1.match(argv[i+1]) ){ ! std::cout << "Invalid port range definition format." << std::endl; ! print_help(argv[0]); ! exit(1); ! }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); ! if(re.groups() > 2) re.group(2,var2); ! struct port_range pr; ! ! if(var2 == ""){ ! sscanf(var.c_str(), "%d", &pr.lower_port); ! pr.upper_port = pr.lower_port; ! }else{ ! sscanf(var.c_str(), "%d-%d", &pr.lower_port, &pr.upper_port); ! } ! par->ports.push_back(pr); ! } ! i++; ! } ! }else{ ! std::cout << "Invalid port range definition format." << std::endl; ! print_help(argv[0]); ! exit(1); ! } ! break; --- 260,264 ---- case 'p': ! parse_ports(i, argc, argv, par->ports); break; Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** csubtarget.h 16 Dec 2006 14:42:43 -0000 1.33 --- csubtarget.h 16 Dec 2006 14:44:56 -0000 1.34 *************** *** 10,14 **** #include "iceoutput.h" #include "iceparams.h" - #include "icediscover.h" #include "nbt_wrapper.h" #include "iceprotocol.h" --- 10,13 ---- *************** *** 27,32 **** class csubtarget; ! void udpscan(icestring, icestring, std::map <int, scanning_port>, iceparams*, iceoutput*, csubtarget*); ! struct scan_socket{ int sid; --- 26,34 ---- class csubtarget; ! //#include "udpscan.h" ! bool udpscan(icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out, csubtarget * subtarget, bool isscan); ! ! #include "icediscover.h" ! struct scan_socket{ int sid; *************** *** 148,153 **** } ! ! int udp_scan(){ // connect scan, -SU --- 150,154 ---- } ! int udp_scan(){ // connect scan, -SU *************** *** 164,172 **** out->line(output_buf); } ! ! if(gethostname(local_hostname,79)) exit(-1); ! 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); --- 165,170 ---- out->line(output_buf); } ! ! udpscan(hostname, scanning_ports, par, out, this, true); // udpscan2(local_hn, hostname, scanning_ports,hostname.c_str(), par, out); Index: iceparams.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/iceparams.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** iceparams.h 16 Dec 2006 00:29:16 -0000 1.11 --- iceparams.h 16 Dec 2006 14:44:56 -0000 1.12 *************** *** 39,49 **** bool ack_ping_discovery; // -PA, ACK Ping ! std::vector <int> pa_ports; bool syn_ping_discovery; // -PS, SYN Ping ! 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 --- 39,49 ---- bool ack_ping_discovery; // -PA, ACK Ping ! std::vector <port_range> pa_ports; bool syn_ping_discovery; // -PS, SYN Ping ! std::vector <port_range> ps_ports; bool arp_discovery; // -PM, ARP Ping ! std::vector <port_range> pm_ports; bool icmp_echo_ping_discovery; // -PE, ICMP Echo (standart) Ping *************** *** 52,56 **** bool udp_ping_discovery; // -PU, UDP send + ICMP reply Ping ! std::vector <int> pu_ports; // Scan Options ( default: -ST ) --- 52,56 ---- bool udp_ping_discovery; // -PU, UDP send + ICMP reply Ping ! std::vector <port_range> pu_ports; // Scan Options ( default: -ST ) Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** icediscover.h 16 Dec 2006 10:23:07 -0000 1.19 --- icediscover.h 16 Dec 2006 14:44:56 -0000 1.20 *************** *** 164,168 **** bool udp_discovery(const char *hostname, iceparams *par, iceoutput *out){ ! return false; } --- 164,183 ---- bool udp_discovery(const char *hostname, iceparams *par, iceoutput *out){ ! std::map <int, scanning_port> scanning_ports; ! ! for(int j = 0; j < par->pu_ports.size(); j++){ ! port_range pr = par->pu_ports[j]; ! ! for(int i = pr.lower_port; i <= pr.upper_port; i++){ ! if(scanning_ports.find(i) == scanning_ports.end()){ ! struct scanning_port sp; ! sp.port_number = i; ! scanning_ports[i] = sp; ! scanning_ports[i].attempt = 0; ! scanning_ports[i].done = false; ! } ! } ! } ! return udpscan(hostname,scanning_ports,par,out,NULL,false); } *************** *** 181,184 **** --- 196,200 ---- if(par->arp_discovery) if( arp_discovery(hostname, par, out) ) return true; + // if(par->udp_ping_discovery) if( udp_discovery(hostname, par, out) ) return true; if(par->verbose>0) *out << "Host discovery failed!" << iceoutput::endl; Index: udpscan.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/udpscan.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** udpscan.h 16 Dec 2006 12:37:31 -0000 1.7 --- udpscan.h 16 Dec 2006 14:44:56 -0000 1.8 *************** *** 19,29 **** 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; --- 19,22 ---- *************** *** 39,43 **** port = ntohs(udp->dest); ! if(par->verbose>0) out->line("Recieved icmp port unreachable."); return port; --- 32,36 ---- port = ntohs(udp->dest); ! if(par->verbose>2) *out << "Recieved icmp port " << port << "unreachable."; return port; *************** *** 50,55 **** } ! void udpscan(icestring hostname, icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out, csubtarget* subtarget){ ! #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ --- 43,56 ---- } ! /* UDP Ping scanning/discovery function ! * destname - destination hostname ! * scaiing_ports - ports for scanning/discovery ! * par - scanning/discovery parameters ! * out - output stream ! * subtarget - target for this scan/discovery ! * isscan - 'true' for scanning, 'false' for discovery ! */ ! bool udpscan(icestring destname, std::map <int, scanning_port> scanning_ports, iceparams *par, iceoutput *out, csubtarget * subtarget, bool isscan){ ! bool result = isscan; #ifndef __CYGWIN__ if(!getuid() || par->forceuid){ *************** *** 61,65 **** #define UDP_SCAN_REPEATS 5 int repeats; - int rep2; csocket sudp(PF_INET, SOCK_DGRAM); crawsocket sicmp(AF_INET, SOCK_RAW, IPPROTO_ICMP); --- 62,65 ---- *************** *** 68,77 **** 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); --- 68,79 ---- memset(zmsg, 0, UDP_SCAN_ZSIZE); int recvbytes; int port; + char hostname[80]; int recvsize = UDP_SCAN_RECVSIZE; ! if(gethostname(hostname,79)) exit(-1); ! ! sudp.bind(hostname, 0, 0); sudp.nonblock(true); sicmp.nonblock(true); *************** *** 80,99 **** 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){ 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; ! subtarget->set_port_status(port, PORT_OPEN, "udp"); } } --- 82,106 ---- sicmp.setsockopt(SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); ! for(repeats = 1; repeats <= UDP_SCAN_REPEATS && !(result ^ isscan); repeats++){ //exit if( isscan = false && result = true ) ! for(std::map <int, scanning_port>::iterator i = scanning_ports.begin(); i!= scanning_ports.end() && !(result ^ isscan); ++i){ if(! (*i).second.done ){ sudp.sendto(destname.c_str(), (*i).first, zmsg, UDP_SCAN_ZSIZE, 0); iceusleep(50000*repeats); + DBGOUTPUT((*i).first); } do{ recvbytes = sudp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL, NULL); ! if(recvbytes > 0){ struct udphdr* udp = (struct udphdr*) recvmsg; port = ntohs(udp->source); if(port!=0 && !scanning_ports[port].done && scanning_ports.find(port) != scanning_ports.end()){ ! if(isscan){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_OPEN, "udp"); ! } ! else{ ! result = true; ! } } } *************** *** 104,134 **** // iceusleep(100000); // } ! recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); if(recvbytes > 0){ port = parse_icmp_udp_packet(recvmsg, recvbytes, par, out); if(port!=0 && !scanning_ports[port].done && !(scanning_ports.find(port) == scanning_ports.end())){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_CLOSED, "udp"); } - p = true; } - // if(!p) rep2++; } iceusleep(50000*repeats); ! }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..."); ! } - #endif /* _udpscan_H */ --- 111,149 ---- // iceusleep(100000); // } ! recvbytes = sicmp.recvfrom(recvmsg, UDP_SCAN_RECVSIZE, 0, NULL); if(recvbytes > 0){ port = parse_icmp_udp_packet(recvmsg, recvbytes, par, out); if(port!=0 && !scanning_ports[port].done && !(scanning_ports.find(port) == scanning_ports.end())){ ! if(isscan){ ! scanning_ports[port].done = true; ! subtarget->set_port_status(port, PORT_CLOSED, "udp"); ! } ! else{ ! result = true; ! } } } } iceusleep(50000*repeats); ! }while(recvbytes > 0 && !(result ^ isscan)); } } ! if(isscan){ ! 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..."); ! result = false; ! } ! return result; } #endif /* _udpscan_H */ |
From: Alexander B. <da...@us...> - 2006-12-16 14:42:46
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1407 Modified Files: TODO csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** csubtarget.h 16 Dec 2006 11:39:17 -0000 1.32 --- csubtarget.h 16 Dec 2006 14:42:43 -0000 1.33 *************** *** 16,19 **** --- 16,21 ---- #define CONNECT_TIMEOUT 14 + #define MAX_PACKETS 512 + #ifdef __CYGWIN__ #define ICE_FD_SETSIZE (128) *************** *** 384,393 **** 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: --- 386,408 ---- perror("Setsockopt HDRINCL:"); ! ! int l = scanning_ports.size()/MAX_PACKETS; ! if(scanning_ports.size() % MAX_PACKETS != 0) l++; ! ! ! int j = 0; ! while(j < l){ ! int attempts = 0; ! while(attempts++ < 10){ ! std::map <int, scanning_port>::iterator i = scanning_ports.begin(); ! ! DBGOUTPUT(attempts); ! ! for(int k=0; k < MAX_PACKETS*j; k++) i++; ! j++; ! ! for(int k = j*MAX_PACKETS; (k < (j+1)*MAX_PACKETS) && i!= scanning_ports.end(); ++i, k++){ ! if(! (*i).second.done ){ switch(par->scan_type){ case FIN_SCAN: *************** *** 418,505 **** (*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); } } --- 433,449 ---- (*i).second.attempt++; ! recieve_tcp_raw(rawrecv, rawsend, source, saddress, scanning_ports, MAGIC_PORT); } ! } ! usleep(1000000); ! int at = 0; ! while(at++<100){ ! recieve_tcp_raw(rawrecv, rawsend, source, saddress, scanning_ports, MAGIC_PORT); ! iceusleep(1000); } + } } *************** *** 519,522 **** --- 463,538 ---- } + void recieve_tcp_raw(crawsocket &rawrecv, crawsocket &rawsend, icestring &source, struct sockaddr_in &saddress, std::map <int, scanning_port> &scanning_ports, int MAGIC_PORT){ + int bytes; + char response[65535]; + struct iphdr *ip = (struct iphdr *) response; + struct tcphdr *tcp; + + while( bytes = rawrecv.recvfrom(response, 65535, 0, NULL) > 0){ + if(ip->saddr = saddress.sin_addr.s_addr){ + tcp = (struct tcphdr *) (response + 4 * ip->ihl); + + if ((tcp->th_flags & TH_RST) && (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); + } + } + } void shutdown_scansocket(int j){ Index: TODO =================================================================== RCS file: /cvsroot/javanetsim/IceScan/TODO,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TODO 16 Dec 2006 12:18:05 -0000 1.13 --- TODO 16 Dec 2006 14:42:43 -0000 1.14 *************** *** 16,22 **** --- 16,25 ---- -- Scanning -- + + Mainmon scan (-SM, FIN/ACK) + UDP Scan (-SU) [QweR] + IP Protocol Scan (-SI) [Key] (??) * do setting random window/seq(ack and seg) for raw scanning + + --ttl option and ttl random generation + + --badchksum option + ARP Scan + Fingerprint (??) |
From: Alexander B. <da...@us...> - 2006-12-16 14:42:46
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1407/icesockets Modified Files: crawsocket.h csocket.h sock_types.h Log Message: no message Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** sock_types.h 16 Dec 2006 12:18:05 -0000 1.13 --- sock_types.h 16 Dec 2006 14:42:42 -0000 1.14 *************** *** 17,21 **** #ifndef __CYGWIN__ ! #include <net/if_arp.h> #endif --- 17,21 ---- #ifndef __CYGWIN__ ! #include <net/if_arp.h> #endif *************** *** 41,44 **** --- 41,53 ---- #endif + + #ifndef WIN32 + + #define INVALID_SOCKET -1 + #define SOCKET_ERROR -1 + typedef int SOCKET; + + #endif + #define my_uint16_t uint16_t #define my_uint32_t uint32_t Index: crawsocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** crawsocket.h 15 Dec 2006 16:24:58 -0000 1.9 --- crawsocket.h 16 Dec 2006 14:42:42 -0000 1.10 *************** *** 13,17 **** this->domain = domain; this->type = type; ! this->protocol = protocol; sstate = -1; --- 13,17 ---- this->domain = domain; this->type = type; ! this->protocol = protocol; sstate = -1; Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** csocket.h 16 Dec 2006 10:02:50 -0000 1.14 --- csocket.h 16 Dec 2006 14:42:42 -0000 1.15 *************** *** 14,18 **** protected: ! int sid; int domain; int sstate; --- 14,18 ---- protected: ! SOCKET sid; int domain; int sstate; *************** *** 31,53 **** struct hostent *hostpointer = gethostbyaddr((char *) &laddr, sizeof(laddr), AF_INET); ! if (hostpointer == NULL) ! return 0; ! ! for (char **p = hostpointer->h_addr_list; *p != 0; p++) { ! (void) memcpy((char *) &in.s_addr, *p, sizeof(in.s_addr)); ! if (hostpointer->h_name) ! return hostpointer->h_name; ! } ! return 0; } public: ! csocket(int domain = PF_INET, int type = SOCK_STREAM, int sid = -1){ this->domain = domain; this->type = type; ! block = true; sstate = -1; --- 31,53 ---- struct hostent *hostpointer = gethostbyaddr((char *) &laddr, sizeof(laddr), AF_INET); ! if (hostpointer == NULL) ! return 0; ! ! for (char **p = hostpointer->h_addr_list; *p != 0; p++) { ! (void) memcpy((char *) &in.s_addr, *p, sizeof(in.s_addr)); ! if (hostpointer->h_name) ! return hostpointer->h_name; ! } ! return 0; } public: ! csocket(int domain = PF_INET, int type = SOCK_STREAM, SOCKET sid = -1){ this->domain = domain; this->type = type; ! block = true; sstate = -1; *************** *** 55,59 **** if(sid == -1){ this->sid = socket(domain, type, 0); ! if(this->sid < 0) sockerror("socket"); else sstate = 0; }else{ --- 55,59 ---- if(sid == -1){ this->sid = socket(domain, type, 0); ! if(this->sid == SOCKET_ERROR) sockerror("socket"); else sstate = 0; }else{ *************** *** 95,102 **** if(!timeout){ if(block){ ! if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) < 0) return sockerror("connect"); }else{ ! if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) >= 0) return -1; else return errno; --- 95,102 ---- if(!timeout){ if(block){ ! if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) == SOCKET_ERROR) return sockerror("connect"); }else{ ! if(::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) != SOCKET_ERROR) return -1; else return errno; *************** *** 116,122 **** tv.tv_usec = 0; ! int res = select(sid + 1, NULL, &sset, NULL, &tv); ! if (res < 0 && errno != EINTR){ nonblock(false); return ICESOCK_ERRNO; } else if (res == 0){ --- 116,128 ---- tv.tv_usec = 0; ! int ndfs = sid + 1; ! ! #ifdef WIN32 ! int res = select(0, NULL, &sset, NULL, &tv); ! #else ! int res = select(ndfs, NULL, &sset, NULL, &tv); ! #endif ! if (res == SOCKET_ERROR && errno != EINTR){ nonblock(false); return ICESOCK_ERRNO; } else if (res == 0){ *************** *** 135,142 **** return sockerror("sockname"); ! if(::bind(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) < 0) return sockerror("bind"); ! if(::listen(sid, size) < 0) return sockerror("listen"); --- 141,148 ---- return sockerror("sockname"); ! if(::bind(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)) == SOCKET_ERROR) return sockerror("bind"); ! if(::listen(sid, size) == SOCKET_ERROR) return sockerror("listen"); |