You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用airbase-ng搭建的Evil Twin伪WiFi热点无法联网的问题求助

airbase-ng搭建的Evil Twin伪WiFi热点无法联网的问题求助

大家好,我正在尝试用airbase-ng搭建伪AP来测试Evil Twin攻击的原理,但遇到了设备能连热点却无法联网的问题,想请各位帮忙排查一下。

先说说我的环境:

  • 网卡:TP-link WN4226(Atheros AR9271芯片组),支持监听模式
  • 系统:Ubuntu 20.04 LTS
  • 笔记本自带WiFi适配器已经连到正常的WPA-PSK网络(ESSID: Mir_Sahib),TP-link是额外的USB网卡

操作步骤回顾

  1. 初始网卡状态(ifconfig输出):

    wlp4s0    IEEE 802.11  ESSID:"Mir_Sahib"
            Mode:Managed  Frequency:2.412 GHz  Access Point: 90:8D:78:0F:FE:CE
            Bit Rate=150 Mb/s   Tx-Power=22 dBm
            Retry short limit:7   RTS thr:off   Fragment thr:off
            Power Management:on
            Link Quality=70/70  Signal level=-33 dBm
            Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
            Tx excessive retries:0  Invalid misc:291   Missed beacon:0
    
    wlxf8d111129a12  IEEE 802.11  ESSID:"Mir_Sahib"
            Mode:Managed  Frequency:2.412 GHz  Access Point: 90:8D:78:0F:FE:CB
            Bit Rate=40.5 Mb/s   Tx-Power=20 dBm
            Retry short limit:7   RTS thr:off   Fragment thr:off
            Power Management:off
            Link Quality=69/70  Signal level=-41 dBm
            Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
            Tx excessive retries:0  Invalid misc:18   Missed beacon:0
    
    enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            ether 8c:16:45:82:04:49  txqueuelen 1000  (Ethernet)
            RX packets 12337  bytes 13508188 (13.5 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 8993  bytes 1146468 (1.1 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
            device interrupt 16  memory 0xec200000-ec220000
    
    wlp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.0.9  netmask 255.255.255.0  broadcast 192.168.0.255
            inet6 fe80::7d86:5034:5192:6952  prefixlen 64  scopeid 0x20<link>
            ether 5c:5f:67:d0:44:be  txqueuelen 1000  (Ethernet)
            RX packets 17280  bytes 16222452 (16.2 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 10496  bytes 1788185 (1.7 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlxf8d111129a12: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
            inet6 fe80::3ff:6be8:710d:7bf8  prefixlen 64  scopeid 0x20<link>
            ether f8:d1:11:12:9a:13  txqueuelen 1000  (Ethernet)
            RX packets 264  bytes 34466 (34.4 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 112  bytes 21293 (21.2 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    自带网卡wlp4s0和TP-link网卡wlxf8d111129a12都连在正常网络上,各自获取了192.168.0.9和192.168.0.10的IP,有线网卡enp0s31f6没启用。

  2. 开启监听模式:

    • 先执行airmon-ng check kill杀掉所有可能干扰的进程
    • 给TP-link网卡开启监听模式:airmon-ng start wlxf8d111129a12,网卡名称变成wlan0mon,状态显示为Monitor模式
    • 重启NetworkManager保证笔记本能正常联网:service NetworkManager start
  3. 启动伪AP:
    执行airbase-ng -e Demo -c 11 wlan0mon,我的手机(Redmi Note7)能搜索到名为Demo的伪热点,也能成功连接。

  4. 配置DHCP和DNS(dnsmasq.conf):
    我的配置文件内容如下:

    interface=at0
    dhcp-range=10.0.0.20,10.0.0.250,255.255.255.0,12h
    dhcp-option=3,10.0.0.1
    dhcp-option=6,10.0.0.1
    server=8.8.8.8
    server=8.8.4.4
    server=64.6.64.6
    server=64.6.65.6
    log-queries
    log-dhcp
    port=5353
    listen-address=127.0.0.1
    

    启动dnsmasq:dnsmasq -C dnsmasq.conf -d

  5. 配置iptables转发规则:
    我写了一个脚本执行以下规则:

    ifconfig at0 up
    ifconfig at0 mtu 1500
    ifconfig at0 10.0.0.1 netmask 255.255.255.0
    route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.0.1
    iptables --table nat --append POSTROUTING --out-interface enp0s31f6 -j MASQUERADE
    iptables --append FORWARD --in-interface at0 -j ACCEPT
    iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.0.11:80
    

    我试过把--out-interface改成wlp4s0(笔记本连网的无线网卡),但还是不行。

当前问题

手机能成功连接Demo伪热点,但完全没有网络访问权限。我怀疑是iptables转发规则哪里出了问题,但自己查不出来。也看到有人用captive portal的方式,但还没尝试,想先解决基础的联网问题。

有没有大佬能帮我看看哪里错了?

备注:内容来源于stack exchange,提问作者mirsahib

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 14:54:07