attack.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. #!/bin/bash
  2. #
  3. # attack the test server and try to make it fall over
  4. #
  5. SERVER=127.0.0.1
  6. PORT=7681
  7. LOG=/tmp/lwslog
  8. A=`which libwebsockets-test-server`
  9. INSTALLED=`dirname $A`
  10. CPID=
  11. LEN=0
  12. function check {
  13. kill -0 $CPID
  14. if [ $? -ne 0 ] ; then
  15. echo "(killed it) *******"
  16. exit 1
  17. fi
  18. dd if=$LOG bs=1 skip=$LEN 2>/dev/null
  19. if [ "$1" = "default" ] ; then
  20. diff /tmp/lwscap $INSTALLED/../share/libwebsockets-test-server/test.html > /dev/null
  21. if [ $? -ne 0 ] ; then
  22. echo "FAIL: got something other than test.html back"
  23. exit 1
  24. fi
  25. fi
  26. if [ "$1" = "defaultplusforbidden" ] ; then
  27. cat $INSTALLED/../share/libwebsockets-test-server/test.html > /tmp/plusforb
  28. echo -e -n "HTTP/1.1 403 Forbidden\x0d\x0aserver: libwebsockets\x0d\x0acontent-type: text/html\x0d\x0acontent-length: 38\x0d\x0a\x0d\x0a<html><body><h1>403</h1></body></html>" >> /tmp/plusforb
  29. diff /tmp/lwscap /tmp/plusforb > /dev/null
  30. if [ $? -ne 0 ] ; then
  31. echo "FAIL: got something other than test.html back"
  32. exit 1
  33. fi
  34. fi
  35. if [ "$1" = "forbidden" ] ; then
  36. if [ -z "`grep '<h1>403</h1>' /tmp/lwscap`" ] ; then
  37. echo "FAIL: should have told forbidden (test server has no dirs)"
  38. exit 1
  39. fi
  40. fi
  41. if [ "$1" = "rejected" ] ; then
  42. if [ -z "`grep '<h1>406</h1>' /tmp/lwscap`" ] ; then
  43. echo "FAIL: should have told forbidden (test server has no dirs)"
  44. exit 1
  45. fi
  46. fi
  47. if [ "$1" = "media" ] ; then
  48. if [ -z "`grep '<h1>415</h1>' /tmp/lwscap`" ] ; then
  49. echo "FAIL: should have told unknown media type"
  50. exit 1
  51. fi
  52. fi
  53. if [ "$1" == "0" ] ; then
  54. a="`dd if=$LOG bs=1 skip=$LEN 2>/dev/null |grep "get\ \ =" | tr -s ' ' | cut -d' ' -f4-`"
  55. if [ "$a" != "$2" ] ; then
  56. echo "URL path '$a' not $2"
  57. exit 1
  58. fi
  59. fi
  60. if [ "$1" == "1" ] ; then
  61. a="`dd if=$LOG bs=1 skip=$LEN 2>/dev/null |grep URI\ Arg\ 1\: | tr -s ' ' | cut -d' ' -f5-`"
  62. if [ "$a" != "$2" ] ; then
  63. echo "Arg 1 '$a' not $2"
  64. exit 1
  65. fi
  66. fi
  67. if [ "$1" == "2" ] ; then
  68. a="`dd if=$LOG bs=1 skip=$LEN 2>/dev/null |grep URI\ Arg\ 2\: | tr -s ' ' | cut -d' ' -f5-`"
  69. if [ "$a" != "$2" ] ; then
  70. echo "Arg 2 '$a' not $2"
  71. exit 1
  72. fi
  73. fi
  74. if [ "$1" == "3" ] ; then
  75. a="`dd if=$LOG bs=1 skip=$LEN 2>/dev/null |grep URI\ Arg\ 3\: | tr -s ' ' | cut -d' ' -f5-`"
  76. if [ "$a" != "$2" ] ; then
  77. echo "Arg 3 '$a' not $2"
  78. exit 1
  79. fi
  80. fi
  81. if [ -z "$1" ] ; then
  82. LEN=`stat $LOG -c %s`
  83. fi
  84. }
  85. rm -rf $LOG
  86. killall libwebsockets-test-server 2>/dev/null
  87. libwebsockets-test-server -d15 2>> $LOG &
  88. CPID=$!
  89. while [ -z "`grep Listening $LOG`" ] ; do
  90. sleep 0.5s
  91. done
  92. check
  93. echo
  94. echo "---- /cgi-bin/settingsjs?UPDATE_SETTINGS=1&Root_Channels_1_Channel_name_http_post=%3F&Root_Channels_1_Channel_location_http_post=%3F"
  95. rm -f /tmp/lwscap
  96. echo -e "GET /cgi-bin/settingsjs?UPDATE_SETTINGS=1&Root_Channels_1_Channel_name_http_post=%3F&Root_Channels_1_Channel_location_http_post=%3F HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  97. check 1 "UPDATE_SETTINGS=1"
  98. check 2 "Root_Channels_1_Channel_name_http_post=?"
  99. check 3 "Root_Channels_1_Channel_location_http_post=?"
  100. check
  101. echo
  102. echo "---- ? processing (/cgi-bin/settings.js?key1=value1)"
  103. rm -f /tmp/lwscap
  104. echo -e "GET /cgi-bin/settings.js?key1=value1 HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  105. check 1 "key1=value1"
  106. check
  107. echo
  108. echo "---- ? processing (/t%3dest?key1%3d2=value1)"
  109. rm -f /tmp/lwscap
  110. echo -e "GET /t%3dest?key1%3d2=value1 HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  111. check 0 "/t=est"
  112. check 1 "key1_2=value1"
  113. check
  114. echo
  115. echo "---- ? processing (%2f%2e%2e%2f%2e./test.html?arg=1)"
  116. rm -f /tmp/lwscap
  117. echo -e "GET %2f%2e%2e%2f%2e./test.html?arg=1 HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  118. check 1 "arg=1"
  119. check
  120. echo
  121. echo "---- ? processing (%2f%2e%2e%2f%2e./test.html?arg=/../.)"
  122. rm -f /tmp/lwscap
  123. echo -e "GET %2f%2e%2e%2f%2e./test.html?arg=/../. HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  124. check 1 "arg=/../."
  125. check
  126. echo
  127. echo "---- spam enough crap to not be GET"
  128. echo "not GET" | nc $SERVER $PORT
  129. check
  130. echo
  131. echo "---- spam more than the name buffer of crap"
  132. dd if=/dev/urandom bs=1 count=80 2>/dev/null | nc -i1s $SERVER $PORT
  133. check
  134. echo
  135. echo "---- spam 10MB of crap"
  136. dd if=/dev/urandom bs=1 count=655360 | nc -i1s $SERVER $PORT
  137. check
  138. echo
  139. echo "---- malformed URI"
  140. echo "GET nonsense................................................................................................................" \
  141. | nc -i1s $SERVER $PORT
  142. check
  143. echo
  144. echo "---- missing URI"
  145. echo -e "GET HTTP/1.1\x0d\x0a\x0d\x0a" | nc -i1s $SERVER $PORT >/tmp/lwscap
  146. check
  147. echo
  148. echo "---- repeated method"
  149. echo -e "GET blah HTTP/1.1\x0d\x0aGET blah HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT >/tmp/lwscap
  150. check
  151. echo
  152. echo "---- crazy header name part"
  153. echo -e "GET blah HTTP/1.1\x0d\x0a................................................................................................................" \
  154. "......................................................................................................................." \
  155. "......................................................................................................................." \
  156. "......................................................................................................................." \
  157. "......................................................................................................................." \
  158. "......................................................................................................................." \
  159. "......................................................................................................................." \
  160. "......................................................................................................................." \
  161. "......................................................................................................................." \
  162. "......................................................................................................................." \
  163. "......................................................................................................................." \
  164. "......................................................................................................................." \
  165. "......................................................................................................................." \
  166. "......................................................................................................................." \
  167. "......................................................................................................................." \
  168. "......................................................................................................................." \
  169. "......................................................................................................................." \
  170. | nc -i1s $SERVER $PORT
  171. check
  172. echo
  173. echo "---- excessive uri content"
  174. echo -e "GET ................................................................................................................" \
  175. "......................................................................................................................." \
  176. "......................................................................................................................." \
  177. "......................................................................................................................." \
  178. "......................................................................................................................." \
  179. "......................................................................................................................." \
  180. "......................................................................................................................." \
  181. "......................................................................................................................." \
  182. "......................................................................................................................." \
  183. "......................................................................................................................." \
  184. "......................................................................................................................." \
  185. "......................................................................................................................." \
  186. "......................................................................................................................." \
  187. "......................................................................................................................." \
  188. "......................................................................................................................." \
  189. "......................................................................................................................." \
  190. "......................................................................................................................." \
  191. | nc -i1s $SERVER $PORT
  192. check
  193. echo
  194. echo "---- good request but http payload coming too (should be ignored and test.html served)"
  195. echo -e "GET /test.html HTTP/1.1\x0d\x0a\x0d\x0aILLEGAL-PAYLOAD........................................" \
  196. "......................................................................................................................." \
  197. "......................................................................................................................." \
  198. "......................................................................................................................." \
  199. "......................................................................................................................." \
  200. "......................................................................................................................." \
  201. "......................................................................................................................." \
  202. "......................................................................................................................." \
  203. "......................................................................................................................." \
  204. "......................................................................................................................." \
  205. "......................................................................................................................." \
  206. "......................................................................................................................." \
  207. "......................................................................................................................." \
  208. "......................................................................................................................." \
  209. "......................................................................................................................." \
  210. "......................................................................................................................." \
  211. | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  212. check defaultplusforbidden
  213. check
  214. echo
  215. echo "---- nonexistent file"
  216. rm -f /tmp/lwscap
  217. echo -e "GET /nope HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  218. check media
  219. check
  220. echo
  221. echo "---- relative uri path"
  222. rm -f /tmp/lwscap
  223. echo -e "GET nope HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  224. check forbidden
  225. check
  226. echo
  227. echo "---- directory attack 1 (/../../../../etc/passwd should be /etc/passswd)"
  228. rm -f /tmp/lwscap
  229. echo -e "GET /../../../../etc/passwd HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  230. check rejected
  231. check
  232. echo
  233. echo "---- directory attack 2 (/../ should be /)"
  234. rm -f /tmp/lwscap
  235. echo -e -n "GET /../ HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  236. check default
  237. check
  238. echo
  239. echo "---- directory attack 3 (/./ should be /)"
  240. rm -f /tmp/lwscap
  241. echo -e -n "GET /./ HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  242. check default
  243. check
  244. echo
  245. echo "---- directory attack 4 (/blah/.. should be /)"
  246. rm -f /tmp/lwscap
  247. echo -e -n "GET /blah/.. HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  248. check default
  249. check
  250. echo
  251. echo "---- directory attack 5 (/blah/../ should be /)"
  252. rm -f /tmp/lwscap
  253. echo -e -n "GET /blah/../ HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  254. check default
  255. check
  256. echo
  257. echo "---- directory attack 6 (/blah/../. should be /)"
  258. rm -f /tmp/lwscap
  259. echo -e -n "GET /blah/../. HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  260. check default
  261. check
  262. echo
  263. echo "---- directory attack 7 (/%2e%2e%2f../../../etc/passwd should be /etc/passswd)"
  264. rm -f /tmp/lwscap
  265. echo -e -n "GET /%2e%2e%2f../../../etc/passwd HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  266. check rejected
  267. check
  268. echo
  269. echo "---- directory attack 8 (%2f%2e%2e%2f%2e./.%2e/.%2e%2fetc/passwd should be /etc/passswd)"
  270. rm -f /tmp/lwscap
  271. echo -e -n "GET %2f%2e%2e%2f%2e./.%2e/.%2e%2fetc/passwd HTTP/1.1\x0d\x0a\x0d\x0a" | nc $SERVER $PORT | sed '1,/^\r$/d'> /tmp/lwscap
  272. check rejected
  273. check
  274. echo
  275. echo "---- http/1.1 pipelining"
  276. rm -f /tmp/lwscap
  277. wget -O/tmp/lwsdump http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html 2>&1 | grep "Downloaded: 8 files" > /tmp/lwscap
  278. good=`cat $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html $INSTALLED/../share/libwebsockets-test-server/test.html | md5sum | cut -d' ' -f1`
  279. if [ "$good" != "`md5sum /tmp/lwsdump | cut -d' ' -f 1`" ] ; then
  280. echo "FAIL: mismatched content good=$good received=`md5sum /tmp/lwsdump`"
  281. exit 1
  282. fi
  283. echo
  284. echo "---- mass testing uri variations"
  285. rm -f /tmp/results
  286. for i in \
  287. /..../ \
  288. /.../. \
  289. /...// \
  290. /.../a \
  291. /.../w \
  292. /.../? \
  293. /.../% \
  294. /../.. \
  295. /.././ \
  296. /../.a \
  297. /../.w \
  298. /../.. \
  299. /../.% \
  300. /..//. \
  301. /../// \
  302. /..//a \
  303. /..//w \
  304. /..//? \
  305. /..//% \
  306. /../a. \
  307. /../a/ \
  308. /../aa \
  309. /../aw \
  310. /../a? \
  311. /../a% \
  312. /../w. \
  313. /../w/ \
  314. /../wa \
  315. /../ww \
  316. /../w? \
  317. /../w% \
  318. /../?. \
  319. /../?/ \
  320. /../?a \
  321. /../?w \
  322. /../?? \
  323. /../?% \
  324. /../%. \
  325. /../%/ \
  326. /../%a \
  327. /../%w \
  328. /../%? \
  329. /../%% \
  330. /./... \
  331. /./../ \
  332. /./..a \
  333. /./..w \
  334. /./..? \
  335. /./..% \
  336. /.//.. \
  337. /.a../ \
  338. /.a/.. \
  339. /.w../ \
  340. /.w/.. \
  341. /.?../ \
  342. /../.. \
  343. /.%../ \
  344. /.%/.. \
  345. //.... \
  346. //.../ \
  347. //...a \
  348. //...w \
  349. //...? \
  350. //...% \
  351. //../. \
  352. //..// \
  353. //../a \
  354. //../w \
  355. //../? \
  356. //../% \
  357. //..a. \
  358. //..a/ \
  359. //..aa \
  360. //..aw \
  361. //..a? \
  362. //..a% \
  363. //..w. \
  364. //..w/ \
  365. //..wa \
  366. //..ww \
  367. //..w? \
  368. //..w% \
  369. //..?. \
  370. //..?/ \
  371. //..?a \
  372. //..?w \
  373. //..?? \
  374. //..?% \
  375. //..%. \
  376. //..%/ \
  377. //..%a \
  378. //..%w \
  379. //..%? \
  380. //..%% \
  381. //./.. \
  382. ///... \
  383. ///../ \
  384. ///..a \
  385. ///..w \
  386. ///..? \
  387. ///..% \
  388. ////.. \
  389. //a../ \
  390. //a/.. \
  391. //w../ \
  392. //w/.. \
  393. //?../ \
  394. //?/.. \
  395. //%../ \
  396. //%/.. \
  397. /a.../ \
  398. /a../. \
  399. /a..// \
  400. /a../a \
  401. /a../w \
  402. /a../? \
  403. /a../% \
  404. /a./.. \
  405. /a/... \
  406. /a/../ \
  407. /a/..a \
  408. /a/..w \
  409. /a/..? \
  410. /a/..% \
  411. /a//.. \
  412. /aa../ \
  413. /aa/.. \
  414. /aw../ \
  415. /aw/.. \
  416. /a?../ \
  417. /a?/.. \
  418. /a%../ \
  419. /a%/.. \
  420. /w.../ \
  421. /w../. \
  422. /w..// \
  423. /w../a \
  424. /w../w \
  425. /w../? \
  426. /w../% \
  427. /w./.. \
  428. /w/... \
  429. /w/../ \
  430. /w/..a \
  431. /w/..w \
  432. /w/..? \
  433. /w/..% \
  434. /w//.. \
  435. /wa../ \
  436. /wa/.. \
  437. /ww../ \
  438. /ww/.. \
  439. /w?../ \
  440. /w?/.. \
  441. /w%../ \
  442. /w%/.. \
  443. /?.../ \
  444. /?../. \
  445. /?..// \
  446. /?../a \
  447. /?../w \
  448. /?../? \
  449. /?../% \
  450. /?./.. \
  451. /?/... \
  452. /?/../ \
  453. /?/..a \
  454. /?/..w \
  455. /?/..? \
  456. /?/..% \
  457. /?//.. \
  458. /?a../ \
  459. /?a/.. \
  460. /?w../ \
  461. /?w/.. \
  462. /??../ \
  463. /??/.. \
  464. /?%../ \
  465. /?%/.. \
  466. /%.../ \
  467. /%../. \
  468. /%..// \
  469. /%../a \
  470. /%../w \
  471. /%../? \
  472. /%../% \
  473. /%./.. \
  474. /%/... \
  475. /%/../ \
  476. /%/..a \
  477. /%/..w \
  478. /%/..? \
  479. /%/..% \
  480. /%//.. \
  481. /%a../ \
  482. /%a/.. \
  483. /%w../ \
  484. /%w/.. \
  485. /%?../ \
  486. /%?/.. \
  487. /%%../ \
  488. /%%/.. \
  489. /a/w/../a \
  490. /path/to/dir/../other/dir \
  491. ; do
  492. R=`rm -f /tmp/lwscap ; echo -n -e "GET $i HTTP/1.0\r\n\r\n" | nc localhost 7681 2>/dev/null >/tmp/lwscap; head -n1 /tmp/lwscap| cut -d' ' -f2`
  493. cat /tmp/lwscap | head -n1
  494. echo ==== $R
  495. if [ "$R" != "403" ]; then
  496. U=`cat $LOG | grep lws_http_serve | tail -n 1 | cut -d':' -f3 | cut -d' ' -f2`
  497. echo $U
  498. echo "- \"$i\" -> $R \"$U\"" >>/tmp/results
  499. else
  500. echo "- \"$i\" -> $R" >>/tmp/results
  501. fi
  502. done
  503. cat <<EOF >/tmp/lwsresult1
  504. - "/..../" -> 406 "/..../"
  505. - "/.../." -> 406 "/.../"
  506. - "/...//" -> 406 "/.../"
  507. - "/.../a" -> 406 "/.../a"
  508. - "/.../w" -> 406 "/.../w"
  509. - "/.../?" -> 406 "/.../"
  510. - "/.../%" -> 403
  511. - "/../.." -> 200 "/"
  512. - "/.././" -> 200 "/"
  513. - "/../.a" -> 415 "/.a"
  514. - "/../.w" -> 415 "/.w"
  515. - "/../.." -> 200 "/"
  516. - "/../.%" -> 403
  517. - "/..//." -> 200 "/"
  518. - "/..///" -> 200 "/"
  519. - "/..//a" -> 415 "/a"
  520. - "/..//w" -> 415 "/w"
  521. - "/..//1" -> 415 "/1"
  522. - "/..//%" -> 403
  523. - "/../a." -> 415 "/a."
  524. - "/../a/" -> 406 "/a/"
  525. - "/../aa" -> 415 "/aa"
  526. - "/../aw" -> 415 "/aw"
  527. - "/../a?" -> 415 "/a"
  528. - "/../a%" -> 403
  529. - "/../w." -> 415 "/w."
  530. - "/../w/" -> 406 "/w/"
  531. - "/../wa" -> 415 "/wa"
  532. - "/../ww" -> 415 "/ww"
  533. - "/../w?" -> 415 "/w"
  534. - "/../w%" -> 403
  535. - "/../?." -> 200 "/"
  536. - "/../?/" -> 200 "/"
  537. - "/../?a" -> 200 "/"
  538. - "/../?w" -> 200 "/"
  539. - "/../??" -> 200 "/"
  540. - "/../?%" -> 403
  541. - "/../%." -> 403
  542. - "/../%/" -> 403
  543. - "/../%a" -> 403
  544. - "/../%w" -> 403
  545. - "/../%?" -> 403
  546. - "/../%%" -> 403
  547. - "/./..." -> 415 "/..."
  548. - "/./../" -> 200 "/"
  549. - "/./..a" -> 415 "/..a"
  550. - "/./..w" -> 415 "/..w"
  551. - "/./..?" -> 200 "/"
  552. - "/./..%" -> 403
  553. - "/.//.." -> 200 "/"
  554. - "/.a../" -> 406 "/.a../"
  555. - "/.a/.." -> 200 "/"
  556. - "/.w../" -> 406 "/.w../"
  557. - "/.w/.." -> 200 "/"
  558. - "/.?../" -> 415 "/."
  559. - "/../.." -> 200 "/"
  560. - "/.%../" -> 403
  561. - "/.%/.." -> 403
  562. - "//...." -> 415 "/...."
  563. - "//.../" -> 406 "/.../"
  564. - "//...a" -> 415 "/...a"
  565. - "//...w" -> 415 "/...w"
  566. - "//...?" -> 415 "/..."
  567. - "//...%" -> 403
  568. - "//../." -> 200 "/"
  569. - "//..//" -> 200 "/"
  570. - "//../a" -> 415 "/a"
  571. - "//../w" -> 415 "/w"
  572. - "//../1" -> 415 "/1"
  573. - "//../%" -> 403
  574. - "//..a." -> 415 "/..a."
  575. - "//..a/" -> 406 "/..a/"
  576. - "//..aa" -> 415 "/..aa"
  577. - "//..aw" -> 415 "/..aw"
  578. - "//..a?" -> 415 "/..a"
  579. - "//..a%" -> 403
  580. - "//..w." -> 415 "/..w."
  581. - "//..w/" -> 406 "/..w/"
  582. - "//..wa" -> 415 "/..wa"
  583. - "//..ww" -> 415 "/..ww"
  584. - "//..w?" -> 415 "/..w"
  585. - "//..w%" -> 403
  586. - "//..?." -> 200 "/"
  587. - "//..?/" -> 200 "/"
  588. - "//..?a" -> 415 "/a"
  589. - "//..?w" -> 415 "/w"
  590. - "//..??" -> 200 "/"
  591. - "//..?%" -> 403
  592. - "//..%." -> 403
  593. - "//..%/" -> 403
  594. - "//..%a" -> 403
  595. - "//..%w" -> 403
  596. - "//..%?" -> 403
  597. - "//..%%" -> 403
  598. - "//./.." -> 200 "/"
  599. - "///..." -> 415 "/..."
  600. - "///../" -> 200 "/"
  601. - "///..a" -> 415 "/..a"
  602. - "///..w" -> 415 "/..w"
  603. - "///..?" -> 200 "/"
  604. - "///..%" -> 403
  605. - "////.." -> 200 "/"
  606. - "//a../" -> 406 "/a../"
  607. - "//a/.." -> 200 "/"
  608. - "//w../" -> 406 "/w../"
  609. - "//w/.." -> 200 "/"
  610. - "//?../" -> 200 "/"
  611. - "//?/.." -> 200 "/"
  612. - "//%../" -> 403
  613. - "//%/.." -> 403
  614. - "/a.../" -> 406 "/a.../"
  615. - "/a../." -> 406 "/a../"
  616. - "/a..//" -> 406 "/a../"
  617. - "/a../a" -> 406 "/a../a"
  618. - "/a../w" -> 406 "/a../w"
  619. - "/a../?" -> 406 "/a../"
  620. - "/a../%" -> 403
  621. - "/a./.." -> 200 "/"
  622. - "/a/..." -> 406 "/a/..."
  623. - "/a/../" -> 200 "/"
  624. - "/a/..a" -> 406 "/a/..a"
  625. - "/a/..w" -> 406 "/a/..w"
  626. - "/a/..?" -> 200 "/"
  627. - "/a/..%" -> 403
  628. - "/a//.." -> 200 "/"
  629. - "/aa../" -> 406 "/aa../"
  630. - "/aa/.." -> 200 "/"
  631. - "/aw../" -> 406 "/aw../"
  632. - "/aw/.." -> 200 "/"
  633. - "/a?../" -> 415 "/a"
  634. - "/a?/.." -> 415 "/a"
  635. - "/a%../" -> 403
  636. - "/a%/.." -> 403
  637. - "/w.../" -> 406 "/w.../"
  638. - "/w../." -> 406 "/w../"
  639. - "/w..//" -> 406 "/w../"
  640. - "/w../a" -> 406 "/w../a"
  641. - "/w../w" -> 406 "/w../w"
  642. - "/w../?" -> 406 "/w../"
  643. - "/w../%" -> 403
  644. - "/w./.." -> 200 "/"
  645. - "/w/..." -> 406 "/w/..."
  646. - "/w/../" -> 200 "/"
  647. - "/w/..a" -> 406 "/w/..a"
  648. - "/w/..w" -> 406 "/w/..w"
  649. - "/w/..?" -> 200 "/"
  650. - "/w/..%" -> 403
  651. - "/w//.." -> 200 "/"
  652. - "/wa../" -> 406 "/wa../"
  653. - "/wa/.." -> 200 "/"
  654. - "/ww../" -> 406 "/ww../"
  655. - "/ww/.." -> 200 "/"
  656. - "/w?../" -> 415 "/w"
  657. - "/w?/.." -> 415 "/w"
  658. - "/w%../" -> 403
  659. - "/w%/.." -> 403
  660. - "/?.../" -> 200 "/"
  661. - "/?../." -> 200 "/"
  662. - "/?..//" -> 200 "/"
  663. - "/?../a" -> 200 "/"
  664. - "/?../w" -> 200 "/"
  665. - "/?../?" -> 200 "/"
  666. - "/?../%" -> 403
  667. - "/?./.." -> 200 "/"
  668. - "/?/..." -> 200 "/"
  669. - "/?/../" -> 200 "/"
  670. - "/?/..a" -> 200 "/"
  671. - "/?/..w" -> 200 "/"
  672. - "/?/..?" -> 200 "/"
  673. - "/?/..%" -> 403
  674. - "/?//.." -> 200 "/"
  675. - "/?a../" -> 200 "/"
  676. - "/?a/.." -> 200 "/"
  677. - "/?w../" -> 200 "/"
  678. - "/?w/.." -> 200 "/"
  679. - "/??../" -> 200 "/"
  680. - "/??/.." -> 200 "/"
  681. - "/?%../" -> 403
  682. - "/?%/.." -> 403
  683. - "/%.../" -> 403
  684. - "/%../." -> 403
  685. - "/%..//" -> 403
  686. - "/%../a" -> 403
  687. - "/%../w" -> 403
  688. - "/%../?" -> 403
  689. - "/%../%" -> 403
  690. - "/%./.." -> 403
  691. - "/%/..." -> 403
  692. - "/%/../" -> 403
  693. - "/%/..a" -> 403
  694. - "/%/..w" -> 403
  695. - "/%/..?" -> 403
  696. - "/%/..%" -> 403
  697. - "/%//.." -> 403
  698. - "/%a../" -> 403
  699. - "/%a/.." -> 403
  700. - "/%w../" -> 403
  701. - "/%w/.." -> 403
  702. - "/%?../" -> 403
  703. - "/%?/.." -> 403
  704. - "/%%../" -> 403
  705. - "/%%/.." -> 403
  706. - "/a/w/../a" -> 406 "/a/a"
  707. - "/path/to/dir/../other/dir" -> 406 "/path/to/other/dir"
  708. EOF
  709. if [ "`md5sum /tmp/results | cut -d' ' -f 1`" != "`md5sum /tmp/lwsresult1 | cut -d' ' -f1`" ] ; then
  710. echo "Differences..."
  711. diff -urN /tmp/results /tmp/lwsresult1
  712. exit 1
  713. else
  714. echo "OK"
  715. fi
  716. echo
  717. echo "--- survived OK ---"
  718. kill -2 $CPID
  719. exit 0