I wrote something similar in sophomore year of college. It didn't work quite as well as this does because I was a noob and wrote it in C/ncurses. Got me a job because it impressed the interviewer. Read all of Kevin mitnick's Ghost in the Wires on it
https://github.com/shortrounddev/books