Internet forwarding from any card with active connection to wlan1

I recently bought an Alpha AWUS1900 wireless adapter. The first “project” I want to use it with is to create a fake access point with captive portal. With hostapd and dnsmasq I can start the access point, but I can’t execute requests with the network card with the active connection and send them back to the connected client. I tried with iptables however it doesn’t work. Also, dnsmasq actually redirects to the hosted page only if I restart it 2 times. On the android devices I use to test the connection, they are almost never redirected, and the message “Log on to the network” only appears that I restart dnsmasq.

List of commands I use: service apache2 start nmcli dev status nmcli dev set wlan1 manage no ifconfig wlan1 down iwconfig wlan1 mode monitor ifconfig wlan1 up ifconfig wlan1 up 10.0.0.1 netmask 255.255.255.0 route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1 ./iptablesRules.sh hostapd hostapd.conf dnsmasq -C dnsmasq.conf -d

I use nmcli dev set wlan1 manage no because my laptop with kali linux gives problem with Network Manager and network card returns to manage mode by itself.

iptablesRules.sh:

“`

!/bin/bash

iptables –flush iptables –table nat –append POSTROUTING –out-interface wlan0 -j MASQUERADE iptables –append FORWARD –in-interface wlan1 -j ACCEPT iptables -t nat -A POSTROUTING -j MASQUERADE

echo “Telling kernel to turn on ipv4 ip_forwarding” echo 1 > /proc/sys/net/ipv4/ip_forward echo “Done. Setting up iptables rules to allow FORWARDING” “`

hostapd.conf:

interface=wlan1 driver=nl80211 ssid=Wifi Gratuito hw_mode=g channel=8 macaddr_acl=0 ignore_broadcast_ssid=0

dnsmasq.conf:

“`

Set the wifi interface

interface=wlan1

Set the IP range that can be given to clients

dhcp-range=10.0.0.10,10.0.0.100,255.255.255.0,8h

Set the gateway IP address

dhcp-option=3,10.0.0.1

Set DNS server address

dhcp-option=6,10.0.0.1

Set Server

server=8.8.8.8

logs

log-queries log-dhcp

Redirect all requests to 10.0.0.1

address=/#/10.0.0.1

address=/www.google.com/10.0.0.1

address=/#.google.com/10.0.0.1

“`

Can anyone help me try to make this work? I have tried any tutorials, and I am very much in the beginning of pentesting and the internet forwarding part I have no idea how it works. Sorry for my bad English.

submitted by /u/rickybeni04
[link] [comments]

April 30, 2023
Read More >>