Giter Club home page Giter Club logo

hacker-scripts's Introduction

English | 简体中文

Hacker Scripts

Based on a true story:

xxx: OK, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown... If something - anything - requires more than 90 seconds of his time, he writes a script to automate that.

xxx: So we're sitting here, looking through his, uhm, "legacy"

xxx: You're gonna love this

xxx: smack-my-bitch-up.sh - sends a text message "late at work" to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron-job. The job fires if there are active SSH-sessions on the server after 9pm with his login.

xxx: kumar-asshole.sh - scans the inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".

xxx: 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.

xxx: (and the oscar goes to) 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.

xxx: holy sh*t I'm keeping those

Original: http://bash.im/quote/436725 (in Russian) (Archive.org link) Pull requests with other implementations (Python, Perl, Shell, etc) are welcome.

Usage

You need these environment variables:

# used in `smack-my-bitch-up` and `hangover` scripts
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

# used in `kumar_asshole` script
[email protected]
GMAIL_PASSWORD=password

For Ruby scripts you need to install gems: gem install dotenv twilio-ruby gmail

Cron jobs

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

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

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

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

Code is released under WTFPL.

hacker-scripts's People

Contributors

ajorpheus avatar alexesprit avatar amirkarimi avatar arjunnambiartc avatar ausshadu avatar b0n3z avatar benjojo avatar bitsapien avatar carlosdp avatar destromas1 avatar kashyapakshay avatar linbudu599 avatar matthew-z avatar mpetitjean avatar narkoz avatar robaganrab avatar samharad avatar samzer avatar syedautherabbas avatar theapache64 avatar thuruv avatar tillenium avatar uranusjr avatar vasspilka avatar waksana avatar ww40 avatar yellowapple avatar yoannduc avatar zenlaboratory avatar zhiephie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hacker-scripts's Issues

fucking_coffee.py can't connect

I noticed fucking_coffee.py (both python and python3 versions) cannot connect to the coffee machine.

I tracked this down to the script trying to connect via telnet instead of SSH.

Please fix!

No cup exception, cup overflow [security issue]

Hello,

In story we have 2 sleeps "waits exactly 17 seconds" and " waits another 24 (!) seconds", but the code waits only:

sleep 64

I think this can be very dangerous to users, due:

  • no time to put a cup,
  • overflow a cup.

Greetings,

Novice here

What is the purpose of having conversation under the Hacker Scripts in README.md ?
Like reading comic?

Please provide Windows scripts

There's a whole lot of Windows developers out there who would love to use this too, and who will contribute based on it.

Use a better license

MIT perhaps, or if you really want people to just "do what the fuck they want to" use CC0.

Hangover Script Early Exit Condition Wrong

In hangover script (python), it should check if there's a terminal open then exit, where as it checks if there's no session then exit.

Line 15-18

# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' not in output:
    sys.exit()

should be

# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' in output:
    sys.exit()

Possibly badly-terminated string in PowerShell script

Issue Description

I've been running the PowerShell version of smack_my_bitch_up in production for a couple of weeks now, and while everything seemed to work great at first, after a few days I began to encounter some erratic behavior - things like no dinner on the table, the cold shoulder treatment, "you're sleeping on the sofa tonight", "no, everything is Just. Fine" and other similar, weird response codes.

Steps to Reproduce

Sadly, I don't have a clear repro on the issue as each run seemed to produce different results, and thus I've been unable to pin down the exact behavior. However, I have since made some changes to the script by adding some randomly-selected string terminators to the $message variable:

$STRTERMS =
  'Love u',
  'You''re beautiful',
  'I''m cooking dinner tomorrow',
  'Girls trip this weekend?'
$term = $STRTERMS | Get-Random
$message = "Late at work. $reason. $term."

While this change did not get rid of all the random issues, it does seem to have taken care of the worst symptoms. For one, I am very happy to report that I've gone back to sleeping in my own bed.

I have no idea whether this is happening due to some specific issue with my production setup, or some weird PowerShell bug I'm unaware of.

I was gonna submit a pull request but I'm not sure my (partial) solution is generally applicable, and unfortunately I don't have the time or resources to set up a separate test environment.

Has anyone else encountered similar issues with this script in the past?

thanks

My Environment

  • one wife (kinda high maintenance)
  • two kids (primary school / kindergarten age)
  • one visiting mother-in-law (can't wait for next Monday when I'll be able to uninstall and re-test without this library)
  • PowerShell v5.1.16299.15 on Windows 10.0.16299.15

$HOME/bin/{fucking_coffee,kumar_asshole} missing

Thanks for the blog post and code ;-D

Really entertained by the story and of course the guy.

Looks like we've already had kumar-asshole.sh and fucking_coffee implemented in Python and Ruby (hopefully more to come, so many polyglot fans), however, the original shell scripts which are supposed to be in $HOME/bin are missing, it'll be great if they can be added.

Thanks again for entertaining the crowd ;-D

Php version

Hi i want you to explain well the script php
In order to tell me how i can use it or test it
Thanks

[Feature] Implementation in GO?

Would an implementation in Golang be useful/valuable to anyone?

I would love take a stab at re-implement (some|all) of this functionality in Go, if the maintainer/owner is accepting PRs.

What type of coffee machine?

Could you please provide more information about the make of the coffee machine etc (because I really want a coffee machine that I can run the coffee script with)?

I'm new to this.

I keep getting and error in my hackerutils.py file: "ImportError: cannot import name 'Dotenv'" and I can't quite figure out why. It's probably a simple fix, I'm just not sure.

Actually fake

This is not actual scripts leaved by genius engineer. Thought this is is actual legacy repository, but actually just a fake.

[Enhancement] Turing test failed on significant other for SMS responses

I suggest making more believable responses that show some affection and more variety will make the script more useful. @popaulina was not pleased with me attempting to put this into practice. She has volunteered her time for the cause (we can use her help for testing).

I suggest ideally some sort of language modeling for these excuses (e.g Markov sentence generator), or at the very least marking excuses that were sent recently to be excluded for the next 6 months or longer if you've recently fucked something up in your relationship.

Thoughts?

[:|||||||||||||||||||||||||:]

[:|||||||||||||||||||||||||:]
[:/\/\/\/\/\/\/\/\/\/\/\/:]
[:|||||||||||||||||||||||||:]
[:/\/\/\/\/\/\/\/\/\/\/\/:]
[:|||||||||||||||||||||||||:]

Ruby script still fails

The script now fails with the following error message :

kumar_asshole.rb:18:in `create_reply': undefined local variable or method `gmail' for main:Object (NameError)
    from kumar_asshole.rb:36:in `block in <main>'
    from kumar_asshole.rb:25:in `each'
    from kumar_asshole.rb:25:in `<main>'

Check the PowerShell scripts for silly conversion errors, please

Had a quick look at https://github.com/NARKOZ/hacker-scripts/blob/master/powershell/fucking_coffee.psm1 but I have some issues with the conversion from the original language:

  • I don't think "if ($env:Username.Count > 0) { return }" does what you think it does. Quick heads-up: PowerShell has no return statement, or a ">" operator (which is written as "-gt" in PowerShell).

  • You don't call defined functions with the "Send-TelNetCommands($Writer, "sys brew", 24)" syntax. Correct syntax here would be "Send-TelNetCommands -writer $Writer -command 'sys brew' -WaitTime 24".

  • Calls to Send-TelNetCommands give wait times in seconds (from the description of the what the script should do elsewhere), but inside the function that parameter value is used as milliseoonds, given "Start-Sleep -Milliseconds $WaitTime" (which by the way does use correct PowerShell parameter syntax)

This is sort of silly, really... :-/

rename "smack-my-bitch-up"

Hate to be an SJW, but rename that script, I think in the spirit of an open source COMMUNITY, we don't need to name files like that. Just call is like "tell-wife-gunna-be-late" or something like that.

IMAP error with Kumar scrpit

When I startup the script with all of the correct info in the right places, I get an IMAP error and I have no idea what from.

Well Done

You did a great work! Learn from you!

Ruby script for kumar_asshole.rb fails

The script fails with this message :

kumar_asshole.rb:21:in `block in <main>': undefined method `[]' for #<Mail::Body:0x007fd4bda2be50> (NoMethodError)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.