Skip to content

Instantly share code, notes, and snippets.

View gitfrage's full-sized avatar

nik gitfrage

  • check24
  • Munich, Germany
View GitHub Profile
strace -s 4096 -F -f `ps -ef | grep php-cgi | awk '{print "-p "\$2}'` &> /tmp/log
# IP
cat access.log | awk '{print $1}' | sort | uniq -c | sort -n | tail -fn 100
# string in request
zgrep 'string' *.zip | tee /tmp/suspicious.log
grep 'string' /tmp/suspicious.log | awk '{ print $7 }' | sort | uniq -c | sort -n
# http count zwischen 0:00 uhr und 0:10
zcat access.log.1.gz |grep 21/Mar/2017:00:0 > /tmp/000
awk '{print $1}' < /tmp/000 |sort|uniq -c|sort -n|tail
@gitfrage
gitfrage / nginx_log_to_mysql_dumper.sh
Created December 22, 2016 13:44
using mysql LOAD DATA INFILE for big log data files
#!/bin/bash
MY_DIR=`dirname $0`
DB='db'
DB_USER='user'
DB_HOST='127.0.0.1'
DB_PORT='3308'
DB_PASS='pass'
LOGPATH='/www/custlogs.cloud.net'
DATE=$(date -d "-1 day" +"%Y%m%d") # select logs for yesterday
LIST=$(ls $LOGPATH/domain.de*$DATE*.log.zip)
@gitfrage
gitfrage / ssl-tls-debug
Created December 21, 2016 13:22
curl vs openssl vs gnutls-cli debug
# curl debug
curl -v https://www.guitarspecs.info
# copenssl debug
openssl s_client -CApath /etc/ssl/certs -connect www.guitarspecs.info:443 -debug
# gnutls debug
gnutls-cli -V -d 9999 www.guitarspecs.de 443
<?php
# @author gitfrage
# @license MIT
# mico php client for elasticsearch
# minimal API similar to the official client https://github.com/elastic/elasticsearch-php
function init($host, $port, $user = '', $pass = '')
{
$ch = curl_init();
#! /bin/sh
DBNAME="mydatabase"
TABLES="table_x table_y"
FILENAME=/tmp/tmp.sql
SOURCE="user@source.net"
DEST="user@dest1.net user@dest2.net"
ssh $SOURCE "sudo mysqldump --single-transaction --hex-blob --order-by-primary --skip-triggers -u user --password=password $DBNAME $TABLES > $FILENAME"
scp $SOURCE:$FILENAME $FILENAME
@gitfrage
gitfrage / users_crontabs.sh
Created November 15, 2016 10:14
List crontab for all users
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done