Simple Security Questions lainchan / sec ---------------------------------------------------------------------- sec · 2019-07-01 05:59 This is the Simple Security Questions thread for simple questions. If you have a simple question and a suitable thread doesn't already exist, just post it here and someone will probably try to answer it for you. Remember to do some research before asking your question. No one wants to answer a question that a simple search can already resolve. ---------------------------------------------------------------------- Ivan Petrov · 2019-07-01 19:59 Lains, I need help configuring a firewall and nat using iptables. I am simulating a net using mininet, pic is a graphic of the net. In r2 I have executed the following command: iptables -I FORWARD -j DROP iptables -A FORWARD -p TCP --sport 80 -s 10.0.1.2 -j ACCEPT iptables -t nat -A PREROUTING -p tcp --dport 80 -i r1-eth0 -j DNAT --to 10.0.1.2 The idea is that h2 makes an http request to r2 and r2 sends the request to the server in h1 (10.0.1.2) What I do is execute nc -l 80 in h1 and then execute wget http://10.0.1.1 in h2. It gets stuck in --2019-07-01 16:58:21-- http://10.0.1.1/ Connecting to 10.0.1.1:80... What am I doing wrong? ---------------------------------------------------------------------- Ender · 2019-07-02 17:22 >>7985 What does nmap say? ---------------------------------------------------------------------- Emmanuel · 2019-07-02 19:42 >>7986 I don't really know what you want me to do with that, but I did execute nmap in h2 to r2 and it said: Starting Nmap 7.60 ( https://nmap.org ) at 2019-07-02 16:40 -03 Nmap scan report for 192.168.100.1 Host is up (0.00067s latency). Not shown: 999 closed ports PORT STATE SERVICE 80/tcp filtered http Nmap done: 1 IP address (1 host up) scanned in 20.08 seconds nmap from h2 to h1: Starting Nmap 7.60 ( https://nmap.org ) at 2019-07-02 16:39 -03 Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn Nmap done: 1 IP address (0 hosts up) scanned in 3.12 seconds ---------------------------------------------------------------------- Cutter · 2019-07-02 19:59 >>7989 >Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn Try that when doing h2 to h1. See if it returns the port as open. Just looking at the config, there's a couple things that I think it could be, although I could be wrong. > iptables -I FORWARD -j DROP From the man page: >Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1, the rule or rules are inserted at the head of the chain. This is also the default if no rule number is specified. Since you're not specifying a rule number, this becomes the first rule in the list. > iptables -A FORWARD -p TCP --sport 80 -s 10.0.1.2 -j ACCEPT Again, according to the man page: > Append one or more rules to the end of the selected chain. Wouldn't this mean that the DROP rule is evaluated before the ACCEPT rule? Also, designating the source port as 80 won't work, since h2 is likely going to attempt to connect to h1 using an ephemeral port. You'd likely instead want to change that to be destination port. I honestly have no idea and could be completely off base here, as I've never really manually configured iptables rules. ---------------------------------------------------------------------- SHODAN · 2019-07-02 22:28 >>7990 I fixed it, thanks. You made me question my self how well I know how firewall rules and read. I was wrong. >Also, designating the source port as 80 won't work, since h2 is likely going to attempt to connect to h1 using an ephemeral port. I think you got it backwards. The server is in h1, h1 is going to connect to an ephemeral port in h2 ---------------------------------------------------------------------- Tank · 2019-07-03 15:49 Anyway, I still don't understand why it wasn't working. h2 is sending data directly to r2, so the packets should have been compared with input rules, not forward ---------------------------------------------------------------------- Yamaoto Toshi · 2019-07-03 16:41 >>7991 Since it's stateful, wouldn't the source port be the ephemeral port from the client, and the destination port would the listener on the server? >>7996 Man page says the following: > It contains the built-in chains INPUT (for packets destined to local sockets), FORWARD (for packets being routed through the box), and OUTPUT (for locally-generated packets). Since the packets aren't destined for local sockets, it would be handled by FORWARD, not INPUT. ---------------------------------------------------------------------- Eldon Tyrell · 2019-07-03 19:12 >>7997 >wouldn't the source port be the ephemeral port from the client, and the destination port would the listener on the server? That is correct, but that is for the packet that goes from the client to the server. The rule is for the router to let the web server's answer go through (the packets that go from the server to the client), these packets will have source port 80 right? >Since the packets aren't destined for local sockets, it would be handled by FORWARD, not INPUT. Why isn't it destined to local socket? I did wget http://*ip of router 2* wouldn't that send it to a local socket of r2? is it because there is no program listening in port 80 (i.e there is no local socket) that is handled by FORWARD? ---------------------------------------------------------------------- Jean Dupont · 2019-07-03 21:57 >>7998 You'd be better off using --state ESTABLISHED, RELATED ---------------------------------------------------------------------- William Holtzer · 2019-07-08 07:15 Is port 80 in i2p tunnel configuration secure? Specifically asking because of what I've seen in this guide. And I have to configure php to something. https://github.com/eyedeekay/basic-tunnel-tutorial ---------------------------------------------------------------------- Hououin Kyouma · 2019-07-11 17:48 By the time I finally figure out iptables, everyone will have moved on to nftables. Then by the time I figure that out, bpfilter will be the new hotness and I'll forever be left in the dust. ugh I should just say fuarrrk it, move to BSD and figure out pf. ---------------------------------------------------------------------- Guthrie · 2019-07-15 18:31 And if not, how do secure it? This is my LUKS-on-LVM setup: Two hard drives are in LVM RAID configuration with both / and /home logical volumes encrypted with LUKS. Next I have an SSD with one unencrypted partition for boot and the rest is set as an LVM cache for the raid volume group. Now I don't know how to directly encrypt the cache *and* decrypt root at boot. Nor can I do LVM on LUKS on LVM because then I wouldn't be able to specify the raid or cache setup. Right now I'm banking that because its LUKS on LVM whatever is written to the LVM is encrypted already. But I don't know for sure. ---------------------------------------------------------------------- tryhard · 2019-07-16 01:05 Been searching around and can't find anything on this. I'm trying to crack a simple box which accepts an image attribute through a HTML POST form. The form looks like this: