Add signal handlers for SIGINFO and SIGUSR1 - anticapum - Handle Università Politecnica delle Marche captive portal (HTM) hg clone https://bitbucket.org/iamleot/anticapum (DIR) Log (DIR) Files (DIR) Refs (DIR) README --- (DIR) changeset a2933e49b6a8ad7d7401052f47fa29b40a639c46 (DIR) parent ccb59827041b40818245f5bbce4f06558341a76e (HTM) Author: Leonardo Taccari <iamleot@gmail.com> Date: Fri, 12 Jan 2018 11:27:46 Add signal handlers for SIGINFO and SIGUSR1 When SIGINFO (e.g. via ^T) or SIGUSR1 are sent to anticapum it will print all current session information (i.e. username, ip, timestamp, sid and pulsante). SIGINFO is an extension only present on BSDs and macOS so check that signal.SIGINFO is present before injecting the handler. Diffstat: anticapum.py | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) --- diff -r ccb59827041b -r a2933e49b6a8 anticapum.py --- a/anticapum.py Thu Jan 11 23:24:03 2018 +0100 +++ b/anticapum.py Fri Jan 12 11:27:46 2018 +0100 @@ -136,6 +136,20 @@ if __name__ == '__main__': import time + import signal + + s = {} + + def siginfo_handler(signum, frame): + print('username:', s.get('username', '')) + print('ip:', s.get('ip', '')) + print('timestamp:', s.get('timestamp', '')) + print('sid:', s.get('sid', '')) + print('pulsante:', s.get('pulsante', '')) + + if hasattr(signal, 'SIGINFO'): + signal.signal(signal.SIGINFO, siginfo_handler) + signal.signal(signal.SIGUSR1, siginfo_handler) username, password = credential()