Intercepting Flutter Based Application Traffic Using iptables

Krushna Lipane
4 min readSep 24, 2023

--

Flutter Applications: A Modern Mobile App Framework

Flutter, created by Google, has emerged as a popular open-source framework for building natively compiled applications for mobile, web, and desktop from a single codebase. However, with great power comes great responsibility, and ensuring the security of Flutter applications is paramount.

iptables: Network Traffic Management for Linux

On the other hand, iptables is a powerful utility for configuring and managing network traffic on Linux-based systems. It allows you to define rules that govern how network packets should be handled, including routing, filtering, and even Network Address Translation (NAT).

Understanding the Process

Before we dive into the commands, let’s understand the overall process:

Wireshark for Packet Capture: To route traffic through iptables, you first need to identify the destination IP and port. You can run Wireshark on your local system while your Flutter application is active to capture packets and determine the target IP and port.

Android tcpdump for Packet Storage: Alternatively, you can use ‘Android tcpdump’ to store device packets in a pcap file. This method allows you to capture traffic directly on your Android device.

Using iptables: Once you have the pcap file and know the destination IP and port, you can configure iptables to intercept and route the traffic accordingly.

Setting Up iptables to Capture Application Traffic

We will dive into the practical aspect of configuring iptables to capture traffic originating from a Flutter application. By following a series of iptables commands, we’ll reroute the network traffic from your Flutter application to Burp Suite for interception and to perform pen-testing.

Below commands allow us to intercept traffic destined for a specific IP address and port and redirect it to Burp Suite.

Step 1: DNAT for Forwarding Traffic

iptables -t nat -A PREROUTING -p tcp -d 18.223.74.63 --dport 3000 -j DNAT --to-destination 192.168.1.9:8088
-t nat: Specifies the nat table, which is used for network address translation.
-A PREROUTING: Appends the rule to the PREROUTING chain, which is executed before routing decisions are made.
-p tcp: Filters traffic for the TCP protocol.
-d 18.223.74.63: Specifies the destination IP address you want to intercept.
--dport 3000: Filters traffic destined for port 3000.
-j DNAT --to-destination 192.168.1.9:8088: Redirects the intercepted traffic to the Burp Suite proxy running on your local machine at port 8088.

Step 2: Accept Incoming Traffic

iptables -t nat -A INPUT -i wlan0 -p tcp --dport 8088 -j ACCEPT
-A INPUT: Appends the rule to the INPUT chain, which handles incoming packets.
-i wlan0: Specifies the network interface (wlan0 in this example) where the incoming traffic is expected.
-p tcp: Filters TCP traffic.
--dport 8088: Allows incoming traffic to reach Burp Suite's proxy running on port 8088.

Step 3: REDIRECT Traffic to Burp Suite

iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 3000 -j REDIRECT --to 8088
-A PREROUTING: Appends the rule to the PREROUTING chain for traffic interception.
-i wlan0: Specifies the network interface (wlan0 in this example) where the intercepted traffic originates.
-p tcp: Filters TCP traffic.
--dport 3000: Specifies the source port that the Flutter application uses.
-j REDIRECT --to 8088: Redirects the intercepted traffic to the local Burp Suite proxy on port 8088.
iptables command

Verify the Configuration

To ensure that the iptables rules are correctly set up, you can use the following command.

iptables -t nat -L -n -v

This command will display a list of NAT rules, including the ones you’ve just configured. Verify that they match your intended configuration.

The Final Step - Start Capturing the Requests

With iptables configured, start Burp Suite and configure your device to use your computer as a proxy and run the application.

Proxy Setting
Android Proxy Setting
Request Interception

Once your device’s traffic is intercepted, you can inspect and analyze it in Burp Suite to identify potential security vulnerabilities within the Flutter application.

Happy Hacking !!!

--

--