Skip to content

Git Nowhere

Arturo and I were going through our commit logs for ooni-probe this morning when he noted that git commits leak geodata through timezone settings. I figured git would have an easy way to set the timezone to GMT, but it turns out that it uses mktime() to get a struct representing the system clock time. There’s a few hacks already for dealing with this, namely setting GIT_AUTHOR_DATE with the –date command:

$ git commit --date="Wed Feb 16 14:00 2037 +0100"

This is not only annoying, but it also doesn’t set GIT_COMMITTER_DATE, so if you wrote the patch and also committed it to a repo, your timezone still leaks.

I thought this was all incredibly annoying, and I don’t want to change my system clock, so I made a bash script to fix it:

#!/bin/bash 
#_____________________________________________________________________________
# Git Nowhere
#-----------------------------------------------------------------------------
#
# Use: Run as "$ . ./gitdate.sh" before "$ git commit" to manually set
# the date to GMT in order to obscure timezone-based geodata tracking.
#
# If you would always like your timestamps to be obscured for a specific
# project, then place this script in /usr/local/bin/. Next, edit
# /your_project_path/.git/hooks/pre-commit and place in it the following two
# lines:
#
# #!/bin/sh
# exec source /usr/local/bin/gitdate.sh
#
# @author Isis Lovecuft, 0x2CDB8B35 [email protected]
# @version 0.0.3
#
# v0.0.3: Also changes the months and years, because that would suck if your
#         commits were accidentally made last year
# v0.0.2: Changes the days too
# v0.0.1: Changes the hours
#_____________________________________________________________________________

DAY=$(date | cut -d ' ' -f 1)
MONTH=$(date | cut -d ' ' -f 2)
DATE=$(date | cut -d ' ' -f 4)
TIME=$(date | cut -d ' ' -f 5)
TIMEZONE="+0000"
YEAR=$(date | cut -d ' ' -f 7)
HOUR=$(echo "$TIME" | cut -d ':' -f 1)
MINUTE=$(echo "$TIME" | cut -d ':' -f 2)
SECOND=$(echo "$TIME" | cut -d ':' -f 3)

# Git uses the system time settings through mktime().  Do a "$ git log" to see
# the timezone offset for your system.  This script assumes -0700. For
# example, if "$ git log" says your timezone is -0500, you would change all
# occurences in the next code block of "7" to "5" and change "17" to "19".

TIMEOFFSET=7

if [ "$HOUR" -lt "17" ]; then
    let HOUR+=7
else
    let TILMIDNIGHT=24-HOUR
    let FALSEDAWN=TIMEOFFSET-TILMIDNIGHT
    let HOUR=FALSEDAWN
fi

# If the hour is one digit, prepend a zero.

if [ "${#HOUR}" -eq "1" ]; then
    HOUR=$(printf "%02d" $HOUR)
fi 

# If it is tomorrow in UTC, make sure we increment the day.

if [[ -n "$FALSEDAWN" ]]; then
    if [ "$DAY" = "Mon" ]; then
        NEXTDAY=$(echo "Tue")
    elif [ "$DAY" = "Tue" ]; then
        NEXTDAY=$(echo "Wed")
    elif [ "$DAY" = "Wed" ]; then
        NEXTDAY=$(echo "Thu")
    elif [ "$DAY" = "Thu" ]; then
        NEXTDAY=$(echo "Fri")
    elif [ "$DAY" = "Fri" ]; then
        NEXTDAY=$(echo "Sat")
    elif [ "$DAY" = "Sat" ]; then
        NEXTDAY=$(echo "Sun")
    elif [ "$DAY" = "Sun" ]; then
        NEXTDAY=$(echo "Mon")
    fi
    DAY=$NEXTDAY

    if [[ "$MONTH" = "Jan" ]] || [[ "$MONTH" = "Mar" ]] || [[ "$MONTH" = "May" ]] || [[ "$MONTH" = "Jul" ]] || [[ "$MONTH" = "Aug" ]] || [[ "$MONTH" = "Oct" ]] || [[ "$MONTH" = "Dec" ]]; then
        if [[ "$DATE" -lt "31" ]]; then
            let DATE+=1
        elif [[ "$DATE" -eq "31" ]]; then
            if [[ "$MONTH" = "Jan" ]]; then
                NEXTMONTH=$(echo "Feb")
            elif [[ "$MONTH" = "Mar" ]]; then
                NEXTMONTH=$(echo "Apr")
            elif [[ "$MONTH" = "May" ]]; then
                NEXTMONTH=$(echo "Jun")
            elif [[ "$MONTH" = "Jul" ]]; then
                NEXTMONTH=$(echo "Aug")
            elif [[ "$MONTH" = "Aug" ]]; then
                NEXTMONTH=$(echo "Sep")
            elif [[ "$MONTH" = "Oct" ]]; then
                NEXTMONTH=$(echo "Nov")
            elif [[ "$MONTH" = "Dec" ]]; then
                NEXTMONTH=$(echo "Jan")
                let YEAR+=1                
            fi
            DATE=1
        fi
    elif [[ "$MONTH" = "Feb" ]] && [[ "$DATE" -lt "28" ]]; then
        let DATE+=1
    elif [[ "$MONTH" = "Feb" ]] && [[ "$DATE" -eq "28" ]]; then
        NEXTMONTH=$(echo "Mar")
        DATE=1
    elif [[ "$MONTH" = "Apr" ]] || [[ "$MONTH" = "Jun" ]] || [[ "$MONTH" = "Sep" ]] || [[ "$MONTH" = "Nov" ]]; then
        if [[ "$DATE" -lt "30" ]]; then
            let DATE+=1
        elif [[ "$DATE" -eq "30" ]]; then
            if [[ "$MONTH" = "Apr" ]]; then
                NEXTMONTH=$(echo "May")
            elif [[ "$MONTH" = "Jun" ]]; then
                NEXTMONTH=$(echo "Jul")
            elif [[ "$MONTH" = "Sep" ]]; then
                NEXTMONTH=$(echo "Oct")
            elif [[ "$MONTH" = "Nov" ]]; then
                NEXTMONTH=$(echo "Dec")
            fi
            DATE=1
        fi
    fi
    if [[ -n "$NEXTMONTH" ]]; then
        MONTH=$NEXTMONTH
    fi
fi

export GIT_AUTHOR_DATE=$(echo "$DAY $MONTH $DATE $HOUR:$MINUTE:$SECOND $YEAR $TIMEZONE")
export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE

unset NEXTMONTH
unset DAY
unset MONTH
unset DATE
unset HOUR
unset MINUTE
unset SECOND
unset YEAR
unset TIMEZONE
unset TILMIDNIGHT
unset FALSEDAWN
unset NEXTDAY
unset TIMEOFFSET

Absense

I’m sorry I haven’t written anything lately. For those of you who have been worrying about me, I’m not dead, and, for reasons which I’ll soon explain, it’s actually a bit ironic that everyone’s worried of that.

So, I starting working for the Tor Project. If all goes well with funding, I’ll be working with Ioerror on reverse engineering a few other “anonymity” tools, hacking on Ooni-probe (a set of tools for detecting different types of censorship around the world) with my Italian friend Hellais, and probably continuing to do itty-bitty things to help Nick and George with Obfsproxy.

I’ve also been scrambling to finish the Dead Man’s Switch for Android, which I’m writing for March Hare Communications Collective. When I finish that, please, everyone, stop pestering me if I’m dead. You will know when I am dead.

And…I’ve been really struggling with the neurological disorder I was diagnosed with. I feel overwhelmed, especially when I have to be around people, which has been nearly constantly for the past three months or so. I want to write an AI that deals with all of the people for me. Maybe I should write an AI that in turn writes all of the blog posts for me. Actually…this is a great idea. “My” next post is going to be awesome.

pyrsync: A pure Python module for the rsync algorithm

I quickly modified and packaged a pure Python implementation of the rsync algorithm today. It’s on Github and PyPi. It’s going to be used in the open-source, symmetrically-encrypted, bandwidth-efficient, cross-platform backup software that I’m writing. Because why, for fuck’s sake, would you trust *all the files* on your computer, plus your cryptographic scheme, and potentially, keys, to a bunch of capitalist pig-dogs?

I hope other people find this useful, because making Python modules is totally not as exciting as just coding in Python.

And jetlag FTL: I need to sleep now. And WTF, America: I hate your filthy guts and I’m leaving ASAFP.