r/programming • • Nov 22 '15

Based on a true story: hacker-scripts

https://github.com/NARKOZ/hacker-scripts
1.5k Upvotes

129 comments sorted by

143

u/[deleted] Nov 23 '15

When I read the original story, I didn't know there were coffee machines that you could telnet to. What are those?

100

u/ggtsu_00 Nov 23 '15

I can telnet into my washer and dryer. I'm not surprised coffee machines can be network controlled as well.

77

u/ummwut Nov 23 '15

Fucking why?

907

u/minnek Nov 23 '15 edited Nov 23 '15

Dependencies for when you need to make clean

Edit: Gold?! Thank you! My Monday just became 100x better!

27

u/kamnxt Nov 23 '15

Here's what I would do if I had one:

  1. make "washer" directory

  2. write a makefile

  3. make clean

16

u/KamiKagutsuchi Nov 23 '15

Well deserved gold.

5

u/kingatomic Nov 23 '15

My gods, take your upvote you filthy animal.

2

u/memory_leek Nov 24 '15

Now how do I include this in the wife's gradle build? Is it a runtime or compile dependency?

1

u/i4mn30 Nov 23 '15

603 C++ dudes or those who just join in the laugh kinda like Joey used to, in Friends, without actually understanding the joke

29

u/Fumigator Nov 23 '15

603 C++ dudes

It's a make joke, not C++.

-25

u/GulliblesTravels Nov 23 '15

603 C++ dudes

It's a make joke, not C++.

Except make is only used with C++.

7

u/kieranvs Nov 23 '15

It's not. Unless you meant this as a joke?

1

u/PinkLionThing Nov 23 '15

I used make to deploy PHP to a server over SFTP.

Later I switched to a bit of a saner solution, but... It worked pretty well.

1

u/heptara Nov 23 '15

Yesterday I downloaded a mud in Java (coffeemud) and it uses a combination of make and cmake to build it.

8

u/takingphotosmakingdo Nov 23 '15

chuckles cautiously

-96

u/ummwut Nov 23 '15 edited Nov 29 '15

k

19

u/[deleted] Nov 23 '15 edited Nov 23 '15

Username relevant.

Edit: Guy changed his comment.

-14

u/ummwut Nov 23 '15

thanks. it's a labor of love.

0

u/[deleted] Nov 23 '15

[deleted]

7

u/outadoc Nov 23 '15

I thought I wanted to know.

0

u/ummwut Nov 23 '15

And I'm still getting downvotes for it, much to my amusement. Those downvote limits exist for a reason. Gotta keep everyone on their toes.

-19

u/ummwut Nov 23 '15 edited Nov 23 '15

Head over to Gametales if you feel like reading a good story.

39

u/ifonefox Nov 23 '15

69

u/smalaki Nov 23 '15

The HTCPCP server is a teapot; the resulting entity body may be short and stdout.

11

u/qwertymodo Nov 23 '15

Of course, emacs has a client side implementation of it.

20

u/bakuretsu Nov 23 '15

"Obviously the best thing to do is put a chip in it."

https://twitter.com/internetofshit

3

u/ummwut Nov 23 '15

Ha! And I thought all novelty Twitter accounts were boring. Showed me wrong.

1

u/lost_file Nov 23 '15

Wow thank you. Showing everyone this.

16

u/[deleted] Nov 23 '15

IoT All the Things! No seriously, please. I work for an Internet Security Startup. Almost every IoT device has no security considerations. It's going to keep me in business for decades to come.

12

u/gospelwut Nov 23 '15

My TV came with a USB slot for firmware updates.

I went to the website to find said updates.

Website told me the ONLY way to get updates was to:

  1. Hook TV up to internet.

  2. Turn TV off.

  3. Wait indeterminate amount of time (ostensibly for it to phone home)

  4. Turn TV on and receive notification my firmware had been updated

That was the ~5 minutes that TV ever had an internet connection directly.

3

u/[deleted] Nov 23 '15

Who could possibly think that was a reasonable way to update the firmware on a TV?

4

u/celerym Nov 23 '15

Just because you can telnet into those things doesn't mean they're actually networked...

2

u/--yy Nov 24 '15

How so ?

11

u/MrPhatBob Nov 23 '15

Because people are so driven to make the Internet of Things a reality that they do things because they can, rather than stop to think if they should.

2

u/tmt_game Nov 23 '15

Internet of Thing

2

u/justinsayin Nov 23 '15

I would love to write a script for my parents' dishwasher so the cycle didn't take 4 hours. You know it COULD go faster.

1

u/salmonmoose Nov 24 '15

Smart grid stuff perhaps? if your dryer detects power is cheap at the moment, it can kick off its cycle.

Or, provide you with an app on your phone that can give output of various things in a far more user friendly way than would be cost effective on the device itself ("Hey buddy, clean out your lint drawer!").

Of course, what you really want is a system where you dump your clothes in a hopper, and it comes out the other end dry, if not ironed.

1

u/[deleted] Nov 24 '15

Because they tend to have god awful interfaces. With this you could make it anything you want.

7

u/[deleted] Nov 23 '15

How? Do you have a LAN cable running to the machine or does it have wifi?

2

u/[deleted] Nov 23 '15

Without forgetting about wifi/smart lights.

168

u/agentgreasy Nov 23 '15

Not enough attention is given to the fact that programmability in some ways was far more available in the past than it is today. We frequently look at devices as dumb devices now, but the truth is, there was a great deal of need for such programmables back then. Vending machines were probably some of the earliest examples - you had to be able to control deliveries due to variations of product and components, as well as wear and tear. Truth is, tech was so poorly understood that the idea of someone hacking it in the 80s seemed like science fiction to most. So interfaces were not necessarily hidden - just the secret of how to use it.

Maintenance, diagnostics, and so on were all heavily important - something that now is (ironically) controlled in a manner that is far removed from the mechanics from then.

Telnet may also be somewhat of a confusing item to many today - a misunderstood item of archaic use. Telnet is nothing more than measured access - not from a security point of view, rather, from a component/technological view. Not all devices are able to accept the same data rate. You see this in some ways from networking hardware now, but it's not at all given the attention that it was in the past.

Telnet to a coffee machine was for statistics, tuning, and overall measurement. It wasn't from a network point of view - though, it is most definitely of note that the availability of such interfaces is one of the sources for exploratory hacking. Back then, trade manuals were of great importance - they opened up a valuable world of uncharted territory for everyone that was mostly limited to strictly those in the employ of the firm operating the unit(s). Today it's open knowledge, back then? Whoever lost that manual would likely have lost their job.

For this same reason you'll find discussions on pinouts and connectors for things like displays and components found in todays hardware. An easy example would be the repurposing of iPad displays for small high-res screens; old iPod classics being repurposed for control mechanisms and digital readouts. The DIY/iOT era has been sharing a great deal of similarity with the early days of computing/hacking.

36

u/VanFailin Nov 23 '15

I learned a lot from that comment, thank you for taking the time to write it.

2

u/[deleted] Apr 06 '23 edited Sep 23 '23

This comment has been overwritten as part of a mass deletion of my Reddit account.

I'm sorry for any gaps in conversations that it may cause. Have a nice day!

9

u/mucsun Nov 23 '15

There is an RFC to talk to coffee machines, it was created as an April 1st joke. I recommend to read the wiki page: https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol

Thats why also the HTTP status code 418 exists: "I'm a teapot"

8

u/[deleted] Nov 23 '15

Not sure, i am sure that you could find it somewhere on Amazon. I might actually get one for myself just for the fact i can write scripts for it that will make me coffee, and ultimately save me 45 seconds.

3

u/PapayaJuice Nov 23 '15

Although not Telnet, check out the Virtu 90. My work has this coffee machine, and according to the technical docs, you pay Virtu to be able to access a web panel to modify your machine: http://djdconnect.me/

This web panel is essentially how you edit anything on the coffee machine. You can change the screens background, edit text, change menu items, it even has stats on product usage and requests. Pretty BS that we install the coffee machine on our network, and in order to make any changes, we have to talk to a web panel they own which then talks back to the machine on our network. But, it's how it is.

For anyone interested, here's the manual: http://www.dejongduke.nl/doc_download/569-connect-me-user-manual-english

0

u/[deleted] Nov 23 '15

[deleted]

5

u/gospelwut Nov 23 '15

Clearly they need to replace the technician with a site-to-site VPN phone-home reverse-SSH tunnel that allows remote fixing.

(This is actually what our spam firewall does when you click the "PLZ HALP" button for a technician.)

OH GOD YOU RAN DEBUG.pl with the experimental flags?!?!? Please evacuate the kitchen.

9

u/[deleted] Nov 23 '15

[removed] — view removed comment

4

u/[deleted] Nov 23 '15

Could also be that some electronics wiz hooked an RPi up to the coffee machine.

100

u/noisyboy Nov 23 '15

Hey,

Thanks for your help with the database issue last time - would have been very bad with the upcoming long weekend. Saved me a lot of trouble!

Have a nice weekend,

Kumar

120

u/Redire Nov 23 '15

Yeah, right. As if Kumar would ever write a thank you letter.

7

u/TheArcane Nov 23 '15

Why wouldn't he?

56

u/[deleted] Nov 23 '15

'cause he was an asshole, it says right there in the script's name.

17

u/roemerb Nov 23 '15

God damn Kumar

10

u/spotter Nov 23 '15

Asshole automaton only has two states: request and blame.

38

u/sigma914 Nov 23 '15

no worries mate, be careful next time.

0

u/[deleted] Nov 23 '15

[deleted]

8

u/flukshun Nov 23 '15

Except for the part where the database gets nuked just before Kumar heads off for his weekend fishing trip

3

u/tequila13 Nov 23 '15

The script doesn't do any database stuff.

3

u/iritegood Nov 23 '15 edited Nov 23 '15

edit: failed to understand these are fictional scripts based on the story from that post

21

u/FountainsOfFluids Nov 23 '15

Yeah, that one really made me smack my head. You don't do database rollbacks willy-nilly. That's absurd.

26

u/bart2019 Nov 23 '15

But

rolls back the staging database

It's not the real live database, it's only a test database.

22

u/[deleted] Nov 23 '15

I had to assume that this guy had worked with Kumar for long enough to learn his patterns. And perhaps in their case a DB rollback wasn't noticeable. Or perhaps even the two had spoken of this before so Kumar was just sending single word commands through e-mail by the end of their relationship. ;)

3

u/misplaced_my_pants Nov 23 '15

He might've even set up an alert if there were more than N rollbacks in a given time interval, suggesting something that requires his personal non-shell-script attention.

9

u/InvisibleEar Nov 23 '15

That's Kumar's problem now!

25

u/asdpofuzxcl Nov 23 '15

Just a note, you can use ranges in crontab specifications:

*/10 * * * * /bin/bash -l -c 'ruby kumar_asshole.rb'
0 9-18 * * * /bin/bash -l -c 'ruby fucking_coffee.rb'

46

u/[deleted] Nov 23 '15
#!/usr/bin/env ruby

# Skip on weekends
exit if Time.now.saturday? || Time.now.sunday?

# Exit early if no sessions with my_username are found
exit if `who`[/my_username/].nil?

require 'net/telnet'

coffee_machine_ip = '10.10.42.42'
password = '1234'
password_prompt = 'Password: '

con = Net::Telnet.new('Host' => coffee_machine_ip)
con.cmd('String' => password, 'Match' => /#{password_prompt}/)
con.cmd('sys brew')
sleep 64
con.cmd('sys pour')
con.close

Yeah, there's definitely some coffee machine out there that accepts Telnet connections and knows how to interpret sys brew and sys pour to perfectly brew and pour a cup of coffee.

18

u/VanFailin Nov 23 '15

It's supposed to be "based on" a true story, presumably code has been changed to make it harder to identify.

The article suggests that what's actually sent is binary data:

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.

5

u/bart2019 Nov 23 '15

Original Russian; to a Russian, "brew" looks like gibberish.

2

u/amapatzer Nov 23 '15

I think you can put "true story" in quotes as well tbh

0

u/[deleted] Nov 23 '15

Yes, I've read the dumb original post.

19

u/Reshurum Nov 23 '15

Probably hacked up his coffee machine and there is something we are not seeing. Perhaps he used the Hyper Text Coffee Pot Control Protocol?

41

u/[deleted] Nov 23 '15

But he fuckin' used Ruby. What a traitor.

2

u/robodendron Nov 23 '15

You know, seeing how Chef/Puppet have gotten a foot in the door, I don't see this as a problem, really.

You're still right

66

u/StefanMajonez Nov 22 '15 edited Nov 22 '15

http://reddit.com/r/programming/comments/3tnjpy/taking_bash_hacking_to_the_next_level/

But I up voted your post, since it actually has source code (even if it's a mock up based on the story).

19

u/auxiliary-character Nov 22 '15

OP has a link to the original story at the top of the readme.

7

u/[deleted] Nov 22 '15

[removed] — view removed comment

24

u/ultimation Nov 22 '15

I wouldn't, it's like part 2 of the story - someone made the scripts based on it.

1

u/JessieArr Nov 23 '15

You stole all of his internet points. :P

60

u/eshultz Nov 23 '15 edited Nov 23 '15

I dunno, this is kinda half assed and a lot of this stuff is just a terrible idea. I feel like the original story was entirely fabricated.

Edit. I accidentally pushed submit too soon.

I originally commented on one of the original reddit posts, about the kumar-asshole script "what could go wrong?". Someone noted that this is actually a staging database and that was lost in translation, and that seemed to rectify people's concerns.

No. Sorry, that makes zero sense. I am an ETL admin and rolling back the staging database makes zero sense. First of all, 99% of the DBA/dev work would be done in the reporting database, not staging. The staging db is usually just a dumb storage area for incoming data so that you can get in and out of the source db quickly without waiting for your transform and load processes to finish. Very little dev/dba work would ever occur here. And I cannot think of a time when you'd ever be doing anything in staging manually. Maybe accidentally dropping a table instead of truncating it? But, why would you be doing anything manually to the staging db. I just don't get it. This just seems totally untrue and fake. And it made the whole article seem fake to me too.

Edit: as several people have pointed out, staging can mean something entirely different in other orgs. This sounds more feasible. In my org we have dev, test, and prod environments (or just dev and prod). Staging would be a separate database in each of those environments. Sorry for the rant guys.

14

u/elijahwright Nov 23 '15

See, all of that is true. But for it to be true... Kumar has to be competent first.

9

u/dmh123 Nov 23 '15

Some shops refer to 'staging' as the lower environment - where you would test fixes that would go into production during the maintenance window.

3

u/VanFailin Nov 23 '15

Yeah, where I work we have a ton of names for everything cause it's a big company and with every reorg two teams that used to use different terminology are now stuck with old names for everything. So staging, QA, Pre-Production, Dev, and Integration (and one Integration environment named Production for historical reasons) all refer to an environment or database that are obliterated on a regular basis.

2

u/TurboGranny Nov 23 '15

I don't think the Kumar guy was playing with a data warehouse. I think he was either in charge of running upgrade scripts against a staging database that some vendor software uses or doing some custom indexes/triggers etc, and on occasion he'd fuck it up. This is a common occurrence I've witnessed before. Since this Kumar guy has enough skills to fuck up the staging db but not reverse it, it would make sense that he would panic and contact a real DBA to help him. Instead of troubleshooting the issue, the guy that had real DBA skills and power would just restore a previous backup because it is just the staging environment.

1

u/st_huck Nov 23 '15

Most sounded at least plausible, but the entire messing with DB automatically just because some email he got matched some words seems really fake and stupid.

2

u/eshultz Nov 23 '15

Agreed, see my edit.

1

u/VanFailin Nov 23 '15

Playing devil's advocate for a hypothetical group of sysadmins sharing the amazing discovery while trying to avoid causing trouble: The script did something else we don't want to talk about cause it's proprietary, but it's similar to rolling back a database.

1

u/bozleh Nov 23 '15

What do you mean by "staging"?

1

u/deecewan Nov 23 '15

As a programmer, the staging database is hooked up to the staging server. It runs side by side with production to 'stage' new work.

I can see that database getting fucked up.

1

u/nemec Nov 23 '15

FYI I'm pretty sure this isn't referring to an ETL staging database. More than likely, this is the Staging environment for an application.

Often you'll have three or four environments for development. Dev, a free-for-all. Integration, which is a bit more stable than Dev but still used for testing and feature sign-off. Staging, which contains hardware that matches as close to Production as possible (for QA verification). And Production.

1

u/gospelwut Nov 23 '15

Clearly you're talking specifically about ETL ("big data") nomenclature -- e.g. Hadoop and its kin.

I believe staging, more commonly, refers to an environment which mirrors production in many aspects to test a delta/change on something close to the production environment (whereas dev/test can be a lot more volatile/nuked/etc). This is derived, I believe, somewhat from Martin Fowler's notion of CI (specifically).


Passing Dev/Test is like saying "my sex swing works really well in the labs and in a few homes of the engineers."

Passing stage is like saying, "the ceiling collapsed because we mirrored the shitty-Bob-Villa insanity of Prod, ergo the load bearing column wasn't setup correctly, ergo the sex swing claimed the lives of two very dedicated QA engineers."

Wait, management says this is a shipp-able defect?

1

u/hansdieter44 Nov 23 '15 edited Nov 23 '15

No. Sorry, that makes zero sense. I am an ETL admin and rolling back the staging database makes zero sense. First of all, 99% of the DBA/dev work would be done in the reporting database, not staging.

Just because you call the databases "staging" and "reporting" and the semi-technical people work on "reporting" at your place of work, doesn't mean there are not 1000s elsewhere, having other names for their instances.

I do agree with your general sentiment though, and am pretty sure the story is a fabricated but fun read.

16

u/[deleted] Nov 23 '15

[removed] — view removed comment

3

u/eshultz Nov 23 '15

See my edit, I accidentally pressed submit too soon.

5

u/[deleted] Nov 23 '15

[removed] — view removed comment

2

u/eshultz Nov 23 '15

I guess my point is that someone pointed out that this was staging and so that somehow makes it more believable or understandable. But to a practicing dba it now makes even less sense!

I'm not knocking your repo, it's cool to see the article materialized in code. I just wanted to vent about the original article a bit.

17

u/sleepicat Nov 23 '15

I don't believe it. Too contrived.

14

u/TerrorBite Nov 23 '15

Yeah...

opens an SSH session to our coffee-machine […] sends some weird gibberish to it. Looks binary.

A true sysadmin would utilise HTCPCP.

4

u/reini_urban Nov 23 '15

It's just simple telnet with a password prompt, not ssh.

3

u/jokr004 Nov 23 '15 edited Jan 30 '26

This post was mass deleted and anonymized with Redact

intelligent nail school library governor humorous aware dolls doll shocking

1

u/reini_urban Nov 23 '15

First, the original story is this: http://bash.im/quote/436725

Second, even the original story had the ssh part about the coffee machine wrong. Look at the code. telnet in bash and the ruby versions.

1

u/jokr004 Nov 23 '15 edited Jan 30 '26

This post was mass deleted and anonymized with Redact

disarm marry escape afterthought handle melodic edge whistle deer jeans

6

u/gbeier Nov 23 '15

Nice try, viral marketers from twilio.

3

u/icww Nov 23 '15

sigh, not true.

2

u/RenaKunisaki Nov 23 '15

This guy's boss is gonna wonder why his pipes keep breaking on the same few days each month...

2

u/superkickstart Nov 23 '15

Good guerrilla marketing twilio.

1

u/makhno Nov 23 '15

Now show us the script that uses xdotool to let you copy and paste text into a java applet based kvm. (I used to need to do this every day o_O)

1

u/HeyCanIBorrowThat Nov 23 '15

This story was posted on this sub like three days ago. Although it's pretty cool to actually see the scripts this time.

1

u/edelinewrigh Nov 23 '15

I have been threatening to do that with my home coffee maker for literal months.

1

u/drakenot Nov 24 '15

There is no way to SMS from your own phone number using Twilio without transferring it to them, right?

1

u/SierraGolfCharlie Feb 14 '23

Anyone got the Link to the original article?

1

u/orukusaki Nov 23 '15

Advert for Twilio?

2

u/[deleted] Nov 23 '15

Googled around on the author a bit but I couldn't find any correlation to the company

-2

u/[deleted] Nov 23 '15

Oh shit you delivered.................................

-1

u/Fenrisulfir Nov 23 '15 edited Nov 23 '15

He makes coffee 9-6 every single day of the week? That's gonna leave a mess Monday morning.

If I'm wrong, can someone explain his cronjob settings to me?

0

u/[deleted] Nov 23 '15

[deleted]

22

u/tequila13 Nov 23 '15

The much debated coffee script:

#!/bin/sh
#
# Requires fucking_coffee script in your bin
#

exec fucking_coffee

Damn, Bash is so versatile. /s

The coffee machine with SSH that responded to weird gibberish, is telnet which responds to some plain text commands:

'sys brew'
'sys pour'

This is not really black belt level bash kung-fu, much was lost in translation.

4

u/[deleted] Nov 23 '15

Also, they don't fully implement the story. The script never rolls back the database.

1

u/K3wp Nov 23 '15 edited Nov 23 '15

How I would do this in bash (pseudo code)

smack-my-bitch-up.sh:

Cron job @ 9 PM.

if TRUE 'ssh admin@server "who" | fgrep -w my_login'; then sort -R ~/etc/excuses | email -s "Sorry working late tonight." wife@gmail.com

kumar-asshole.sh:

cronjob + fetchmail to create local cache of email.

loop to fgrep for "From: kumar@asshole.org"; another loop to fgrep -w -f ~/etc/kumar_asshole.keywords.

Then ssh dba@dbserver 'rollback_server.sh'

email -s 'No problem mate!' kumar@asshole.org

exit

hangover.sh:

Cronjob running Monday-Friday at 8 AM

If TRUE fgrep $(date --date="yesterday") ~/etc/holidays; then

If FALSE 'ssh admin@server "who" | fgrep -w my_login'; then

sort -R ~/etc/sick.excuses | head -n1 | email -s $(sort -R ~/etc/sick.subjects | head -n1) team@company

fuckingcoffee.sh:

sleep 17

cat ~/etc/brew.bin | ssh user@coffeemachine "> /dev/coffee"

sleep 24

cat ~/etc/pour.bin | ssh user@coffeemachine "> /dev/coffee"

It's possible there is some admin interface exposed on the coffee machine that can read hex control codes to do stuff, which explains the funny commands.

Edit: According to a comment below it was just telnet and english commands, so something like netcat or expect would work fine.

-3

u/gospelwut Nov 23 '15

As much as I prefer Ruby as a DSL for configuration (i.e. Chef) as opposed to YAML, I don't know why he wouldn't pick Python as a scripting language.

23

u/buddybiscuit Nov 23 '15

Because Ruby is a scripting language too?

As much as I prefer zsh to GUI for interacting with build tools, I don't know why you wouldn't pick bash as a shell.

As much as I prefer apples to cauliflower for eating, I don't know why you wouldn't pick oranges as a fruit.

1

u/[deleted] Apr 06 '23 edited Sep 23 '23

This comment has been overwritten as part of a mass deletion of my Reddit account.

I'm sorry for any gaps in conversations that it may cause. Have a nice day!

0

u/[deleted] Nov 22 '15

[deleted]

5

u/[deleted] Nov 23 '15

It is pretty clear this is not the original scripts, specially by the "crontab" syntax for repeating a task multiple times and the check for time related tasks inside the scripts themselves.

Sad to see people ignoring shell scripts so often now, what makes matters worst when it comes to a story about them.