Simple Safe Cracking (Epoch, Overpoch, Overpochins)
Some one asked for this in dayz help, I figured other people might find it useful.
Use at your own risk.
Credits: Krzysztof Jelonek
Video tutorial:
Code Snippets:
Support the mouse :
Code:
class Mouse {
public:
POINT p;
Mouse() {
}
void readPos() {
GetCursorPos(&p);
}
void resetPos() {
SetCursorPos(p.x, p.y);
}
void leftClick() {
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
Sleep(25);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
Sleep(25);
}
void middleClick() {
mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0);
Sleep(25);
mouse_event(MOUSEEVENTF_MIDDLEUP,0,0,0,0);
Sleep(25);
}
void wheel() {
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -120, 0);
Sleep(25);
}
void move(int x, int y) {
mouse_event(MOUSEEVENTF_MOVE, x, y, 0, 0);
p.y += y;
p.x += x;
SetCursorPos(p.x, p.y);
readPos();
}
void moveAbsolute(int x, int y, int screenX, int screenY) {
int dx = x * (65535 / screenX);
int dy = y * (65535 / screenY);
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
readPos();
}
void right(int x) {
move(x, 0);
}
void left(int x) {
move(-x, 0);
}
void up(int y) {
move(0, -y);
}
void down(int y) {
move(0, y);
}
};
The state of the lock :
Code:
class DoorsState {
public:
int row1;
int row2;
int row3;
DoorsState() {
row1 = 0;
row2 = 0;
row3 = 0;
}
void read(int number) {
row1 = (number / 100);
row2 = (number - row1 * 100) / 10;
row3 = (number - row1 * 100 - row2 * 10);
}
int getNumber() {
return row1 * 100 + row2 * 10 + row3;
}
void reset() {
read(0);
}
DoorsState getClickDiff(DoorsState state) {
DoorsState clicks;
int newRow1 = state****w1;
int newRow2 = state****w2;
int newRow3 = state****w3;
if (state****w1 < row1) {
newRow1 += 10;
}
if (state****w2 < row2) {
newRow2 += 10;
}
if (state****w3 < row3) {
newRow3 += 10;
}
clicks****w1 = abs(newRow1 - row1);
clicks****w2 = abs(newRow2 - row2);
clicks****w3 = abs(newRow3 - row3);
return clicks;
}
};
In short, several methods:
Color Picker :
Code:
COLORREF getLockColor() {
HDC hDC;
COLORREF color;
HWND hwnd = FindWindow(NULL,TEXT("ArmA 2 OA"));
hDC = GetDC(hwnd);
if (hDC == NULL)
return CLR_INVALID;
color = GetPixel(hDC, colorPoint.x, colorPoint.y);
ReleaseDC(hwnd, hDC);
return color;
}
Verification of whether the lock is visible ( color comparison ) :
Code:
bool isLockVisible() {
int redValue = GetRValue(currentColor);
int greenValue = GetGValue(currentColor);
int blueValue = GetBValue(currentColor);
int redValue1 = GetRValue(lockColor);
int greenValue1 = GetGValue(lockColor);
int blueValue1 = GetBValue(lockColor);
return redValue == redValue1 &&
greenValue == greenValue1 &&
blueValue == blueValue1;
}
Set the selected set of numbers:
Code:
void setRows(int number) {
if (number >= 0 || number < 999) {
DoorsState previousState;
previousState.read(state.getNumber());
state.read(number);
DoorsState diffState = previousState.getClickDiff(state);
lock.moveToRow1();
for (int i = 0; i < diffState****w1; i++) {
lock.leftClick();
}
lock.moveToRow2();
for (int i = 0; i < diffState****w2; i++) {
lock.leftClick();
}
lock.moveToRow3();
for (int i = 0; i < diffState****w3; i++) {
lock.leftClick();
}
}
}
Brute force within the indicated range :
Code:
void startUnlocking(int startNumber, int endNumber) {
for (int i = startNumber; i < endNumber; i++) {
//USTAWIENIE STANU:
setRows(i);
//KLIK NA UNLOCK:
lock.moveToUnlock();
lock.sleep();
lock.leftClick();
Sleep(150);
lock.enterLocker();
lock.sleep();
//JEŻELI KŁÓDKA ZNIKŁA
lock.readCurrentColor();
if (!lock.isLockVisible()) {
//PRZERWA 10s.
Sleep(10020);
//MOUSE SCROLL I PONOWNE OTWORZENIE ZAMKA
lock.enterLocker();
lock.sleep();
lock.readCurrentColor();
if (!lock.isLockVisible()) {
//KONIEC, ZŁAMANY KOD TO: i
break;
}
//WYZEROWANIE POZCYJI (KŁÓDKA PO PONOWNYM POJAWIENIU ZAWSZE JEST W STANIE ZEROWYM)
state.read(0);
}
}
}