Category: command-line

  • A Quick Guide to Noobwatcher

    curl -O http://svn.collab.net/repos/svn/trunk/tools/client-side/showchange.pl
    mv showchange.pl $HOME/bin
    svn co http://codebelay.com/noobwatcher
    mkdir watched_repositories
    cd watches_repositories
    cp $HOME/noobwatcher/trunk/noobwatcher.rb .
    svn co

    Create and edit a settings.yml file. Mine looksl like this:

    path: /Users/barce/nooblive/trunk
    repo: http://www.example.com/the_repo_I_am_watching
    diffs: /Users/barce/nooblive/diffs
    twitter_email: the_twitter_email_that_notifies_you@example.com
    twitter_password: the_password_to_the_twitter_email_that_notifies_you
    twitter_recipient: your_twitter_account
    sleepseconds: 60

    Start noobwatcher:

    ./noobwatcher.rb
  • Remove ^M characters and more with repl.bash

    Hey folks, this is a goody but quicky.

    First off, respect the character encoding of a file. I don’t know how many devs out there violate this rule, but if you’re like me and Joel On Software, you’ll agree that you should respect the character encoding of a file.

    If you happen to see that your file has gotten code page 1252 aka Windows-Latin 1 in it, then you’ll have a variety of random characters like ^M or ?~@~Y or ?~@~\ or ?~@~] .

    Well, I wrote a script that removes these guys and makes sure that the file format of Unix is respected. Here it is:

    #!/bin/bash
    #
    # By: barce[a t]codebelay.com
    # ——————-
    # this script replaces microsoft special chars with plain ol’ ascii
    #
    # usage: ./repl.bash filename
    #

    # replace ^M characters
    perl -pi -e ‘s/\x{0D}\x{0A}/\x{0A}/g’ $1

    # replace garbage with single-quotes
    # ?~@~Y
    perl -pi -e ‘s/\x{E2}\x{80}\x{99}/\x{27}/g’ $1
    perl -pi -e ‘s/\x{80}\x{99}/\x{27}/g’ $1
    perl -pi -e ‘s/\x{80}\x{9c}/\x{27}/g’ $1
    perl -pi -e ‘s/\x{80}\x{9d}/\x{27}/g’ $1

    # replace garbage with asterisk
    # ?~@?
    # e280 a2
    perl -pi -e ‘s/\x{E2}\x{80}\x{A2}/\x{2A}/g’ $1

    # replace garbage quotes with plain quotes
    # start: ?~@~\
    # close: ?~@~]
    # e2 809c
    perl -pi -e ‘s/\x{E2}\x{80}\x{9C}/\x{22}/g’ $1
    perl -pi -e ‘s/\x{E2}\x{80}\x{9D}/\x{22}/g’ $1

    # replace garbage hyphens with plain hyphens
    perl -pi -e ‘s/\x{E2}\x{80}\x{93}/\x{2D}/g’ $1

    # replace garbage with ellipsis
    perl -pi -e ‘s/\x{E2}\x{80}\x{A6}/\x{2E}\x{2E}\x{2E}/g’ $1

  • Darwin Ports when OS X Idiosyncracies Get You Down

    I started using Darwin Ports when tools like hping3 and ctags didn’t work quite right on OS X. For example, the berkeley packet filter on OS X is totally different from the one on Linux, so hping3 wouldn’t compile correctly. Also, ctags in OS X doesn’t have the -R flag for recursion.

    With Darwin Ports, I can install libraries and executables that don’t work quite right on OS X but work great on Linux.

  • Sending Files with hping3

    This is a quick cheat sheet on how to use hping3 to send a text file. Thanks Gr@ve Rose for inspiring this.

    The target machine should be listening like so:

    hping3 192.168.0.108 –listen signature –safe –icmp

    The source machine should be set up like so:
    hping3 192.168.0.108 –listen signature –safe –icmp
    hping3 192.168.0.108 –icmp -d 100 -c 2 –sign signature –file ./test.txt

    -d specifies the data size
    -c specifies the number of pings to send. We just need 2 pings to send the test file below.

    test.txt just contains lolspeak:
    —- start —-
    oh hai
    we bustin pass dey bad fire wall
    yay!
    —- end —-

    I haven’t tested this out with binary files, but I’m pretty optimistic that a uuencoded file would get through, and could be re-assembled at the target server. Also, hping3 can be used to turn on a network service like sshd if it receives the correct “signature”.