06. Destroying files

Source: Internet
Author: User

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

  
 
  1. ;为了省事把所有变量都global了
  2. ;demageFileFun.ahk
  3. demageFile(fileName) {
  4. global
  5. openFile(fileName)
  6. writeFileTimes()
  7. file.close()
  8. }
  9. openFile(filename){
  10. global
  11. file := FileOpen(filename,"rw")
  12. FileGetSize,size,%filename%
  13. LOOPTIMES := round(RATE * size); Writechar writes one byte at a time, so how many bytes are looped;
  14. }
  15. writeFileTimes(){
  16. global
  17. wirteFile(0); The beginning, the middle, and the end of the file are damaged;
  18. wirteFile(round(size * 0.5))
  19. wirteFile(round(size * (1- RATE )))
  20. }
  21. wirteFile(pos) {To damage the back part of the specified position of the file;
  22. global
  23. file.seek(pos)
  24. loop,%LOOPTIMES%
  25. {
  26. Random, rand , 0, 127
  27. file.Writechar(rand) ;writeChar一次写入一个字节;参数rand是整数也行;
  28. }
  29. }
  30. ^escape::exitapp

  
 
  1. ;2015-12-31 星期四 12:04
  2. ;demageFile-手动选择.ahk
  3. #NoTrayIcon
  4. #singleinstance force
  5. if 1=
  6. {
  7. FileSelectFile, deFile
  8. if 1=
  9. exitapp,0
  10. } else {
  11. ;可以把文件拖放到图标上的方式来传递参数
  12. deFile =%1%
  13. }
  14. RATE := 0.2
  15. try {
  16. demageFile(deFile)
  17. msgbox 损坏成功
  18. exitapp,0
  19. } catch e {
  20. msgbox 损坏失败
  21. msgbox %e%
  22. exitapp,1
  23. } finally {
  24. file.close()
  25. }
  26. return
  27. #include demageFileFun.ahk

  
 
  1. ;2015-12-31 星期四 12:04
  2. ;demageFile.ahk
  3. #NoTrayIcon
  4. #singleinstance force
  5. if 1=
  6. {
  7. msgbox 必须传入参数:文件名
  8. exitapp,1
  9. }
  10. deFile =%1%
  11. RATE := 0.2; The ratio of one corrupted file
  12. try {
  13. demageFile(deFile) ;这里用%1%会出错...
  14. exitapp,0
  15. } catch e {
  16. msgbox %e%
  17. exitapp,1
  18. } finally {
  19. file.close()
  20. }
  21. return
  22. #include demageFileFun.ahk

 
   
  
  1. Instructions for use:
  2. 注意:一旦损坏,数据无法恢复;请谨慎使用!!











From for notes (Wiz)

List of attachments

    06. Destroying files

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.