ํ•ด๋‹น ๋‚ด์šฉ์€ ์„œ๋ฒ„์— sql injetction ๊ณต๊ฒฉ์„ ๋ฐ›์•˜์„ ๊ฒฝ์šฐ

DB๋ณต๊ตฌ๊ฐ€ ์•„๋‹Œ ํ•ด๋‹น DB ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ์ฟผ๋ฆฌ๋ฌธ์ž…๋‹ˆ๋‹ค.

 

์‚ฌ์šฉ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜ ์ฃผ์„ ์„ ํ•ด์ œํ•˜๋ฉด ํ•ด๋‹นDB์— ํ•ด๋‹นํ•˜๋Š” ๊ตฌ๋ฌธ์„ ์ฐพ์•„ ์—…๋ฐ์ดํŠธ ํ•ฉ๋‹ˆ๋‹ค.

๋ฌผ๋ก  ์‹ค์ œ DATA๊ฐ€ ์‚ฌ๋ผ์งˆ ๊ฒฝ์šฐ๋„ ์žˆ์œผ๋‹ˆ ์ฃผ์˜ํ•˜์—ฌ ์‚ฌ์šฉํ•˜์‹œ๊ธธ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

====================================================================================

DECLARE @T varchar(255), @C varchar(255);

DECLARE Table_Cursor CURSOR FOR

SELECT a.name, b.name

FROM sysobjects a, syscolumns b

WHERE a.id = b.id AND a.xtype = 'u' AND

(b.xtype = 99 OR b.xtype = 35 OR b.xtype = 231 OR b.xtype = 167);

OPEN Table_Cursor;

FETCH NEXT FROM Table_Cursor INTO @T, @C;

WHILE (@@FETCH_STATUS = 0) BEGIN

 

print ('select ['+@C+'] from ['+@T+'] where ['+@C+'] like ''%<script%</script>''');

exec ('select ['+@C+'] from ['+@T+'] where ['+@C+'] like ''%<script%</script>''');

-- ์„ ํƒ์‹œ ์ฃผ์˜

--exec('update ['+@T+'] set ['+@C+'] = left(convert(varchar(8000), ['+@C+']),len(convert(varchar(8000), ['+@C+'])) - 6 -patindex(''%tpircs<%'',reverse(convert(varchar(8000), ['+@C+'])))) where ['+@C+'] like ''%<script%''');

 

FETCH NEXT FROM Table_Cursor INTO @T, @C;

END;

CLOSE Table_Cursor;

DEALLOCATE Table_Cursor;

 

====================================================================

 

DECLARE @T varchar(255), @C varchar(255);

DECLARE Table_Cursor CURSOR FOR

SELECT a.name, b.name

FROM sysobjects a, syscolumns b

WHERE a.id = b.id AND a.xtype = 'u' AND

(b.xtype = 99 OR b.xtype = 35 OR b.xtype = 231 OR b.xtype = 167);

OPEN Table_Cursor;

FETCH NEXT FROM Table_Cursor INTO @T, @C;

WHILE (@@FETCH_STATUS = 0) BEGIN

 

print ('select ['+@C+'] from ['+@T+'] where ['+@C+'] like ''%<script src%</script>''');

exec ('select ['+@C+'] from ['+@T+'] where ['+@C+'] like ''%<script src%</script>''');

-- ์„ ํƒ์‹œ ์ฃผ์˜

--exec('update ['+@T+'] set ['+@C+'] = left(convert(varchar(8000), ['+@C+']),len(convert(varchar(8000), ['+@C+'])) - 10 -patindex(''%crs tpircs<%'',reverse(convert(varchar(8000), ['+@C+'])))) where ['+@C+'] like ''%<script src%''');

 

FETCH NEXT FROM Table_Cursor INTO @T, @C;

END;

CLOSE Table_Cursor;

DEALLOCATE Table_Cursor;

'๋ฆฌ๋ˆ…์Šค > MYSQL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

MariaDB(Mysql) varํด๋”์—์„œ homeํด๋”๋กœ ๋ณ€๊ฒฝ  (0) 2017.04.25
mysql root ๊ณ„์ • ๋ณ€๊ฒฝ  (0) 2016.07.10

๋ธ”๋กœ๊ทธ ์ด๋ฏธ์ง€

extron

๋ชจ๋ฐ”์ผ+IT

,