The officially official Devuan Forum!

You are not logged in.

#1 2020-05-23 14:40:58

siva
Member
Registered: 2018-01-25
Posts: 282  

wifi tool (wefe as a C program)

My wifi script is now a C program. It was a way to practice C for a course.

The biggest caveat is there's no config right now. That means, you'll have to rebuild it if your wireless card identifies as anything other than wlan0. Not sure if it would be better to rebuild for a different wireless interface, pass it as an argument, what the standard is for C config files, etc.

Anyways.

Love it. Hate it. Give valuable critique about it.

https://gitlab.com/souperdoupe/thom-uti … aster/wefe

Offline

#2 2020-05-24 12:17:56

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: wifi tool (wefe as a C program)

siva wrote:

Love it

^ This. Thanks for sharing smile

I can't get it to work in my Debian buster box though.

I edited config.h and substituted wlp4s0 in place of wlan0 then ran

make clean
make
# make install

And tried to run it as root with

E485:~# wefe scan
Incorrect network interface: No such device
E485:~1#

What am I missing here? Does it matter that I'm using systemd?

siva wrote:

critique

It is considered bad practice to run the make command as root, I would prefer to build the package under my normal user and only invoke root privileges to actually install the package (as demonstrated above).

The wpa_supplicant(8) command can be passed a list of potential drivers so your utility can be made to support older devices OOTB by changing the relevant line in config.h to

	"-B -Dnl80211,wext",				// wpasupplicant options

The iwconfig(8) command is now considered obsolete so you could replace that with iw(8) instead: https://wireless.wiki.kernel.org/en/use … e-iwconfig

For example:

				"/sbin/iw %s connect %s",

And finally the wpa_passphrase(8) command generates a configuration file that contains a (commented-out) line with the password in plain text so perhaps it would be best to delete that line. Not sure if your utility already does this though, my C skills are nearly non-existent and I can't try it out for myself at the moment.

HTH


Brianna Ghey — Rest In Power

Offline

#3 2020-05-24 22:25:42

siva
Member
Registered: 2018-01-25
Posts: 282  

Re: wifi tool (wefe as a C program)

Thanks, I'm glad you like it smile And thanks for the feedback. Here's some followup:

I edited config.h and substituted wlp4s0 in place of wlan0 then ran...

That one's on me. The scanner library wasn't accepting the data type for the def.iface. To test, I just dropped "wlan0" directly in that function. Then I forgot to remove it. That should be fixed now.

I also modified the wpasupplicant driver list (idk what others are popular and might be in there as well), and changed iwconfig -> iw ^_^

It is considered bad practice to run the make command as root, I would prefer to build the package under my normal user and only invoke root privileges to actually install the package (as demonstrated above).

Is the suggestion to prevent root from running anything other than make install? I'm confused.

Finally, the removal-of-plaintext-password idea is legit. Not sure how this will look in C, but I went ahead and added a config option in the meantime, just as a reminder.

Last edited by siva (2020-05-24 22:36:54)

Offline

#4 2020-05-24 23:58:59

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: wifi tool (wefe as a C program)

siva wrote:

Is the suggestion to prevent root from running anything other than make install? I'm confused.

Sorry, no, I was just commenting on the README.md which says to run all three steps as root.

Btw you seem to have broken your Makefile the last commit by adding spaces around the = in the PREFIX, FOLDER & CONFIG lines.

An uninstall target in the Makefile would also be nice even though it's only a folder and a single binary.

Another error with the new version:

E485:~# wefe add '1337 h4x0r' 
sh: 1: cannot create /etc/wefe/wefe-sup/1337: Directory nonexistent
Errors occurred while adding 1337 h4x0r.Done.
E485:~#

And yes, I do have a space in my SSID smile

I created /etc/wefe/wefe-sup manually and tried again:

E485:~# wefe add '1337 h4x0r'
Errors occurred while adding 1337 h4x0r.Done.
E485:~#

A file was created at /etc/wefe/wefe-sup/1337 (so perhaps the space was the issue), the content was:

Passphrase must be 8..63 characters

I didn't see my passphrase as I typed it in, not sure if that is intended (I can see it when I use wpa_passphrase(8) manually).

Sorry to be a pain here, I'm sure I'm doing something wrong.


Brianna Ghey — Rest In Power

Offline

#5 2020-05-25 01:25:07

siva
Member
Registered: 2018-01-25
Posts: 282  

Re: wifi tool (wefe as a C program)

Head_on_a_Stick wrote:

...the README.md which says to run all three steps as root.

Fixed.

Btw you seem to have broken your Makefile the last commit by adding spaces around the = in the PREFIX, FOLDER & CONFIG lines.

An uninstall target in the Makefile would also be nice even though it's only a folder and a single binary.

Fixed.

Another error with the new version...space in my SSID smile

Definitely fixed. (It wasn't pointing to the def.config_file path.)

Sorry to be a pain here, I'm sure I'm doing something wrong.

You're not --- the code was the pain ^_^

Offline

#6 2020-05-25 10:17:26

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: wifi tool (wefe as a C program)

It all works now, posting this connected via wefe smile

If deleting the plain-text password line in /etc/wefe/saved/* is too much trouble then perhaps consider using chmod 600 to prevent non-root users from reading the file.

siva wrote:

I also modified the wpasupplicant driver list (idk what others are popular and might be in there as well)

There are only two drivers for wpa_supplicant(8).


Brianna Ghey — Rest In Power

Offline

Board footer