Ataraxia Consulting

Peace of mind for consulting

Monitor All Network Traffic On A Virtual Host Within A Virtual Machine On That Host

Recently I was asked to explore means to monitor/audit network traffic of a virtual host (i.e. all traffic on the Dom0 and DomUs) without the monitoring software running inside the privileged domain (Dom0). If you are ok with running the monitoring software inside the privileged domain then you need not read the rest of this blog. Normal network auditing software comes in the form of tcpdump, SNORT, or even a collection of software such as OSSIM. Most of this software gleans its information by setting a network interface into promiscuous mode and then using a hub or port mirroring on your switch to duplicate all packets to that network interface for auditing. Hubs are used in lieu of switches because they operate merely as repeaters, where as a switch tries to limit network congestion by sending packets to only the port that a given destination resides behind. This same switching technology is employed by the bridge interface in Linux and most other virtualization platforms. The most common way to achieve network auditing inside of a virtual machine guest (DomU) is to assign the physical interfaces from the bare metal to the guest (pci mapping) such that the guest sees the physical hardware, thus bypassing the bridge normally used at the Host/Hypervisor level. There are a few cons to this approach. In this deployment you can't just add hardware and use port mirroring on your switch to capture all traffic from the Host. This will only capture traffic from sources and to destinations external to the host you're monitoring, and won't capture traffic among the guests running on your host. To get around that obstacle you could use this guest then as the route of all traffic to and from and among the host and virtual machine guests. However you're then relying on a specific guest to stay available to handle the traffic and audit, and if that guest dies all other guests on the host will be without network connectivity. Some permutation of this solution is probably acceptable if you're simply interested in monitoring traffic to and from your gateway where rogue traffic is more likely to initiate. Another possible solution is to "simply" duplicate all packets in the privileged domain and send them "over the wire" to another virtual machine for auditing. The solution is what I'll dub virtual port mirroring, and can be achieved with iptables (or probably more suitably ebtables) and extensions from [http://xtables-addons.sourceforge.net/](http://xtables-addons.sourceforge.net/) `iptables -t mangle -A PREROUTING -j TEE --gateway 192.168.0.100` You'll probably want to make sure this rule is at the top of your PREROUTING chain and you're likely going to want to make the rule considerably more specific (not the least of which is preventing a feedback loop from the destination because of its own traffic). For instance, on the network I intend to deploy this on there's a backend network handling DRBD replication, those are probably packets you're not going to want to duplicate unless you're extra paranoid. But this solution is simple, straight forward, and if I do say so myself elegant. Traffic in and out of the host and among the guests are all duplicated and sent to a specific destination and if that destination is down the packets merely drop. I still need to perform some stress testing to see just how far you can push the network stack before it falls over, but it's certainly advantageous to keep the destination on the same host and not push that traffic external for security and network congestion related issues. Note that this will not audit the rest of the traffic on your presumably switched network. You'll want to devise a means to audit on each of your physical hosts and then collect that data in a central location later. I performed all this on the Xen stack provided from Debian in Lenny and unfortunately xtables-addons is only a Squeeze package right now (because it deps on iptables >= 1.4.3) so I ended up building these packages on my own. If there are others out there who would like to implement a similar solution in their Lenny stacks and don't want to build the packages leave a comment and I'll create a repo for the packages on i386 and amd64 platforms. read more

Posted in 


Muppet Movie -- Im Going to Go Back There Someday -- Guitar Tabs Chords

I've been in a Muppet mood recently, as such I've found myself playing along with soundtracks. I was quite unsatisfied with the chords I found for Gonzo's lament from The Muppet Movie so here is my transcription, the end of the bridge may not be 100% but it doesn't sound terrible
G          C   G     Em      A
This looks familiar, vaguely familiar,
G        C     G         Em          A
Almost unreal, yet, it's too soon to feel yet.
Am          D             Bm     E
Close to my soul, and yet so far away.
    Am          D              G
I'm going to go back there someday
 
G          C     G      Em            A
Sun rises, night falls, sometimes the sky calls.
G         C    G          Em     A
Is that a song there, and do I belong there?
Am         D               Bm         E
I've never been there, but I know the way.
    Am          D              G
I'm going to go back there someday.
 
 
Em          A             D
Come and go with me, it's more fun to share,
Em               A          D
We'll both be completely at home in midair.
      E           C#m         F#m         F#m/E
We're flyin', not walkin', on featherless wings.
       D         Am/C         Am        G/D    D
We can hold onto love like invisible strings.
 
 
G             C    G       Em                 A
There's not a word yet for old friends who've just met.
G            C     G        Em           A
Part heaven, part space, or have I found my place?
Am           D          Bm        E
You can just visit, but I plan to stay.
    Am          D              G
I'm going to go back there someday.
    Am          D              G
I'm going to go back there someday.
read more

Posted in  chords tabs


Making imaplib simple

Not long ago I wrote an imap polling script for work that used Python's [imaplib](http://docs.python.org/library/imaplib.html). Shortly after that [HoopyCat](http://blog.hoopycat.com/) wrote an excellent [imap backup script](http://blog.hoopycat.com/index.php/2009/07/04/imap2maildir-a-tool-for-mirroring-imap-t) that also used imaplib. We exchanged some stories and opined on wanting a simpler mechanism to get imaplib to return an [email.Message](http://docs.python.org/library/email.message.html) object (a feature that should be available from the core). I happened to have to look at my code again this week and decided to work up a quick example of the interface I expected to actually find in the core imaplib
import imaplib
import email
 
class __simplebase:
  def get_messages_by_folder(self, folder, charset=None):
    ids = self.get_ids_by_folder(folder, charset=charset)
 
    for m in self.get_messages_by_ids(ids):
      yield m
 
  def get_ids_by_folder(self, folder, charset=None):
    self.select(folder)
    status, data = self.search(charset, 'ALL')
    if status != 'OK':
      raise Exception(data)
 
    return data[0].split()
 
  def get_messages_by_ids(self, ids):
    for i in ids:
      yield self.get_message_by_id(i)
 
  def get_message_by_id(self, id):
    status, data = self.fetch(id, '(RFC822)')
 
    if status != 'OK':
      raise Exception(data)
 
    return email.message_from_string(data[0][1])
 
class SimpleImap(imaplib.IMAP4, __simplebase):
  pass
 
class SimpleImapSSL(imaplib.IMAP4_SSL, __simplebase):
  pass
The SimpleImap and SimpleImapSSL classes should be drop in replacements for your existing usage of IMAP4 and IMAP4_SSL. You'll notice the use of generator objects (the yield keyword), this means that each iteration the message you're working on is pulled from the server right then. That's useful when you have a lot of messages that you don't necessarily want to cache into memory or when they'll potentially have large attachments. On the other hand, it will result in considerably more imap commands and traffic than if you were to just pull all the messages at once. Here's a sample usage that prints out the subject of every message in your inbox:
c = SimpleImap('mail.example.com', 143)
c.login('someluser', 'stupersekrit')
for m in c.get_messages_by_folder('INBOX'):
  print m['subject']
c.logout()
read more

Posted in 


twuuenc the uuencode of web2.0

For far too long now, you have been limited by those 140 characters of microblogging sites like twitter. I present you with twuuenc, take your tweet that is longer than 140 characters and stuff it into fewer unicode characters. Take for instance the beginning of the [Gettysburg Address](http://en.wikipedia.org/wiki/Gettysburg_Address): Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. That's a total of 175 characters, twitter just won't have it. But if you run it through twuuenc you get: ɹҺξɌǶᖜᘫᓿϧѶ`✢Εǚᖣ¼Ј|ᓅɋöᖛӪ❡Ѯ9ᒡ✲ᐑᖨᙃ¥ѰҺΨᙦɖǞᗍʼО;◆ɌɺǪᙃ¦јѺĖ◐ΑȕөŤѐƢᘟ◐ýǪᗌᘋŇğ◆ᘕ˼ᖸᒋӽШѥÛᙵŶᖨ᙮ŰŇ{ᒧɋɸᕰᔋоҀƞ`✲❼ȖᓫᓿѠᑺ◊◡ǹᖰᔌ❚ŇᓹĆ✮Pᖐᕣ°ЈѥĆ✒˘ǒᘫᕀҀƞ`ᘶýᕤᕤᗟ That tweet is only 128 characters (130 with markers), there's still 12 characters left for you to insert a wise crack! What's better is that this allows you send binary data over twitter, imagine the possibilities! Just for starters, let's add some additional compression to the address through Zlib ңᙦ˥ᖐąᒟǐТ;ӤУᗔ○Õ¢Ñ◀ᓫӆᕪ✼ᙜ❉ӆʃ%ᗽᐉᘰҫᑻǧɪȰŠᖔᙱ¯ķ▭ᑜᔨɳĺᘗŐ◇ᔇђʗᑵËᘎᙁᑶʓǿ⟘nΗˀЧЏȜ➒⟘Ɲᖁʉᘧ➳ːȰ✩❈❢✜¨Ȁѣ➫ᗧңᔯᓞϓ❯ᒑȰ❰˒Ӝń Now our tweet only takes up 93 characters (95 with markers), You have a full 47 characters to be clever! You can also optionally include the markers around the message to signify that the following message should be twuuenc decoded. A message wrapped in ☹ means it is twuuenc encoded but not compressed; while a message wrapped in ☺ means it's encoded and compressed with zlib. The alphabet twuuenc uses only has 2048 characters, but if you can get that up to 4096 that's another whole bit you can store per character in your tweet. You can find the source for the encoding and decoding [here](http://git.atxconsulting.com/cgi-bin/gitweb.cgi?p=twuuenc;a=blob_plain;f=tw_uuencode.py;hb=HEAD) with an [MIT](http://www.opensource.org/licenses/mit-license.php) license. The code relies on [http://code.google.com/p/python-bitstring/](http://code.google.com/p/python-bitstring/) which is also in the git repo (similarly licensed). read more

Posted in 


Dr. Horrible Lyrics -- Slipping -- Guitar Chords Tabs

Now for the Act III tension builder where our favorite villain (anti-hero?) gets caught monologuing, these are the tabs for "Slipping" I don't have much prowess for tabs as it is, and the darker/minor the song the more difficult it is for me to transcribe, lemme know of errors or clarifications you can spot
Gm            Cm/G
Look at these people
Gm          Cm/G
Amazing how sheep'll
     Gm         Ddim
Show up for the slaughter
Gm         Cm/G
No one condemning you
      Gm      Cm/G
Lined up like lemmings
    Gm         Ddim
You led to the water
Gm                      Cm
Why can’t they see what I see?
               Gm             Cm
Why can’t they hear the lies?
Gm                 Cm                 Gm
Maybe the fees too pricey for them to realize
F#dim            Gm       Cm/G Gm
Your disguise is slipping
Cm/G           Gm       Cm
I think you’re slipping!
 
Gm            Cm/G       Gm           Cm/G
Now that your saviour is still as the grave
       Gm           Ddim
You’re beginning to fear me!
Gm                Cm/G
Like cavemen fear thunder
  Gm            Cm/G
I still have to wonder
    Gm         Ddim
Can you really hear me?
Cm/G
I bring you pain
    Gm                    Cm/G    Ddim
The kind you can’t suffer quietly
Cm
Fire up your brain
Gm                     Gm
Remind you inside your rioting
F#dim      Gm      Cm/G  Gm
Society is slipping
Cm/G         Gm      Cm/G D
Everything’s slipping     away…
 
So…
 
Gm        Bb
Go ahead, run away
Cm         D
Say it was horrible!
Gm               Bb
Spread the word, tell a friend
Cm            D
Tell them the tale
Gm         Bb
Get a pic, do a blog
Cm         D
Heroes are over with!
Gm           Bb
Look at him, not a word
Cm          D
Hammer meet Nail!
Gm          Bb
Then I win, then I get
Cm         D
Everything I ever
Gm            Bb
All the cash, all the fame
Cm         D
And social change
Gm       Bb
Anarchy, that I run
Cm                  D
It’s Dr. Horrible’s turn
 
(notes)
 
D   Eb    D   Eb  D    Eb F#
You peo - ple all have to learn
D    Eb    D  Eb  D Eb
This world is going to
 
Gm
burn!
 
Gm
Burn!
[yeah, it’s two r’s- h-o-r-r, right]
Gm
Burn!
 
(Chords)
 
Gm         Cm/G
No sign of Penny
      Gm           Cm/G
Good, I would give anything
Gm          Ddim
Not to have her see
     Gm       Cm/G
It’s gonna be bloody
     Gm       Cm/G
Head up Billy Buddy
        Gm          Ddim
There’s no time for mercy
Gm           Ddim
Here goes no mercy!
read more

Posted in  chords dr-horrible tabs


Dr. Horrible Lyrics -- So They Say -- Guitar Chords Tabs

Act III the phenomenal finish to Dr Horrible starts off with this catchy ditty "So They Say", thanks again to all the folks at [http://whedonesque.org/](http://whedonesque.org) for starting me off with the lyrics
Intro
      F#    G#m   B    C#   F#(chords)
G# A# F# C# G# C# B D# C# F F#(notes)
         C# G# C# B D# C# F F#(notes use the same chords)
 
        C#
So they say
        F#         G#m        B
Captain hammer’s become a crusader
    C#           F#       G#m    B
Political he’s   cleaning up the streets
      C#
About time
 
F#        G#m
  So they say
          B
That it’s real love,
C#            F#
  so romantic
G#m    B          C#
    He signed this
 
        F#
So they say
           G#m          B
We’ll have blankets and beds
       C#      F#
We can open by Monday
  G#        B
  Thanks to you
          C#
Thanks to me
 
B         D#m
  It’s the perfect story
B         F#
  So they say
       G#m         B
A hero leading the way
         D#m
Hammer’s call to glory
G#m       C#     B
Let’s all be our best
               F#
Next up: Who’s gay?
 
G#m B        C#     F#            G#m
     So they say he saved her life
 
B         C#                 F#
 They say she works with the homeless
    G#m         B
And doesn’t eat meat
C#
  We have a
F#           G#m   B
Problem with her!
            C#
This is his hair!
 
F# G#m        B  C#
      This is so nice
  F#         G#m            B         C#
I just might sleep with the same girl twice
              F#                G#m
They say it’s better the second time
     B              C#          F#    G#m
They say you get to do the weird stuff
 
B           C#
  We do the weird stuff!
 
B         D#m
  This is perfect for me
B         F#
  So they say
             G#m
I guess he’s pretty ok
B       D#m
  After years of stormy
G#m     C#     B                 F#
Sailing have I finally found the bay?
 
F# G#m B C#
F# G#m B C#
 
B            D#m           B        F#
  There’s no happy ending - So they say
    G#m          B
Not for me anyway
 
         D#m
Should I stop pretending?
         Stop pretending
 
G#m      C#        B                 F#
          Or is this a  brand    new day?
take the chance to build a brand new day!
 
G#m B C#
 
        F#      G#m
This is his dry cleaning bill
B    C#      F#
Four sweater vests
 
F# G#m B C#
read more

Posted in  chords dr-horrible tabs


Dr. Horrible Lyrics -- Everyones A Hero -- Guitar Chords Tabs

The very triumphant second song from Act III "Everyone's A Hero"
G
It may not feel too classy
C               G
Begging just to eat
        D
But you know who does that?
                Am            D
Lassie, and she always gets a treat
 
G
So you wonder what your part is
             C            G
Cause you’re homeless and depressed
    D
But home is where the heart is
        Am          C       D
So your real home’s in your chest
 
G            D             C
Everyone’s a hero in their own way
Am             C                  D
Everyone’s got villains they must face
B
They’re not as cool as mine
C
But folks you’ll know it’s fine
             D
To know your place
G            D             C
Everyone’s a hero in their way
         Am       C    D      G
In their own, not that heroic way
 
G
So I thank my girlfriend, Penny
         C           G
Yeah, we totally had sex
    D
She showed me there’s so many
          Am            D
Different muscles I can flex
            G
There’s the deltoids of compassion
            C            G
There’s the abs of being kind
     D
It’s not enough to bash in heads
       Am     C       D
You’ve got to bash in minds
 
G            D             C
Everyone’s a hero in their own way
Am             C                  D
Everyone’s got something they can do
B
Get up, go out and fly
C                                   D
Especially that guy, he smells like poo!
G            D             C
Everyone’s a hero in their own way
Am              C      D      G
You and you and mostly me and you
 
    F
I’m poverty’s new sheriff
        C
And I’m bashing in the slums
  F    C/E
A hero doesn’t care if you’re
  F               C     A/C#   D
A bunch of sca-ry al-co-ho-lic bums
 
Eb
Everybody!
 
Ab           Eb            Db
Everyone’s a hero in their own way
Bbm          Db             Eb
Everyone can blaze a hero’s trail
C
Don’t worry if it’s hard
          Db
If you’re not a friggin tard
         Eb
You will prevail
Ab           Eb            Db
Everyone’s a hero in their own way
Bbm          Db      Eb     (Ab)
Everyone’s a hero in their- (way)
read more

Posted in  chords dr-horrible tabs


Dr. Horrible -- Brand New Day -- Guitar Chords Tabs

To finish off Act II here is "Brand New Day" from Dr. Horrible's Sing-Along Blog. Not the best I've done in the series, would probably sound better if I played guitar. Everything is mostly in fifths and not full chords I don't know if that equates to power chords or not. The slow section talking about Penny needs some more attention as well.
Fm                 Db                       Fm
This appeared as a moral dilemma, 'cause at first
                   Db                     Bbm
it was weird how I swore to eliminate the worst
                   Db                      Bbm
of the plague that devoured humanity. It's true
                   Eb                         Db
I was vague on the how, so how can it be that you
                  Ab
have shown me the light?
 
 
       Fm                     Fm/E
It's a brand new day, and the sun is high.
        Db                            Bbm   Eb
All the birds are singing that you're gonna die.
      Fm               Bbm
How I hesitated, now I wonder why.
       Gb
It's a brand new day.
 
(Notes only)
Gb F Eb C Eb Bb Ab F
 
Fm                     Db                        Fm
All the times that you beat me unconscious, I forgive.
                    Db                                 Bbm
All the crimes, incomplete, listen, and honestly, I'll live. 
                    Db                    Bbm 
Mister Cool, Mister Right, Mister Know-It-All, is through,
                    Eb                         Db
now the future's so bright and I owe it all to you,
                  Ab
who showed me the light.
 
Fm                            Fm/E
It's a brand new me, I've got no remorse.
        Db                    Bbm      Eb
Now the water's rising, but I know the course.
          Fm                     Bbm
I'm gonna shock the world, gonna show bad horse
       Gb
it's a brand new day.
 
(Aside from the Fsus these are just the bass notes)
 
    Db                 C
And Penny will see the evil me.
      Eb                      Fsus F
Not a joke, not a dork, not a fail-ure.
    Db                   C
And she may cry, but her tears will dry
       F                      C                 
when I hand her the keys to a shiny new Australia.
 
       Fm                       Fm/E
It's a brand new day. Yeah, the sun is high.
        Db                          Bbm   Eb
All the angels sing, because you're gonna die!
    Fm                          Bbm       Fm
Go ahead and laugh! Yeah, I'm a funny guy.
           Bbm         Fm   Bbm
Tell every one goodbye!
       Gb            Fm
It's a brand new day.
read more

Posted in  chords dr-horrible tabs


Dr. Horrible -- Pennys Song -- Guitar Chords Tabs

Act II's sentimental sexual-tension building Penny's Song has now been transcribed, it has a nice and easy "Seasons of Love"(Rent)/"What's going to happen"(Scrubs) feel to it. The opening chords are the same to "Will You Lend a Hand" sung by Penny in Act I, it wasn't long enough song for me to transcribe, but I was glad the theme was reprised in Act II there are certainly good elements of musical theater in this show.
C        F                   Em7              Am
Here's a story of a girl who grew up lost and lonely,
 
C             F                 Em7            Am         F
thinking love was fairytale and trouble was made only for me. 
 
C           FM7             C            F
Even in the darkness, every color can be found, 
 
    C            FM7               C
and every day of rain brings water flowing 
 
          Am         G   F
to things growing in the ground.
 
C              F               Em7         Am
Grief replaced with pity for a city barely copin'. 
 
C              F              Em7             Am     F
Dreams are easy to achieve if hope is all I'm hopin' to be. 
 
C              FM7                  C            F
Anytime you're hurt there's one who has it worse around, 
 
C                 FM7                C
and every drop of rain will keep you growing  
 
             Am            F
seeds you're sowing in the ground. 
 
C                     F
So keep your head up, Billy buddy.
read more

Posted in  chords dr-horrible tabs


Dr. Horrible -- On The Rise -- Guitar Chords Tabs

Continuing our series of Dr. Horrible's Sing-Along Blog lyrics and chords/tabs I present the first song from Act II: On The Rise. I found some other like minded folks transcribing the lyrics at [http://whedonesque.org/viewtopic.php?t=1725](http://whedonesque.org/viewtopic.php?t=1725) they make getting the words right the first time easy. I've also decided to try the more inline approach of the dueling lyrics, hopefully this will make changes clearer.
(Dr. Horrible)
Bm intro
 
Bm
Any dolt with half a brain
Can see that human kind has gone insane
To the point where i don't know
If I'll upset the status quo
If I throw poison in the water main.
 
G               Bm
Listen close to everybody's heart
 
G                      Bm
And hear that breaking sound
 
G                    Bm
Hopes and dreams are shattering apart
 
    F#m             A
And crashing to the ground.
 
 
Bm                  G
I cannot believe my eyes
 
Bm                          A         G
How the world's filled with filth and lies
 
         Bm       A
But it's plain to see
 
       E/G#       G          Bm
Evil inside of me  is on the rise.
 
(Penny)
 
D
Look around
We're living with the lost and found.
Just when you feel you've almost drowned
You find yourself on solid ground
 
          Em                    Bm
And you believe there's good in everybody's heart
 
Em               Bm
Keep it safe and sound.
 
Em        Bm
With hope you can do your part
 
   A
To turn a life around
 
D                   G
I cannot believe my eyes
 
D                    A       G
Is the world finally growing wise?
 
Bm                 A
Cause it seems to me
 
             E/G#    G          Bm
Some kind of harmony  is on the rise.
 
(Both: Dr Horrible first line, Penny second)
 
D
Anyone with half a brain
Take        it     slow
 
D
            Could spend their whole life howling in pain
He looks at me and seems                         to know
 
D
                    Cause the dark is everywhere And Penny doesn't seem to care
The things that I'm afraid                       to show           And suddenly
 
D
That soon the dark in me is all that will remain
I feel                                 this glow
 
         Em                   Bm
         Listen close to      everybody's heart
And I believe there's good in everybody's heart
 
    Em                 Bm
And hear that breaking sound
    Keep it safe   and sound
 
Em                   Bm
Hopes and dreams are shattering apart
    With hope you can     do your part
 
F#                  A
And crashing to the ground.
     To turn a life around.
 
D                   G
I cannot believe my eyes
I cannot believe my eyes
 
D                           A         G
How the world's filled with filth and lies
How the world's finally     growing   wise
 
         Bm                       A
But it's plain to see
                And it's plain to see
 
        E/G#             G
Evil inside of me
       Rapture inside of me
 
          Bm
is on the rise...
is on the rise...
 
Bm outro
read more

Posted in  chords dr-horrible tabs