PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/engine/ids.php

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