home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / fragrouter / Libnet-0.99b / test / test-step.sh < prev   
Encoding:
Linux/UNIX/POSIX Shell Script  |  1999-07-26  |  6.8 KB  |  292 lines

  1. #!/bin/sh
  2. #
  3. #   $Id: test-step.sh,v 1.1.1.1 1999/05/18 15:33:42 dugsong Exp $
  4. #
  5. #   libnet
  6. #   Copyright (c) 1998, 1999 Mike D. Schiffman <mike@infonexus.com>
  7. #                             route|daemon9 <route@infonexus.com>
  8. #   All rights reserved.
  9. #
  10. #   Redistribution and use in source and binary forms, with or without
  11. #   modification, are permitted provided that the following conditions
  12. #   are met:
  13. #
  14. #   1. Redistributions of source code must retain the above copyright
  15. #      notice, this list of conditions and the following disclaimer.
  16. #   2. Redistributions in binary form must reproduce the above copyright
  17. #      notice, this list of conditions and the following disclaimer in the
  18. #      documentation and/or other materials provided with the distribution.
  19. #
  20. #   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21. #   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. #   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. #   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24. #   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. #   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. #   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. #   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. #   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. #   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. #   SUCH DAMAGE.
  31.  
  32. #
  33. #   Hard coded defaults (ie: user hits enter at prompts)
  34. #
  35.  
  36. DST_IP=10.0.0.1
  37. SRC_IP=10.0.0.2
  38. SRC_PRT=100
  39. DST_PRT=200
  40. DEV=de0
  41.  
  42. echo "Libnet test code step through dealy"
  43. echo ""
  44. echo "This script will run you through all the testcode modules and verify
  45. echo "functionality \(hopefully\).  You may want to use tcpdump in conjuction
  46. echo "with this script to make sure things are working as they should be."
  47. echo ""
  48. echo "Although this script is here to quickly take you through the testcode"
  49. echo "modules and confirm correct operation, the user is encouraged to descend"
  50. echo "into the test directories and peruse the code for examples on how to use"
  51. echo "the library effectively."
  52. echo ""
  53. echo "I will need some information from you for some of these tests."
  54. echo "We don't check for sane input here, so don't be an idiot."
  55. echo ""
  56.  
  57. #
  58. #   Intial setup.
  59. #
  60.  
  61. echo -n "Most of the test modules require a source IP address (x.x.x.x): "
  62. read tmp
  63. if test "$__tmp" != ""; then
  64.     SRC_IP=__tmp
  65. fi
  66.  
  67. echo -n "And most of the test modules also require a destinaion IP address (x.x.x.x): "
  68. read __tmp
  69. if test "$__tmp" != ""; then
  70.     DST_IP=__tmp
  71. fi
  72.  
  73. echo -n "The TCP and UDP tests need a source port: "
  74. read __tmp
  75. if test "$__tmp" != ""; then
  76.     SRC_PRT=__tmp
  77. fi
  78.  
  79. echo -n "And a destination port: "
  80. read __tmp
  81. if test "$__tmp" != ""; then
  82.     DST_PRT=__tmp
  83. fi
  84.  
  85. echo -n "Some need a link-layer device: "
  86. read __tml
  87. if test "$__tmp" != ""; then
  88.     DEV=__tmp
  89. fi
  90.  
  91. echo -n "The ethernet tests need a source ethernet address (x:x:x:x:x:x):"
  92. read __tmp
  93. if test "$__tmp" != ""; then
  94.     SRC_ETH=__tmp
  95. fi
  96.  
  97. echo -n "And a destination ethernet address (x:x:x:x:x:x):"
  98. read __tmp
  99. if test "$__tmp" != ""; then
  100.     DST_ETH=__tmp
  101. fi
  102.  
  103. echo "Gotit!  The game can start now."
  104.  
  105. #
  106. #   Internal win/loss variable setup.
  107. #
  108.  
  109. TOTAL_WON=$((0))
  110. TOTAL_LOST=$((0))
  111.  
  112. # The TCP tests
  113. WIN=$((0))
  114. LOSE=$((0))
  115. cd TCP
  116. echo ""
  117. echo "TCP test suite"
  118.  
  119. if test -x tcp; then
  120.     ./tcp -s$SRC_IP.$SRC_PRT -d$DST_IP.$DST_PRT
  121.     if [ $? -eq -0 ]; then
  122.         WIN=`expr $WIN + 1`
  123.     else
  124.         LOSE=`expr $LOSE + 1`
  125.     fi
  126.     echo "-return-"
  127.     read
  128. fi
  129. if test -x tcp+data; then
  130.     ./tcp+data -s$SRC_IP.$SRC_PRT -d$DST_IP.$DST_PRT
  131.     if [ $? -eq -0 ]; then
  132.         WIN=`expr $WIN + 1`
  133.     else
  134.         LOSE=`expr $LOSE + 1`
  135.     fi
  136.     echo "-return-"
  137.     read
  138. fi
  139. if test -x tcp+data+ipopt; then
  140.     ./tcp+data+ipopt -s$SRC_IP.$SRC_PRT -d$DST_IP.$DST_PRT
  141.     if [ $? -eq -0 ]; then
  142.         WIN=`expr $WIN + 1`
  143.     else
  144.         LOSE=`expr $LOSE + 1`
  145.     fi
  146.     echo "-return-"
  147.     read
  148. fi
  149.  
  150. echo "completed TCP test suite $WIN test(s) succeeded, $LOSE test(s) failed"
  151. TOTAL_WON=`expr $TOTAL_WON + $WIN`
  152. TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
  153. cd ..
  154.  
  155. # The UDP tests
  156. WIN=$((0))
  157. LOSE=$((0))
  158. cd UDP
  159. echo ""
  160. echo "UDP test suite"
  161.  
  162. if test -x udp; then
  163.     ./udp -s$SRC_IP.$SRC_PRT -d$DST_IP.$DST_PRT
  164.     if [ $? -eq -0 ]; then
  165.         WIN=`expr $WIN + 1`
  166.     else
  167.         LOSE=`expr $LOSE + 1`
  168.     fi
  169.     echo "-return-"
  170.     read
  171. fi
  172. if test -x udp+data; then
  173.     ./udp+data -s$SRC_IP.$SRC_PRT -d$DST_IP.$DST_PRT
  174.     if [ $? -eq -0 ]; then
  175.         WIN=`expr $WIN + 1`
  176.     else
  177.         LOSE=`expr $LOSE + 1`
  178.     fi
  179.     echo "-return-"
  180.     read
  181. fi
  182.  
  183. echo "completed UDP test suite $WIN test(s) succeeded, $LOSE test(s) failed"
  184. TOTAL_WON=`expr $TOTAL_WON + $WIN`
  185. TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
  186. cd ..
  187.  
  188. # The ICMP tests
  189. WIN=$((0))
  190. LOSE=$((0))
  191. cd ICMP
  192. echo ""
  193. echo "ICMP test suite"
  194.  
  195. if test -x icmp_echo; then
  196.     ./icmp_echo -s$SRC_IP -d$DST_IP
  197.     if [ $? -eq -0 ]; then
  198.         WIN=`expr $WIN + 1`
  199.     else
  200.         LOSE=`expr $LOSE + 1`
  201.     fi
  202.     echo "-return-"
  203.     read
  204. fi
  205. if test -x icmp_timestamp; then
  206.     ./icmp_timestamp -s$SRC_IP -d$DST_IP
  207.     if [ $? -eq -0 ]; then
  208.         WIN=`expr $WIN + 1`
  209.     else
  210.         LOSE=`expr $LOSE + 1`
  211.     fi
  212.     echo "-return-"
  213.     read
  214. fi
  215. if test -x icmp_timexceed; then
  216.     ./icmp_timexceed -s$SRC_IP -d$DST_IP
  217.     if [ $? -eq -0 ]; then
  218.         WIN=`expr $WIN + 1`
  219.     else
  220.         LOSE=`expr $LOSE + 1`
  221.     fi
  222.     echo "-return-"
  223.     read
  224. fi
  225. if test -x icmp_unreach; then
  226.     ./icmp_unreach -s$SRC_IP -d$DST_IP
  227.     if [ $? -eq -0 ]; then
  228.         WIN=`expr $WIN + 1`
  229.     else
  230.         LOSE=`expr $LOSE + 1`
  231.     fi
  232.     echo "-return-"
  233.     read
  234. fi
  235.  
  236. echo "completed ICMP test suite $WIN test(s) succeeded, $LOSE test(s) failed"
  237. TOTAL_WON=`expr $TOTAL_WON + $WIN`
  238. TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
  239. cd ..
  240.  
  241. # The Ethernet tests
  242. WIN=$((0))
  243. LOSE=$((0))
  244. cd Ethernet
  245. echo ""
  246. echo "Ethernet test suite"
  247.  
  248. if test -x icmp_mask; then
  249.     ./icmp_mask -i$DEV -s$SRC_IP -d$DST_IP
  250.     if [ $? -eq -0 ]; then
  251.         WIN=`expr $WIN + 1`
  252.     else
  253.         LOSE=`expr $LOSE + 1`
  254.     fi
  255.     echo "-return-"
  256.     read
  257. fi
  258. if test -x arp; then
  259.     ./arp -i$DEV
  260.     if [ $? -eq -0 ]; then
  261.         WIN=`expr $WIN + 1`
  262.     else
  263.         LOSE=`expr $LOSE + 1`
  264.     fi
  265.     echo "-return-"
  266.     read
  267. fi
  268. if test -x tcp; then
  269.     ./tcp -i$DEV -s$SRC_IP.$SRC_PRT -d$DST_IP.$DST_PRT
  270.     if [ $? -eq -0 ]; then
  271.         WIN=`expr $WIN + 1`
  272.     else
  273.         LOSE=`expr $LOSE + 1`
  274.     fi
  275.     echo "-return-"
  276.     read
  277. fi
  278.  
  279. echo "completed Ethernet test suite $WIN test(s) succeeded, $LOSE test(s) failed"
  280. TOTAL_WON=`expr $TOTAL_WON + $WIN`
  281. TOTAL_LOST=`expr $TOTAL_LOST + $LOSE`
  282. cd ..
  283.  
  284. # Random tests
  285.  
  286.  
  287. # IP tests
  288.  
  289. echo "completed entire test suite $TOTAL_WON test(s) succeeded, $TOTAL_LOST test(s) failed"
  290.  
  291. # EOF
  292.