TCPMUX – a mostly overlooked TCP service

TCPMUX is described in RFC-1078 (written some 20 years ago). A reference implementation by Network Wizards can be found at ftp://ftp.nw.com/nw/software/tcpmux.c . It is also implemented in DragonFlyBSD’s inetd, NetBSD’s inetd and FreeBSD’s inetd. OpenBSD does not support for it.

The Protocol

A TCP client connects to a foreign host on TCP port 1. It sends the service name followed by a carriage-return line-feed . The service name is never case sensitive. The server replies with a single character indicating positive (“+”) or negative (“-“) acknowledgment, immediately followed by an optional message of explanation, terminated with a . If the reply was positive, the selected protocol begins; otherwise the connection is closed.

The 15+ years I have been a sysadmin I have never seen anyone making a use of it, which is a pity: Most of the time I see fellow sysadmins who want to write a custom daemon, either write it as a standalone server (usually starting with passivesock.c or passiveTCP.c from Comer’s Internetworking with TCP/IP vol.3), or writing is as a simple stdin/stdout application that is started via inetd. The most trivial problem is sometimes more than trivial:

– What port will this application run on?

It seems that 65535 ports is a lot of freedom to choose from and most people want to use “interesting” port numbers (for any definition of interesting). Add firewall policies and router access lists in the picture, you can have a non-technical deadlock in no time!

TCPMUX might be a choice to help simplify / avoid such situations. Any service that supports TCPMUX listens on port 1/tcp and can be forked by inetd(8) (either internally or externally with the help of a tiny server). After all, it can be considered as an “inetd inside inetd” (the classic inetd responding to requests on a port, TCPMUX responding to requests based on the name of the service) and even if you do not want to use TCPMUX, a similar (homegrown) solution might be the answer to keeping your packet filters lean and less complex. It does not have to be less complex than it has to be though. The Wikipedia article on tcpmux clearly identifies risks that come with deploying it. Personally, I view tcpmux as an old and simple TCP RPC mechanism.

Appendix: tcpmux.c

Since the Network Wizards site seems to be down / taken over by some other entity, here is the original tcpmux daemon code (also at github https://github.com/a-yiorgos/tcpmux ):

Continue reading “TCPMUX – a mostly overlooked TCP service”

On the prehistory of Greek CERT(s)

Lately I find myself attending meetings where the need for a single coordinating body over the various efforts of computer / network / cyber security is stressed. Roll back 15 years:

Once upon a time (circa 1996) the GRNET-CERT was formed. It was nothing official, just three guys (me, Georgios Koutepas and Costas Troulos) and a mail alias. Since we had no funding and the legal landscape was non-existent our main focus was on trying to stop whatever incidents occurred. It seemed to work pretty well at the time. We even managed to find some funding and some of us attened FIRST‘s 1998 and 1999 meetings. With the emergence of the GRNET2 project GRNET-CERT was handed over to another institute for operations. Our interests had already shifted from (pure) incident response and we never really followed-up the national progress on that front.

In the meantime the Greek state responded to the void that was forming regarding the legal side of matters. And it did so in the wisest of ways that we are used to being treated to. It formed a multitude of authorities to cover the area, sometimes conflicting one another. Nature abhors vacuum, but as Rob Pike said “sometimes when you fill the vacuum, it still sucks”. There can appear types of incidents that might require reporting to three (or even four) different authorities with no clear roadmap on what one is expected to do if one receives conflicting guidance on subjects that at times require rapid response.

It is a saddening thought to see that the manpower and the resources exist (something that was not that obvious back in 1996), that people with skill, knowledge and willingness to work exist, yet the overall progress is kind of minimal.

30 χρόνια επιτυχίες

Kat was a Greek computer that dual-booted MS-DOS and Apple II

Ψάχνοντας για την ιστορία της Gigatronics και του Kat, έπεσα πάνω σε αυτό το PDF. Χρήσιμο ανάγνωσμα για όσους ενδιαφέρονται για την ανάπτυξη της Πληροφορικής στην Ελλάδα, τότε που ήμασταν παιδιά.

C interpreters

I spotted today on Hacker News an article about PicoC, a small C interpreter. This triggered my memory in a journey back in 1994 when I had asked over at comp.compilers whether any C interpreter existed. It was then that I learned about ICI, a cool C-like scripting language that deserves more attention, the Quincy C interpreter which evolved to an IDE, and Smac, the C-like
interpreter that comes embedded with the XCoral editor.

Then there are also CINT which is part of an even more interesting project, and of course Ch.

But the coolest interpreter that I’ve seen, is written by Diomidis Spinellis:

#include "/dev/tty"

It changed the rules for the IOCCC.

Open Systems Security – an Architectural Framework

“In the old days” when security information was scarce and many of us began shaping our security mentality (be it white, gray or black) by reading “Improving the Security of Your Site by Breaking Into it” and the Computer Security FAQ and running tools like iss and Crack. I think it was there that I first read about Arto Karila’s PhD thesis. Even though it is an OSI based document, it helped understand basic concepts. However there were two problems with the document:

  1. It was hard to find, and
  2. It was in a weird PostScript format that even modern versions of ghostscript refuse to display.

With the help of a friend I managed to transform it to PDF and upload it to Scribd: Open Systems Security – an Architectural Framework

Of historical value mostly.

Update 2013/04/13: Now available at https://github.com/a-yiorgos/karila

Counting large numbers of events in small registers

“What does the logarithm do?”, asked a Professor a bunch of us back in 1990. “It is the inverse of e^{x} , I said. “No” he replied, “I ask again, what does the logartihm do?”. A friend started to say something along the lines of the Wikipedia definition. “You tell me how it is calculated, but not what it stands for; why do we need it?”. He then proceeded asking us the value of the logarithm of some numbers:

x log_{10}(x)
1 0
10 1
100 2
1000 3
10000 4

– Do you see a pattern now?

“The length of the number is \lfloor log_{10}(x) \rfloor +1, one of us observed.

– Exactly!

I was reminded of this discussion when stumbling on Counting large numbers of events in small registers written by Robert Morris (father of the Robert T. Morris). Basically, what Morris observes in this paper is that with n bits available, one can count up to 2^{n}-1. He had 8 bit registers available only, so this limited counting up to 255 which did not suite the application he had at hand. So he began by simply having the value of a register representing v(n) = log_{2}(1+n) and reached to a generalized result of v(n) = \frac{log(1+\frac{n}{a})}{log(1+\frac{1}{a})} where a controls both the maximum count that can be held in the register and the expected error.

The maximum number is n_{v} = a((1+\frac{1}{a})^{v}-1). The expected error of n after n counts can be calculated from the formula \sigma^{2} = \frac{n(n-1)}{2a}.

This is a really nice hack if you need to count large numbers of events and where accuracy is not a must. It maybe helpful to people working with embedded systems or otherwise deprived environments.

(Triggered-By:)

Practical Reusable Unix Software

(I think I bought mine sometime in 1997. The price tag says £26.50 which means that I had UrBaN buy it for me.)

Το βιβλίο γράφτηκε το 1995 και είναι ενδεικτικό των εργαλείων, αλλά και της φιλοσοφίας που επικρατούσε στην AT&T Research εκείνη την εποχή. Χάρη σε αυτό έμαθα για το graphviz (που με βοήθησε να φτιάξω ένα από τους πρώτους χάρτες του 6BONE αλλά και του irc.gr), το UWIN (οπότε και κατάφερα ένα από τα πρώτα native ports του netcat), τη vmalloc (που πάντα ήταν χρήσιμη όταν κάποιο πρόγραμμα είχε προβλήματα memory allocation – π.χ. το CLP(R) με κάποιες GLIBC της εποχής). Το σημαντικότερο όμως που μπορεί να προσφέρει αυτό το βιβλίο ακόμα και σήμερα, 14 χρόνια μετά και με μερικά από τα εργαλεία που παρουσιάζει όχι και τόσο χρήσιμα, είναι ο τρόπος σκέψης: ορισμός προβλήματος, προσέγγιση, αρχιτεκτονική και λύση. Και αυτά in a system administrator’s way.

Το βιβλίο είναι διαθέσιμο σε μορφή PDF και το software που περιγράφει (αλλά και άλλο νεώτερο) βρίσκεται στο http://www.research.att.com/sw/tools

[via]

Applied Cryptography

Όταν αγόρασα το Applied Cryptography υπήρχε σε ισχύ ακόμα ο ITAR, αυτός ο περίεργος νόμος που απαγόρευε την εξαγωγή από τις ΗΠΑ κρυπτογραφικού software επειδή θεωρούνταν όπλο, αλλά όχι εάν ήταν τυπωμένος κώδικας σε χαρτί(!) πράγμα που επέτρεπε την κυκλοφορία του βιβλίου και έξω από τις ΗΠΑ.

[ Εκείνα τα χρόνια για παράδειγμα η RSA είχε αναπτύξει ένα πακέτο με την ονομασία RSAREF, το οποίο δεν επιτρεπόταν να κυκλοφορεί εκτός ΗΠΑ λόγω του ITAR. Για το λόγο αυτό είχε αναπτυχθεί το API compatible πακέτο με την ονομασία RSAEURO. ]

Το βιβλίο αυτό συντήρησε ένα ελάχιστο ενδιαφέρον μου για τα Μαθηματικά, κάτι που δεν είχαν καταφέρει για χρόνια οι καθηγητές του Γενικού Τμήματος (σημερινό ΣΕΜΦΕ). Όχι δεν το διάβασα όλο, ούτε έγινα κρυπτογράφος. Το βιβλίο είναι εξαιρετικό reference (κι ας μην έχει π.χ. το AES), αλλά υπήρξε περίοδος που το διάβαζα σελίδα-σελίδα και το έφτασα μέχρι το κεφάλαιο 14 (GOST). Αυτή είναι μία χρήσιμη διαδικασία, γιατί συνήθως ο κόσμος αντιμετωπίζει το κρυπτογραφικό software είτε σαν κρυπτογράφος (“καταλαβαίνω τι κάνει”), είτε σαν μη κρυπτογράφος (“υπάρχουν κάποιοι που καταλαβαίνουν τι κάνει, άρα είναι καλό”). Τουλάχιστον έμαθα να έχω σωστές ερωτήσεις και τι να ψάχνω για τα κομάτια που δεν καταλαβαίνω.

[ Για όποιον ενδιαφέρεται να διαβάσει γιατί έχει σημασία η ενασχόληση με τη θεωρία, έστω και σαν διάλειμα μετά από χρόνια “πραγματικής” εργασίας, παραπέμπω σε αυτό το post του Mark Burgess. ]

Έτσι όταν τον Μάιο κοίταγα το site του Schneier, χάρηκα πολύ που έδινε σε CD-ROM τον κώδικα του βιβλίου για US $40. Το παράγγειλα αμέσως.

Αρχικά αυτό το post ήταν χεστήριο προς τον Schneier, αλλά την Παρασκευή το CD με περίμενε στο σπίτι.

small talk

Το προηγούμενο post για τη SmallTalk μου ξύπνησε αναμνήσεις:

7700 δραχμές το 1991. Τόσο έκανε το “Smalltalk-80: the language”. Είχα δουλέψει σε μια οικοδομή για να μπορέσω να το αγοράσω. Έπρεπε να το διαβάσω για ένα μάθημα του Ζάχου (άλλοι είχαν να μάθουν για Modula-2, Oberon, Eiffel και άλλα εξωτικά και μόνο ο κουμπάρος μου είχε κάτι πιο συμβατικό: C++).

Ωραίο βιβλίο: Με έβαλε στο τριπάκι των γλωσσών προγραμματισμού για τα καλά. Και καθώς “τα χρόνια εκείνα” ήταν δύσκολο να προλάβει να έχει ένας προπτυχιακός πρόσβαση στα Sun του softlab, όπου και έτρεχε η (γραφική) version του Xerox PARC, έπρεπε να βρω εναλλακτικές. Και η καλύτερη εναλλακτική εκείνη την περίοδο ήταν η Little SmallTalk του Tim Budd.

Ακόμα θυμάμαι τις αφελείς ερωτήσεις που του έστελνα καθώς πολλές κλάσσεις που περιέγραφε το “SmallTalk-80: the language” δεν υποστηρίζονταν από τη δικιά του εκδοχή. Όμως τότε και ψάχνοντας λίγο στα anonymous FTP directories του Budd, έπεσα πάνω σε δύο σημαντικά για εμένα πράγματα: Το βιβλίο του “An Introduction to Object-Oriented Programming” το οποίο δανείστηκα (δε θυμάμαι εάν ήταν σε κάποια από τις βιβλιοθήκες του ΕΜΠ, ή από κάποιο καθηγητή) και το “The Kamin Interpreters in C++”.

Ποιος ήταν ο Kamin; Γιατί οι interpreters του που είχαν τόσο ενδιαφέρον ώστε να τους ξαναγράψει κάποιος σε C++;

O Samuel N. Kamin έχει γράψει το βιβλίο “Programming Languages: An Interpreter-Based Approach” (υπάρχει στη βιβλιοθήκη του ΕΜΠ), στο οποίο υλοποιεί βαθμιαία και χρησιμοποιώντας Pascal, μια σειρά από interpreters: Lisp, APL, Scheme, SASL, CLU, Smalltalk και Prolog (Μετά από χρόνια και ψάχνοντας ξανά για το βιβλίο είδα πως και ο ίδιος ο Kamin έχει κάνει μια υλοποίηση των interpreters του σε C, αλλά αυτή τη στιγμή δε μπορώ να βρω το link Η σελίδα του βιβλίου, η έκδοση σε Pascal και η έκδοση σε C).

Τώρα τον μπαμπά του “Smalltalk-80: the language”, το “Smalltalk-80: the language and its implementation”, τον δίνει δωρεάν (όπως και μερικά άλλα σημαντικά -έστω και με ιστορική μόνο αξία- βιβλία) σε μορφή PDF η ACM. Η Little SmallTalk έχει γίνει ξεχωριστό free software (MIT License) και το βιβλίο του Budd “A Little SmallTalk” είναι επίσης διαθέσιμο σαν PDF.

[more on the ACM Classic Books Series]