Tag Archives: ID

As seen on StackOverflow:

#!/root/perl/bin/perl
use warnings;
use strict;
use Email::MIME 1.901;
use IO::Socket::SSL;
use Mail::IMAPClient;
use POSIX qw/ strftime /;
use Term::ReadKey;
sub read_password {
    local $| = 1;
    print "Enter password: ";

    ReadMode "noecho";
    my $password = <STDIN>;
    ReadMode "restore";

  die "$0: unexpected end of input"
      unless defined $password;

    print "\n";
    chomp $password;
    $password;
}
my $pw = read_password;
my $imap = Mail::IMAPClient->new(
 #Debug    => 1,
  User     => "you\@domain.com",
  Password => $pw,
  Uid      => 1,
  Peek     => 1,  # don't set \Seen flag
  Socket   => IO::Socket::SSL->new(
                Proto    => 'tcp',
                PeerAddr => 'imap.domain.com',
                PeerPort => 993,
              ),
    );

die "$0: connect: [email protected]" if defined [email protected];
$imap->select("INBOX")
    or die "$0: select INBOX: ", $imap->LastError, "\n";
my $today = strftime "%Y%m%d", localtime $^T;
my @messages = $imap->search(SUBJECT => $today);
die "$0: search: [email protected]" if defined [email protected];
foreach my $id (@messages) {
    die "$0: funky ID ($id)" unless $id =~ /\A\d+\z/;

  my $str = $imap->message_string($id)
      or die "$0: message_string: [email protected]";

    my $n = 1;
    Email::MIME->new($str)->walk_parts(sub {
        my($part) = @_;
    return unless $part->content_type =~ /\bname="([^"]+)"/;  # " grr...

        my $name = "./$today-$id-" . $n++ . "-$1";
        print "$0: writing $name...\n";
    open my $fh, ">", $name
        or die "$0: open $name: $!";
    print $fh $part->content_type =~ m!^text/!
                ? $part->body_str
                : $part->body
                or die "$0: print $name: $!";
    close $fh
        or warn "$0: close $name: $!";
                                       });
}

 

You may have tried to change your wordpress username in phpadmin and found that you no longer have the Network Admin option on the Dashboard menu. If you did, you need to check with the procedure below and see if you followed it correctly, to change your multiuser admin username:

In Phpmyadmin,

Edit the follwing:

wp_users table:

Find the row corresponding to “ID” of 1. On the same row, edit the user_login field and change “admin” to a new user name.

wp_sitemeta table:

Find site_admins field containing the string “admin“.

It may be like:

a:2:{i:0;s:6:"totaluser";i:3;s:5:"admin";}

Note that the 5 just before admin is the character count of admin. So you need to change admin to your new user name, and substitute 5 by the new character count of your username.

There, that’s it! Now you’ve successfully changed your admin username and thus hardened your wordpress installation a bit further. If you need to secure it further, pick an alphanumeric long username, and a very long password containing alphanumerics and special characters.

To drive home the point, I will reiterate. If Network Admin menu is not visible under “My Sites” on WordPress, the main thing you need to check is whether your username and its character count are correctly set in the table wp_sitemeta, field site_admins.

Three cheers to [email protected] for his post regarding this.

If you install adb somewhere and try to run it, you get the an error stating “Insufficent permissions”. So we need to setup a couple of steps to get adb ready to work on Linux with our device.

1. Install Android SDK (Instructions found elsewhere)
First install Android SDK to someplace and set its path in ~/,bashrc

2. Setup path to adb
Edit bashrc and add the following line after the normal PATH statement:

PATH=$PATH:/pathto_adb

Set paths like this:

kate ~/.bashrc

Eg:

PATH=$PATH:~/android/sdk:~/android/android-ndk-r6b:~/android/sdk/tools:~/android/sdk/platform-tools:~/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:~/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/bin[/code]
3. set up permissions

On Android Lollipop, you need to enable adb from Developer options:
First enable developer mode, by clicking on build version in About menu multiple times.

Next, under Debugging>Android debugging, toggle it on.
[email protected]:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0424:2512 Standard Microsystems Corp. USB 2.0 Hub
Bus 004 Device 002: ID 046d:c03d Logitech, Inc. M-BT96a Pilot Optical Mouse
Bus 001 Device 004: ID 0bb4:0c87 High Tech Computer Corp. Desire (debug)
Bus 001 Device 005: ID 0781:5406 SanDisk Corp. Cruzer Micro U3

The important part is this: Bus 001 Device 004: ID 0bb4:0c87 High Tech Computer Corp. Desire (debug)

Note: ID 0bb4:0c87

Or it might be:

[[email protected] ~]$ lsusb | grep -i 'desire'
Bus 001 Device 007: ID 0bb4:0ff9 High Tech Computer Corp. Desire / Desire HD / Hero (Charge Mode)

Here, note

0bb4:0ff9[/code]
N.B: The ID 0bb4:0c87 (or 0bb4:0ff9 depending on the PC) is unique for the Desire. So you can just as well copy and paste into the permissions file.

For a Samsung Galaxy Note 2, it is:
[[email protected] ~]$ lsusb
Bus 001 Device 009: ID 04e8:6860 Samsung Electronics Co., Ltd 

For one plus one, it is:
Bus 002 Device 008: ID 05c6:6764 Qualcomm, Inc. A0001 Phone [OnePlus One]

For Oneplus 3, locating it was slightly more difficult:
First you have to enable Developer mode (Clicking on Build version 5 times), and then toggle USB debugging to On.

lsusb showed:

[email protected]:~$ lsusb
Bus 002 Device 014: ID 2a70:9011
Bus 002 Device 004: ID 1058:0820 Western Digital Technologies, Inc. My Passport Ultra (WDBMWV, WDBZFP)
Bus 002 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I couldnt get any clue as to which one was OnePlus 3.
So I disconnected and reconnected the device, and took a look at dmesg logs:
dmesg:

[email protected]:~$ dmesg
[22373.685139] usb 2-1.4: USB disconnect, device number 13
[22377.722778] usb 2-1.4: new high-speed USB device number 14 using ehci-pci
[22377.816588] usb 2-1.4: New USB device found, idVendor=2a70, idProduct=9011
[22377.816598] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[22377.816603] usb 2-1.4: Product: Android
[22377.816607] usb 2-1.4: Manufacturer: Android
[22377.816611] usb 2-1.4: SerialNumber: 87a9854a
[22377.820830] usb-storage 2-1.4:1.1: USB Mass Storage device detected
[22377.821088] scsi host15: usb-storage 2-1.4:1.1
[22378.819918] scsi 15:0:0:0: CD-ROM            OnePlus  Device Driver    0318 PQ: 0 ANSI: 2
[22378.829944] sr 15:0:0:0: [sr1] scsi-1 drive
[22378.830294] sr 15:0:0:0: Attached scsi CD-ROM sr1
[22378.830507] sr 15:0:0:0: Attached scsi generic sg4 type 5

Thus from idVendor=2a70, idProduct=9011, I found out that the line ID 2a70:9011 referred to Oneplus 3

Create/Edit /etc/udev/rules.d/99-android.rules

gksu gedit /etc/udev/rules.d/99-android.rules (Gnome)
kdesudo kate /etc/udev/rules.d/99-android.rules (KDE)

 

Or use your favorite editor.

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4:0c87", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"
TEST=="/var/run/ConsoleKit/database", 
RUN+="udev-acl --action=$env{action} --device=$env{DEVNAME}"

For OnePlus 1:

ATTR{idVendor}=="05c6", ATTR{idProduct}=="6764", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

For OnePlus 3:

ATTR{idVendor}=="2a70", ATTR{idProduct}=="9011", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
sudo service udev restart

Now unplug and then reinsert the Device to the usb connection.

Now, adb devices shows my device

On Ubuntu 16.04, and my Oneplus One all of this is no longer necessary. The steps are:
sudo apt install android-tools-adb
OPO:
Connect phone in MTP mode.
Developer options (enable it by multi-tapping About:Android version) > Android debugging: On
Accept the “Trust computer” dialog
Test with

adb devices