Thursday, August 11, 2016

Sometimes I Prefer Computers to People

Computers are easy. If the computer is not making sense, or doing something weird like crashing, freezing, or shutting down spontaneously, than it's definitely either your fault, or something is simply broken. It's almost always easily fixable. People, on the other hand, are much more complicated. People don't keep kernel logs, and are much less debuggable. I wish human brains ran on Linux and kept verbose debug logs. Than I could just sort of like ...



# ssh into the brain in question
anon@nixbox:$ ssh root@brain
Last login: n/a          
##############################


# get uptime, unset history, and grab emotional/chemical stats
 
root@brain:# unset HISTFILE ; uptime ; env|grep "EMO\|CHEM"|tr -d '\n'
14:50:31 up 1 day, 19:24,  1 user,  load average: 0.61, 0.74, 0.93
EMO_HAPPY=0 EMO_SAD=1 EMO_FEAR=1 EMO_LOVE=0 CHEM_DOPAMINE=44% CHEM_SERATONIN=53% CHEM_GABA=50% CHEM_epinephrine=87%
root@brain:# dmesg | grep 'because\|reason'

# remount the responsible parts of brain as writable
root@brain:# mount -o remount,rw /dev/amygdala /mnt/brain0
root@brain:# mount -o remount,rw /dev/hippocampus /mnt/brain1

# strace whatever program is responcible for emotions for a while
 
root@brain:# strace -v /mnt/hippocampus/bin/emotions > out.log
 grep "happ*\|sad*\|ang*\|anx*\|fear*\|*secure*\|love*\|hate*\|irritat*\|panic*\|comfort*\|joy\|despair\|disgust\| \
 trust*\|scare*\|relief\|bliss" out.log > debug.log ; shred -zu out.log

# diagnostics: figure out what they're feeling and why
root@brain:# grep "feeling\|because\|reason\|suggest*\|CHEM*" debug.log

 

Mon Aug 08 01:23:59 EDT 2016 DEBUG: feeling happy because: 'sun is shining, skies are blue '
 CHEM: [dopamine: 75%] [seratonin: 89% ] [GABA: 90%] [epinephrine: 10%]
Tue Aug 09 18:23:53 EDT 2016 INFO: feeling angry because: 'smells like teen spirit playing on radio again '
 CHEM: [dopamine: 45%] [seratonin: 57% ] [GABA: 70%][epinephrine: 51%]
Wed Aug 10 12:02:26 EDT 2016 INFO: feeling happy because: 'got paid today, '
 CHEM: [dopamine: 75%] [seratonin: 60% ] [GABA: 100%][epinephrine: 3%]
Thu Aug 11 09:55:41 EDT 2016 WARN: feeling irritable because 'craving nicotine, low dopamine '
 CHEM: [dopamine: 24%] [seratonin: 51% ] [GABA: 70%][epinephrine: 60%]
Thu Aug 11 12:30:44 EDT 2016 ERR:  system unstable, reason: 'chemical inbalance! '
 CHEM: [dopamine: 15%] [seratonin: 42% ] [GABA: 10%][epinephrine: 88%]
Fri Aug 12 08:12:43 EDT 2016 WARN: feeling anxious because: 'sleep deprivation [-2 hours] '
 CHEM: [dopamine: 55%] [seratonin: 60% ] [GABA: 42%][epinephrine: 90%]
Fri Aug 12 08:12:43 EDT 2016 INFO: suggest: '10 mgs diazepam to induce somnia and more sleep'
Fri Aug 12 11:56:01 EDT 2016 FATAL: feeling: 'depressed because: '(null) error: no reason found'


# shred the evidence (not sure that in any universe this would be legal)
 
root@brain:# shred -zu debug.log 


# create a boot script to kill bad emotions, trigger good ones, and let's just do our brain owner a favor and correct that seratonin inbalance once and for all, each reboot (or, every morning, i suppose. [it's pseudo science fiction].)
 
root@brain:# grep -v "exit 0" /etc/rc.local > /tmp/rc.tmp ;
root@brain:# echo "echo 1 > /proc/emo/happy ; echo 0 > /proc/emo/sad ; echo 0 > /proc/emo/fear ;echo 1 > /proc/emo/love;\
 echo 100 > /dev/chem/dopamine ; echo 100 > /dev/chem/seratonin ; echo 0 > /dev/chem/epinephrine ; echo 100 > /dev/chem/GABA \
 exit 0" >> /tmp/rc.tmp && mv /tmp/rc.tmp > /etc/rc.local


# turn panic attacks into blissful trips, in fact, lets just unset panic as a variable altogether and save some pharma costs. than we should be good to simply reboot the brain and all will be well
 
root@brain:# echo 'alias PANIC="echo 1 > /proc/emo/bliss;echo 0 >/proc/emo/panic ; unset PANIC\"' >> /etc/profile
root@brain:# ln -s /dev/chem/GABA /dev/chem/epinephrine ; reboot
Broadcast message from root@brain
        (/dev/pts/1) at 13:21 ...
The system is going down for reboot now!
Connection closed by remote host.


# log back in and make sure nothing went terribly wrong




anon@nixbox:$ ssh root@brain
Last login: Fri Aug 12 15:29:57 EDT 2016 from nixbox.lan
##############################
root@brain:# env|grep "EMO\|CHEM"|tr -d '\n'
EMO_HAPPY=1 EMO_SAD=0 EMO_FEAR=0 EMO_LOVE=1 CHEM_DOPAMINE=100% CHEM_SERATONIN=100% CHEM_GABA=100% CHEM_epinephrine=0%
root@brain:# >$HISTFILE; exit
Connection to brain-099343343322.lan closed
anon@nixbox:$ # All better now


# Looks good. Our subject is flying on dopamine, has a health seratonin balance, lots of GABA, and we've disabled adrenaline (for now, cause ya, adrenaline has it's uses)


As nice as this would be, it's just not the way life works. Life is not binary. The world is not black and white, it's rather colorful. But it's nice to dream.

Sunday, August 7, 2016

Making Facebook Chat Suck Less: Messenger Over IRC!

The Problem: 

We all know how bad the Facebook Messenger platform is, so I won't go into too much detail. The CIA probably has access to every single message ever sent over the service, and the mobile messenger app requires permissions to just about everything on your phone. The only other option is to use the HTML service on facebook's site, or the standalone messenger client, which is equally inconvenient. But if you are using a mobile device, you may have noticed that you can't even use the browser anymore (at least, not without spoofing your user agent string). If you're on a smartphone, it seems Facebook will stop at nothing to get you to install their spyware-oozing, trojanized, piece-of-shit app. (Why, Zuckerburg, in God's name, WHY?)

There used to be an alternate way, connecting via the XMPP service that Facebook used to provided. This allowed users to use the service on the XMPP client of their choice (profanity is mine, Pidgin is more commonly used). Many users, myself included, were quite angry when Facebook killed that service. After that happened, I pretty much gave up on ever using facebook chat for anything other than occasionally tracking down long lost friends.

After all, who needs this crap? There are plenty of ways to communicate with your friends securely, with end to end encryption, and away from the prying eyes of Google and the NSA. There is Signal Private Messenger, a plethora of XMPP servers available for public use, and hell, even doing clumsy shit like:

echo -ne "Decrypt this shit"|gpg -a -r 'Alice' --encrypt|nc lol.com 6969

is better than facebook messenger! The problem is getting your friends to use the encrypted services (which, btw, are very easy to use). Sometimes the party you need to talk to just doesn't know how or care to use alternate communication services. Maybe you're dating someone who is not as technically oriented as you are, or someone that just really likes to use facebook. Or maybe you have to use Facebook because of your job, or maybe your friends simply don't care that every word exchanged over that service is being stored on tape inside one of Dick Cheney's underground bunkers.

The attitude toward perpetual warrentless wiretapping in this country is somewhere between an apathetic "oh well" and a misguided "i don't care because i have nothing to hide". I could tell you about how those attitudes, throughout human history, have lead to awesome events such as the rise of the Nazi Germany, but I digress. Besides, if you're using Facebook's servers in any way, than forget about hiding messages from three letter organizations.

Messenger's Annoying (Anti)Features:

That aside, I cannot be the only one that feels like their chatting experience has been wrecked by all of these new "features", such as the ability to see when your friend has "seen" the message your sent, or the distracting ability to see when your contact is typing you a message. Perhaps you also don't appreciate the fact that everyone in the world can see your idle time, down to the second, from which you were last online (this is how my mom used to know when I stayed up till 3:00 AM).

Maybe you think I am being silly, perhaps you like these features. I would not mind them if I simply had the option to shut them off, without disabling chat altogether. I feel like the seen, is typing. and idle features rob the user of some of the better aspects of text messaging that make it appealing to begin with. For instance, I like how when talking to someone over sms, I feel like I can take my time replying, and do not feel like my cell phone is eating my attention span alive. With IRC and sms, I am engaged with both the conversation and world around me. But with facebook, I feel like my attention span has been totally hijacked and monopolized. I don't want the distraction of knowing the second someone "sees" my messages. Maybe sometimes I don't want them to know when i saw theirs. I don't like when people can see that I am typing either. Sometimes I feel compelled to type faster, or feel silly if I spend five full minutes typing a message, only to delete it and say "yeah". Sometimes I feel like if I don't reply in a reasonable time, than I am somehow indirectly "ignoring" my contact. Yes, it all sounds trivial, but that's how the messenger platform makes me feel. Wouldn't good old IRC be better?

Whatever the reason compelling you to use this terrible platform, if you find yourself with a facebook browser tab open all of the time, running inside of your dedicated sketchy virtual machine to avoid cross contamination with all your other shit, than I have good news for you. If you also hate these ever increasing amount of anti-features like "seen", than this blog is for you too. The situation is fixable! Without further ado, meet Bitlbee.

Making It Suck (Way) Less: 

(Note: it should go without saying that no matter how you interact with facebook's servers, your messages will still be stored on those servers. Besides using some end-to-end encryption plugin like blowssi or copy and pasting gpg encrypted messages, there is nothing you can do about that part of the problem.)

There is finally a way to chat on facebook, using your IRC client of choice (I like irssi), while reclaiming some privacy. Finally, I can talk to people on Facebook without ever having to leave the comfort of my terminal emulator. This is possible thanks to Bitlbee, and bitlbee-mqtt. What is bitlbee?
"BitlBee brings IM (instant messaging) to IRC clients. It's a great solution for people who have an IRC client running all the time and don't want to run an additional MSN/AIM/whatever client.
BitlBee currently supports the following IM networks/protocols: XMPP/Jabber (including Google Talk and Hipchat), MSN/Skype, Yahoo! Messenger, AIM and ICQ, the Twitter microblogging network (plus all other Twitter API compatible services like status.net)
There are also plugins for facebook and steam, and you can use libpurple to get even more protocols."
Basically, Bitlbee provides a way to use all of your favorite (or most hated) messaging services over good old IRC. It is an irc daemon, so preferably you should run it on some linux box that is online all of the time.

How to Bitlbee-Facebook:

Full instructions here. You will need:

 - a linux server
 - a facebook account
 -  ~ 30 minutes
 - an irc client
 - an irc bouncer
 - an IQ =< 60
 - some basic linux skills 

First you need to install  both bitlbee and bitlbee-facebook. These packages can either be built from source, or you can use the bitlbee repositories if your Linux distribution is supported (easier). Pre-compiled binaries may also be available, but I don't mess with those, and neither should you.

For simplicities sake, let's use the repositories. First, find out if your distro is supported. Currently, a few Debian and Ubuntu releases are:

wheezy:  Debian 7.0 (old-stable)
jessie:  Debian 8.0 (stable)
testing:         Debian testing
trusty:  Ubuntu 14.04 LTS (trusty tahr), Linux Mint 17
wily:    Ubuntu 15.10 (wily werewolf)

There are two repositories you need to add, the readme's are located here and here. I'll assume you are using Debian Jessie, because it's my favorite out of all of those, and this is my blog. If you're using something else, just replace the distro when you run these commands (where applicable).

First, we need the release key (same for all versions), and than we need to add an entry to our sources.list for apt:

$ wget -O- https://code.bitlbee.org/debian/release.key | sudo apt-key add -
$ wget -O- https://jgeboski.github.io/obs.key | sudo apt-key add -
 
Than we need to add the repositories to our sources list (as root):
 
# echo 'deb http://code.bitlbee.org/debian/master/jessie/amd64/ ./'\
 >/etc/apt/sources.list.d/bitlbee.list
# echo 'deb http://download.opensuse.org/repositories/home:/jgeboski/jessie ./'\
 >/etc/apt/sources.list.d/jgeboski.list

Next, we need to update apt and than install the packages bitlbee and bitlbee-facebook, and than restart the daemon for good measure:

sudo apt-get update;sudo apt-get install bitlbee bitlbee-facebook;(sudo service bitlbee restart || sudo service bitlbee start)

Congratulations, you should now have a functional bitlbee server that supports facebook! Now it's time to make sure that everything works. First, generate an app password for bitlbee to use (this is much more secure than logging in using your actual facebook password). Next, using your favorite IRC client (i like irssi), connect to your server, try to add a facebook account, and message someone:

/server localhost
account add facebook <email> <password>
account facebook on 
/msg PersonsDisplayName hello from an oldschool irc client! 

If everything went well, you should be logged in to facebook chat. In the channel &Bitlbee, you will see all of your friends as they come on and offline. You start a conversation just like you would on any other IRC server, by doing /msg UserName. You will notice that Bitlbee's mqtt works much better than the old XMPP did. Hyper-links and images work properly too, they are converted to unique links to facebook's content delivery service that you can open in your browser to view. It's really quite impressive how well this works. As an added bonus, you will appear online all of the time, so nobody can get your idle time, nobody can see when you are typing, and the "seen" feature is rendered useless as well (this behaviour can be changed, see the docs).

At this point, everything works, but you may have noticed that bitlbee does not natively support SSL. And while bitlbee does have a nice feature for taking over sessions when you switch devices, everything runs much more smoothly if you configure an IRC bouncer that does support SSL, and run it on the same box as the bitlbee server. This way you can simultaneously be online from multiple devices, and you won't miss any messages when you switched devices, or if/when your connection drops. The bouncer will cache those messages for you, providing both convenience, and if the bouncer supports SSL, security (funny how that works out in this case). A popular bouncer that is available in the Debian/Ubuntu repositories is ZNC, which is very easy to configure (just run znc --makeconf , and follow the prompts).

This is what it looks like when everything is working, using irssi. This is a screenshot of my facebook friends coming online and going idle. Nerds like me will appreciate how bitlbee translates facebook mqtt messages into emulated irc messages:


This is a screenshot of a conversation in irssi. Notice how when the user goes idle, bitlbee emulates that by with an irc quit message:


Finally, here is a screenshot of the &Bitlebee status feed on an Android, in this case using the AndChat IRC client (of course you could also use connectbot and tmux or something):


A conversation on AndChat:



Pretty cool, right? I can finally use facebook on my phone without dealing with browers and user agents (I have always refused to use Messenger).

So, that's how you can reclaim some of your privacy, and turn your attention-monopolizing facebook experience into something much more pleasant, with a retro IRC feel.

Important:

Do not use Bitlbee straight over the internet! Either use a bouncer that supports SSL, run it through a VPN, tunnel it over SSH, or use something else, like stunnel. The IRC protocol is ancient, and operates over plain text. Intercepting your messages and passwords would be trivial for an ISP or someone on your LAN to do.

I am considering running a public Bitlbee server, which would use SSL. If you think you would be interested in using that service, leave a message. I hope that this blog helps someone. Enjoy.