Privacy Experiments: How to Auto-Generate Random Web Traffic

Published on December 15, 2017 (↻ February 5, 2024), filed under (RSS feed for all categories).

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 is a risk for 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 neutrality—no!—are therefore, in my view, direct threats to our individual and collective rights and well-being.

This all holds particularly as there are agents like the United States and England who infringe on non-American and non-British people’s rights (or have they declared war on us 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.

Not to dive deeper into the topic, and without commenting on my motivation—many of you know how I love experimenting—, 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 also set up to 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 for improvement 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):

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. I hope it works for you (and please let me know about improvements for the setup described here).

The only trouble-shooting notes I can make, 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). Also, eventually you need to “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 thoughts for improvements. âśŚď¸Ź

Was this useful or interesting? Share (toot) this post, become a one-time nano-sponsor, or support my work by learning with my ebooks.

About Me

Jens Oliver Meiert, on November 9, 2024.

I’m Jens (long: Jens Oliver Meiert), and I’m a frontend engineering leader and tech author/publisher. I’ve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, I’m a contributor to several web standards, and I write and review books for O’Reilly and Frontend Dogma.

I love trying things, not only in web development (and engineering management), but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (Please be critical, interpret charitably, and give feedback.)