Chit chat.

========

Nice little command but it requires admin rights.

$ sudo arp-scan –localnet
[sudo] password for eddie:
Interface: eth0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.8.1 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.1.1 00:00:00:00:00:00 Buffalo Inc.
192.168.1.32 00:00:00:00:00:00 DELL COMPUTER CORPORATION
192.168.1.99 00:00:00:00:00:00 Cellvision Systems, Inc.

3 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.8.1: 256 hosts scanned in 1.741 seconds (147.04 hosts/sec). 3 responded
$

——————————————-

This is an article I wrote a long time ago, but found a minor error. Instead of going back and changing the original article, thought I would repost the article here.

Simple calendar

$ for i in {0..365};do date -d “Jan 1 2012 + $i day” + ”*%B %_d – “; done

In theory would print out:
*January 1 –
*January 2 –
*January 3 –
*January 4 –
*January 5 –

*December 28 –
*December 29 –
*December 30 –
*December 31 –

Now lets put that in a batch file called moncal.sh and mod it a little bit.

moncal.sh

# use start month and add number of days after the first day of that month i.e. ./moncal.sh Oct 60
let l=$2-1;for i in $(eval echo {0..$l});do date -d "$1 1 2012 + $i day" +"*%B %_d - ";done

$ chmod +x moncal.sh

Then try it

$ ./moncal.sh Feb 29

You get:
*February 1 –
*February 2 –
*February 3 –
—–
*February 27 –
*February 28 –
*February 29 –

A little fun:

$ ./moncal.sh Feb 60

*February 1 –
*February 2 –
*February 3 –

*March 30 –
*March 31 –

Databook
$ ./moncal.sh Feb 29 > feb_databook

$ vim feb_databook

(or nano or gedit, or etc)

Insert data into file using underscores (easier to dump data into spreadsheet).

dateadd.sh:

read -p "Words to add to list: " t
t1=$(echo $t | sed -e 's/ /_/g')
sed '/'$2'/a
>_'$t1 $1 > test
mv test $1

$ ./daterecord.sh Feb_datebook -3
Words to add to list: This date has passed
[eddie@oedt01 ~]$ cat Feb_datebook
*February -1 –
*February -2 –
*February -3 –
>_This_date_has_passed
*February -4 –
*February -5 –
*February -6 –

——————————————-

Reverse tunnel?

Screenshot - 06052014 - 06:46:48 AM

Have you ever wanted to ssh to your Linux box that sits behind NAT? Now you can with reverse SSH tunneling. This document will show you step by step how to set up reverse SSH tunneling. The reverse SSH tunneling should work fine with Unix like systems.

Let’s assume that Destination’s IP is 192.168.20.55 (Linux box that you want to access).

You want to access from Linux client with IP 138.47.99.99.

Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99)

1. SSH from the destination to the source (with public ip) using command below:

ssh -R 19999:localhost:22 sourceuser@138.47.99.99

* port 19999 can be any unused port.

2. Now you can SSH from source to destination through SSH tuneling:

ssh localhost -p 19999

——————————————-

The CGI (Common Gateway Interface) defines a way for a web server to interact with external content-generating programs, which are often referred to as CGI programs or CGI scripts. It is the simplest, and most common, way to put dynamic content on your web site. The main point of this is that you can use your own programming interface to push or pull data from a web page.

Cgi install in part. assuming apache2 is already installed.

$ sudo apt-get install libapache2-mod-perl2
sudo a2enmod cgi 
$ sudo service apache2 restart

For example I like to use Freebasic to control ports for automation. The cgi interface allows me to do that. Actually what I wanted to talk about is changing the directory where you usually store the files. Here is a typical entry for cgi scripts location.

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Options FollowSymLinks
Require all granted
</Directory>


The current directory is just fine and probably best for admins to control.However, I would
like to used a different directory. All you have to do is to change the script alias and the directory lines.

 ScriptAlias /cgi-bin/ /var/wwww/cgi-bin/
<Directory "
/var/wwww/cgi-bin/">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Options FollowSymLinks
Require all granted
</Directory>

You will now want to restart Apache2

$ sudo service apache2 restart

Then just copy your cgi and other support files to the directory.

$ cp *.cgi  /var/wwww/cgi-bin/

Now you can use your special pages. 

-----

A bash cgi example:

 #!/bin/sh
    echo "Content-type: text/htmln"
     
    # read in our parameters
    CMD=`echo "$QUERY_STRING" | sed -n 's/^.*cmd=([^&]*).*$/1/p' | sed "s/%20/ /g"`
    FOLDER=`echo "$QUERY_STRING" | sed -n 's/^.*folder=([^&]*).*$/1/p' | sed "s/%20/ /g"| sed "s/%2F///g"`
     FOLDER1=`echo "$QUERY_STRING" | sed -n 's/^.*folder1=([^&]*).*$/1/p' | sed "s/%20/ /g"| sed "s/%2F///g"`
FOLDER2=`echo "$QUERY_STRING" | sed -n 's/^.*folder2=([^&]*).*$/1/p' | sed "s/%20/ /g"| sed "s/%2F///g"`
    # our html header
    echo "<html>"
    echo "<head><title>Bash CGI</title></head>"
    echo "<body>"
     
    # test if any parameters were passed
    if [ $CMD ]
    then
      case "$CMD" in
        ifconfig)
          echo "Output of ifconfig :<pre>"
          /sbin/ifconfig
          echo "</pre>"
          ;;
     
        uname)
          echo "Output of uname -a :<pre>"
          /bin/uname -a
          echo "</pre>"
          ;;
     
        dmesg)
          echo "Output of dmesg :<pre>"
          /bin/dmesg
          echo "</pre>"
          ;;
     
        df)
          echo "Output of df -h :<pre>"
          /bin/df -h
          echo "</pre>"
          ;;
     
       free)
          echo "Output of free :<pre>"
          /usr/bin/free
          echo "</pre>"
          ;;
     
        hw)
              echo "Hardware listing :<pre>"
              /usr/bin/lshw
              echo "</pre>"
              ;;
        lsusb)
              echo "lsusb :<pre>"
              /usr/bin/lsusb
              echo "</pre>"
              ;;
        lsuser)
              echo "List of users :<pre>"
              /usr/bin/lsuser
              echo "</pre>"
              ;;
        ls)
          echo "Output of ls $FOLDER :<pre>"
          /bin/ls "$FOLDER"
          echo "</pre>"
          ;;
     
            lsal)
              echo "Output of ls $FOLDER1 :<pre>"
              /bin/ls -al "$FOLDER1"
              echo "</pre>"
              ;;
            wol)
              echo "System to wake: $FOLDER2 :<pre>"
              /usr/bin/wakeonlan "$FOLDER2"
              echo "</pre>"
              ;;
        lsb_release)
          echo "Ubuntu version :<pre>"
          /usr/bin/lsb_release -a
          echo "</pre>"
          ;;
     
           cpuinfo)
              echo "Cpu information :<pre>"
              cat /proc/cpuinfo
              echo "</pre>"
              ;;
       
         *)
          echo "Unknown command $CMD<br>"
          ;;
      esac
    fi
     
    # print out the form
     
    # page header
    echo "<p>"
    echo "<center>"
    echo "<h2>Bash commands</h2>"
    echo "</center>"
    echo "<p>"
    echo "<p>"
     
    echo "Choose which command you want to run"
    echo "<form method=get>"
    echo "<input type=radio name=cmd value=ifconfig checked> ifconfig (Network configuration) <br>"
    echo "<input type=radio name=cmd value=uname> uname -a (Kernel version)<br>"
    echo "<input type=radio name=cmd value=dmesg> dmesg (System messages) <br>"
    echo "<input type=radio name=cmd value=lsb_release> lsb_release (Ubuntu version) <br>"
    echo "<input type=radio name=cmd value=df> df -h (Free disk space) <br>"
    echo "<input type=radio name=cmd value=free> free (Memory info)<br>"
        echo "<input type=radio name=cmd value=cpuinfo> Cpu information <br>"
        echo "<input type=radio name=cmd value=hw> Hardware listing <br>"
    echo "<input type=radio name=cmd value=lsuser> User listing <br>"
    echo "<input type=radio name=cmd value=lsusb> lsusb (Usb ports info)<br>"
    echo "<input type=radio name=cmd value=ls> ls  -- folder <input type=text name=folder value=/mnt/flash><br>"
    echo "<input type=radio name=cmd value=lsal> ls -al -- folder <input type=text name=folder1 value=/mnt/flash><br>"
        echo "<input type=radio name=cmd value=wol> wakeonlan (enter mac address) <input type=text name=folder2 value=00:00:00:00:00:00><br>"
    echo "<input type=submit>"
    echo "</form>"
    echo "</body>"
    echo "</html>"

——————————————-

Two diy tv antennas

antennaa

Bpf6PONCcAE9N1E.png:large

——————————————-

Lasagna bianco.

lasagnabianco

Good day.

Advertisements