Active Topics

 


Reply
Thread Tools
Yeshua's Avatar
Posts: 38 | Thanked: 19 times | Joined on Jan 2012 @ 127.0.0.1
#1
I'm fed up with several bugs (number one, the fact that I regularly don't get a ringtone when I receive an SMS), so I'm trading my N9 for a Samsung Galaxy S4 Mini. My godchild is the new N9 owner.

One thing that I want to do is duplicating my Wi-Fi connections. SSID isn't a problem, but there are several hidden (WPA Pre-Shared) Keys that I forgot. Is there a way to show these or are they lost forever?
__________________
Man is virus.

I my N9 16GB Black.
(059J201 RM-696 NDT BENELUX BLACK 16GB)
 

The Following 2 Users Say Thank You to Yeshua For This Useful Post:
HtheB's Avatar
Moderator | Posts: 3,718 | Thanked: 7,419 times | Joined on Dec 2009 @ Bize Her Yer Trabzon
#2
Here you go: http://store.ovi.com/content/257443
QAD WLAN Password Recovery

TMO Thread: http://talk.maemo.org/showthread.php?t=82489
__________________
www.HtheB.com
Please donate if you think I'm doing a good job.
 

The Following 3 Users Say Thank You to HtheB For This Useful Post:
Posts: 151 | Thanked: 158 times | Joined on Apr 2012 @ UK
#3
From memory, using the following command in terminal can display the SSID and related key:

gconftool -R

Save all output with:

gconftool -R > /home/user/MyDocs/output.txt
 

The Following 3 Users Say Thank You to Nad For This Useful Post:
Yeshua's Avatar
Posts: 38 | Thanked: 19 times | Joined on Jan 2012 @ 127.0.0.1
#4
Originally Posted by HtheB View Post
Here you go: http://store.ovi.com/content/257443
QAD WLAN Password Recovery

TMO Thread: http://talk.maemo.org/showthread.php?t=82489
I don't seem to be able to download QAD WLAN Password Recovery. The process is stuck on "wait". Same goes for WiFi Pass Recovery...

@ Nad

This results in: "Must specify one ore more directories to recursively list."

output.txt is created, but there is nothing in it.

Eidt: Never mind. I rebooted and tried again and this time I could download and install QAD WLAN Password Recovery.

Tnx, HtheB!
__________________
Man is virus.

I my N9 16GB Black.
(059J201 RM-696 NDT BENELUX BLACK 16GB)

Last edited by Yeshua; 2014-02-03 at 21:35.
 

The Following 3 Users Say Thank You to Yeshua For This Useful Post:
Posts: 1,048 | Thanked: 1,127 times | Joined on Jan 2010 @ Amsterdam
#5
It simply tells you it doesn't know where to start reading...

Add the path "/" like so

Code:
 gconftool -R / > /home/user/MyDocs/output.txt
Search the resulting txt file for your keys.

Installing apps for trivial tasks like this... Where is this world heading? :P
 

The Following 4 Users Say Thank You to anthonie For This Useful Post:
Posts: 986 | Thanked: 1,526 times | Joined on Jul 2010
#6
i use a script to get/set my wifi networks from plaintext that i store on my laptop {i do the same for all my devices, that way i only have to add a network once, and not once per device}.

i modified it to just print the wifi networks nicely {this is not much more useful than gconftool | grep | sed}

Code:
#!/usr/bin/perl
use strict;
use warnings;

sub addWifiFromNet();
sub clearAllWifi();
sub getExisting();
sub getWifiGconf($$$);

sub getGconfCmds($);
sub gconfGetCmd($);
sub gconfSetCmd($$$;$);
sub listInt($);
sub listString($);
sub ssidListInt($);
sub wpaPskListInt($$);
sub randHex($);
sub randomId();
sub runBT(@);

my $usage = "Usage:
  $0
    print all wifi networks on the phone
";

my $rootDir = '/system/osso/connectivity/IAP';
my $noAutoFile = "$ENV{HOME}/Code/n9/wifi-noauto";
my $TRUE = ['true', 'bool'];
my $FALSE = ['false', 'bool'];

my $wifiAtts = {
  name => [""],
  wlan_ssid => listInt [],
  EAP_wpa_preshared_key => listInt [],
  EAP_wpa_preshared_passphrase => [""],

  http_check_status => ["no_login"],
  proxytype => ["NONE"],
  wlan_hidden => $FALSE,
  wlan_security => ["WPA_PSK"],
  type => ["WLAN_INFRA"],
  autoconnect => $TRUE,
  ipv4_type => ["AUTO"],
};
my $gprsAtts = {
  name => [""],
  gprs_accesspointname => [""],
  sim_imsi => [""],
  gprs_username => [""],
  gprs_password => [""],
  type => ["GPRS"],
  autoconnect => $TRUE,
  ask_password => $FALSE,
  first_time_dialog_shown => $TRUE,
  ipv4_autodns => $TRUE,
  ipv4_type => ["AUTO"],
};

sub main(@){
  my $get = 1;
#  if(@_ == 1 and $_[0] =~ /^(-g)$/){
#    $get = shift;
#  }
  die $usage if @_ > 0;

  if(defined $get){
    my $networks = getExisting();
    my $sortByName = sub{$$networks{$a}{name} cmp $$networks{$b}{name}};
    for my $id(sort $sortByName keys %$networks){
      if($$networks{$id}{type} eq "WLAN_INFRA"){
        my $name = $$networks{$id}{name};
        my $key = $$networks{$id}{EAP_wpa_preshared_passphrase} || '';
        print "$name => $key\n";
      }
    }
  }else{
    #print "clearing all wifi networks\n";
    #clearAllWifi();
    #print "\n\n";
    #print "adding wifi networks from net\n";
    #addWifiFromNet();
  }
}

sub addWifiFromNet(){
  my @cmds;
  my %noAuto = map {chomp; $_ => 1} `cat $noAutoFile 2>/dev/null`;
  for my $ssidName(sort split /\n/, runBT "winfo", "--list-all"){
    my $info = runBT "winfo", $ssidName;
    my $ssid = $1 if $info =~ /^ssid:(.*)$/m;
    my $enc = $1 if $info =~ /^enc:(.*)$/m;
    my $key = $1 if $info =~ /^key:(.*)$/m;
    my $mode = $1 if $info =~ /^mode:(.*)$/m;
    my $auto = $1 if $info =~ /^auto:(.*)$/m;
    my $autoConnect = $auto =~ /^\d+$/ ? 'true' : 'false';
    if($enc =~ /WPA/i and $mode =~ /managed/i){
      if(defined $noAuto{$ssid}){
        print "  forcibly disabling autoconnect for $ssid\n";
        $autoConnect = 'false';
      }
      my $wifiCmds = getGconfCmds(getWifiGconf $ssid, $key, $autoConnect);
      push @cmds, "echo adding: SSID='$ssid' WPA='$key' auto='$autoConnect'";
      @cmds = (@cmds, @$wifiCmds);
    }
  }

  system "n9", "-s", join "\n", @cmds;
}

sub clearAllWifi(){
  my $networks = getExisting();
  my @cmds;
  for my $id(keys %$networks){
    if($$networks{$id}{type} eq "WLAN_INFRA"){
      my $name = $$networks{$id}{name};
      $name = '' if not defined $name;
      push @cmds, "echo 'deleting $id => $name'";
      push @cmds, "gconftool --recursive-unset $rootDir/$id";
    }
  }
  system "n9", "-s", join "\n", @cmds if @cmds > 0;
}
sub getExisting(){
  #my @iapLines = `n9 -u user -s gconftool -R $rootDir`;
  my @iapLines = `gconftool -R $rootDir`;
  my %allAtts = (%$wifiAtts, %$gprsAtts);

  my $id;
  my $networks = {};
  my $h4Re = "[a-f0-9]{4}";
  my $h8Re = "[a-f0-9]{8}";
  my $h12Re = "[a-f0-9]{12}";
  my $attRe = join "|", keys %allAtts;
  for my $line(@iapLines){
    if($line =~ /^ $rootDir\/($h8Re-$h4Re-$h4Re-$h4Re-$h12Re):$/){
      $id = $1;
      $$networks{$id} = {};
    }elsif(defined $id and $line =~ /^  ($attRe) = (.*)$/){
      $$networks{$id}{$1} = $2;
    }
  }
  return $networks;
}

sub getWifiGconf($$$){
  my ($ssid, $wpa, $auto) = @_;
  my $id = randomId;
  my $dir = "$rootDir/$id";

  my $gconf = {};
  for my $att(keys %$wifiAtts){
    $$gconf{"$dir/$att"} = $$wifiAtts{$att};
  }
  $$gconf{"$dir/name"} = [$ssid];
  $$gconf{"$dir/wlan_ssid"} = ssidListInt $ssid;
  $$gconf{"$dir/EAP_wpa_preshared_key"} = wpaPskListInt $ssid, $wpa;
  $$gconf{"$dir/EAP_wpa_preshared_passphrase"} = [$wpa];
  $$gconf{"$dir/autoconnect"} = $auto =~ /true/i ? $TRUE : $FALSE;
  return $gconf;
}

sub getGconfCmds($){
  my $gconf = shift;
  my $cmds = [];

  for my $key(keys %$gconf){
    my @arr = @{$$gconf{$key}};
    my $val = shift @arr;
    my $type = @arr > 0 ? shift @arr : 'string';
    my $listType = @arr > 0 ? shift @arr : undef;
    push @$cmds, gconfSetCmd($key, $val, $type, $listType);
  }
  return $cmds;
}
sub gconfGetCmd($){
  return "gconftool-2 --get $_[0]";
}
sub gconfSetCmd($$$;$){
  my ($key, $val, $type, $listType) = @_;
  my $cmd = "gconftool-2 --set '$key' '$val' --type=$type";
  if(lc $type eq 'list'){
    $cmd .= " --list-type=$listType";
  }
  return $cmd;
}

sub listInt($){
  my @list = @{shift()};
  my $val = '[' . (join ',', @list) . ']';
  return [$val, 'list', 'int'];
}
sub listString($){
  my @list = @{shift()};
  my $val = '[' . (join ',', @list) . ']';
  return [$val, 'list', 'string'];
}
sub ssidListInt($){
  my ($ssid) = @_;
  my @dec;
  for(my $i=0; $i<length $ssid; $i++){
    push @dec, ord(substr $ssid, $i, 1);
  }
  return listInt(\@dec);
}
sub wpaPskListInt($$){
  my ($ssid, $passphrase) = @_;
  my $net = runBT "wpa_passphrase", $ssid, $passphrase;
  if($net =~ /^\s*psk=([0-9a-f]+)\s*$/m){
    my $psk = $1;
    my @bytes;
    for(my $i=0; $i<length $psk; $i+=2){
      push @bytes, substr $psk, $i, 2;
    }
    my @dec = map {sprintf("%d", hex($_))} @bytes;
    return listInt(\@dec);
  }
  return undef;
}

sub randHex($){
  my $digs = shift;
  return lc sprintf "%0${digs}X", rand(16**$digs);
}
sub randomId(){
  return join '-', randHex(8), randHex(4), randHex(4), randHex(4), randHex(12);
}

sub runBT(@){
  open FH, "-|", @_;
  my @lines = <FH>;
  close FH;
  return join '', @lines;
}

&main(@ARGV);
save it to wifi-print.pl, copy it to the phone, and run it with "perl ~/MyDocs/wifi-print.pl" or whatever

original {with the restore} is at https://raw.github.com/teleshoes/n9-...364b/sync-wifi
note that restoring the wifi networks relies on my own linux network manager {which afaik has an active and lively user base of precisely 2 people}, located at: https://github.com/teleshoes/net
__________________
~ teleshoes ~
 

The Following 4 Users Say Thank You to wolke For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 10:20.