1
+ #!/usr/bin/env php
1
2
<?php
2
- namespace HackerScripts ;
3
3
4
- /**
5
- * Class fucking_coffee
6
- *
7
- * @package HackerSripts
8
- *
9
- * Lewis Lancaster 2015
10
- */
4
+ require 'vendor/autoload.php ' ;
11
5
12
- use HackerScripts \ Lib \ Telnet ;
6
+ use Bestnetwork \ Telnet \ TelnetClient ;
13
7
14
- class fucking_coffee
15
- {
16
-
17
- /**
18
- * The telnet class
19
- *
20
- * @var HackerScripts\Lib\Telnet
21
- */
22
-
23
- protected $ telnet ;
24
-
25
- /**
26
- * The password for this coffee machine
27
- *
28
- * @var string
29
- */
30
-
31
- protected $ password = "" ;
32
-
33
- /**
34
- * The host of this coffee machine
35
- *
36
- * @var string
37
- */
38
-
39
- protected $ host = "" ;
40
-
41
- /**
42
- * The port of this coffee machine
43
- *
44
- * @var string
45
- */
46
-
47
- protected $ port = "" ;
48
-
49
- /**
50
- * Delay for 24 seconds.
51
- *
52
- * @var int
53
- */
54
-
55
- protected $ delay = 24 ;
56
-
57
- /**
58
- * What we do when we construct this class
59
- */
60
-
61
- public function __construct ()
62
- {
63
-
64
- /**
65
- * Lets not run this on the weekends
66
- */
67
-
68
- if ( $ this ->IsWeekend ( date ('m.d.y ' ) ) == false )
69
- {
70
-
71
- return false ;
72
- }
73
-
74
- /**
75
- * Create a new telnet class
76
- */
77
-
78
- $ this ->telnet = new Telnet ( $ this ->host , $ this ->port );
79
-
80
- /**
81
- * Once we have completed this, we can brew our coffee!
82
- */
83
-
84
- $ this ->BrewCoffee ( function (){
85
-
86
- /**
87
- * Echo out a message
88
- */
89
-
90
- echo "coffee has been poured " ;
91
-
92
- /**
93
- * Unset
94
- */
95
-
96
- unset( $ this ->telnet );
97
- });
98
-
99
- /**
100
- * Return tue
101
- */
102
-
103
- return true ;
104
- }
105
-
106
- /**
107
- * Brews our coffee
108
- *
109
- * @param $callback
110
- */
111
-
112
- public function BrewCoffee ( $ callback )
113
- {
114
-
115
- if ( $ this ->telnet != null )
116
- {
117
-
118
- /**
119
- * Execute and enter the password
120
- */
121
-
122
- $ this ->telnet ->exec ('Password: ' . $ this ->password );
123
-
124
- /**
125
- * Brew the coffee
126
- */
127
-
128
- $ this ->telnet ->exec ('sys brew ' );
129
-
130
- /**
131
- * Wait
132
- */
133
-
134
- sleep ( $ this ->delay );
135
-
136
- /**
137
- * Pour the coffee
138
- */
139
-
140
- $ this ->telnet ->exec ('sys pour ' );
141
-
142
- /**
143
- * Execute our callback
144
- */
145
-
146
- call_user_func ( $ callback );
147
- }
148
- }
149
-
150
- /**
151
- * Is this currently the weekend?
152
- *
153
- * @param $date
154
- *
155
- * @return bool
156
- */
157
-
158
- public function IsWeekend ( $ date )
159
- {
160
-
161
- if ( date ('N ' , strtotime ( $ date ) ) >= 6 )
162
- {
163
-
164
- return true ;
165
- }
166
-
167
- return false ;
168
- }
169
-
170
- }
8
+ (date ('N ' ) < 6 ) or exit ('weekend ' );
9
+ (strpos (exec ('who ' ), getenv ('USER ' )) !== false ) or exit ('no session ' );
10
+ sleep (17 );
11
+ $ con = new TelnetClient ('10.10.42.42 ' );
12
+ $ con ->execute ('1234 ' , 'Password: ' );
13
+ $ con ->execute ('sys brew ' );
14
+ sleep (24 );
15
+ $ con ->execute ('sys pour ' );
0 commit comments