Skip to content

Latest commit

 

History

History
269 lines (218 loc) · 9.74 KB

CloubitFileSystem.md

File metadata and controls

269 lines (218 loc) · 9.74 KB

WARNING: Using the information could damage your CloudBit beyond repair.

Use this information at your own risk.

Read CloubBit FileSystem

This webpage from LittleBits meant to post a link to the open parts of CloubBits source code. Looks like they put a wrong link there.

Based on the componenetly used by the device it seems easy enough to just mount CloudBits filesystem on Mac and try and find the web interfaces manually.

Prerequisites

The CloudBits filesystem is ext4 which in not natvily supported by OSX. You will need to install some tools to enable support for ext4.

NOTO: If I can get permission from LittleBits I will provide access to a CloudBit image that already has SSHD running and ready..

Backup SD Card (just incase)

Warning dd can be a very dagerous command that can wipe your SDCard or worse you Mac harddrive. You should study up on this command before you use it.

  • Open terminal
  • connect sdcard to Mac
  • type sudo dd if=/dev/disk1s3 of=/tmp/backupfile.img
  • type open /tmp
  • put the file somewhere safe
  • Create a duplicate of the card to keep the original safe
  • TODO: descibe how to do this....

Mount FileSystem

  • Remove SD card from the CloudBit
  • Use Spotlight to open Disk Utility
  • Connct SD card to your Mac and Note the new names
  • Open Terminal
    • mkdir /Volumes/little
    • sudo fuse-ext2 -o force /dev/disk1s3 /Volumes/little
    • cd /Volumes/little (or view in finder with: open /Volume/little )

One line form: mkdir /Volumes/little && sudo fuse-ext2 -o force /dev/disk1s3 /Volumes/little && cd /Volumes/little

Enable sshd on CloudBit

This part assume you already mounted the SD card from the CloudBit.

  • edit /Volumes/little/etc/ssh/sshd_config
    • change UsePAM yes to UsePAM no
    • uncommnet #PermitRootLogin yes to PermitRootLogin yes
    • save and close file
  • edit /Volumes/little/usr/lib/sysctl.d/50-default.conf
    • Add line net.ipv4.conf.default.rp_filter = 0
  • Disable iptables
    • mv /Volumes/little/etc/systemd/system/multi-user.target.wants/iptables.service /Volumes/little/etc/systemd/
  • cd /Volumes/little/etc/systemd/system
    • cp /Volumes/little/usr/lib/systemd/system/sshdgenkeys.service .
    • cp /Volumes/little/usr/lib/systemd/system/sshd.service .
  • TODO: decribe howto setup password
  • Unmount SDCARD
  • Put back into CloudBit and ssh to device

Linux Access

  • Shadow file
    • Generate password: openssl passwd -1 -salt bit cloud
    • Original root shadow password $6$p9leKwKF$MkCEuyjkObA0/Yl7GD93WaqHHEA/yFY4sWpUqN5vB2YVIdBOf/UoQfMUgB0uh1enC7q2BrEaCRJfcD0tkheXZ/

Other Info

  • netstat -an
    • tcp 0 0 10.0.6.181:56173 54.235.112.129:9480 ESTABLISHED
ps -efxw
 PID TTY      STAT   TIME COMMAND
   2 ?        S      0:00 [kthreadd]
   3 ?        S      0:06  \_ [ksoftirqd/0]
   4 ?        S      0:03  \_ [kworker/0:0]
   5 ?        S<     0:00  \_ [kworker/0:0H]
   7 ?        S<     0:00  \_ [kworker/u:0H]
   8 ?        S      0:01  \_ [watchdog/0]
   9 ?        S<     0:00  \_ [cpuset]
  10 ?        S<     0:00  \_ [khelper]
  11 ?        S      0:00  \_ [kdevtmpfs]
  12 ?        S<     0:00  \_ [netns]
  13 ?        S      0:00  \_ [kworker/u:1]
 159 ?        S      0:00  \_ [bdi-default]
 160 ?        S<     0:00  \_ [kintegrityd]
 162 ?        S<     0:00  \_ [kblockd]
 205 ?        S      0:00  \_ [khubd]
 305 ?        S      0:00  \_ [khungtaskd]
 308 ?        S      0:00  \_ [kswapd0]
 309 ?        S      0:00  \_ [fsnotify_mark]
 310 ?        S<     0:00  \_ [cifsiod]
 311 ?        S<     0:00  \_ [crypto]
 368 ?        S<     0:00  \_ [ci_otg]
 380 ?        S      0:00  \_ [kworker/u:2]
 391 ?        S<     0:00  \_ [deferwq]
 394 ?        S      0:14  \_ [mmcqd/0]
 400 ?        S      0:00  \_ [jbd2/mmcblk0p3-]
 401 ?        S<     0:00  \_ [ext4-dio-unwrit]
 419 ?        S      0:00  \_ [kworker/0:2]
 806 ?        S      0:14  \_ [RTW_CMD_THREAD]
   1 ?        Ss     0:56 /sbin/init HOME=/ TERM=linux
 425 ?        Ss     0:01 /usr/lib/systemd/systemd-journald LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin NOTIFY_SOCKET=@/org/freedesktop/systemd1/notify LISTEN_PID=425 LISTEN_FDS
 528 ?        Ss     0:00 /usr/lib/systemd/systemd-udevd LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin NOTIFY_SOCKET=@/org/freedesktop/systemd1/notify LISTEN_PID=528 LISTEN_FDS=2
 717 ?        Ss     0:00 /usr/bin/sshd -D LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
1018 ?        Ss     0:16  \_ sshd: root@pts/0                                                                         n
1020 pts/0    Ss     0:07      \_ -bash USER=root LOGNAME=root HOME=/root PATH=/usr/bin:/bin:/usr/sbin:/sbin MAIL=/var/mail/root SHELL=/bin/bash SSH_CLIENT=10.0.6.169 58324 22 SSH_CONNECTION=10.0.6.169 583
3226 pts/0    R+     0:00          \_ ps -efxw TERM=xterm-256color SHELL=/bin/bash SSH_CLIENT=10.0.6.169 58324 22 SSH_TTY=/dev/pts/0 USER=root MAIL=/var/mail/root PATH=/usr/local/sbin:/usr/local/bin:/usr/b
 720 ?        Ss     0:00 /usr/local/lb/ADC/bin/ADC.d LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 723 ?        Ss     0:00 login -- root                                                                                       
 786 ttyAMA0  Ss+    0:00  \_ -bash HOME=/root USER=root SHELL=/bin/bash TERM=vt102 PATH=/usr/local/lb/ADC/bin:/usr/local/lb/Button/bin:/usr/local/lb/DAC/bin:/usr/local/lb/LEDcolor/bin:/usr/local/lb/cloud_
 725 ?        Ss     0:00 /usr/local/lb/DAC/bin/DAC.d LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 731 ?        Ss     0:26 /usr/local/lb/Button/bin/button.d LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 781 ?        Ss     0:00 /usr/lib/systemd/systemd-logind LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin NOTIFY_SOCKET=@/org/freedesktop/systemd1/notify WATCHDOG_PID=781 WATCHDOG_U
 782 ?        Ss     0:00 /usr/lib/systemd/systemd --user LANG=en_US.UTF-8 PATH=/usr/local/lb/ADC/bin:/usr/local/lb/Button/bin:/usr/local/lb/DAC/bin:/usr/local/lb/LEDcolor/bin:/usr/local/lb/cloud_client/bi
 784 ?        S      0:00  \_ (sd-pam)   HOME=/ TERM=linux
 811 ?        Ss     0:01 wpa_supplicant -B -P /run/wpa_supplicant_wlan0.pid -i wlan0 -D nl80211,wext -c/etc/wpa_supplicant/cloudbit.conf OLDPWD=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin PWD
 947 ?        Ss     0:00 dhcpcd -4qL -t 30 wlan0 OLDPWD=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin PWD=/ LANG=en_US.UTF-8 SHLVL=1 _=/usr/sbin/dhcpcd
 977 ?        Ss     0:04 /usr/local/lb/cloud_client/bin/cloud_client LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 980 ?        Ss     0:00 /usr/local/lb/LEDcolor/bin/LEDcolor.d LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 981 ?        Ss     0:27 /bin/bash /usr/local/lb/bit-util/monitorNetctl.sh &> /dev/null & LANG=en_US.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
3225 ?        S      0:00  \_ sleep 5 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin PWD=/ LANG=en_US.UTF-8 SHLVL=1 _=/usr/sbin/sleep
[root@alarm etc]# 

Set output level

  • Set output to max /usr/local/lb/DAC/bin/setDAC ffff
  • Set output to min /usr/local/lb/DAC/bin/setDAC 0

Query ADC

[root@alarm /]# /usr/local/lb/ADC/bin/getADC -1
126
15
[root@alarm /]# /usr/local/lb/ADC/bin/getADC -1
0
0

Other commands

[root@alarm /]# tree /usr/local/lb
+---lb
| +---ADC
| | +---bin
| +---Button
| | +---bin
| +---DAC
| | +---bin
| +---LEDcolor
| | +---bin
| +---bit-util
| +---cloud_client
| | +---bin
| +---comm-util
| +---etc
| | +---hostapd
| | +---iptables
| | +---lighttpd
| | +---systemd
| +---hw_util
| | +---bin
| +---mfg_test
| | +---ADCtoDAC
| | | +---bin
| | +---RGBcycle
| | | +---bin
Total directories = 25

Cloud Client Conf

#Cloud Client Conf
[cloud_parameters]
cloud_host = cloud.littlebits.cc
cloud_port = 9480
setup_version = 1.0.0
protocol_version = 1.1.0
use_ssl = 1
dont_ignore_pings = 1 #switch to 1 if you want to connect to staging, this switches ping styles 

[daemon_parameters]
adc_host = /var/lb/ADC_socket
dac_host = /var/lb/DAC_socket
led_host = /var/lb/SET_COLOR_socket

[client_parameters]
mac_file = /var/lb/mac
hash_id_file = /var/lb/id
ssid_file = /var/lb/current_ssid
device = littlebits-module-cloud
current_ssid = /var/lb/current_ssid
#this (and other parameters) should be pulled from the same place as the scripts do
firmware_version=1.0.140611a
ping_timeout = 2400
ping_maxmiss = 3
rx_buff_len = 100
tx_buff_len = 1000
token_len = 11

Scripts Conf

#!/usr/bin/env

# GENERAL
WADAP=wlan0
LB_WWW="www.littlebits.cc"
LB_DOM="littlebits.cc"
NTP_SERVER="pool.ntp.org"
TMP_DIR="/var/lb"
PM_MODE="/var/lb/power_mode"
CLOUDID="/var/lb/id"
MACADDR="/var/lb/mac"
SALT="/var/salt"

# LED COLORS
DEFAULT_COLOR="violet"
COMMISSION_COLOR="blue"
CONNECTING_COLOR="yellow"
CONNECTED_COLOR="green"
NOT_CONNECTED_COLOR="red"

# COMMISSIONING
GATEWAYIP=10.0.0.1
NETMASK=255.255.255.0
DOMAIN="cloudsetup.cc"
NETCTL_CONFIG="/etc/netctl/cloudbit"
WPA_CONFIG="/etc/wpa_supplicant/cloudbit.conf"
HOSTAPD_CONFIG="/etc/hostapd/hostapd.conf"
DNS_CONFIG="/etc/dnsmasq.conf"
COMM_LOG="/var/log/commissioning"

# DAEMON PATHS
CCPATH=/usr/local/lb/cloud_client/bin
BUTTONPATH=/usr/local/lb/Button/bin
ADCPATH=/usr/local/lb/ADC/bin
DACPATH=/usr/local/lb/DAC/bin
LEDPATH=/usr/local/lb/LEDcolor/bin

# SCRIPT PATHS
TESTPATH=/usr/local/lb/mfg_test
CUTILPATH=/usr/local/lb/comm-util

References