diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-04-27 00:03:22 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-04-27 00:03:22 +0300 |
commit | 442af5cc3d7ffbd4e31fbb13132b9a44e38af694 (patch) | |
tree | d56b115f6a66712be665669cb086a0c4231b8418 /user_mods/password.hmod | |
parent | 020485c1b9c7ac5df70ea8c1951ec42a8012df55 (diff) |
Many minor fixes, new modules
Diffstat (limited to 'user_mods/password.hmod')
-rw-r--r-- | user_mods/password.hmod/S810password | 50 | ||||
-rw-r--r-- | user_mods/password.hmod/install | 7 | ||||
-rw-r--r-- | user_mods/password.hmod/password.raw.gz | bin | 0 -> 9577 bytes | |||
-rw-r--r-- | user_mods/password.hmod/password_fail.raw.gz | bin | 0 -> 7866 bytes | |||
-rw-r--r-- | user_mods/password.hmod/password_ok.raw.gz | bin | 0 -> 5174 bytes | |||
-rw-r--r-- | user_mods/password.hmod/readme.txt | 3 | ||||
-rw-r--r-- | user_mods/password.hmod/uninstall | 5 |
7 files changed, 65 insertions, 0 deletions
diff --git a/user_mods/password.hmod/S810password b/user_mods/password.hmod/S810password new file mode 100644 index 00000000..baef6e35 --- /dev/null +++ b/user_mods/password.hmod/S810password @@ -0,0 +1,50 @@ +#!/bin/sh + +# Some constants +# Controller pseudo-file +clovercon=/dev/input/by-path/platform-twi.1-event-joystick +# Password pattern - it's Konami Code :) +password="c202 c202 c302 c302 c002 c102 c002 c102 3101 3001 3b01" +# Max tries +max_tries=30 + +# Init scripts are executed with "start" argument when system boots and with "stop" argument during shutdown +# So we need to check that it's boot state, not shutdown +[ -z "$1" ] || [ "$1" == "start" ] || exit 0 + +# Drawing "ENTER PASSWORD" image +gunzip -c /etc/password.raw.gz > /dev/fb0 + +# Endless loop +while [ true ]; do + # Wait while pseudo-file doesn't exists (controller is not connected or is not initialized yet) + while [ ! -e $clovercon ]; do usleep 100; done + # Reading buttons + buttons=$(cat $clovercon | hexdump -v -e '1/1 "%02x"' -n 32) + buttons=${buttons:20:4} + # Appending pressed button to "str" variable + str="$str $buttons" + # If "str" variable is longer than password string, cut it + # So we get only last presses + [ "${#str}" -gt "${#password}" ] && str="${str:$((${#str}-${#password})):${#password}}" + + # Is password correct? + if [ "$str" == "$password" ]; then + # Display "OK" image + gunzip -c /etc/password_ok.raw.gz > /dev/fb0 + # Exit and continue system loading + exit 0 + fi + + # Password is not correct yet, decrease tries counter + max_tries=$(($max_tries-1)) + # Is it zero? + if [ "$max_tries" == "0" ]; then + # Display "ACCESS DENIED" image + gunzip -c /etc/password_fail.raw.gz > /dev/fb0 + # Wait for three seconds + sleep 3 + # Shutdown system + poweroff + fi +done diff --git a/user_mods/password.hmod/install b/user_mods/password.hmod/install new file mode 100644 index 00000000..2f66861a --- /dev/null +++ b/user_mods/password.hmod/install @@ -0,0 +1,7 @@ +local script=S810password
+copy $script $rootfs/etc/init.d/
+chmod +x $rootfs/etc/init.d/$script
+copy password.raw.gz $rootfs/etc/
+copy password_ok.raw.gz $rootfs/etc/
+copy password_fail.raw.gz $rootfs/etc/
+return 1
diff --git a/user_mods/password.hmod/password.raw.gz b/user_mods/password.hmod/password.raw.gz Binary files differnew file mode 100644 index 00000000..afa6cc3b --- /dev/null +++ b/user_mods/password.hmod/password.raw.gz diff --git a/user_mods/password.hmod/password_fail.raw.gz b/user_mods/password.hmod/password_fail.raw.gz Binary files differnew file mode 100644 index 00000000..e60ba2d2 --- /dev/null +++ b/user_mods/password.hmod/password_fail.raw.gz diff --git a/user_mods/password.hmod/password_ok.raw.gz b/user_mods/password.hmod/password_ok.raw.gz Binary files differnew file mode 100644 index 00000000..c37c5860 --- /dev/null +++ b/user_mods/password.hmod/password_ok.raw.gz diff --git a/user_mods/password.hmod/readme.txt b/user_mods/password.hmod/readme.txt new file mode 100644 index 00000000..ebff0c8c --- /dev/null +++ b/user_mods/password.hmod/readme.txt @@ -0,0 +1,3 @@ +=== Password Protection Hack ===
+
+This module adds password protection to NES Mini. Default password is Konami Code :)
diff --git a/user_mods/password.hmod/uninstall b/user_mods/password.hmod/uninstall new file mode 100644 index 00000000..b5247786 --- /dev/null +++ b/user_mods/password.hmod/uninstall @@ -0,0 +1,5 @@ +local script=S810password
+rm $rootfs/etc/init.d/$script
+rm $rootfs/etc/password.raw.gz
+rm $rootfs/etc/password_ok.raw.gz
+rm $rootfs/etc/password_fail.raw.gz
|