Privacy Experiments: How to Auto-Generate Random Web Traffic
Published on DecĀ 15, 2017 (updated FebĀ 5, 2024), filed under misc (feed). (Share this on Mastodon orĀ Bluesky?)
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.Ā āļø
About Me
Iām Jens (long: Jens Oliver Meiert), and Iām a web developer, manager, and author. Iāve been working as a technical lead and engineering manager for companies youāve never heard of and companies you use every day, Iām an occasional contributor to web standards (like HTML, CSS, WCAG), 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. (I value you being critical, interpreting charitably, and giving feedback.)