[FilterScript] [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP
#13

Looks pretty nice, but I spotted some rather nasty mistakes.

Код:
// OnPlayerText
format(sMysqlQuery, sizeof(sMysqlQuery), "INSERT INTO rstats_chatmessages VALUES(null, %d, '%s', NOW())", iUserid[playerid], text);
mysql_query(sMysqlQuery);
Код:
// OnPlayerCommandText
format(sMysqlQuery, sizeof(sMysqlQuery), "INSERT INTO rstats_commands VALUES(null, %d, '%s', NOW())", iUserid[playerid], cmdtext);
mysql_query(sMysqlQuery);
The user input is not escaped, which means if someone says for instance "It's a pencil", the query will fail. (because of the apostrophe).

However, not all people are nice, and someone might say
Код:
'); DROP TABLE `rstats_users`; /*
which would delete the whole table. Even if you do not allow the MySQL user to drop or truncate, someone could still ruin all your data with simple update queries. For instance
Код:
'); UPDATE `rstats_users` SET `score` = 0 WHERE 1; /*
would set everyone's score to 0.

Both queries would run just fine, but the database server would interpret that as multiple queries: INSERT INTO rstats_chatmessages VALUES(null, %d, ''); DROP TABLE `rstat_users`; /* , NOW())
The part after /* will be interpreted as comment and therefore omitted.

So I highly recommend you to escape all user input to prevent mysql injections.
Reply


Messages In This Thread
[FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by R@f - 13.09.2012, 22:03
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by EliteDrive - 13.09.2012, 22:16
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by CeLo Jeaam - 13.09.2012, 22:55
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by jpeg - 13.09.2012, 23:26
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by Ricop522 - 13.09.2012, 23:39
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by R@f - 14.09.2012, 08:03
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by CeLo Jeaam - 14.09.2012, 09:41
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by Mr.Faqahat - 29.09.2012, 12:52
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by M3mPHi$_S3 - 29.09.2012, 13:02
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by Edvin - 08.10.2012, 16:57
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by CrusherCpt - 09.10.2012, 14:02
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by AMEENAMEEN - 25.11.2012, 00:02
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by Johnson_boy - 26.11.2012, 18:05
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by TheChimpJr - 27.11.2012, 04:03
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by RevCeo - 09.09.2013, 01:35
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by awsomedude - 09.09.2013, 01:54
Re: [FS/PHP/MySQL]RStats - Detailed player stats for SA-MP - by RevCeo - 14.09.2013, 12:45

Forum Jump:


Users browsing this thread: 4 Guest(s)