Skip to content

Instantly share code, notes, and snippets.

@misodengaku
Created December 6, 2015 08:42
Show Gist options
  • Save misodengaku/2b7f60345ea4f37d159a to your computer and use it in GitHub Desktop.
Save misodengaku/2b7f60345ea4f37d159a to your computer and use it in GitHub Desktop.
QRpuzzle (win) solver
#include <windows.h>
#include <stdio.h>
void sendtxt(char *txt);
void pushkey(byte code);
void alldel();
void main()
{
FILE *fp;
char dic[1365][26];
int i = 0, j;
// 辞書ロード
fp = fopen("dic.txt", "r");
while (fscanf(fp, "%s", dic[i]) != EOF) {
i++;
}
fclose(fp);
// QRpuzzleを見付ける
HWND qr = FindWindow(NULL, "QRpuzzle for SECCON 2015 (by KeigoYAMAZAKI)");
SetForegroundWindow(qr);
// 300ステージなんで300回にしたけどたぶん終わらないんで適宜なんとかする
for (i = 0; i < 300; i++)
{
printf("Loop: %d\n", i);
for (j = 0; j < 1365; j++)
{
alldel();
sendtxt(dic[j]);
pushkey(13);
Sleep(15);
}
}
}
void sendtxt(char *txt)
{
int l = strlen(txt);
int i = 0;
while (i < l)
{
pushkey(txt[i]);
i++;
}
}
void alldel()
{
keybd_event(17, NULL, 0, 0); // Ctrl
pushkey('A');
keybd_event(17, NULL, KEYEVENTF_KEYUP,0);
pushkey(46); // Delete
}
void pushkey(byte code)
{
keybd_event(code, NULL, 0, 0);
keybd_event(code, NULL, KEYEVENTF_KEYUP, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment