ids.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // Copyright (C) ReloadCMS Development Team //
  4. // http://reloadcms.sf.net //
  5. // //
  6. // This program is distributed in the hope that it will be useful, //
  7. // but WITHOUT ANY WARRANTY, without even the implied warranty of //
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
  9. // //
  10. // This product released under GNU General Public License v2 //
  11. ////////////////////////////////////////////////////////////////////////////////
  12. if(!empty($system->config['enable_ids'])){
  13. $urlref = ($_SERVER['REQUEST_URI']);
  14. if(isset($_COOKIE['UID'])) {
  15. print('Error connecting to MySQL database. Please try later');
  16. die();
  17. }
  18. function logattack(){
  19. global $system;
  20. rcms_log_put('Hack attempt', $system->user['username'], 'Remote address: ' . ($_SERVER['REMOTE_ADDR']) . "\n" .
  21. 'Suspected URI: ' . ($_SERVER['REQUEST_URI']) . "\n" . 'Suspected referer: ' . ($_SERVER['HTTP_REFERER']) . "\n" .
  22. 'User agent: ' . ($_SERVER['HTTP_USER_AGENT']) . "\n");
  23. }
  24. // search of SQL Injections like a index.php?module=articles&c=news&b=1&a=1+[SQL injection here]
  25. if ((stristr($urlref, 'articles')) AND (stristr($urlref, 'news')) AND (stristr($urlref, 'union')))
  26. {
  27. logattack();
  28. print ('You have an error in your SQL syntax near \'WHERE newsid =');
  29. die();
  30. }
  31. // search of SQL Injections like a index.php?module=articles&c=news&b=1+[SQL injection here]&a=1
  32. if ((stristr($urlref, 'module=articles')) AND (stristr($urlref, 'b=+')) AND (stristr($urlref, 'union')))
  33. {
  34. logattack();
  35. print ('You have an error in your SQL syntax near \'WHERE bid =');
  36. die();
  37. }
  38. // search of trivial fopen bug like index.php?module=user.list&user=../../../../etc/passwd
  39. if ((stristr($urlref, 'user.list')) AND (stristr($urlref, 'user')) AND (stristr($urlref, 'etc/passwd')))
  40. {
  41. logattack();
  42. print ('failed to open stream: No such file or directory /etc/passwd');
  43. die();
  44. }
  45. // search of trivial fopen bug like index.php?module=user.list&user=../../../../etc/shadow
  46. if ((stristr($urlref, 'user.list')) AND (stristr($urlref, 'user')) AND (stristr($urlref, 'etc/shadow')))
  47. {
  48. logattack();
  49. print ('failed to open stream: No such file or directory /etc/shadow');
  50. die();
  51. }
  52. // search of SQL Injections in gallery
  53. if ((stristr($urlref, '=gallery')) AND (stristr($urlref, 'id=')) AND (stristr($urlref, 'union')))
  54. {
  55. logattack();
  56. print ('You have an error in your SQL syntax near \'WHERE imageid =');
  57. die();
  58. }
  59. // Test for DoS via SQL injection like index.php?[someparam]=BENCHMARK(10000000,BENCHMARK(10000000,md5(current_date)))
  60. if (stristr($urlref, 'benchmark'))
  61. {
  62. logattack();
  63. setcookie('UID', rand(2,50), time()+7200);
  64. die();
  65. }
  66. //Showing some usefulpasswd file ;)
  67. if (stristr($urlref, 'module=../../../../etc/passwd'))
  68. {
  69. $passwdfile='
  70. root:x:0:0::/root:/bin/bash
  71. bin:x:1:1:bin:/bin:
  72. daemon:x:2:2:daemon:/sbin:
  73. adm:x:3:4:adm:/var/log:
  74. lp:x:4:7:lp:/var/spool/lpd:
  75. sync:x:5:0:sync:/sbin:/bin/sync
  76. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  77. halt:x:7:0:halt:/sbin:/sbin/halt
  78. mail:x:8:12:mail:/:
  79. news:x:9:13:news:/usr/lib/news:
  80. uucp:x:10:14:uucp:/var/spool/uucppublic:
  81. operator:x:11:0:operator:/root:/bin/bash
  82. games:x:12:100:games:/usr/games:
  83. ftp:x:14:50::/home/ftp:
  84. smmsp:x:25:25:smmsp:/var/spool/clientmqueue:
  85. mysql:x:27:27:MySQL:/var/lib/mysql:/bin/bash
  86. rpc:x:32:32:RPC portmap user:/:/bin/false
  87. sshd:x:33:33:sshd:/:
  88. gdm:x:42:42:GDM:/var/state/gdm:/bin/bash
  89. pop:x:90:90:POP:/:
  90. nobody:x:99:99:nobody:/:
  91. firebird:x:1006:102:Firebird Database Administrator:/opt/firebird:/bin/bash
  92. sql:x:1007:100:,,,:/home/sql:/bin/bash
  93. nagios:x:1008:100::/home/nagios:
  94. iconci:x:1009:100:Iconci,,,:/home/iconci:/bin/bash
  95. httpd:x:1010:104:Apache HTTPD User,,,:/home/httpd:/bin/bash
  96. ';
  97. logattack();
  98. print($passwdfile);
  99. die();
  100. }
  101. //And showing more useful shadow file withe real passwords ;)
  102. if(stristr($urlref, 'module=../../../../etc/shadow')) {
  103. $shadowfile='
  104. root:$1$SWU0pAUD$Ht3oFKJy/Qt/Cp.yTvygZ1:12835:0:99999:7:::
  105. bin:*:12796:0:99999:7:::
  106. daemon:*:12796:0:99999:7:::
  107. adm:*:12796:0:99999:7:::
  108. lp:*:12796:0:99999:7:::
  109. sync:*:12796:0:99999:7:::
  110. shutdown:*:12796:0:99999:7:::
  111. halt:*:12796:0:99999:7:::
  112. mail:*:12796:0:99999:7:::
  113. news:*:12796:0:99999:7:::
  114. uucp:*:12796:0:99999:7:::
  115. operator:*:12796:0:99999:7:::
  116. games:*:12796:0:99999:7:::
  117. gopher:*:12796:0:99999:7:::
  118. nobody:*:12796:0:99999:7:::
  119. vcsa:!!:12796:0:99999:7:::
  120. rpm:!!:12796:0:99999:7:::
  121. xfs:!!:12796:0:99999:7:::
  122. rpc:!!:12796:0:99999:7:::
  123. dbus:!!:12796:0:99999:7:::
  124. mailnull:!!:12796:0:99999:7:::
  125. smmsp:!!:12796:0:99999:7:::
  126. rpcuser:!!:12796:0:99999:7:::
  127. nfsnobody:!!:12796:0:99999:7:::
  128. nscd:!!:12796:0:99999:7:::
  129. ntp:!!:12796:0:99999:7:::
  130. sshd:!!:12796:0:99999:7:::
  131. pcap:!!:12796:0:99999:7:::
  132. amanda:!!:12796:0:99999:7:::
  133. named:!!:12796:0:99999:7:::
  134. apache:!!:12796:0:99999:7:::
  135. desktop:!!:12796:0:99999:7:::
  136. mailman:!!:12796:0:99999:7:::
  137. fax:!!:12796:0:99999:7:::
  138. mysql:!!:12796:0:99999:7:::
  139. nut:!!:12796:0:99999:7:::
  140. postgres:!!:12796:0:99999:7:::
  141. pvm:!!:12796:0:99999:7:::
  142. squid:!!:12796:0:99999:7:::
  143. webalizer:!!:12796:0:99999:7:::
  144. wnn:!!:12796:0:99999:7:::
  145. nagios:!!:12796:0:99999:7:::
  146. netdump:!!:12796:0:99999:7:::
  147. popa3d:!!:12796:0:99999:7:::
  148. snort:!!:12796:0:99999:7:::
  149. admin:$1$A/TbUhKj$UOoGXnP3gWgaCFFDukJhQ/:12848:0:99999:7:::';
  150. logattack();
  151. print($shadowfile);
  152. die();
  153. }
  154. }
  155. ?>