2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-23 19:07:33 +00:00
hacker-scripts/python3/fucking_coffee.py
2015-11-24 01:38:12 +08:00

40 lines
779 B
Python
Executable File

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
import telnetlib
import time
from hackerutils import sh
COFFEE_MACHINE_ADDR = '10.10.42.42'
COFFEE_MACHINE_PASS = '1234'
COFFEE_MACHINE_PROM = 'Password: '
def main():
# Skip on weekends.
if datetime.date.today().weekday() in (0, 6,):
return
# Exit early if no sessions with my_username are found.
if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
return
time.sleep(17)
conn = telnetlib.Telnet(host=COFFEE_MACHINE_ADDR)
conn.open()
conn.expect([COFFEE_MACHINE_PROM])
conn.write(COFFEE_MACHINE_PASS)
conn.write('sys brew')
time.sleep(64)
conn.write('sys pour')
conn.close()
if __name__ == '__main__':
main()