I was curious how hard it is to access Windows Native Libraries (.dll files) with Java, so I made some time for a small and fun project this week: I made a bot for a Facebook application called Word Challenge. The Word Challenge Bot (I named it NRBot for now – haven’t made up my mind on a final name) isn’t done yet, but the basics are. It already allows you to score a lot of points in a small amount of time without doing a lot
So what’s still to be done then? Well here are some points I was thinking about, but I’m not sure when or if I will ever complete them, because I need to finish some other projects first:
- improve UI (now it’s just an ugly console app)
- improve code to find the correct window (now I’m just calling User32.FindWindowA with a hardcoded name in it – this will only work with Mozilla Firefox and if the game window was the last window that was opened)
- use OCR (Optical Character Recognition) to auto detect the letters provided by the application – this way the bot would become totally automatic!
Here’s some information on how the bot works:
It will only work on Windows. I’m using JNA (Java Native Access) to directly access native shared libraries (.dll files). You might say I should’ve used Java AWT (Abstract Windowing Toolkit), more specifically the Robot class, or that I should code such tools in C or C++, but as I mentioned before I made this decision on purpose because I wanted to know how hard it was to access Native Libraries from Java.
When you start the program, it searches the World Challenge application window. Like I said above, I still have to improve this. After this, the bot asks to type in the 6 letters you get from Word Challenge and then starts bruteforcing every possible combination with these letters. To do this, I used a PermutationGenerator I found on the internet (actually this only returns all 6 char possibilities so I used a bit of common sense to find the smaller unique combinations). Then the bot sends every possible combination to the application using SendMessageA(int hWnd, int msg, int wParam, int lParam); followed by a carriage return and a line feed.
I did some tests already, and the bot finds ALL possible words within a few seconds! Awesome, isn’t it?
Here’s the sourcecode (you will have to add the JNA library to your project to compile), and for those who just want to cheat but don’t care about Java a .jar file is included (run from CommandLine with “java -jar NRWords.jar”).
Feel free to use and improve the source any way you want, but I would appreciate it if you let me know you did!
Don’t make unsubscribing from a newsletter too easy!
Published February 11, 2009 General Leave a CommentTags: captcha, commentary, newsletter, spam, unsubscribe
It’s probably a commercial trick to make the process of unsubscribing from a newsletter (*cough* spam *cough*) a bit harder than subscribing to it, but this time I must say I stumbled accross an extreme case!
1. The very easy subscribing part:
About 10 minutes ago I got an e-mail on an e-mail account I haven’t used in the last 2 years. I even forgot about the existence of it (the reason I still received this e-mail is because I set it up to forward mails to my real e-mail account) and before that I may have used it 4 or 5 times at most. I’m sure about this since I made it with a special reason.
Although I can’t remember doing so, it seems I somehow magically managed to subscribe to a newsletter with it and they have now e-mailed me.
2. The extremely difficult unsubscribing part.
I was very happy to see a little message at the end of the e-mail that said “click here to unsubscribe”. So I clicked on it and then I landed on this page (in case the website goes down, I included a screenshot at the end of my post). Ironic captcha, isn’t it?
Being very competitive I decided to give it a few tries, but I gave up after all and decided to blog about it. Now that I’ve done so, I think it’s time to do some DNS and whois lookups