|
# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> GRANT ALL ON test.* TO ben@"%";
mysql> FLUSH PRIVILEGES;
| 默認(rèn)情況下,GreenSQL運(yùn)行在3305端口上,小于MySQL的默認(rèn)端口(3306)。如果你使用mysql控制臺客戶端并連接到GreenSQL的3305 端口上,你將無法創(chuàng)建新表。如果你直接通過3306端口連接到MySQL,就可以創(chuàng)建新表。
$ mysql --verbose -h 127.0.0.1 -P 3305 test
mysql> create table foo ( id int );
--------------
create table foo ( id int )
--------------
Query OK, 0 rows affected (0.01 sec)
mysql> insert into foo values ( 55 );
--------------
insert into foo values ( 55 )
--------------
ERROR 1146 (42S02): Table 'test.foo' doesn't exist
$ mysql --verbose -h 127.0.0.1 -P 3306 test
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> create table foo ( id int );
--------------
create table foo ( id int )
--------------
Query OK, 0 rows affected (0.01 sec)
mysql> insert into foo values ( 55 );
--------------
insert into foo values ( 55 )
--------------
Query OK, 1 row affected (0.00 sec)
mysql> insert into foo values ( 131 );
--------------
insert into foo values ( 131 )
--------------
Query OK, 1 row affected (0.00 sec)
mysql> select * from foo;
--------------
select * from foo
--------------
+------+
id
+------+
55
131
+------+
2 rows in set (0.00 sec)
| 如果使用默認(rèn)配置,你將無法通過GreenSQL防火墻丟棄數(shù)據(jù)表。這倒無妨,因?yàn)楸斫Y(jié)構(gòu)不太可能經(jīng)常改變,更不可能通過Web界面改 變。
$ mysql --verbose -h 127.0.0.1 -P 3305 test
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> select * from foo;
--------------
select * from foo
--------------
+------+
id
+------+
55
131
+------+
2 rows in set (0.00 sec)
mysql> drop table foo;
--------------
drop table foo
--------------
Query OK, 0 rows affected (0.00 sec)
mysql> select * from foo;
--------------
select * from foo
--------------
+------+
id
+------+
55
131
+------+
2 rows in set (0.01 sec)
| 注入測試看來沒有如所期望的那樣正常工作。第一次測試是在條件一直為真時刪除表。這會清除表內(nèi)的所有數(shù)據(jù),留下一個空表。默 認(rèn)地此查詢會通過防火墻進(jìn)行:
$ mysql --verbose -h 127.0.0.1 -P 3305 test
mysql> delete from foo where 1=1;
--------------
delete from foo where 1=1
--------------
Query OK, 2 rows affected (0.00 sec)
mysql> select * from foo;
--------------
select * from foo
--------------
Empty set (0.00 sec)
| 對于上面的SQL刪除命令來說,/var/log/greensql.log文件包含了下面的信息:
SQL_DEBUG: QUERY command[]: delete from foo where 1=1
SQL_DEBUG: AFTER NORM : delete from foo where ?=?
SQL_DEBUG: RISK : 0
| /etc/greensql/greensql.conf文件準(zhǔn)許你設(shè)置某些內(nèi)容的風(fēng)險(xiǎn)程度。例如,你可以將10指定給union關(guān)鍵字使用,或者在查詢中使用 直接的變量比較(如同1=2之類的東西)。這些變量包括“block_level = 30”,所以RISK大于30的任何查詢都不轉(zhuǎn)發(fā)給MySQL服務(wù)器 。為了讓GreenSQL標(biāo)記出上面的查詢,筆者將risk_var_cmp_var 和 risk_always_true從默認(rèn)的30增加至150。但很不幸,這次查詢 看起來仍是風(fēng)險(xiǎn)為零。
本新聞共 3頁,當(dāng)前在第 2頁 1 2 3 |
【收藏】【打印】【進(jìn)入論壇】 |
|
|
|
|
|
|
|