Jens Oliver Meiert

Privacy Experiments: How to Auto-Generate Random Web Traffic

Post from December 15, 2017, filed under .

I believe that privacy, which has never been about “hiding something,” is a fundamental civil right, and as such worth defending and fighting for. I believe that freedom, in one part, rests on privacy. And I also believe that lack of privacy and freedom seriously harms us individually and endangers our communities.

The ever growing amount of surveillance—as I had once theorized, we totally f’ed up if the Snowden revelations had ever been about gauging public reaction—, together with attempts to topple net neutralityno!—are therefore, in my view, direct threats to our individual and collective rights and well-being.

This all holds particularly as there are foreign agencies like the United States and England who infringe on non-American and non-British people’s rights (or have they declared war on us yet so to continue spying on everyone?), and also particularly as it’s all a farce: cooperation, negotiation, regular police work all do work better than adversity, ignorance, and mass surveillance.

Before we go even deeper into the topic, and without actually commenting on my motivation—many people here know how I love experimenting with stuff—I was working on a basic script to randomize machine traffic patterns. Again, as I had done with the “New Tab Traffic Randomizer” Chrome extension.

Now, the result is actually “too random” as to seriously obscure traffic, and it’s set up to also be very easy on the network (one request every five minutes), but—it works, and it can be modified to suit people’s needs.

Important: This is from a test, and it should probably remain a test. Use at your own risk and discretion.

1. Extend .bashrc

If you also work with macOS and if your local setup is anything like mine, then you first need some functions set up for random strings and the generation of protocols and top-level domains.

Add the following to your .bashrc (on other UNIX distributions you may need to modify the cat command):

randomstring() {
  cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z' | fold -w ${1:-32} | head -n 1
}

randomprotocol() {
  arr[0]="http://"
  arr[1]="https://"
  arr[2]="ftp://"
  rand=$[$RANDOM % ${#arr[@]}]
  echo ${arr[$rand]}
}

randomtld() {
  arr[0]=".com"
  arr[1]=".net"
  arr[2]=".org"
  arr[3]=".info"
  arr[4]=".eu"
  rand=$[$RANDOM % ${#arr[@]}]
  echo ${arr[$rand]}
}

I’m not an expert but rather a pragmatist in script matters, so please share suggestions here or through email. Thank you!

2. Test wget

Now, test whether you can use these functions together with wget (make sure that you’ve source’d your .bashrc, and installed wget if necessary):

wget -p -k $(randomprotocol)$(randomstring $(echo $[RANDOM%20+1]))$(randomtld) --tries=3

In this setup we grab a random number that’s at least 1 to generate a hostname; we limit the number of wget tries to three to avoid excessive guessing and traffic.

An a bit more advanced version and test of this may add a few HTTP headers; for example:

wget -p -k $(randomprotocol)$(randomstring $(echo $[RANDOM%20+1]))$(randomtld) --tries=3 --header="User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20100101 Firefox/23.0" --header="Accept: image/png,image/*;q=0.8,*/*;q=0.5" --header="Accept-Language: en-US,en;q=0.5" --header="Accept-Encoding: gzip, deflate" --header="Referer: http://www.$(randomstring).com/"

3. Set up a Cronjob

To run this on a regular basis, but in a lightweight fashion, create a cronjob (crontab -e):

*/5 * * * * cd ~/.Trash; wget -p -k $(randomprotocol)$(randomstring $(echo $[RANDOM%20+1]))$(randomtld) --tries=3 &> /dev/null

This runs the command every five minutes, from the trash, and sends all output to /dev/null—any more advanced setup can be done in like fashion.

Trouble-Shooting

There are a couple of things implied in this how-to, like how to find and edit the different files, how to install, also how to fix any other glitches. Sorry if it doesn’t work instantly for you (but please let me know about easy improvements for the setup described here).

The only trouble-shooting note I can make here, off the top of my head, is that if your commands don’t work, check whether using the full path helps (as with referring to /usr/local/bin/wget), and eventually source your .bashrc in the cronjob (as with starting it with source /Users/johndoe/.bashrc) in order to make the function calls possible (I’m not sure whether that step is needed in any case; if it is I’ll rewrite things here).

Voilà, then, for a basic setup that fetches a random web page every x minutes. It’s been a test; and as such I document it here. As I said, use this at your own risk and discretion, and please share any thoughts for improvements in the comments or through mail. ✌️

About the Author

Jens Oliver Meiert, photo of April 13, 2018.

Jens Oliver Meiert is an author and developer (O’Reilly, W3C, ex-Google). He plays with philosophy, art, and adventure. Here on meiert.com he shares and generalizes and exaggerates some of his thoughts and experiences. (Beware: More often than he wants it he’s wrong.)

There’s more Jens in the archives and at Goodreads. If you have any questions or concerns (or recommendations) about what he writes, leave a comment or a message.

Read More

Have a look at the most popular posts, possibly including:

Say hello on Twitter, Google+, or LinkedIn.

Looking for a way to comment? Comments have been disabled, unfortunately.

Found a mistake? Email me, jens@meiert.com.

You are here: HomeArchive2017 → Privacy Experiments: How to Auto-Generate Random Web Traffic

Last update: December 15, 2017

“The end does not justify the means.”