Skip to content

Instantly share code, notes, and snippets.

@SegoCode
Created May 29, 2019 00:46
Show Gist options
  • Save SegoCode/e572eb75b7e311913336364970afafa1 to your computer and use it in GitHub Desktop.
Save SegoCode/e572eb75b7e311913336364970afafa1 to your computer and use it in GitHub Desktop.
Java file honeypot for ransomware
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