hacker-scripts README

The project's README from github.com/NARKOZ/hacker-scripts. As one markdown file: README.md.

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 (NARKOZ/hacker-scripts)

Searching Database…

这是什么?一套带有喜剧色彩的系统管理员自动化脚本合集,灵感来自一篇热门论坛帖子。帖子讲的是一位构建工程师把各种烦人的琐事都写成了脚本,从深夜伪造 SSH 活动,到自动回复客户那些惊慌失措的邮件。
这是能直接放到我服务器上用的真工具包,还是更像个玩笑?这是一套恶搞合集:smack-my-bitch-up.sh 和 fucking-coffee.sh 这类脚本是为了好笑而写的,并不适合用于生产环境,不过其中有几个用到了 cron、SSH、Twilio 和 gmail 等真实工具。
我到底该怎么运行这些脚本?先为你想用的脚本设置所需的环境变量(如 API 密钥、SSH 凭据等),然后对于 Ruby 脚本,用 `gem install dotenv twilio-ruby gmail` 安装所需的 gem;大多数脚本都设计为配置成 cron 任务,在特定条件下触发。
运行 Ruby 脚本需要先安装什么?需要 Ruby,以及用于发送短信和收发邮件的 dotenv、twilio-ruby 和 gmail gem;合集里的其他脚本还依赖 cron 调度器、SSH 访问,其中一个还需要一台联网并开放了 TCP 套接字的咖啡机。
这些脚本能直接拿来用吗?不能。它们是根据一个故事记录下来的,并不是成品工具,所以在它们真正能运行之前,你需要自己补全短信发送、邮件解析或咖啡机控制的实际逻辑。
这个仓库的背后是什么故事?它源于一篇俄语论坛帖子,讲的是一位即将离职的构建工程师留下的脚本。其中一个会自动给妻子发短信,编造各种晚上加班的理由;另一个则会在一位惊慌的 DBA 发邮件求助时,回滚客户的预发布数据库。
哪个脚本最荒唐?fucking-coffee.sh 会先等待 17 秒,然后通过 telnet 连到办公室里联网的咖啡机煮一杯拿铁。时间算得刚好,开发者一走过去,咖啡就煮好了。
Which topics is it in?meme, satire, sms, fun, cron, scripting, collection, bash, ruby, email, ssh, sysadmin
Creator
NARKOZ
Size
0.1 MB
Stars
49.9K
Updated
CommitAug 07
Age
10y
Commits · 90 Days