Corrupt files: principle: Binary way to open files, byte by bit replaced by random characters;;( Inspired by the Baidu Cloud, it replaced the video all 0)
Two kinds of usage: ① the user to manually select the file, break the window prompt after the completion of the destruction, ② command line invocation and other ways to pass parameters, the destruction is not possible after the window popup; so: Write the kernel code (some functions) of the corrupted file in the file Demagefilefun.ahk, and then in the " demagefile-manually select. Ahk "and" Demagefile.ahk "include Demagefilefun.ahk
;为了省事把所有变量都global了
;demageFileFun.ahk
demageFile(fileName) {
global
openFile(fileName)
writeFileTimes()
file.close()
}
openFile(filename){
global
file := FileOpen(filename,"rw")
FileGetSize,size,%filename%
LOOPTIMES := round(RATE * size); Writechar writes one byte at a time, so how many bytes are looped;
}
writeFileTimes(){
global
wirteFile(0); The beginning, the middle, and the end of the file are damaged;
wirteFile(round(size * 0.5))
wirteFile(round(size * (1- RATE )))
}
wirteFile(pos) {To damage the back part of the specified position of the file;
global
file.seek(pos)
loop,%LOOPTIMES%
{
Random, rand , 0, 127
file.Writechar(rand) ;writeChar一次写入一个字节;参数rand是整数也行;
}
}
^escape::exitapp
;2015-12-31 星期四 12:04
;demageFile-手动选择.ahk
#NoTrayIcon
#singleinstance force
if 1=
{
FileSelectFile, deFile
if 1=
exitapp,0
} else {
;可以把文件拖放到图标上的方式来传递参数
deFile =%1%
}
RATE := 0.2
try {
demageFile(deFile)
msgbox 损坏成功
exitapp,0
} catch e {
msgbox 损坏失败
msgbox %e%
exitapp,1
} finally {
file.close()
}
return
#include demageFileFun.ahk
;2015-12-31 星期四 12:04
;demageFile.ahk
#NoTrayIcon
#singleinstance force
if 1=
{
msgbox 必须传入参数:文件名
exitapp,1
}
deFile =%1%
RATE := 0.2; The ratio of one corrupted file
try {
demageFile(deFile) ;这里用%1%会出错...
exitapp,0
} catch e {
msgbox %e%
exitapp,1
} finally {
file.close()
}
return
#include demageFileFun.ahk
- Instructions for use:
注意:一旦损坏,数据无法恢复;请谨慎使用!!
From for notes (Wiz)
List of attachments
06. Destroying files