What's new

Join to Wireless network with CLI

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

mmbonsai

New Around Here
Hello Guys!

I'm working on an RT-N66U for a while and try to join to a wireless network which has encryption but could not succeed.
If I try to join to an open wifi network it works after the following commands:
Code:
udhcpc -i eth1 -s /tmp/udhcpc -O33 -O249
wl ap 0
wlconf eth1 up
wl -i eth1 join MyNetwork imode bss amode open

At this point I'll get an IP address but it will not be assigned to the interface. So I have to assign it manually with the following command:

Code:
ifconfig eth1 OFFERED_IP up


To join to an encrypted network I tried the following:
Code:
wl -i eth1 wpa_auth 0x80
wl -i eth1 wsec 4
wl -i eth1 join MyNetwork key 64_LONG_HEX imode bss amode open

From AP site I got the following log:
Dec 1 15:37:21 onebox hostapd: wlan0: STA 70:8b:cd:c6:d0:e0 IEEE 802.11: authenticated
Dec 1 15:37:21 onebox hostapd: wlan0: STA 70:8b:cd:c6:d0:e0 IEEE 802.11: associated (aid 1)
Dec 1 15:37:23 onebox hostapd: wlan0: STA 70:8b:cd:c6:d0:e0 IEEE 802.11: authenticated
Dec 1 15:37:23 onebox hostapd: wlan0: STA 70:8b:cd:c6:d0:e0 IEEE 802.11: associated (aid 1)
.
.
.

No authentication and handshaking, do you have any idea what is the correct way to join an encrypted wifi network through CLI?

(AsusWRT-Merlin 380.69 alpha1)
 
I tried to catch the call of the wlconf/wlcconnect/wl commands but they are on read-only filesystem so can not create any dummy runnable to log the parameters.
 
I tried to catch the call of the wlconf/wlcconnect/wl commands but they are on read-only filesystem so can not create any dummy runnable to log the parameters.

I wrote this script to track ip/iptables command invocations. You should be able to modify the script to track your desired commands.

/jffs/scripts/Trace_cmd.sh

e.g. Change line 35
Code:
ip|iptables)
to
Code:
wlconf|wl)
then set up the command tracing
Code:
./Trace_cmd.sh   wlconf
./Trace_cmd.sh   wl

Code:
#!/bin/sh
VER="v01.01"
#======================================================================================================= © 2016-2017 Martineau, v01.01
#
# Create a trace of command execution requests to Syslog for the following selected commands
#
#  ip
#  iptables
#
#          Trace_cmd     {['ip | 'iptables]}' [reset]
#
#          Trace_cmd     ip
#                        Tracing of 'ip' commands will be enabled. (Useful if called by 'init-start' ?)
#          Trace_cmd     ip reset
#                        Tracing of 'ip' commands will be disabled.
# Print between line beginning with '#==' to first blank line inclusive
ShowHelp() {
 awk '/^#==/{f=1} f{print; if (!NF) exit}' $0
}
ANSIColours () {
 cRESET="\e[0m";cBLA="\e[30m";cRED="\e[31m";cGRE="\e[32m";cYEL="\e[33m";cBLU="\e[34m";cMAG="\e[35m";cCYA="\e[36m";cGRA="\e[37m"
 cBGRA="\e[90m";cBRED="\e[91m";cBGRE="\e[92m";cBYEL="\e[93m";cBBLU="\e[94m";cBMAG="\e[95m";cBCYA="\e[96m";cBWHT="\e[97m"
 aBOLD="\e[1m";aDIM="\e[2m";aUNDER="\e[4m";aBLINK="\e[5m";aREVERSE="\e[7m"
 cRED_="\e[41m";cGRE_="\e[42m"
}
#===============================================Main===================================================

ANSIColours

# Create a substitute wrapper script to intercept the real command and write the trace message to Syslog before calling the original true command
case $1 in
 ip|iptables)
  case $1 in
   iptables)
    umount /usr/sbin/xtables-multi 2> /dev/null
    rm /tmp/xtables-multi 2> /dev/null
    ;;
   *)
    umount /usr/sbin/$1 2> /dev/null
    rm /tmp/$1 2> /dev/null
    ;;
  esac
 
  #
  if [ "$2" != "reset" ];then
 
   cp /usr/sbin/$1 /tmp/$1       # Clone the original cmd
 
   # Create the wrapper script to emulate the original cmd
   echo -e "#/bin/sh\n\n# Fake '$1' command - wrapper script (Created $(date) by $0)\n"          > /tmp/fake$1
   echo -e "echo -e \"\e[33m\"\n# Write trace message to Syslog and console display terminal"   >> /tmp/fake$1
   # logger hates '-' chars in the string to be printed!!!!!!!
   #echo -e "logger -st \"(\$(basename \$0))\" \$\$ \"**TRACE: cmd request--> $1\" \"\$*\""     >> /tmp/fake$1
   echo -e "echo -e \"\$(date \"+%b %d %T\") \$(nvram get productid) spoof.logger (\$(basename \$0)) \$\$ **TRACE: cmd request--> $1\" \$* >>/tmp/syslog.log" >> /tmp/fake$1
   echo -e "echo -e \"**TRACE: cmd request--> $1\" \$*\n"                                       >> /tmp/fake$1
   echo -e "echo -e \"\e[0m\"\n"                                                                >> /tmp/fake$1
   echo -e "/tmp/$1 \$*\t\t\t# Call clone of required original command\n\n\nexit 0"             >> /tmp/fake$1
 
   chmod +x /tmp/fake$1        # Ensure 'fake' command can execute
 
   mount -o bind /tmp/fake$1 /usr/sbin/$1
 
   echo -e $cBGRE
   logger -st "($(basename $0))" $$ "Fake '/tmp/$1' wrapper script enabled - will write '$1' invocation trace messages to Syslog....."
   echo -e $cRESET
  else
   echo -e $cBYEL
   logger -st "($(basename $0))" $$ "Fake '/tmp/$1' command deleted, and '$1' invocation trace messages to Syslog disabled."
   echo -e $cRESET
  fi
  ;;
 *)
  echo -e "\a\n\t$cBRED**ERROR cmd to be substituted '"$1"' not defined to be traceable!!\n"$cRESET
  exit 99
  ;;
esac
 
Last edited:
Thank you very much for your help, this script worked very well but the wl/wlconf is not called during start-up. Which basically means that they are build the driver calls inside the Firmware. So I'm still not able to reconnect to a different network especially in router mode as a client.
 
the script needs to call the wpa_supplicant when attaching to a secure network...
 
the script needs to call the wpa_supplicant when attaching to a secure network...
Actually, Broadcom doesn't use the supplicant.....it calls it's own closed source 'nas' component (just went through that update when porting the KRACK fix)
 
Actually, Broadcom doesn't use the supplicant.....it calls it's own closed source 'nas' component (just went through that update when porting the KRACK fix)

That's right, having a senior moment, LOL...

Anyways - one does have to pass along the credentials so the WPA handshake is successful..
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top