Skip to content

Commit b8dd025

Browse files
authored
Merge pull request #1 from NARKOZ/master
Updating from upstream
2 parents f9321f0 + 64f2d1b commit b8dd025

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1437
-113
lines changed

CSharp/Hangover.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace Hacker_Scripts
2+
{
3+
using System;
4+
using Twilio;
5+
using System.Linq;
6+
7+
class Hangover
8+
{
9+
public static string TWILIO_ACCOUNT_SID = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
10+
public static string AUTH_TOKEN = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
11+
12+
public static string YOUR_NUMBER = "9879789978";
13+
public static string BOSS_NUMBER = "3213213233";
14+
15+
static void Main(string[] args)
16+
{
17+
var twilio = new TwilioRestClient(TWILIO_ACCOUNT_SID, AUTH_TOKEN);
18+
19+
string[] randomMessages = {
20+
"Locked out",
21+
"Pipes broke",
22+
"Food poisoning",
23+
"Not feeling well"
24+
};
25+
26+
int randomIndex = new Random().Next(randomMessages.Count());
27+
String messageToSend = (randomMessages[randomIndex]);
28+
29+
var message = twilio.SendMessage(YOUR_NUMBER, BOSS_NUMBER, messageToSend);
30+
Console.WriteLine(message.Sid);
31+
}
32+
}
33+
}
34+

CSharp/SmackMyBitch.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Twilio;
7+
8+
namespace Hacker_Scripts
9+
{
10+
class SmackMyBitch
11+
{
12+
public static string TWILIO_ACCOUNT_SID = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
13+
public static string AUTH_TOKEN = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
14+
15+
public static string YOUR_NUMBER = "9879789978";
16+
public static string HER_NUMBER = "3213213233";
17+
18+
static void Main(string[] args)
19+
{
20+
var twilio = new TwilioRestClient(TWILIO_ACCOUNT_SID, AUTH_TOKEN);
21+
22+
string[] randomMessages = {
23+
"Working hard",
24+
"Gotta ship this feature",
25+
"Someone fucked the system again"
26+
};
27+
28+
int randomIndex = new Random().Next(randomMessages.Count());
29+
String messageToSend = (randomMessages[randomIndex]);
30+
31+
var message = twilio.SendMessage(YOUR_NUMBER, HER_NUMBER, messageToSend);
32+
Console.WriteLine(message.Sid);
33+
}
34+
}
35+
}

R/hangover.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
library(httr)
2+
3+
today = Sys.Date()
4+
5+
# skip weekends
6+
if( weekdays(today) %in% c('Saturday','Sunday') ){
7+
quit()
8+
}
9+
10+
# exit if no sessions with my username are found
11+
output = system("who", intern = TRUE)
12+
if( !( grep('^my_user_name', output) ) ){
13+
quit()
14+
}
15+
16+
# returns 'None' if the key doesn't exist
17+
TWILIO_ACCOUNT_SID = Sys.getenv('TWILIO_ACCOUNT_SID')
18+
TWILIO_AUTH_TOKEN = Sys.getenv('TWILIO_AUTH_TOKEN')
19+
20+
# Phone numbers
21+
my_number = '+xxx'
22+
number_of_boss= '+xxx'
23+
24+
excuse = c(
25+
'Locked out',
26+
'Pipes broke',
27+
'Food poisoning',
28+
'Not feeling well'
29+
)
30+
31+
POST(paste("https://api.twilio.com/2010-04-01/Accounts/",TWILIO_ACCOUNT_SID,"/Messages.json",sep=""),
32+
body = list(From=my_number,To=number_of_boss,Body=paste("Gonna work from home. ", sample(excuse,1))),
33+
authenticate(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN) )
34+
35+
print( paste("Message sent at",Sys.time()) )

R/smack_my_bitch_up.R

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
library(httr)
2+
3+
today = Sys.Date()
4+
5+
# skip weekends
6+
if( weekdays(today) %in% c('Saturday','Sunday') ){
7+
quit()
8+
}
9+
10+
# exit if no sessions with my username are found
11+
output = system("who", intern = TRUE)
12+
if( !( grep('^my_user_name', output) ) ){
13+
quit()
14+
}
15+
16+
# returns 'None' if the key doesn't exist
17+
TWILIO_ACCOUNT_SID = Sys.getenv('TWILIO_ACCOUNT_SID')
18+
TWILIO_AUTH_TOKEN = Sys.getenv('TWILIO_AUTH_TOKEN')
19+
20+
# Phone numbers
21+
my_number = '+xxx'
22+
her_number = '+xxx'
23+
24+
reasons = c(
25+
'Working hard',
26+
'Gotta ship this feature',
27+
'Someone fucked the system again'
28+
)
29+
30+
POST(paste("https://api.twilio.com/2010-04-01/Accounts/",TWILIO_ACCOUNT_SID,"/Messages.json",sep=""),
31+
body = list(From=my_number,To=her_number,Body=paste("Late at work. ", sample(reasons,1))),
32+
authenticate(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN) )
33+
34+
print( paste("Message sent at",Sys.time()) )

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ story](https://www.jitbit.com/alexblog/249-now-thats-what-i-call-a-hacker/)_:
1515
1616
> xxx: [`hangover.sh`](https://github.com/NARKOZ/hacker-scripts/blob/master/hangover.sh) - another cron-job that is set to specific dates. Sends automated emails like "not feeling well/gonna work from home" etc. Adds a random "reason" from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45am.
1717
18-
> xxx: (and the oscar goes to) [`fucking-coffee.sh`](https://github.com/NARKOZ/hacker-scripts/blob/master/fucking-coffee.sh) - this one waits exactly 17 seconds (!), then opens an SSH session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has SSHD up and running) and sends some weird gibberish to it. Looks binary. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.
18+
> xxx: (and the oscar goes to) [`fucking-coffee.sh`](https://github.com/NARKOZ/hacker-scripts/blob/master/fucking-coffee.sh) - this one waits exactly 17 seconds (!), then opens a telnet session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has a TCP socket up and running) and sends something like `sys brew`. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.
1919
2020
> xxx: holy sh*t I'm keeping those
2121
@@ -37,22 +37,22 @@ GMAIL_PASSWORD=password
3737
```
3838

3939
For Ruby scripts you need to install gems:
40-
`gem install dotenv twilio gmail`
40+
`gem install dotenv twilio-ruby gmail`
4141

4242
## Cron jobs
4343

4444
```sh
45-
# Runs `smack-my-bitch-up.sh` daily at 9:20 pm.
46-
20 21 * * * /path/to/scripts/smack-my-bitch-up.sh >> /path/to/smack-my-bitch-up.log 2>&1
45+
# Runs `smack-my-bitch-up.sh` monday to friday at 9:20 pm.
46+
20 21 * * 1-5 /path/to/scripts/smack-my-bitch-up.sh >> /path/to/smack-my-bitch-up.log 2>&1
4747

48-
# Runs `hangover.sh` daily at 8:45 am.
49-
45 8 * * * /path/to/scripts/hangover.sh >> /path/to/hangover.log 2>&1
48+
# Runs `hangover.sh` monday to friday at 8:45 am.
49+
45 8 * * 1-5 /path/to/scripts/hangover.sh >> /path/to/hangover.log 2>&1
5050

5151
# Runs `kumar-asshole.sh` every 10 minutes.
5252
*/10 * * * * /path/to/scripts/kumar-asshole.sh
5353

54-
# Runs `fucking-coffee.sh` hourly from 9am to 6pm.
55-
0 9-18 * * * /path/to/scripts/fucking-coffee.sh
54+
# Runs `fucking-coffee.sh` hourly from 9am to 6pm on weekdays.
55+
0 9-18 * * 1-5 /path/to/scripts/fucking-coffee.sh
5656
```
5757

5858
---

coffee/fucking.coffee

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env coffee
2+
3+
username = 'name'
4+
5+
host = 'localhost'
6+
port = '3000'
7+
pass = '5555'
8+
9+
sh = require('child_process').execSync
10+
11+
# weekend
12+
process.exit 0 if new Date().getDay() in [6, 0]
13+
14+
# no sessions
15+
process.exit 0 unless new RegExp(username).test sh('who -q').toString()
16+
17+
conn = require('net').createConnection port, host
18+
19+
setTimeout ->
20+
conn.write "#{pass}\nsys brew\n"
21+
setTimeout ->
22+
conn.end 'sys pour'
23+
process.exit 0
24+
, 2 * 1000
25+
, 1 * 1000
26+
27+
# alert
28+
sh 'say come here and take your fucking coffee'

fucking_coffee.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
# Skip on weekends
4-
exit if Time.now.saturday? || Time.now.sunday?
5-
63
# Exit early if no sessions with my username are found
74
exit unless `who -q`.include? ENV['USER']
85

go/hangover.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"math/rand"
7+
"os"
8+
9+
"github.com/codeskyblue/go-sh"
10+
"github.com/subosito/twilio"
11+
)
12+
13+
const my_number string = "+xxxxx"
14+
const boss_number string = "+yyyyy"
15+
16+
func main() {
17+
//exit if sessions with my username are found
18+
_, err := sh.Command("who").Command("grep", "my_username").Output()
19+
if err != nil {
20+
os.Exit(1)
21+
}
22+
23+
//Grab Twilio ID and token from environment variables
24+
Account_Sid := os.Getenv("TWILIO_ACCOUNT_SID")
25+
Auth_Token := os.Getenv("TWILIO_AUTH_TOKEN")
26+
27+
//create the reasons slice and append reasons to it
28+
reasons := make([]string, 0)
29+
reasons = append(reasons,
30+
"Locked out",
31+
"Pipes broke",
32+
"Food poisoning",
33+
"Not feeling well")
34+
35+
// Initialize Twilio client and send message
36+
client := twilio.NewClient(Account_Sid, Auth_Token, nil)
37+
message := fmt.Sprint("Gonna work from home...", reasons[rand.Intn(len(reasons))])
38+
39+
params := twilio.MessageParams{
40+
Body: message,
41+
}
42+
s, resp, err := client.Messages.Send(my_number, boss_number, params)
43+
44+
if err == nil {
45+
log.Fatal(s, resp, err)
46+
}
47+
}

go/smack_my_bitch_up.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"math/rand"
6+
"os"
7+
"os/exec"
8+
"strings"
9+
"time"
10+
)
11+
12+
func main() {
13+
output1, err := exec.Command("who").Output()
14+
output2 := os.Getenv("USER")
15+
users := string(output1[:])
16+
current_user := string(output2[:])
17+
if !strings.Contains(users, current_user) {
18+
return
19+
}
20+
21+
reasons := []string{"Working hard", "Gotta ship this feature", "Someone fucked the system again"}
22+
23+
rand.Seed(time.Now().UTC().UnixNano())
24+
message := "Late at work. " + reasons[rand.Intn(len(reasons))]
25+
26+
TWILIO_ACCOUNT_SID := string(os.Getenv("TWILIO_ACCOUNT_SID"))
27+
TWILIO_AUTH_TOKEN := string(os.Getenv("TWILIO_AUTH_TOKEN"))
28+
MY_NUMBER := string(os.Getenv("MY_NUMBER"))
29+
HER_NUMBER := string(os.Getenv("HER_NUMBER"))
30+
31+
response, err := exec.Command("curl", "-fSs", "-u", TWILIO_ACCOUNT_SID+":"+TWILIO_AUTH_TOKEN, "-d", "From="+MY_NUMBER, "-d", "To="+HER_NUMBER, "-d", "Body="+message, "https://api.twilio.com/2010-04-01/Accounts/"+TWILIO_ACCOUNT_SID+"/Messages").Output()
32+
if err != nil {
33+
fmt.Printf("Failed to send SMS: %s", err)
34+
return
35+
}
36+
37+
fmt.Printf("Message Sent Successfully with response: %s ", response)
38+
}

groovy/fucking_coffee.groovy

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@Grab(group='org.hidetake', module='groovy-ssh', version='1.1.8')
2+
@GrabExclude('org.codehaus.groovy:groovy-all')
3+
import org.hidetake.groovy.ssh.Ssh
4+
5+
final def ssh = Ssh.newService()
6+
7+
final def HOST = '10.10.42.42'
8+
final def USER = 'my_username'
9+
final def PASSWORD = '1234'
10+
final def DELAY = 24
11+
12+
ssh.remotes {
13+
webServer {
14+
host = HOST
15+
user = USER
16+
password = PASSWORD
17+
}
18+
}
19+
20+
ssh.run {
21+
session(ssh.remotes.webServer) {
22+
execute 'sys brew'
23+
execute "sleep ${DELAY}s"
24+
execute 'sys pour'
25+
}
26+
}

0 commit comments

Comments
 (0)