|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
这里我们讨论用binlog来实现闪回的方案。serverSETNOCOUNTON
DECLARE@LogicalFileNamesysname,@MaxMinutesINT,@NewSizeINT
USEgrades--要操纵的数据库名
SELECT@LogicalFileName=grades_log,--日记文件名
@MaxMinutes=10,--Limitontimeallowedtowraplog.
@NewSize=1--你想设定的日记文件的巨细(M)
--Setup/initialize
DECLARE@OriginalSizeint
SELECT@OriginalSize=sizeFROMsysfilesWHEREname=@LogicalFileName
SELECTOriginalSizeof+db_name()+LOGis+
CONVERT(VARCHAR(30),@OriginalSize)+8Kpagesor+
CONVERT(VARCHAR(30),(@OriginalSize*8/1024))+MB
FROMsysfiles
WHEREname=@LogicalFileName
CREATETABLEDummyTrans(DummyColumnchar(8000)notnull)
DECLARE@CounterINT,@StartTimeDATETIME,@TruncLogVARCHAR(255)
SELECT@StartTime=GETDATE(),@TruncLog=BACKUPLOG+db_name()+WITHTRUNCATE_ONLY
DBCCSHRINKFILE(@LogicalFileName,@NewSize)
EXEC(@TruncLog)
--Wrapthelogifnecessary.
WHILE@MaxMinutes>DATEDIFF(mi,@StartTime,GETDATE())--timehasnotexpired
AND@OriginalSize=(SELECTsizeFROMsysfilesWHEREname=@LogicalFileName)
AND(@OriginalSize*8/1024)>@NewSize
BEGIN--Outerloop.
SELECT@Counter=0
WHILE((@Counter<@OriginalSize/16)AND(@Counter<50000))
BEGIN--update
INSERTDummyTransVALUES(FillLog)
DELETEDummyTrans
SELECT@Counter=@Counter+1
END
EXEC(@TruncLog)
END
SELECTFinalSizeof+db_name()+LOGis+
CONVERT(VARCHAR(30),size)+8Kpagesor+
CONVERT(VARCHAR(30),(size*8/1024))+MB
FROMsysfiles
WHEREname=@LogicalFileName
DROPTABLEDummyTrans
SETNOCOUNTOFF
mysql使用内部操作字符集gbk来进行操作,即执行"SELECT*FROMtestWHEREname=xxxor1=1/*LIMIT1";从而注入成功 |
|