Skip to content

Instantly share code, notes, and snippets.

View gomasy's full-sized avatar

Gomasy gomasy

View GitHub Profile
@gomasy
gomasy / base.patch
Last active October 4, 2015 01:51
patch of base.py
--- base.py.orig 2015-09-12 12:04:29.771884700 +0900
+++ base.py 2015-09-12 12:05:47.339417230 +0900
@@ -38,7 +38,10 @@
class command_echo(HoneyPotCommand):
def call(self):
- self.writeln(' '.join(self.args))
+ if len(self.args) and self.args[0].strip().count('-n'):
+ self.write(' '.join(self.args[1:]))
+ else:
@gomasy
gomasy / getenvaddr.c
Last active October 16, 2015 05:46
get environment variable
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
char *ptr;
if (argc < 3) {
printf("Usage: %s [environment] [path]\n", argv[0]);
return 0;
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char msg[1024];
static int flag = 0;
if (argc < 2) {
printf("[*] Error: no argument specified.\n");
return 1;
@gomasy
gomasy / 00-route.sh
Last active August 19, 2018 13:58
xl2tpd により L2TP コネクションが確立した際に自動的に経路を追加するスクリプト
#!/bin/sh
# This script is run by pppd after the link is established.
# It executes all the scripts available in /etc/ppp/ip-up.d directory,
# with the following parameters:
# $1 = interface name (e.g. ppp0)
# $2 = tty device
# $3 = speed
# $4 = local IP address
# $5 = remote IP address
@gomasy
gomasy / mail.rb
Last active July 13, 2017 00:09
なんか
require "net/smtp"
require "securerandom"
require "base64"
FOOTER = "\n\n-----\nThis mail was issued by Ruby #{RUBY_VERSION} on Arch Linux (x86_64)."
def send_mail(server, from, to, subject, body)
Net::SMTP.start(server[:host], server[:port], `uname -n`.chomp, server[:user], server[:pass], :cram_md5) do |smtp|
smtp.send_message(
"Message-Id: <#{SecureRandom.uuid}@#{server[:host]}>\n" + \
#!/bin/sh
declare -A prev
declare -A next
renewal=0
domain=("gomasy.jp" "gomasy.net")
for d in ${domain[@]}; do
prev+=([$d]=`date -r /etc/letsencrypt/live/$d/cert.pem "+%s"`)
@gomasy
gomasy / mail2slack.rb
Last active March 6, 2020 01:21
ありがとう Slack
require "digest/md5"
require "net/https"
require "json"
require "mail"
require "time"
require "uri"
def parse_envelope(data)
if data.multipart?
data.parts.map do |pt|
@gomasy
gomasy / ssh-alert.rb
Last active March 7, 2018 13:03
ゴリ押し
require "net/https"
require "ipaddr"
require "json"
require "uri"
slack_url = URI.parse("") # slack webhook url
user = ENV["USER"]
remote_ip = IPAddr.new(ENV["SSH_CONNECTION"].split(" ")[0])
local_ip = IPAddr.new(ENV["SSH_CONNECTION"].split(" ")[2])
@gomasy
gomasy / nut-governor.c
Last active March 24, 2022 00:54
CPU governor changer for Network UPS Tools
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
const char basepath[] = "/sys/devices/system/cpu/cpu%d/cpufreq/%s";
void update_governor(int cpu, char *gov) {
FILE *fp;
char path[64];
.status__wrapper .status {
padding: 8px 10px 8px 8px;
}
.status__wrapper .status__content {
line-height: 20px;
margin-left: 56px;
margin-top: -34px;
}