APP CookiesMonster loves Browser Cookies


Thành viên VIP
Everyone knows that Web-Surfing is a nice time-killing fun. But fun without risk is never an exciting fun, isn't it? The more attractive sites you visit, the riskier your fun would be.

What risk you may ask, right? Well, it's the risk of spying cookies. Every Web Provider naturally wants to know who is currently viewing the page and where he was before he came here. Because of the Private Data Protection law the web providers are prohibited to extract and to stow the visitor's personal data .

IT is not IT if there weren't an alternative to circumvent the law. And the alternative is the cookie.

What is an IT Cookie? I am too lazy to explain cookie to you so I let Wikipedia explain it:
HTTP cookies (also called web cookies, Internet cookies, browser cookies, or simply cookies) are small blocks of data created by a web server while a user is browsing a website and placed on the user's computer or other device by the user's web browser. Cookies are placed on the device used to access a website, and more than one cookie may be placed on a user's device during a session.

Cookies serve useful and sometimes essential functions on the web. They enable web servers to store stateful information (such as items added in the shopping cart in an online store) on the user's device or to track the user's browsing activity (including clicking particular buttons, logging in, or recording which pages were visited in the past). They can also be used to save for subsequent use information that the user previously entered into form fields, such as names, addresses, passwords, and payment card numbers.
(Source: click WIKI)


Aha! Cookie is a small block of data and is "placed" on the user's computer. Further, Cookie enables web servers to store stateful information...:-L If you are familiar with Enterprise JavaBeans (or Jakarta Enterprise Beans) you know what STATEFUL means and effects. So, the "stateful" cookie won't reveals your name, nor your personal details (such as age, address, etc.) but its presence on your computer indicates when and where you were on the Web. And that is more than enough to conclude your "web behavior". Your web behavior is as precious as gold. It lets the web provider know about your taste, your shopping habit and even your social movement.

How? Simple. When you, for example, visit Amazon, then eBay, then facebook and finally your favorite site (music, forum, etc.) the providers, which provide goods (Amazon or eBay) or advertise (facebook or your favorite site), implant a specific cookie into your computer (when a cookie does not exist) or read the cookie on your computer. Whatever they do they always know where the cookie originates: Amazon, eBay, facebook, etc. Enough to draw an image about your surfing behavior.

To minimize the risk and to confuse the spying-thirsty providers I show you a little app in Java SWING that allows you to "clean up" the cookies whenever you want or let it clean up periodically with a defined time interval. This app is written on WINDOWS 10. If your computer runs with other OS (UBUNTU or any other LINUX) you should explore into the HOME directory and check for the subdirectories where your browsers stow the cookies. The app is named CookiesMonster and requires an input text file CookiesList.txt as following:
# WINDOWS 10. On LINUX you have to check for the subdirectories in the
# HOME directory.
COOKIES_0=/AppData/Roaming/Opera Software/Opera Stable/cookies
COOKIES_1=/AppData/Roaming/Opera Software/Opera Stable/cookies-journal
COOKIES_2=/AppData/Local/Google/Chrome/User Data/Default/cookies
COOKIES_3=/AppData/Local/Google/Chrome/User Data/Default/cookies-journal
COOKIES_4=/AppData/Local/Google/Chrome/User Data/Default/Safe Browsing cookies
COOKIES_5=/AppData/Local/Google/Chrome/User Data/Default/Safe Browsing cookies-journal
COOKIES_6=/AppData/Local/Microsoft/Edge/User Data/Default/cookies
OPERA=/AppData/Roaming/Opera Software/Opera Stable
CHROME=/AppData/Local/Google/Chrome/User Data/Default
EDGE=/AppData/Local/Microsoft/Edge/User Data/Default
import java.util.concurrent.*;
import java.nio.file.*;
import java.util.*;
import javax.swing.*;
// Joe T. Nartca (C)
public class CookiesMonster extends Thread {
  // Constructor
  public CookiesMonster(String file) throws Exception {
    // load the confi file for existed browsers
    // and "sweeping" time
    FileInputStream fin = new FileInputStream(file);
    prop = new Properties();
    // Cookies sweeping time (milliSeconds)
    String cookies = prop.getProperty("SWEEP");
    if (cookies != null) {
      time = Integer.parseInt(cookies);
      if (time < 200) time = 200;
    fLst = new ArrayList<>();
    for (int i = 0; ; ++i) {
      cookies = prop.getProperty("COOKIES_"+i);
      if (cookies == null) break;
      fLst.add((home+cookies).replace("/", File.separator));
    start( );
  public void run( ) {
    // set FixedThreadPool
    pool = Executors.newFixedThreadPool(Integer.parseInt(prop.getProperty("POOL_SIZE")));
    for (final String fN : fLst) pool.submit(()-> {
      // check for Cookie entry by listening to the WatchKey
      // if a cookie is created or modified StandardWatchEventKind becomes true
      // if StandardWatchEventKind is true then the length of CookiesFile is set to 0 (or clear the content)
      // then take a "sweeping time" pause before next sweeping action restarts
      RandomAccessFile raf = null;
      try {
        raf = new RandomAccessFile(fN, "rw");
        int p = fN.lastIndexOf(File.separator);
        WatchKey wk = Paths.get(fN.substring(0, p)).register(FileSystems.getDefault().newWatchService(),
                                StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY);
        String fil = fN.substring(p+1);
        OUT: while (true) {
          for (WatchEvent<?> event : wk.pollEvents()) {
            WatchEvent.Kind<?> kind = event.kind();
            if (((WatchEvent<Path>)event).context().toString().equalsIgnoreCase(fil) &&
                (kind == StandardWatchEventKinds.ENTRY_MODIFY ||  kind == StandardWatchEventKinds.ENTRY_CREATE)) {
              if (raf.length() > 0) try {
                raf.setLength(0); // reset cookies
              } catch (Exception ex) { }
            if (end) break OUT;
          if (end) break;
          try { Thread.sleep(time); }
          catch (Exception e) { }
      } catch (Exception ex) {
      try {
        if (raf != null) raf.close();
      } catch (Exception ex) { }
  public void halt( ) {
    end = true;
    cleanNow( );
    if (pool != null) pool.shutdownNow();
  public void cleanNow( ) {
    // force to clean up all cookies of the listed browsers
    if (prop != null) try {
      String cookies;
      if (fLst != null) for (String file:fLst) {
        RandomAccessFile raf = new RandomAccessFile(file "rw");
      cookies = prop.getProperty("OPERA");
      if (cookies != null) { // Opera
        FileOutputStream fou = new FileOutputStream((home+cookies+"/opera_autoupdate.log").replace("/", File.separator), false);
        File[] files = new File(cookies).listFiles();
        for (File file : files) if (file.isFile()) {
          String fn = file.getName(); // remove all ssdfp... files
          if (fn.indexOf("ssd") == 0 && fn.indexOf(".lock") < 0 || fn.indexOf(".old") > 0) file.delete();
      cookies = prop.getProperty("CHROME");
      if (cookies != null) { // Chrome
        File[] files = new File((home+cookies).replace("/", File.separator)).listFiles();
        for (File file : files) if (file.isFile() && file.getName().indexOf(".old") > 0 ) file.delete();
      cookies = prop.getProperty("FIREFOX");
      if (cookies != null) {
        File[] files = new File((home+cookies).replace("/", File.separator)).listFiles();
        for (File file : files) if (file.isFile() && file.getName().indexOf(".bak") > 0 ) file.delete();
    } catch (Exception ex) { }
  private int time = 500;
  private Properties prop;
  private List<String> fLst;
  private ExecutorService pool;
  private static CookiesMonster zombie;
  private volatile boolean end = false;
  private String home = System.getProperty("user.home");
  public static void main(String... argv) throws Exception {
    JFrame jf = new JFrame("CookiesMonster");
    JLabel msg = new JLabel("Enter CookiesList and press ENTER to start");
    JTextField conf = new JTextField(argv.length > 0? argv[0]:"CookiesList.txt");
    conf.addActionListener(e -> {
      if (zombie == null) try {
        zombie = new CookiesMonster(conf.getText());
        msg.setText("CookiesMonster is lurking...");
      } catch (Exception ex) {
    JLabel labC = new JLabel("CookiesList file");
    JButton but = new JButton("CLEAN COOKIES NOW");
    but.addActionListener(e -> {
      if (zombie != null) {
        msg.setText("All cookies were swept away");
    JButton stop = new JButton("EXIT & CLEAN UP");
    stop.addActionListener(e -> {
      if (zombie != null) zombie.halt();
      else System.exit(0);
    jf.addWindowListener(new java.awt.event.WindowAdapter() {
       public void windowClosing(java.awt.event.WindowEvent ew){
        if (zombie != null) zombie.halt();
        else System.exit(0);
    JPanel north = new JPanel();
    north.add(labC); north.add(conf);
    JPanel center = new JPanel();
    center.add(but); center.add(stop);
    JPanel south = new JPanel();

    jf.add("North", north);
    jf.add("Center", center);
    jf.add("South", south);
if you have successfully downloaded the codes and the list, modified the list and compiled them you get this screen

Good luck and enjoy.
Sửa lần cuối: