/*--------------------------------------------------* * $Header: /usr/src/Projects/rain/RCS/rain_die.c,v 1.1 2001/06/11 20:44:09 root Exp root $ * $Author: root $ * rain_die.c * rain - by Evil (mystic@tenebrous.com) * A flexible packet flooder for testing stability. * Copyright(c) 2001 * Licensed under the GNU General Public License * * $Log: rain_die.c,v $ * Revision 1.1 2001/06/11 20:44:09 root * Initial revision * * Revision 1.1 2001/06/11 02:59:26 root * Initial revision * *-------------------------------------------------*/ #include "rain_common.h" /* * Print version information */ extern void DieWithVersion(void) { printf("\nrain %s (%s) [%s]\n" "Compiled %s %s\n", RAIN_VERSION, RAIN_PLATFORM, RAIN_URL, __DATE__, __TIME__); exit(0); } /* * Main error handling */ extern void DieWithError(char *error, int errornum) { if(errornum == 0); else errno = errornum; fprintf(stderr,"\n\n- - Error...: %s", error); if(errno != 0) fprintf(stderr," (%s)", strerror(errno)); /* * Print possible solutions to certain error numbers: */ printf("\n- - Solution:"); switch(errno) { /* * system errors */ case ENOMEM:{ fprintf(stderr," Try shutting down any unnecessary processes and try again."); break; } /* * socket errors - return values determined from man pages */ case ECONNREFUSED:{ fprintf(stderr," Try a different target port"); break; } case EMSGSIZE:{ fprintf(stderr," Set packet-size below your outgoing MTU (Usually 1500)"); break; } case EACCES:{ fprintf(stderr," Make sure you run this program as root"); break; } case TRY_AGAIN:{ fprintf(stderr, " Use a valid hostname"); break; } case 11: /* resource temporarily unavailable */ case NO_RECOVERY: case ENETUNREACH:{ fprintf(stderr," Make sure you are connected to the internet"); break; } /* * Operation not Supported: */ case 95:{ fprintf(stderr," Your kernel does not support a feature you specified"); break; } /* * custom errors */ case R_CONFLICT:{ fprintf(stderr," Do not combine protocol types such as --tcp and --udp"); break; } case R_CONFLICTTCP:{ fprintf(stderr," The only TCP type flags that can be combined are --ack and --syn"); break; } case R_UNKNOWNICMP:{ fprintf(stderr," Use a valid ICMP type/code combination. Try --help --icmp-type"); break; } case R_NOSPOOF:{ fprintf(stderr, " --stream and --connect cannot be used with a spoofed source address"); break; } case R_NOPROTO:{ fprintf(stderr, " Specify a protocol to use. ie: --tcp, --udp, --icmp, --igmp"); break; } case R_MAXLINES:{ fprintf(stderr," Make sure the config file you specified does not exceed 80 lines"); break; } case R_TOOBIG:{ fprintf(stderr," Make sure payload length does not exceed packet size"); break; } default:{ fprintf(stderr," No suggestions for this error."); break; } } printf("\n"); /* * Free our buffered memory */ freebuf(buffer); exit(1); } /* * Incompatible arguments */ extern void DieWithIncompatible(char *arg1, char *arg2) { fprintf(stderr,"\n- - Error: %s is not compatible with %s\n", arg1, arg2); exit(1); } /* * Bad argument specified */ extern void DieWithBadArg(char *arg) { fprintf(stderr,"\n- - Error: %s is not recognized\n", arg); exit(1); } /* * Argument requires an extra parameter */ extern void DieWithRequire(char *arg) { fprintf(stderr,"\n- - Error: %s requires an argument\n", arg); DieWithHelp(NULL,arg); exit(1); } /* * Print usage */ extern void DieWithUsage(char *program) { fprintf(stderr,"\nUsage: %s [options] -t \n" "Try %s --help for a list of options.\n", program, program); exit(1); } /* * Print help menu * * Note: root and normal users have two * seperate menus */ extern void DieWithHelp(char *program, char *topic) { int i = 0; int userid = getuid(); static unsigned char siminfo[6][16] = { "fawx2.c", "bloop.c", "jolt2.c", "trash2.c", "raped.c" }; /* * root (userid 0) help menu */ if((topic == NULL) && (userid == 0)) { printf("Usage: %s [options] -t \n", program); printf("options available for root:\n" " -v Causes rain to output more information (verbose)\n" " Use up to 3 times for more verbose output\n" " -c Specifies how many packets to send\n" " - Default is 0 (infinite)\n" " -d Specifies delay (in microseconds) between sends\n" " - Default is 10000\n" " -b Specify this option if the target host is a\n" " broadcast address\n" " -s Specifies source address; 0 for random\n" " - Default is 127.0.0.1\n" " -t Specifies target address\n" " --size Specifies packet size in bytes\n" " - Default is 1024\n" " --dport | -p Specifies port on target host\n" " - 0 for random; Default is 138\n" " --sport Specifies port on local host\n" " - 0 for random; Default is 420\n" " --timeout Specifies timeout in seconds\n" " for streamed packets.\n" " --sim Simulate other known attacks\n" " (--help --sim for a list of attacks)\n" "\n" " --noblock Sets non-blocking I/O on socket\n" " --oob Send packets as Out-of-Band data\n" " --noroute Bypass routing table when sending packets\n" "\n" " --udp Use UDP shower\n" "\n" " --tcp Use TCP shower (Default)\n" " --stream Use a streaming, non-spoofed TCP send shower\n" " --connect Use a streaming, non-spoofed TCP connect shower\n" " --seq Specifies the TCP sequence number\n" " - Default is process ID\n" " --win Specifies the TCP window size\n" " - Default is 56\n" " --urg Set TCP URG bit\n" " --ack Set TCP ACK bit\n" " --psh Set TCP PSH bit\n" " --rst Set TCP RST bit\n" " --syn Set TCP SYN bit\n" " --fin Set TCP FIN bit\n" " --ack-seq Specifies the initial TCP acknowledgement sequence\n" " - Default is 0 (overflow)\n" " --res This sets the TCP reserved bits. Default is 0.\n" " - Note: number cannot exceed 15\n" "\n" " --icmp Use ICMP shower\n" " --list-icmp Lists ICMP type/code combinations\n" " --icmp-type Set ICMP type\n" " --icmp-code Set ICMP code\n" " --icmp-id Specifies the ICMP id number\n" " --icmp-seq Specifies the ICMP sequences number\n" " --icmp-mtu Specifies the allowed MTU for certain ICMP types\n" " --icmp-gw | -g
Specifies the ICMP gateway address\n" "\n" " --igmp Use IGMP shower\n" " --list-igmp Lists IGMP type/code combinations\n" " --igmp-type Set IGMP type\n" " --igmp-code Set IGMP code\n" " --igmp-ga | -g
Specifies the IGMP group address\n" "\n" " --frag Set fragment offset; - Default is 0 (No setting)\n" " --df Set \"Don't Fragment\" bits\n" " --tos Specifies Type of Service value\n" " --ttl Specifies the Time to Live of the packet\n" " - Default is 64\n" " --id Specifies the id sequence of the packet\n" " - Default is the process ID\n" " --id-of When specified, rain will overflow the id field\n" " of each packet by increasing it with each send\n" " --payload | --pl Specifies an (optional) string to store in the\n" " packet's payload\n" " --fill Specifies an ascii character to fill the send\n" " buffer with.\n" " - This does not conflict with --payload\n" "\n" " --version | -V Prints version information\n" " --help Prints this help menu\n" "\nTry %s --help