Saturday, November 10, 2012

libyeux.so: a scrap library for linux

You want to create a bot ? ok, but how can you determine which cards you hold ? how much your opponent has bet ? 
Well ... there is several way to do this:
- reverse engineering of ram memory and find where are stored theses informations ? 
- reverse engineering of network communication ?
Well ... both way are not easy to do, in particulary because network communication are encrypted (maybe by openssl), and they may also encrypt all ram-information ? And not to mention that this method is not portable ! you will have to do this reverse engineering for every poker site !
So using OCR and scrap region we are interested is the best way.

OpenHoldem is a poker plateform and it scrap screen image to find all needed information. So I decided to port scrap files for linux, and I create a library libyeux.so

If you are a macos/BSD user, it's should also work for you.

Thursday, November 8, 2012

How to simulate mouse and keyboard ?

SendInput

The easiest way to do it is to use SendInput function.
here is a link explaining how to do it, and, trust me, it does work

Be aware that you can be detected as using a bot, that why you should use this function only if you are playing on site where botting is not forbidden

The problem is the poker software can use GetAsyncKeyState function to check if the button was pressed, and unfortunately SendInput cannot trick this function. Maybe there is a workaround to clear this key state ? I don't know, but as long as you are using this kind of api, your program won't behave the same way as human does, and you will still have risk to be detected

OpenHoldem or WinHoldem platform are using bring.exe program which is a close source software, so I don't know how it works, but I suppose that it's using SendInput function. I would not try to use bring.exe with pokerstars without knowing what he is doing.

Create a fake mouse and keyboard driver

This is a good solution if you are using a real computer (not a virtual machine). There is no way to find if a button was pressed by the your bot or by a human, well ... it's not completely true.
The application may check the driver and check build date, checksum. (is it possible that a player have a unknown mouse driver ?)

Create a fake usb mouse and keyboard

I'm not talking about creating your own driver as I does previously, but I'm talking about using usb  communication to simulate a standard usb mouse or a standard usb keyboard.
Note:
If you are going this way, note that you can buy a dvi to usb (or vga to usb) adapator. So you will be able to analyse your picture without to have any running application on the computer where you run the poker client.

use vmware or virtualbox api/sdk

If you are using a virtual machine then you should try to use theses solutions as there is no way for the poker client to know if a button is pressed by your hardware or by the virtual machine api
For virtualbox, you can use putMouseEventAbsolute for mouse simulation and putScancode for keyboard simulation

Warning:

Whatever the chosen solution, you may want to move your mouse and click like human:
- don't click the same pixel, even if the center of the button have more chance to be cicked than pixel in border of the button. (openholdem is using a Gaussian equation)
-  maybe the mouse moement should be as human as possible. (no teleportation, don't follow a mathematical straight line
 - wait some random time before 2 pressed buttons
- etc ...