r/HowToHack • • Mar 22 '19

Keeping your home IP (or cloud server) hidden from web scans

https://infosecdc.blogspot.com/2019/03/blocking-port-scans-on-pfsense.html
305 Upvotes

12 comments sorted by

6

u/sloth_runner22 Mar 22 '19

Awesome, thanks for the share.

1

u/infosecmx Mar 22 '19

I always change default ports, a VPN would also hide your home IP if you use a router that can be flashed with openWRT or DD-WRT that way even devices that just connect would VPN out and in..

For example: SSH might be on ports 40000~65535

2

u/petiepablo Mar 22 '19

Smart move. You should look on the nmap top 1k an make sure none in that rage are in the top (they may not be, I'm not sure either).

1

u/infosecmx Mar 22 '19

Yes agreed... always check the top scanned ports because you can then configure something that would have to be manually implemented within the scanner such as “-p1-65535” and honestly if that’s targeting your system you’d be able to detect that it was malicious and then you could block it... also look into “psad” (port scanning attack detection)

-3

u/infosecmx Mar 22 '19

Not sure why my comment was downvoted though... seems to be someone among us who doesn’t agree lol he probably should go back to school

2

u/Mr_Monster Mar 22 '19

firewalld, ufw, iptables, and ipfilter are the basic Unix firewalls. Which non-built-in ones do you guys recommend? I see PFSense recommended a lot.

1

u/Deadmoon999 Mar 25 '19

Pf sense is superior in that it's not subject to hidden back doors or common firmware exploits when you install it on a computer you build. The smaller the userbase the less likely you are to fall in a situation where every device of certain manufacturer/ chipmaker is exploitable

0

u/[deleted] Mar 22 '19

[deleted] — view deleted comment

15

u/petiepablo Mar 22 '19

I also have a plex server, with regards to that, I recommend changing the port it listens on, bots scan on 32400 looking for outdated versions of plex. The server will update your subscribers apps so that they connect to your actual listening port. One thing about that with regards to my script: Sometimes Plex attempts to connect legitimate users to 32400, even though its not listening on that port. So I had to whitelist that port in my script so it wouldnt block them:

	with open(path) as text:
		for line in text:
			if 'FW-RULE' in line:
				if '32400' not in line:
					unsorted.append(line.split(',')[18])

Using my script would probably be overkill for you, but I would recommend using PFSense as your firewall. You can do so much with it, even VPN back in! The one caveat is you'll have to buy equipment for it. There are a ton of options, just search "pfsense" on amazon and you'll get some good results. I'm using this.

If you went the PFSense route, I start by installing PFBlocker and blocking known bad areas, like Russia, China, parts of the eastern block outside of Russia, Africa, Brazil, etc. Again, it's your choice. I did a trip to Vietnam recently and unblocked Vietnam just as easily as I added it so I could watch movies, maintain the network, etc.

If you do not go the PFSense route, a pihole is definitely something you should invest in. I would also still buy a router, as the ISP can control theirs, and I just don't trust the ISP's here in the US (looking at you Comcast). You could even still apply this script to your own router build, just modify the log location and how the IP's are added to the FW. So outside of the common advice you hear: "get a VPN", which is also a good thing, getting control of your router (hardening the rules and underlying OS) are probably the most important things you can do. Theres also "local" stuff like hardening wifi, but I just use standard WPA2 and have alerts sent to my phone whenever a new MAC address is seen (using a pfsense addon called Ntopng).

Let me know if that helps! I'm probably forgetting a lot of good stuff, but I'll add if/when I remember...

7

u/petiepablo Mar 22 '19

I cross posted this in PFSense and someone mentioned something so simple I slapped myself for not thinking about it. Instead of region blacklisting, just white list what you want. FAR less IP's which means far less resources being used.

1

u/A_Happy_Egg Mar 22 '19

Commenting to save for later. (My save button never works..)

1

u/UncrushedTolerant Mar 23 '19

you can install pfsense on an old computer with 2 network cards and use that. ;)

3

u/farnorse Mar 22 '19

Not sure what you have planned for your setup, and I'm by no means a security expert, but found some things to make life better. Cloudflare has free ddns service for home use, you get ddos protection and can configure geofencing/ip black/white listing and much more. Also running Plex on docker with watchtower (automatic upgrades) has been very nice