antiTree | projects and info
posted by antitree on Jun 21, 2017

If you’re like me and want to stand up a quick server that can response on all ports, here’s a quick way to do it. You’ll need a ton of memory to pull this off so setup your machine or VM accordingly. This works for nginx but you’ll have to go through some of the same steps for other services.

Linux Ulimits

Check current ulimits, hard limits, and soft limits on your current account: ulimit -n ulimit -Hn ulimit -Sn

To check them for the “www-data” user you can log in via: sudo su -s /bin/bash www-data

This gist has a pretty good summary of possible nginx configuration options you want to choose.

  • add fs.file-max = 999999 to /etc/sysctl.conf`
  • add www-data soft nofile 999999 and www-data hard nofile 999999 in /etc/security/limits.conf
  • run sysctl -p
  • add worker_rlimit_nofile 999999; in /etc/nginx/nginx.conf`

Listen on all ports

Replace the listening on port 80 and add all of the ports to the /etc/nginx/sites-available/default.

python -c 'for i in range(1,65535): print("\tlisten\t%s;" % i)' > alltheports.txt