Saturday, February 11, 2017

What does the fake news you repost say about you?

I've seen some really convincing garbage come across my Facebook feed as of late (turning it into a bit of a Fecesbook).

 I've made it a point to really dig in and research the "articles" and "studies". It takes some time, maybe 20 minutes, to get through the best of them and see that they are all bunk.

One pice of work I saw today purports that someone did a study that identified 72 refugees from the 7 nations of Trumps ban that are convicted terrorists. 

http://www.washingtonexaminer.com/report-72-terrorists-came-from-7-muslim-countries-trump-targeted/article/2614582

On the surface, this seems to pass the BS test:


  1. The website has other content on it. Looks like someone wrote this with spell and grammar check turned on. The name doesn't sound too fishy. 
  2. It presents a list of Mulsim names and their convictions. Someone must have gone through and collected all that data, so it's probably right. I don't see any non-muslim names on the list, so that's consistent with the article (refugees from Muslim countries and terrorists, of course). 


That seems to be the standard tests for even diligent consumers of internet news. Check those boxes and boom, ready to post!

 However, with about 20 minutes of googling and some reading, things start to quickly unravel:


  • Some of the names on the list got convictions for minor offenses like fake ids and had to do a few months of probation. Hardly what you would call someone a "terrorist" for. 
  • Some names aren't even refugees! 
  • The charges on the list are often wrong (based on reading through referenced court documents that are publicly available) 
  • A shocking realization that our government seems to have a repeated strategy of something that looks a lot like entrapment to nail poor, ESL, immigrants. 
  • The source is on a very short list of Hate groups funded by a white supremacist (identified by the SPLC). 
My favorite quote of the night from my research:
"Someday we'll look back on the present national paranoia over terrorism and the excesses done in its name with the same national embarrassment that Americans feel for Sen. Joe McCarthy's communist witch hunts of the 1950s and our appalling treatment of Japanese-Americans during World War II. Someday. But not anytime soon, and certainly not before Yassin M. Aref, the former imam at an Albany mosque, and Mohammed M. Hossain, a pizza shop owner, are sentenced… Looking up from a warm seat somewhere, Senator Joe must be viewing all this with a knowing smile.”
The fact that this propaganda works is evidence of a deeper issue. All fake news is designed to bait us on our deep seated emotions and assumptions.

 This article works because it has a list of Muslim names and that's what people want to believe.

Before you post a link, think and research. It's not that hard! Remember, the fake junk you post says a lot about you.

Thursday, May 31, 2012

Sending PDF Attachments with Sendmail

I was only able to find explanations of how to do this with mutt (which isn't working for me, god knows why).  In any case, sendmail seems to work and I wrote a script to help.


 #!/bin/sh  
 export MAILTO="$1"  
 export SUBJECT="$2"  
 export BODY=""  
 export ATTACH="$3"  
 (  
  echo "To: $MAILTO"  
  echo "From: from@domain.com"  
  echo "Subject: $SUBJECT"  
  echo "MIME-Version: 1.0"  
  echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'  
  echo  
  echo '---q1w2e3r4t5'  
  echo "Content-Type: text/html"  
  echo "Content-Disposition: inline"  
  echo ""  
  #cat $BODY  
  echo "Email Body Here"  
  echo ""  
  echo '---q1w2e3r4t5'  
  echo 'Content-Disposition: inline; filename="'$(basename $ATTACH)'"'  
  echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'  
  echo "Content-Transfer-Encoding: base64"  
  echo ""  
  uuencode --base64 $ATTACH $(basename $ATTACH)  
  echo '---q1w2e3r4t5--'  
 ) | /usr/sbin/sendmail -f from@domain.com $MAILTO  


(you'll need to change the address from@domain.com)

called as follows:

./sendemail.sh to_user@domain.com "Subject" /tmp/file.pdf

Monday, January 17, 2011

Server Upgrade

We were using a 10 year old Dell desktop as our router/webserver/misc computer.

Our needs evolved to require running RT and Asterisk on the system. Since they're considerably higher weight applications, I decided to upgrade the hardware.

After getting my new server, I needed to clone the linux installation. Since the old server had an IDE hard drive, and the new one was SATA, I purchased a $20 USB-SATA/IDE adapter from Amazon to help with the transition.

Step 1 - Clone Drive

I used a livecd version of gparted on my new system to clone the old drive. I used the clonezilla tool that was included to do a raw copy. The result was a new installation that was literally identical to my old one

Step 2 - Resize Partitions

Since my old server was from the dawn of the centry, the hard drive was only 60G. the new machine has a 250G drive (of course, for a fraction of the price). By doing the raw copy in step #1, the hard drive looks exactly like my old one (from a software point of view), and has a single 60G partition.

I used the gparted liveCD to resize my main partition. While I'd like to simply resize /dev/sda1, the swap partition gets in the way. As such, I needed to delete the swap partition, resize my main partition, then re-add my swap partition. To do this correctly, I had to edit /etc/fstab and update the UUID of /etc/sda5(my swap partition) with the UUID of the new partition I created

Step 3 - Fix stuff that broke

Given all the hardware in the system magically changed in an instant (from the view of the linux installation) I was quite impressed that it all booted at all. The main issue i had was getting my network interfaces to work.

Linux keeps track of network adapters by MAC address. I had to edit /etc/udev/rules.d/70-persistent-net.rules to update the network interfaces with the new cards and remove the old ones (from the previous system).

After that little update, everything really just worked! It was quite impressive! I finally did a distribution upgrade that broke some perl modules and apache configuration bits, but all in all, not bad.

Wednesday, December 15, 2010

Forwarding XML-RPC

I've always struggled with GUIs for embedded systems.

Our robots generally run linux. Generally, the systems run w/out monitors or keyboards, so the best option is to ssh into a linux box, with X11 forwarding turned on, and pretend like I was at the terminal. This is great as long as you have a laptop. The question is how I could do this in a more platform agnostic way. It'd be great if I had one GUI for windows/linux/mac/ios/etc, and if that GUI required no software installation.

Since GUI programming isn't my forte, and my GUIs literally just call my API functions with a lot of extra code for layout, this seemed like a great opportunity to fuse web and embedded software. Since we had used xmlrpc before, it seems to work OK, and there were javascript libraries for it, I decided to try writing my gui in a webpage with javascript, and write a xmlrpc wrapper for my robot api.

The first issue I ran into was a security limitation on the XMLHTTPost function in javascript. You can only post to the server the script came from. That extends to the port on the server the script came from. Since xmlrpc runs over HTTP, it has to be a different port than my GUI webpage (served by apache).

This was a pain, but I got around it by writing what is effectively a xmlrpc forwarder.

I created a php file with the following content:

1:  // Make Sure that it's a POST request that we're forwarding
2: if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
3: {
4: // Read the input from stdin
5: $data = trim(file_get_contents('php://input'));
6: }
7: // initialize curl
8: $ch=curl_init();
9: // The URL of our actual server
10: $url="http://localhost/RPC2";
11: // The XML payload is the data that was posted, with the XML tag
12: define('XML_PAYLOAD', '<?xml version="1.0"?>'."\n".$data);
13: // Set all the options for cURL
14: curl_setopt($ch,CURLOPT_URL,$url);
15: // Running on port 8080
16: curl_setopt($ch,CURLOPT_PORT,8080);
17: // Get request is default, make this a POST
18: curl_setopt($ch,CURLOPT_POST,1);
19: curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
20: curl_setopt($ch, CURLOPT_TIMEOUT, 4);
21: curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD);
22: // This has to be set for it to be an XML post
23: curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
24: $myFile = "/tmp/xml_forward_debug.txt";
25: $fh = fopen($myFile, 'w') or die("can't open file");
26: fwrite($fh, XML_PAYLOAD);
27: fwrite($fh, "\n\n*** Response\n\n");
28: $ret=curl_exec($ch);
29: fwrite($fh, $ret);
30: fclose($fh);
31: header('Content-Type: text/xml');
32: print $ret;

My javascript uses mimic.

My C++ server uses xmlrpc for c++

My test web post calls the classic "add" method



1:       var request = new XmlRpcRequest("index.php", "sample.add"); 
2: request.addParam(1);
3: request.addParam(3);
4: var response = request.send();
5: alert(response.parseXML());

This all seems to work so far! Very exciting. Still quite a ways to go as I work out messaging, etc., but I'm hoping this was the biggest step. Will post more as the project progresses.

Friday, December 3, 2010

Displaying The IP Address of my linux computer

I'm building a robot that has a computer monitor as it's head (literally), but no keyboard or mouse to support a UI. I'd like to connect to it by using the IP address for general operation, but I need to know what it is. What to do?

I've seen many posts about people looking for how to display the ip address on the desktop. My case is similar. My solution was to write a shell script that was added to the startup programs (under Settings >> Sessions & Startup) that looks like this:


#/bin/bash

w=$(ifconfig eth0 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}')
wl=$(ifconfig wlan0 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}')
msg=$(echo "Wired :" $w "\n" "Wireless :" $wl)

zenity --info --text="$msg" &



On startup, a message box is displayed that indicates the IP address.

Thursday, October 22, 2009

wxWidgets and Failed Assertions

I was writing my first GUI in C++ on linux using wxwidgets and would erratically get this message:

./../src/xcb_lock.c:33: _XCBUnlockDisplay: Assertion `xcb_get_request_sent(dpy->xcb->connection) == dpy->request' failed

it did take a couple different forms (i think there was one other), but usually had a dpy->request in it and xcb_lock.c), but this one came up quite often. it was very erratic, and would sometimes keep my gui from coming up at all.

I ultimately (thanks to the help of people in #wxWidgets on freenode) figured out it was because wxWidgets is not thread safe and my worker thread was calling member functions of my GUI.

To fix this I added wxMutexGuiEnter() and wxMutexGuiExit() around my code that access the gui and all issues were resolved.

Monday, June 29, 2009

Getting mail from gmail using fetchmail

So I wanted to setup RT on my ubuntu box. It's been rough so far, but I figured I'd document this as well.

First, I was running ubuntu 7.10 and needed to upgrade to 8.04. That was a bit tricky as i tried to do 'do-dist-upgrade' but it kept failing. I finally figured out it was because i had all the repositories in /etc/apt/sources.list enabled. Needed to pear it back to just be the first one in the file.

So, after I did that I was up to 8.04. From there, I grabbed the 'request-tracker3.6' package using apt-get. This is by far the best way to do this, as it gets everything else you need as well. These instructions were well chronicled at http://www.ubuntugeek.com/request-trackerrt-ticketing-system-for-your-support-group.html. I stupidly didn't setup the database, so got a lot of weird errors.

Next, to get email integration to work... I wanted to check a gmail mailbox for our domain. To do that you need to configure postfix, these instructions (scroll down to the end where it say "Fetchmail\nWhy Fetchmail") http://souptonuts.sourceforge.net/postfix_tutorial.html. One thing it misses is that you need to remember to copy the hashed links of your certs to /etc/ssl/certs.

I have yet to get rt-mailgate to work, though.