1
+ <#
2
+ . SYNOPSIS
3
+ Simple script to connect to a coffee part using TelNet then issue specific commands that
4
+ brew and pourt a cup of coffee for the user.
5
+ . DESCRIPTION
6
+ This script was converted using the ruby version of the fucking_coffee script. In this script,
7
+ I left the use of environment variables since its only use was to determine if the user was
8
+ still logged in to the system. Per issue #42 (https://github.com/NARKOZ/hacker-scripts/issues/42)
9
+ I left the password string hard coded until a decision is made by NARKOZ, the project owner, as
10
+ to how the information should be stored.
11
+ .OUTPUT
12
+ None
13
+ . NOTES
14
+ Author: Tyler Hughes
15
+ Twitter: @thughesIT
16
+ Blog: http://tylerhughes.info/
17
+
18
+ Changelog:
19
+ 1.0 Initial Release
20
+ #>
21
+
22
+ Function Fucking-Coffee
23
+ {
24
+ # Exit early if no sessions with my username are found
25
+ if ($env: Username.Count > 0 ) {
26
+ return
27
+ }
28
+
29
+ $coffee_machine_ip = ' 10.10.42.42'
30
+ $password = ' 1234'
31
+
32
+ Start-Sleep - s 17
33
+
34
+ $socket = New-Object System.Net.Sockets.TcpClient($coffee_machine_ip )
35
+ if ($socket ) {
36
+ $stream = $connection.GetStream ()
37
+ $Writer = New-Object System.IO.StreamWriter($Stream )
38
+ $Buffer = New-Object System.Byte[] 1024
39
+ $Encoding = New-Object System.Text.AsciiEncoding
40
+
41
+ # Start issuing the commands
42
+ Send-TelNetCommands ($Writer , $password , 1 )
43
+ Send-TelNetCommands ($Writer , " sys brew" , 24 )
44
+ Send-TelNetCommands ($Writer , " sys pour" , 4 )
45
+
46
+ $socket.Close ()
47
+ }
48
+ }
49
+
50
+ Function Send-TelNetCommands
51
+ {
52
+ Param (
53
+ [Parameter (ValueFromPipeline = $false )]
54
+ [System.IO.StreamWriter ]$writer ,
55
+ [String ]$command ,
56
+ [int ]$WaitTime
57
+ )
58
+
59
+ $writer.WriteLine ($command )
60
+ $writer.Flush ()
61
+ Start-Sleep - Milliseconds $WaitTime
62
+ }
0 commit comments