Commit Diff
Diff:
d7e3cedd521ab0c8074ca448495bee1a1ea146ad
505e1e94c62b2fb5604a061e85ac4dcc994dee06
Commit:
505e1e94c62b2fb5604a061e85ac4dcc994dee06
Tree:
73636948c39407237e94ec1963a55994edab5f5e
Author:
alienus <alienusATcahouetDOTnet>
Committer:
alienus <alienusATcahouetDOTnet>
Date:
Sun Mar 29 17:41:09 2015 UTC
Message:
plop
blob - /dev/null
blob + 784de3e998b338f713148a2662a63908bade0487 (mode 755)
--- /dev/null
+++ rezo
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+#
+# rezo.pl
+#
+# Copyright 2015 Frédéric Galusik <alienus~at~cahouet~dot~net>
+# License: BSD Revised
+#
+########################################################################
+
+use strict;
+use warnings;
+use 5.010;
+use Getopt::Long;
+use re;
+#use Data::Dumper;
+
+# check root
+( $< == 0 ) or die "Sorry, but only root can play with networks, aborting...\n";
+
+# rezo version
+my $VERSION = '0.0';
+
+# wireless interface & ifconfig path
+my $nwif = 'iwn0';
+my $ifconfig = '/sbin/ifconfig';
+# help
+sub usage {
+ say "Usage: $0 [options]\n";
+ say "Options:";
+ say " -v | --version\t\tprint rezo version";
+ say " -h | --help\t\tprint this message";
+ exit 0;
+ }
+
+# CLI options
+my ($help, $version);
+GetOptions(
+ 'version' => \$version,
+ 'help' => \&usage,
+ );
+
+if ($version) {
+ say "Rezo, version $VERSION";
+ say "Copyright 2015 Frédéric Galusik";
+ say "https://gitlab.com/alienus/rezo";
+ exit 0;
+ }
+#else {
+# die "Wrong usage, run rezo --help for informations.\n";
+# }
+
+# check
+sub check_ifc {
+ if ( ! -e $ifconfig ) {
+ die "$ifconfig is not installed, aborting...\n";
+ }
+}
+check_ifc();
+
+# status
+
+
+# scan
+my @netlist;
+#my ($nwid,$SSID,$chan,$channb,$bssid,$bssidn,$db,$agn,$desc);
+sub scan {
+ open SCANR, "$ifconfig $nwif scan |" or die "Error: $!\n";
+ while (<SCANR>) {
+ s/^\s*//;
+ chomp;
+ if ( ! /^nwid/ ) {
+ next;
+ }
+ #if ( /^nwid/) {
+ # my $line = $_;
+# if ( /\"\w+[\s\w+]*\"/ ) {
+ if ( /(^nwid\s")(.*)(".*)/ ) {
+ # $line =~ /(.*)(\"\w+[\s\w+]*\")(.*)/;
+# $_ =~ /(.*)(\"\w+[_\w+]*\")(.*)/;
+ my $un = $1;
+ my $rep = $2;
+ my $trois = $3;
+ $rep =~ s/\s/_/g;
+ $_ = $un . $rep . $trois;
+ }
+ #say "$line";
+ push @netlist, [ split ];
+ # nwid NEUF_B7B4 chan 1 bssid 00:17:33:c8:b7:b8 220dB 54M privacy,short_slottime,wpa2
+ #my ($nwid,$SSID,$chan,$channb,$bssid,$bssidn,$db,$agn,$desc) = ($1,$2,$3,$4,$5,$6,$7,$8,$9);
+
+ }
+ close SCANR;
+ return @netlist;
+}
+scan();
+
+
+my $inet = @netlist;
+# http://fr.perlmaven.com/les-tableaux-en-perl
+sub test {
+ for my $i (0 .. ($inet - 1) ) {
+ #say "$n";
+ say "$netlist[$i][1]\t\t: $netlist[$i][6]";
+ }
+}
+test();
Frédéric Galusik