All posts by fash

Led Firewall (netled)

FW led box without labels

Above is a picture of a Box with leds which lightup when certain network packets are seen on the network.

It is connected to the parallel port of a PC (using port 0x3bc)

Makefile:

CC=gcc
CCOPT=-O2 -I/usr/include/pcap
LIBS=-lpcap

all:	netled

netled:	netled.c
	$(CC) $(CCOPT) -o netled netled.c $(LIBS)

netled.c code ( older version, i will upload a newer if found)

#include <stdio.h>
#include <pcap.h>
#include <netinet/in.h>
#include <sys/io.h>
#include <sys/time.h>
#include <signal.h>
#include "ether.h"
#include "ethertype.h"
#include "ip.h"
#include "tcp.h"

#define LP_PORT 0x3bc
#define CAPLEN 64
#define DELAY 30000

char *program_name;
static pcap_t *pd;
const u_char *snapend;
u_char leds = 0;
int mode = 0;
long packets;

void do_leds() {
    mode ^= 1;

    if(!leds && mode) return;

    if(mode) {
	outb(leds, LP_PORT);
	leds = 0;
    }
    else {
	outb(0, LP_PORT);
    }
}

int do_tcp(register const u_char *bp) {
    register const struct tcphdr *tp;
    u_int16_t sport, dport;

    tp = (struct tcphdr *)bp;
    sport = ntohs(tp->th_sport);
    dport = ntohs(tp->th_dport);

    if (sport == 22 || dport == 22) {
	leds |= 8;
    }

    return;
}

int do_ip(register const u_char *bp, register u_int length) {
    register const struct ip *ip;
    register u_int hlen, len, len0, off;
    register const u_char *cp;

    ip = (const struct ip *)bp;

    if ((u_char *)(ip + 1) > snapend ||
	length < sizeof (struct ip)) {
	return;
    }

    hlen = IP_HL(ip) * 4;
    if (hlen < sizeof (struct ip)) {
	fprintf(stderr, "bad-hlen %d\n", hlen);
	return;
    }

    len = ntohs(ip->ip_len);
    if (length < len)
	(void)printf("truncated-ip - %d bytes missing!",
	    len - length);
    len -= hlen;
    len0 = len;


    off = ntohs(ip->ip_off);
    if ((off & 0x1fff) == 0) {
	cp = (const u_char *)ip + hlen;

	switch(ip->ip_p) {

	    case IPPROTO_TCP:
		// fprintf(stderr, "TCP!\n");
		leds |= 128;
		do_tcp(cp);
		break;

	    case IPPROTO_UDP:
		// fprintf(stderr, "UDP!\n");
		leds |= 64;
		break;

	    case IPPROTO_ICMP:
		// fprintf(stderr, "ICMP!\n");
		leds |= 32;
		break;

	    default:
		fprintf(stderr, "HUH? [ip_proto: %i]\n", ip->ip_p);
		break;
	}
    }
}

void handler(u_char *user, const struct pcap_pkthdr *h, const u_char *p) {
    u_int caplen = h->caplen;
    u_int length = h->len;
    u_short ether_type;
    register const struct ether_header *ep;
    u_short extracted_ethertype;

    if (caplen < ETHER_HDRLEN) {
	printf("c: [%d] e: [%d]\n", caplen, ETHER_HDRLEN);
	return;
    }

    ep = (struct ether_header *)p;
    ether_type = ntohs(ep->ether_type);

    snapend = p + caplen;
    p += ETHER_HDRLEN;
    length -= ETHER_HDRLEN;
    if (ether_type > ETHERMTU) {


	switch (ether_type) {

	    case ETHERTYPE_ARP:
	    case ETHERTYPE_REVARP:
		// leds |= 8;
                // fprintf(stderr, "(R)ARP\n");
		break;

	    case ETHERTYPE_IP:
		// fprintf(stderr, "IP!\n");
		do_ip(p, length);
		break;

	    default:
		fprintf(stderr, "HUH? [et: %i]\n", ether_type);

	}
    }
}

int main(int argc, char *argv[]) {
    char *device;
    char ebuf[PCAP_ERRBUF_SIZE];
    register char *cp;
    u_char *pcap_userdata;
    void *sig_old;
    struct itimerval timer_old, timer_new;

    if ((cp = (char *)strrchr(argv[0], '/')) != NULL)
	program_name = cp + 1;
    else
	program_name = argv[0];

    if(ioperm(LP_PORT,3,1))
	error("IOPEEEEERM!\n");

    sig_old = signal(SIGALRM, do_leds);
    if (sig_old == SIG_ERR)
	error("SIGNAAAAAAAAAAAAAL!\n");
    timer_new.it_value.tv_usec = DELAY;
    timer_new.it_value.tv_sec = 0;
    timer_new.it_interval.tv_usec = DELAY;
    timer_new.it_interval.tv_sec = 0;
    if(setitimer(ITIMER_REAL, &timer_new, &timer_old))
	error("SETITIMEEEEEER!\n");

    device = pcap_lookupdev(ebuf);
    if (device == NULL)
	error("%s", ebuf);

    pd = pcap_open_live(device, CAPLEN, 1, 1000, ebuf);
    if (pd == NULL)
	error("%s", ebuf);

    if (pcap_loop(pd, -1, handler, pcap_userdata) < 0) {
	(void)fprintf(stderr, "%s: pcap_loop: %s\n",
	    program_name, pcap_geterr(pd));
	exit(1);
    }

    return 0;
}

Fireworks disaster Enschede

I lived in Enschede at that moment.

A book about the disaster

It was a beautiful day in May, and a lot of people were outside enjoying themselves.

Monique was working in the garden, and i was sitting in the living room.

We heard some commotion and saw the smoke.
Some people said that the Chinese restaurant in that neighbourhood (containing illegal fireworks) was burning.

We heard a big explosion and Monique was blown off her feet, and sat down in the garden.

I saw the large livingroom window bulging to the inside and moving outside again. (This had loosen the mortar around the window)

When seeing the now black smoke, we went inside, to the opposite site of our home, and turned on the news/checked websites.

We were lucky that there was a large factory between us and the blast (Polaroid factory)

Large pieces of cement where found 100m further than our house was.

Below some of my own media, for a better understanding of the destruction and aftermath of the disaster check the divers websites.

A scary time.

Tracking ip/access websites

I wanted to know when a certain webpage was being accessed.
Also when an archive website was being accessed.

So I used below scripts

This one checks the apache log file, using a bash script which was being run every night at 0:00

#!/bin/bash
: > /tmp/mail
today=$(date +%d/%b/%Y --date="yesterday")
grep -i $today /var/log/httpd/xxxxxxxx.henriaanstoot.nl-access.log | cut -f1,7 -d" " | grep /$ | grep -v feed > /tmp/today

nslookup friendofmine.nl | grep Address | tail -1 | cut -f2 -d" " > /tmp/ipcheck
nslookup myworkgateway | grep Address | tail -1 | cut -f2 -d" " >> /tmp/ipcheck
nslookup xxxx.dyndns.org | grep Address | tail -1 | cut -f2 -d" " >> /tmp/ipcheck
echo "192.168.1.99" >> /tmp/ipcheck

cat /tmp/ipcheck | while read; do
grep "$REPLY " /tmp/today >> /tmp/mail
done
cat /tmp/mail | mutt -s "ipgrabber" fash@mailserver

The script which tracked a certain webpage realtime was using something like a pixel tracker. But it was a complete logo.

I created a cgi-bin bash script which, when called, just printed a jpg with the correct headers, and because the server was in my room, it played a soundfile over the speakers also.

Just place the following part somewhere in your webpage

#!/bin/sh
echo Content-type: image/jpeg
echo
cat /var/lib/httpd/htdocs/banners/logo.jpg
bwavplay /data/test.wav > /dev/null
echo ACCESS | mail 0612345678@gin.nl -s "Archive Site Accessed"

Old hardware projects unsorted – till 2000

Will add to this page … when dates are unsure

1997-2000 somewhere – Hardware webcounter

Build a hardware webcounter (it was a thing back then) , i used below schematic. Wanted to use huge 7 segment displays but never got around it to buy the large ones.. It was easily converted to multiple segments. I think i used 4 and pulses where send via a parallel port.

Old webcounter schematic

The three (my case four) buttons are to get the counter in sync with my real counter which was a CGI script. It generated html code with took numeric images and displayed these on a page, the state was stored in a file. No numbers where send to the counter, only a pulse. So no synchronisation! Not the way to do this nowadays!

Joystick recorder

I designed a joystick movement recorder for a school project.

You could record movement, and press a button to start recording. (and starting the game) It was not really usable. Because, it needed a higher recording rate, a game which always reacted to the player in the same manner. Only made a half proof of concept.

Drawing images using lasers

For another school project i wanted to be able to draw figures using a laser. One of my teachers fixed a meetup for me with a guy attending university in Enschede. He was using lasers to scan miniscule objects using a laser in groves something resembling a longplayer record.

I wanted to use two DACs to control the movement of two mirrors.
But i’d had to take into account the speed of the movement and the weight of the mirrors, else images where distorted.

He gave me a schematic which used:
2 controllabe video disc mirrors, light split glasses and amplifier part.

Previous project with Oscilloscope drawings helped, with understanding those problems.
https://www.henriaanstoot.nl/1992/01/01/oscilloscope-graphics-using-a-amiga-bonus-vectrex/

I’ve still got the components, except for the high grade laser i lend from a friend.
But a simple laser pen should suffice

Made a webinterface for my DIY webcam

Using a steppermotor controller with two motors. A video capturing device (videoblaster) and a mini B/W camera.

  • Up/down/left/right and diagonal
    • Red double speed green single speed
  • Reset view
  • 2 Presets with save and recall
Setup with parallel cable

Written software in html and some CGI scripts.
Perl and C.

#include <asm/io.h>

# C Code for moving left

int main(int agrc,char agrv[])
{
  int i,wachten;
  int richting1[8]={0x27,0x2d,0x1c,0x0d,0x03,0x09,0x38,0x29};
  int richting2[8]={0x29,0x38,0x09,0x03,0x0d,0x1c,0x2d,0x27};
  ioperm(0x378,3,1);
  ioperm(0x37a,3,1);
  wachten=100;


for (i=0; i<=7; i=i+1)
        {
        outb(richting2[i], 0x378);
        outb(1, 0x37a);
        usleep(wachten);
        outb(0, 0x37a);
        usleep(wachten);
        outb(1, 0x37a);
        usleep(wachten);
        }

 return(0);
}
#!/usr/bin/perl
# Perl CGI script 

# Uses 204 no content trick to stay on same page
use LWP::Simple;
my $img = get ('http://10.1.0.1/cgi-bin/left.cgi');
print "Status: 204 No content\n\n";

Streaming video was done using progressive JPG push.
Later i used the capturing command in the loop below.

#!/bin/sh

# push jpg, and update after 1sec
# output mime header

echo Content-type: multipart/x-mixed-replace;boundary=--WebcamRules\n
echo
echo --WebcamRules

# create stream

while true; do
   echo Content-type: image/jpeg
   echo
   cat /var/lib/httpd/htdocs/webcam.jpg
   echo
   echo --WebcamRules

   sleep 1
done

Steppermotor card was using a parallel port.

Aluminum machined part by Joost

Old skool Home Automation & GPC

The date of this post is when we worked on GMC’s GPC, but i’ll post some other own made hardware related to domotica.

GPC Original Page: https://gpc.metro.cx/gpc/README

This DIY home automation was written by GMC in C.
Later we made little microcontroller prints, which could control/switch lights and more.

PIC16x84

We uses GPASM as assembler

One of my schematics
What is this?
=============

 This is the Global Premises Control package. It is intended to be a
complete solution to the DIY home automation. It provides you with a
daemon which will centralize all control functions, and some custom
programs for sound, remote control and things like that.
 The first steps to realizing the goal was made by Koen Martens. He wrote
the first daemon and made the first support programs. Other people got
interested and ported the GPC package to their homes. Since then it seemed
wise to coordinate development to prevent from having three different
versions of the package. It is currently under development and is far from
complete.

History
=======

 15-03-98 - The first initiative
	    With the help of Henri Aanstoot and Marco Geels the first
	    cables were mounted in the ceiling at Waalstraat 136. This
            involved re-dedicating some high voltage lines for the low 
	    voltage used by GPC equipment.
	    The next few days Koen Martens spend his time writing software
	    to switch on the lights (which was not possible without
	    software anymore :). This software was very rudimentry and 
	    did not feauture the daemon yet.
 28-03-98   Version 1.0 was born.
	    The need for a global way to control the premises arose, and
	    Koen Martens decided to write a daemon which would control the
	    input and output lines, with support programs for the logic.
	    This resulted in global, the gpc daemon. 
	    Running on different servers there were programs to control
	    lights and lightswitches (light_control), sound (sound) and
	    the alarm clock (wakeup). 
 10-06-98   Version 2.0 (r0.2.0) was born. 
	    The support programs containing any logic had vanished,
	    instead the daemon had all the logic encoded in it.    
 03-07-98   Version 2.0 still.
	    - Added remote control receiver code.
 29-11-98   GPC r0.3.0
	    - Started coordinated development
 11-12-98   GPC r0.3.1
	    - Security support included, providing a (basic) interface
	      for protecting variables with passwords on a security level 
	      clearance basis.
	    - Global notify protocol added, clients can now register one
	      or more variables. This makes the old (0.3.0) polling method
	      obsolete thus reducing the network load dramatically.
	    - Logging library added.

Development
===========

 The development is done on the following beta sites:

 - Subnet
	Location	: Waalstraat 136, Enschede, Netherlands
	Site coordinator: Koen Martens AKA gmc (gmc@freemail.nl)
	Site description: Single floor appartment
			  3 occupants (1 human, 2 rats)
			  P60 32MB RAM running linux
			  486 8MB RAM running FreeBSD
			  486 8MB RAM running linux
			  DEC Writer
			  WYSE terminal
			  The 486 linux machine has the daemon, and is 
			  hooked up to the premises.
			  The P60 has a sound card and a RC receiver.
 - Lip-on-ice
	Location	: Lipperkerkstraat 321, Enschede, Netherlands
	Site coordinator: Willem-Jan Faber AKA aloha AKA xtz ( And Henri Aanstoot AKA Fash)
			  (w-jfaber@freemail.nl)
	Site description: Three floor house
			  Four occupants (3 male, 1 female)
			  Connected to three other premises.
			  Computer list not yet in!
			  
 - Venom
	Location	: P. Mondriaanstraat ??, Almelo, Netherlands
	Site coordinator: Sebastiaan Smit AKA venom (wssmit@freemail.nl)
	Site description: Three floor house
			  Three occupants
			  4 computers

 If you would like to join the development, mail me at gmc@freemail.nl.


In progress
===========

 The following projects are in progress right now:
	- A script language to describe the control logic for the daemon
		Koen Martens
	- An cgi interface for the http connectivity
	- Support for sharing variables on multiple daemons

Usage
=====

 Use is for your own risk. We can not be held responsible for any damage
resulted from running any of this software.
 Keeping that in mind, usage is very simple but work needs to be done on
the documentation :)

DIY door sensor using a bend CDROM and a sensor i got

I’d would send a signal to our computers and playing a sound sample on our sound system. Also a IRCbot named (lampje) would mention “Backdoor open” in our own channel. (We where running our own IRC servers, interconnected .. because we can. A average of 3 Clients per server sound the way to go .. LOL )
Lampje the IRCbot also controlled the livingroom light and more.

ICH Meeting

Internet Club Hengelo ..

Later we started Intranet Club Enschede, which was the birth of Icecrew.

Some explained website building, browsing the net, and tools to use.

Bigred and me build the network, and services which where used for demonstrations.
We also helped with solving network related problems.

Interview Radio Oost

Above was done with my little DIY streaming webcam.
(progressive push jpg cgi script, see other post)

I found some text/log about this day
(found a scanned item first, then i used namazu .. i love namazu, it found the original ascii text file.
(Dutch only)

Zaterdag 20 September 1997
--------------------------

's ochtens om 8 uur wakker gemaakt door Marco.
Ik was nog een beetje ziek, maar toch maar de 2 pc's ingepakt.
(die van Miko en die van mij)
Ook Marco z'n pc met cd-brander stond al in de auto.
Omdat het een kleine opel kadett was moesten we behoorlijk proppen.
Ondertussen had ik al overgegeven maar ik kon moeilijk thuisblijven want ik moest het netwerk voor die dag nog aan de praat zien te krijgen.
Na een 'bumpy ride' in de Kadett waren we eindelijk op de plaats van bestemming.

Hier aangekomen bleek dat waar we de pc's neer moesten zetten, toch verder van de ISDN-aansluiting was als verwacht.
Moest ik nu mijn pc (welke als proxy-server/firewall moest werken) nu in dit kantoortje staan en dan een coax naar de rest van de pc's of moesten we voor een lang ISDN kabel zorgen?
Omdat de Webcam aan mijn pc zat moesten we eigenlijk een langere ISDN kabel hebben.
(Het was ook nog een probleem met de ISDN aansluitingen omdat de beide aansluitingen die de PTT had aangelegd al bezet waren i.v.m. de telefoonaansluitingen)
Nadat we 1 van de aansluitingen eruit hadden getrokken bleek dat he helft van de telefoons in het gebouw niet meer werken.

Na bij de PTT kabel's te hebben gekocht (1x 10 meter en 1x 25 meter plus en tussenstukje 62 gulden nogwat)
Kon ik eindelijk beginnen met het opzetten van de proxy server.

(Ondertussen nog even iemand van een netwerk-kaart voorzien en andere problemen opgelost)
Ook de netwerk instellingen moesten marco en ik bij iedereen behalve Miko en mijzelf veranderen.
(Komt er ook nog 1 zeuren over Office enzo)

Na wat aanpassingen werkte de proxy-server en de webcam.
Ook de http-server op Miko's pc werkte tegelijkertijd.

We werden ook nog geinterviewed door radio-oost ofzo. Dit wilden we tegelijkertijd via de webcam op internet laten zien, maar dat kon niet want die radio-meneer moest
zijn microfoon via de telefoon laten werken om rechtstreeks in de uitzending te komen.
Dus de proxy-server maar even uitgezet en het interview als avi opgenomen.

Later nog een website gemaakt met wat foto's van die dag erop.

Voor de volgende keer moet ik wel zorgen dat ik ook Irc en Mail via de proxy kan laten werken.

Op de terugweg nog een paar keer problemen gehad met de auto, deze viel zomaar uit.
Na met een startkabel tegen de stuurkolom de auto weer aan 't starten te hebben gekregen.
Liet marco de startkabel maar tussen de deur van de auto, zo kon hij nog een paar keer de auto simpel starten door de startkabel (welke van onder de moterkap kwam) tegen de stuurkolom te houden.
Website with pictures, avi part probably contained the streaming webcam part

My first Linux installation

Roalt helped me to get my first Linux system running.

I don’t know if it was a floppy install or cd-roms.

I remember buying cdrom sets like these at our local computershop for later installs.

A year later my system was reinstalled with Slackware by Gmc.
Although Roalt helped me getting started with Linux, i’ve learned a lot from Gmc.

First time i saw an Unix system was at my friend Richard when i was 16-ish.
It was a commercial unix system he had on loan. Later he installed Minix or something simulair. This was all pre-linux

I used the Slackware distribution for a long time, but tried others also.

List of Linux distributions and other Unix variants i remember.

  • Suse
  • Redhat
  • Gentoo
  • Fedora
  • Centos/Rocky
  • Bsd
  • Aix
  • Solaris
  • Debian
  • Ubuntu
  • Mint
  • Damn Small Linux
  • Backtrack
  • Kali
  • OpenZaurus
  • Slax
  • Puppy Linux
  • Linux Router Project