Firewall Evasion Flashcards

1
Q

Read/ Firewalls can be too restrictive, making it inconvenient for users. For example, many
companies and schools enforce egress filtering, which blocks users inside of their
networks from reaching out to certain websites or Internet services, such as game
and social network sites.
* There are many ways to evade firewalls. A typical approach is to use the tunneling
technique, which hides the real purposes of network traffic.
* There are a number of ways to establish tunnels. The two most common tunneling
techniques are Virtual Private Network (VPN) and port forwarding.

A

done

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Setup:Firewall Rules

// Ingress filtering: only allows SSH traffic
iptables -A FORWARD -i eth0 -p tcp -m conntrack \
–ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp –dport 22 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp -j DROP

// Egress filtering: block www.example.com
iptables -A FORWARD -i eth1 -d 93.184.216.0/24 -j DROP
what does it do?

A

-Allows TCP packets to come in if they belong to an established or related connection (stateful firewall rule).

-Allows SSH

-Drops all other TCP packets if they do not satisfy the first or the second rule.

-Egress firewall rule, and it prevents the internal hosts from sending packets to 93.184.216.0/24 (www.example.com)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Setup: VPN Tunneling: Ingress Firewall

Set Up A VPN Tunnel:
* Client: Home
* Server: Apollo

A

ssh -w 0:0 root@192.168.60.5 \
-o “PermitLocalCommand=yes” \
-o “LocalCommand= ip addr add 192.168.53.88/24 dev tun0 && \
ip link set tun0 up” \
-o “RemoteCommand=ip addr add 192.168.53.99/24 dev tun0 && \
ip link set tun0 up”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is LocalCommand and RemoteCommand

A

The LocalCommand entry specifies the command
running on the VPN client side. It configures the
client-side TUN interface

The RemoteCommand entry specifies the command
running on the VPN server side. It configures the
server-side TUN interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ssh -w 0:0 root@192.168.60.5 \
-o “PermitLocalCommand=yes” \
-o “LocalCommand= ip addr add 192.168.53.88/24 dev tun0 && \
ip link set tun0 up” \
-o “RemoteCommand=ip addr add 192.168.53.99/24 dev tun0 && \
ip link set tun0 up”
what does it do?

A

This SSH command creates a point-to-point VPN tunnel using tun0 on both the client and the server.
It uses LocalCommand to configure the client’s tun0 interface, and RemoteCommand to configure the server’s tun0 interface with IP addresses 192.168.53.88 and 192.168.53.99 respectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ip route replace 192.168.60.0/24 dev tun0

A

This command routes all traffic to the 192.168.60.0/24 network through the VPN tunnel (tun0).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ip route add 192.168.60.5/32 via 10.9.0.11

A

This command ensures that traffic to the VPN server (192.168.60.5) goes through the regular network, not the VPN tunnel, to avoid breaking the SSH connection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

iptables -t nat -A POSTROUTING -j MASQUERADE -o eth0

A

This command enables NAT on the server. It makes traffic from the VPN client appear as if it’s coming from the server’s IP address before going out to the internet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ssh -4NT -L 8000:192.168.60.6:23 seed@192.168.60.5

A

This command sets up local port forwarding. It allows the Home machine to access 192.168.60.6:23 (Work) through Apollo by connecting to localhost:8000.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ssh -4NT -L 8000:www.example.com:80 seed@10.9.0.5

A

This command sets up a local port forwarding tunnel from Apollo to www.example.com:80 through Home. It is used to bypass an Egress Firewall that blocks access to the website.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

curl –proxy localhost:8000 http://www.example.com

A

here you can access the blocked site

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ssh -4NT -R 0.0.0.0:8000:192.168.60.6:80 seed@10.9.0.5

A

This command creates a reverse SSH tunnel from Apollo to Home. It allows the Home machine to access the internal web server (192.168.60.6:80) through port 8000 on localhost.
This is useful for bypassing an ingress firewall that blocks direct access to the web server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Static Port Forwarding?

A
  • Destinations are fixed
  • One tunnel for each destination
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q: What is Dynamic Port Forwarding (SOCKS5 Tunnel)?

A
  • Destinations are NOT fixed
  • One tunnel for many destinations
  • Therefore, typically called Proxy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q: What does the command ssh -4NT -D 9000 seed@10.9.0.5 do?

A

It creates a SOCKS5 proxy on Apollo at port 9000, allowing traffic to be routed through Home (10.9.0.5).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

curl –proxy socks5h://localhost:9000 https://www.example.com

A

Use localhost:9000 as a proxy and you can access the website

17
Q

How does the dynamic port forwarding work?

A
  • The destination is not specified
  • The client must tell the proxy the destination information
  • The client and proxy use a protocol for that purpose
18
Q

SOCKS protocol

A
  • Socket secure, version 5 (SOCKS5)
  • The client must have a native support of SOCKS protocol
19
Q

nc -lv 8080

A

start a server: we will access it via a proxy

20
Q

What Happens Between Client and Proxy

A
  • Client and Proxy establish a TCP connection
  • Using the TCP connection, Client and Proxy initiate the SOCKS protocol.
    • Client tells Proxy the destination of the port forwarding (10.9.0.5:8080).
    • The port forwarding setup is complete
  • Proxy forwards the traffic from one end of the tunnel to the other end,
    from where the data will be further forwarded to the final destination (10.9.0.5:8080)
21
Q

Q: What are SOCKS5 and VPN both used for?

A
  • Bypassing firewall
  • Protecting communication
22
Q

Q: Is SOCKS5 proxy transparent?

A

No, it is not transparent. You must configure each application to use it.

23
Q

Q: Is VPN transparent?

A

Yes, it is system-wide and doesn’t need per-app configuration.

24
Q

Which is easier to set up: SOCKS5 or VPN?

A

SOCKS5 is easier. VPN is more complex.

25
Can one SOCKS5 tunnel be used by multiple applications?
No, it’s application-specific. Each app needs its own config.
26
Is VPN tunnel shared by many apps?
Yes, VPN works for all applications once connected.
27
Does SOCKS5 encrypt traffic?
It depends on the application.
28
Does VPN encrypt traffic?
Yes, VPN always encrypts the tunnel.