Posts

Showing posts from February, 2015

Miss Robot wars?

Image
More fun than old fashioned wrestling.

Proof of aliens?

Image

Child's story come to life.

Image

ssh-copy-id.

Image
Replace traditional command to install ssh-keys cat ~/.ssh/id_rsa.pub | ssh usr@host’cat >> .ssh/authorized_keys’ With a single command: ssh-copy-id -i ~/.ssh/id_rsa.pub user@host SSH-COPY-ID(1) BSD General Commands Manual SSH-COPY-ID(1) NAME ssh-copy-id — use locally available keys to authorise logins on a remote machine SYNOPSIS ssh-copy-id [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname ssh-copy-id -h | -? DESCRIPTION ssh-copy-id is a script that uses ssh(1) to log into a remote machine (presumably using a login password, so password authentication should be enabled, unless you’ve done some clever use of multiple identities). It assembles a list of one or more fingerprints (as described below) and tries to log in with each key, to see if any of them are already installed (of course, if you are not using ssh-agent(1) this may result in you being repeatedly prompted for pass-phrases). It then assembles a list of those that fai

Geek valentine.

Image

What's on the network?

Image
Our goal here to see what is live on the network and how possibly vulnerable those machines are. Might be interesting to use with a wifi network. First lets get the live systems at the moment. You will need to change your code depending on your network, alive.sh [code]  #!/bin/bash rm goodips is_alive_ping() {   ping -c 1 $1 > /dev/null   [ $? -eq 0 ] && echo $i >> goodips } for i in 192.168.1.{1..255} do is_alive_ping $i & disown done [/code] Generated goodips file: 192.168.1.1 192.168.1.32 192.168.1.99 192.168.1.126 Then we can run a sort of network scanner. scannet.sh [code] datafile="goodips" a=1 m="not done" while read line do fdata[$a]=$line echo $line         let a=a+1        for p in {1..1023};        do        (echo >/dev/tcp/$line/$p) >/dev/null 2>&1 && echo "$p open"        done done < $datafile [/code] Then we can run the bash file to see what is open.

It could happen...

Image

More Whiptail.

Image
Here are some more examples on using whiptail expanding on what we did in the last article. A message box shows any arbitrary text message with a confirmation button to continue. whiptail --title "<message box title>" --msgbox "<text to show>" <height> <width> Example: #!/bin/bash whiptail --title "Test Message Box" --msgbox "Create a message box with whiptail. Choose Ok to continue." 10 60 Example: #!/bin/bash  whiptail --title "Message Box" --msgbox "Create a message box with whiptail. Choose Ok to continue." 10 60 Create a Yes/No Box One common user input is Yes or No. This is when a Yes/No dialog box can be used. whiptail --title "<dialog box title>" --yesno "<text to show>" <height> <width> #!/bin/bash if (whiptail --title "Yes/No Box" --yesno "Do you like computers (yes/no)?" 10 60) then echo "Yes, you like

Experimental mysql database setup scripts.

Image
Some experimental mysql database setup scripts. ( USE AT YOUR OWN RISK !) Original script: #!/bin/bash EXPECTED_ARGS=3 E_BADARGS=65 MYSQL=`which mysql` #Danger do not use GRANT ALL ON *.* Q1="CREATE DATABASE IF NOT EXISTS $1;" Q2="GRANT ALL ON *.* TO '$2'@'localhost' IDENTIFIED BY '$3';" Q3="FLUSH PRIVILEGES;" SQL="${Q1}${Q2}${Q3}" if [ $# -ne $EXPECTED_ARGS ] then echo "Usage: $0 dbname dbuser dbpass" exit $E_BADARGS fi $MYSQL -uroot -p -e "$SQL" To use it, just run: ./createdb testdb testuser secretpass Someone's modified script: #!/bin/bash BTICK=’`’ EXPECTED_ARGS=3 E_BADARGS=65 MYSQL=`which mysql` Q1=”CREATE DATABASE IF NOT EXISTS ${BTICK}$1${BTICK};” Q2=”GRANT ALL ON ${BTICK}$1${BTICK}.* TO ‘$2’@’localhost’ IDENTIFIED BY ‘$3′;” Q3=”FLUSH PRIVILEGES;” SQL=”${Q1}${Q2}${Q3}” if [ $# -ne $EXPECTED_ARGS ] then echo “Usage: $0 dbname dbuser dbpass” exit $E_BADARG

Programmers at work.

Image

Chmod review.

Image
With more and more people using the command line, changing permissions is a must. Chmod (chmod) is used to change permissions of a file. Do not use it that much except when setting permissions on the .ssh folder or on a web server application directories i.e. $ sudo chmod -R 755 appdirectory or $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/* Explanation examples: Permissions Command User Group World rwx rwx rwx chmod 777 filename rwx rwx r-x chmod 775 filename rwx r-x r-x chmod 755 filename rw- rw- r-- chmod 664 filename rw- r-- r-- chmod 644 filename r = readable  w = writable x = executable  - = no permission Here is another way of looking at it: ugw --- function 400 r-- read by owner 040 -r- read by group 004 --r read by anybody (other) 200 w-- write by owner 020 -w- write by group 002 --w write by anybody 100 x-- execute by owner 010 -x- execute by group 001 --x execute by anybody To get a combination, just add them up. For exam

Source code allows software to be immortal.

Image
You can take software from years even decades ago and still reuse it. For example, found some accounting source code originally written as early as the 1970's that can be compiled and used on present day systems. Albeit that the software needs some polish to be presentable by today's standards, it still works just as well. Account setup: Then you can enter some data: Lastly, you can view the results of your entries say in a simple t-account format: The datafile: $ cat bizness 02052015               XX X X X X X XXXXXXXXassets             XXXXXXXXXXXXXXXliabilities        XXXXXXXXXXXXXXXcapital            XXXXXXXXXXXXXXXincome             XXXXXXXXXXXXXXXexpenses           XXXXXXXXXXXXXXXunused             XXXXXXXXXXXXXXXunused             XXXXXXXXXXXXXXXincome/expense sum.XXXXXXXXXXXXXXXCash               d�D c Cd@�D czCc�c D cHCXXXXXXXXSupplies           d C    c�BXXXXXXXXXXXXXEquipment          dzDXXXXXXXXXXXXXXAccounts payable   czd DXXXXXXXX

Arch linux on the rpi

Image
Set up an sd card with arch linux. You should be logged in as root. Decided to make a sd card with arch linux using these instructions: SD Card Creation Replace sdX in the following instructions with the device name for the SD card as it appears on your computer. Start fdisk to partition the SD card: fdisk /dev/sdX At the fdisk prompt, delete old partitions and create a new one: Type o . This will clear out any partitions on the drive. Type p to list partitions. There should be no partitions left. Type n , then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +100M for the last sector. Type t , then c to set the first partition to type W95 FAT32 (LBA). Type n , then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector. Write the partition table and exit by typing w . Create and mount the FAT filesystem: mkfs

Experimental AM transmitter.

Image
Try at your own risk. Your system could be damaged. Plug goes into a sound card output. Of course, you will need an AM capable radio to receive the transmissions. Dial needs to be set at or near 100x10khz. There was several strong competing stations where we tested this project.