Ubuntu Pastebin

Paste from ogra at Wed, 19 Aug 2015 15:47:31 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/sh

PORT=80

rm -f out
mkfifo out

trap "rm -f out" EXIT

while true
do
  cat out | nc -l $PORT | {
    export QUERY=
    export HOST=
    export UA=
    while read line
    do
      line=$(echo "$line" | tr -d '[\r\n]')
      case $line in
          'GET /'*)
              QUERY=$(echo "$line" | cut -d ' ' -f2)
              ;;
          'Host:'*)
              HOST=$(echo "$line" | cut -d ' ' -f2 | sed "s/:.*$//")
              ;;
          'User-Agent:'*)
              UA=$(echo "$line" | sed "s/^.*: //")
              ;;
          '')
              echo "$(date +%d.%m\ %H:%M) Request: $QUERY From: $HOST with User Agent: $UA"
              case $QUERY in
                  /ps)
                      ps ax > out
                      ;;
                  /cpu)
                      cat /proc/cpuinfo > out
                      ;;
                  /mem)
                      cat /proc/meminfo > out
                      ;;
                  *)
                      echo > out
                      ;;
              esac
              ;;
        esac
    done
  }
done
Download as text