Supermatic – HTTP server in Bourne Shell

Have you, like me, ever dreamed about having your own WEB server? I mean, the real one – not a blog or a page in a social network.

Now my dream came true. I have my own WEB server, it’s called Supermatic and I spent the whole morning coding it in Bourne Shell 🙂

The power of Supermatic in action!

It works perfectly on my FreeBSD, so the most actual question now is: are there any free VPS servers anywhere in Internet, just to show everyone how it works somewhere except my home test-pet.

This is the project page for Supermatic on my blog and there are sources on GitLab.

Advertisements
Posted in My projects | Tagged , , , , , , | Leave a comment

Configuring Linux server to work with the BeaST storage system over iSCSI protocol

I continue to test the BeaST on a real hardware and here is an update to the Linux client configuration guide:

Posted in BeaST, Storage | Tagged , , , , , , | Leave a comment

“Empty” gets more mentions in hacking, IT security and science

Celebrating another birthday of Empty – my expect-like tool to automate interactive tasks.

Though, I didn’t pay much attention to it for some time, it collects more and more mentions over Internet. It looks like Empty is mostly useful in hacking, IT-security, science and even teaching.

After more then 10 years from the first release in August, 2005 it has around 500 downloads per month and now you may find it everywhere from computing clusters to embedded systems, various small Raspberry (and not only) devices, routers, modems and so on. And here are the most intriguing references and usage cases.

Expect article in Wikipedia mentions Empty in Alternatives section:

Drones Hacking Drones by Darren Kitchen and Hak5:

PARROT DRONES HIJACKING by Pedro Cabrera for RSA Conference

Network Performance and Security: Testing and Analyzing Using Open Source and low-cost tools by Chris Chapman

Transplanting Binary Decision Trees by Eli M. Dow and Tim Penderghest from Clarkson University

Posted in empty, Impressions, My projects | Tagged , , , , , , | Leave a comment

IPv6 multicast ping in Python

In the meantime, I continue to reinvent the wheel: just added IPv6 multicast ping to my small ICMP script collection in Python.

Usage:
	sp_mping6.py -i interface [-a address] [-m ttl] [-t timeout] [-v]

Options:
	-i				interface Interface to work on
	[-a address]	IPv6 multicast address to ping or ff02::1
	[-m ttl]		TTL of outgoing packets. Default is 64
	[-s number]		Packet sequence number: 0-65535. Default is 0
	[-t timeout]	Timeout on socket. Default is 5
	[-v]			Be verbose (show more info about packets)

Note! You must be root to run this program.

And finally, sp_ping project page is here. Sources are there.

Posted in My projects, sp_ping | Tagged , , , , , | 1 Comment

My ICMP ping supports IPv6 now

Wohoo! This Sunday was awesome: I have just added IPv6 support to my own ICMP ping implementation in Python 3. Amazing, but it works:
I’m not sure about Linux, but it successfully pings Google from my small FreeBSD box 🙂

Posted in My projects, sp_ping | Tagged , , , , | Leave a comment

Compare two regular or device files block by block

Yes, there are a number of utilities like cmp, bdiff and etc that allow to compare binary files and even create patches. Anyway, here is my script, which I hope, will ease tracking changes on block granularity within storage volumes and partition images while I’m working on the BeaST storage system and the BQ daemon.

bfcmp.sh - Compare two regular or device files block by block

Usage:
    bfcmp.sh -s /path/to/src.bin -d /path/to/dst.bin [-b size][-v 0-3][-f][-D]

Where:
    -s  Source file to compare [SRC]
    -d  Destination file [DST]
    -b  Block size. Default is 512 bytes
    -v  Verbosity level 0 to 3. Default is 2
    -f  Enable fullscan mode. Continue to scan for different blocks even
        if [SRC] and [DST] filesizes are different
    -D  Enable debug mode

UPD 2018.07.27 To pair bfcmp.sh a new script to “patch” destination file is added:

bfmerge.sh - Compare and merge two regular or device files block by block

Usage:
	bfmerge.sh -s /path/to/src.bin -d /path/to/dst.bin [-b size][-v 0-2][-BfD]

Where:
	-s	Source file to compare [SRC]
	-d	Destination file [DST]
	-b	Block size. Default is 512 bytes
	-v	Verbosity level 0 to 2. Default is 1
	-f	Enable fullscan mode. Do not stop if [SRC] and [DST] filesizes differ
	-D	Enable debug mode

I was trying to keep old school Bourne shell syntax while writing both scripts. Everything should run on FreeBSD, Mac OS and Linux.

Posted in BeaST, BeaST Quorum, Storage, Storage Automation | Tagged , , , , , , | Leave a comment

Printing lines side by side in shell

Everybody knows, there is paste command in every *NIX to print two files side by side or join which is obviously used to join text-files by their key-fields. And there are a lot of examples and tutorials over Internet, so the subject is as trivial as cat-ting files together with right command-line options.

Ah, wait… What if we have textual data stored not in files but in two variables as a result, for example, of piping or redirection?

Imagine there’s no heaven two variables:

a="aa qq
bb ww
cc ee"

b="11 44
22 55
33 66"

And we want to see this as the result:

aa qq | 11 44
bb ww | 22 55
cc ee | 33 66

It’s not an issue having Bash and arrays:

#!/usr/bin/env bash

a="aa qq
bb ww
cc ee"

b="11 44
22 55
33 66"

IFS=$'\n' read -d '' -a a_arr <<< "$a"
IFS=$'\n' read -d '' -a b_arr <<< "$b"

for  i in ${!a_arr[@]}; do
	echo ${a_arr[i]} "|" ${a_arr[i]}
done

The main trick is done with read command which stores lines in arrays, while the rest is just a loop which scans arrays to print lines with the same index.

But life is not always easy and sometimes one could still deal with pure old Bourne shell without any hints on arrays where set command was utilised to create $@ array of $1 to $n elements. Agree, this is not always handy.

So, in the worst case it’s always possible to use a counter variable and an external tool to scan over the strings. For example, awk:

#!/bin/sh

a="aa qq
bb ww
cc ee"

b="11 44
22 55
33 66"

cnt=0
echo "$a" | while read -r ln; do
	cnt=`expr $cnt + 1`
	printf "$ln | "
	printf "$b" | awk -v c="$cnt" 'NR==c {print}'
done

or even like this:

#!/bin/bash

a="aa qq
bb ww
cc ee"

b="11 44
22 55
33 66"

for l in $(seq 1 `wc -l <<< "$a"`); do
	awk -v l="$l" 'BEGIN {ORS=" | "} NR==l {print}' <<< "$a"
	awk -v l="$l" 'NR==l {print}' <<< "$b"
done

Keeping in mind external tools and languages, there are much more possibilities to do the task, but lets stop on this for a while 🙂

Posted in Tips & tricks | Tagged , , , , | 10 Comments