Created
March 27, 2018 23:01
-
-
Save webdev23/4c6ba420df321729aa5dc11e821f3b40 to your computer and use it in GitHub Desktop.
Realtime keystrokes in php bash scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$trap = []; | |
system("xinput list | grep -Po 'id=\K\d+(?=.*slave\s*keyboard)' \ | |
| xargs -P0 -n1 xinput test > keys &"); | |
while (true){ | |
$data = file("keys"); | |
$key = $data; | |
array_push($trap,$key); | |
if ((@strpos(implode($trap[count($trap)-1]), 'press 36') !== false)){ | |
echo "[+] return!"; | |
$trap = []; | |
file_put_contents("keys", ""); | |
} | |
if ((@strpos(implode($trap[count($trap)-1]), 'press 37') !== false)){ | |
echo "\n[+] left ctrl!"; | |
$trap = []; | |
file_put_contents("keys", ""); | |
} | |
usleep(10000); /* <- CAUTION */ | |
} | |
//🜛 keycodes list: | |
//🜛 xmodmap -pke | less |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This base script will detect RETURN and LEFT CTRL keys press from php.
Can be adapted for any keys.
Require linux tools, any x env.
NO ROOT
It listen for keystrokes globally, the focus can be outside the shell window