mirror of
https://github.com/narkoz/hacker-scripts
synced 2025-08-23 10:57:13 +00:00
keep things simple
This commit is contained in:
parent
eb7f1d840c
commit
793c49a6df
5
php/composer.json
Normal file
5
php/composer.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"bestnetwork/telnet": "^1.0"
|
||||
}
|
||||
}
|
@ -1,170 +1,15 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
namespace HackerScripts;
|
||||
|
||||
/**
|
||||
* Class fucking_coffee
|
||||
*
|
||||
* @package HackerSripts
|
||||
*
|
||||
* Lewis Lancaster 2015
|
||||
*/
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use HackerScripts\Lib\Telnet;
|
||||
use Bestnetwork\Telnet\TelnetClient;
|
||||
|
||||
class fucking_coffee
|
||||
{
|
||||
|
||||
/**
|
||||
* The telnet class
|
||||
*
|
||||
* @var HackerScripts\Lib\Telnet
|
||||
*/
|
||||
|
||||
protected $telnet;
|
||||
|
||||
/**
|
||||
* The password for this coffee machine
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $password = "";
|
||||
|
||||
/**
|
||||
* The host of this coffee machine
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $host = "";
|
||||
|
||||
/**
|
||||
* The port of this coffee machine
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $port = "";
|
||||
|
||||
/**
|
||||
* Delay for 24 seconds.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
|
||||
protected $delay = 24;
|
||||
|
||||
/**
|
||||
* What we do when we construct this class
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
/**
|
||||
* Lets not run this on the weekends
|
||||
*/
|
||||
|
||||
if( $this->IsWeekend( date('m.d.y') ) == false )
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new telnet class
|
||||
*/
|
||||
|
||||
$this->telnet = new Telnet( $this->host, $this->port );
|
||||
|
||||
/**
|
||||
* Once we have completed this, we can brew our coffee!
|
||||
*/
|
||||
|
||||
$this->BrewCoffee( function(){
|
||||
|
||||
/**
|
||||
* Echo out a message
|
||||
*/
|
||||
|
||||
echo "coffee has been poured";
|
||||
|
||||
/**
|
||||
* Unset
|
||||
*/
|
||||
|
||||
unset( $this->telnet );
|
||||
});
|
||||
|
||||
/**
|
||||
* Return tue
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Brews our coffee
|
||||
*
|
||||
* @param $callback
|
||||
*/
|
||||
|
||||
public function BrewCoffee( $callback )
|
||||
{
|
||||
|
||||
if( $this->telnet != null )
|
||||
{
|
||||
|
||||
/**
|
||||
* Execute and enter the password
|
||||
*/
|
||||
|
||||
$this->telnet->exec('Password: ' . $this->password);
|
||||
|
||||
/**
|
||||
* Brew the coffee
|
||||
*/
|
||||
|
||||
$this->telnet->exec('sys brew');
|
||||
|
||||
/**
|
||||
* Wait
|
||||
*/
|
||||
|
||||
sleep( $this->delay );
|
||||
|
||||
/**
|
||||
* Pour the coffee
|
||||
*/
|
||||
|
||||
$this->telnet->exec('sys pour');
|
||||
|
||||
/**
|
||||
* Execute our callback
|
||||
*/
|
||||
|
||||
call_user_func( $callback );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this currently the weekend?
|
||||
*
|
||||
* @param $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
public function IsWeekend( $date )
|
||||
{
|
||||
|
||||
if( date('N', strtotime( $date ) ) >= 6 )
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
(date('N') < 6) or exit('weekend');
|
||||
(strpos(exec('who'), getenv('USER')) !== false) or exit('no session');
|
||||
sleep(17);
|
||||
$con = new TelnetClient('10.10.42.42');
|
||||
$con->execute('1234', 'Password: ');
|
||||
$con->execute('sys brew');
|
||||
sleep(24);
|
||||
$con->execute('sys pour');
|
Loading…
x
Reference in New Issue
Block a user