Created
May 29, 2019 00:46
-
-
Save SegoCode/e572eb75b7e311913336364970afafa1 to your computer and use it in GitHub Desktop.
Java file honeypot for ransomware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HoneyPot { | |
public static void main(String[] args) throws IOException, InterruptedException { | |
JOptionPane.showMessageDialog(null, "Honeypot created,\nMonitoring file"); | |
Path path = FileSystems.getDefault().getPath(System.getProperty("user.home"), "Documents"); | |
File file = new File(path + "\\Password.docx"); | |
file.createNewFile(); | |
WatchService watchService = FileSystems.getDefault().newWatchService(); | |
WatchKey watchKey = path.register(watchService, StandardWatchEventKinds.ENTRY_DELETE); | |
WatchKey wk = watchService.take(); | |
wk.pollEvents().stream().map((event) -> (Path) event.context()).filter((changed) -> (changed.endsWith("Password.docx"))).forEachOrdered((_item) -> { | |
modify(); | |
}); | |
} | |
public static void modify() { | |
JOptionPane.showMessageDialog(null, | |
"Malicius activity detected", "Inane warning", JOptionPane.WARNING_MESSAGE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment