[Linux服务器] Linux WIFI 扫描

664 0
Honkers 2025-3-16 04:37:38 | 显示全部楼层 |阅读模式

 启动wifi服务

  1. connmanctl disable wifi
  2. connmanctl enable wifi
  3. ifconfig wlan0 down
  4. ifconfig wlan0 up
复制代码

wpa_supplicant包含两个主要的可执行工具:wpa_supplicant和wpa_cli。

wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。

大部分情况下编辑好配置文件,运行wpa_supplicant 就可以连通网络了,

创建一个  wpa_supplicant.conf

可以     

echo "update_config=1" > /tmp/ema_wpa_supplicant.conf
echo "ctrl_interface=/var/run/wpa_supplicant" >> /tmp/ema_wpa_supplicant.conf

  1. vi /tmp/wpa_supplicant.conf
复制代码
  1. ctrl_interface=/var/run/wpa_supplicant
  2. update_config=1
  3. 其中,update_config=1使能配置更改。
复制代码

 关闭  wpa_supplicant

 kill -9 `pgrep wpa_supplicant`

wpa_supplicant 命令如下

  1. usage:
  2. wpa_supplicant [-BddhKLqqtuvW] [-P<pid file>] [-g<global ctrl>] \
  3. [-G<group>] \
  4. -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
  5. [-b<br_ifname>] [-e<entropy file>] [-f<debug file>] \
  6. [-o<override driver>] [-O<override ctrl>] \
  7. [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
  8. [-m<P2P Device config file>] \
  9. [-p<driver_param>] [-b<br_ifname>] [-I<config file>] ...]
  10. drivers:
  11. nl80211 = Linux nl80211/cfg80211
  12. wext = Linux wireless extensions (generic)
  13. wired = Wired Ethernet driver
  14. options:
  15. -b = optional bridge interface name
  16. -B = run daemon in the background
  17. -c = Configuration file
  18. -C = ctrl_interface parameter (only used if -c is not)
  19. -d = increase debugging verbosity (-dd even more)
  20. -D = driver name (can be multiple drivers: nl80211,wext)
  21. -e = entropy file
  22. -f = log output to debug file instead of stdout
  23. -g = global ctrl_interface
  24. -G = global ctrl_interface group
  25. -h = show this help text
  26. -i = interface name
  27. -I = additional configuration file
  28. -K = include keys (passwords, etc.) in debug output
  29. -L = show license (BSD)
  30. -m = Configuration file for the P2P Device interface
  31. -M = start describing new matching interface
  32. -N = start describing new interface
  33. -o = override driver parameter for new interfaces
  34. -O = override ctrl_interface parameter for new interfaces
  35. -p = driver parameters
  36. -P = PID file
  37. -q = decrease debugging verbosity (-qq even less)
  38. -t = include timestamp in debug messages
  39. -u = enable DBus control interface
  40. -v = show version
  41. -W = wait for a control interface monitor before starting
  42. example:
  43. wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
复制代码

 其中最常用的为:

-i 指定端口

-c 指定配置文件

-D 指定使用的wifi驱动

我们这里只指定端口和配置文件,驱动使用默认的。

 查看网卡端口 ifconfig

  1. 使用以下命令配置
  2. wpa_supplicant -i wlan0 -D nl80211 -c/tmp/ema_wpa_supplicant.conf -B
复制代码

 

  1. wpa_cli -i wlan0 scan 扫描
  2. sleep 10
  3. wpa_cli -i wlan0 scan_results | grep "$2"
复制代码

 

 这样就测试WiFi成功

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Honkers

特级红客

关注
  • 3025
    主题
  • 36
    粉丝
  • 0
    关注
这家伙很懒,什么都没留下!

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行