Showing posts with label Forensic. Show all posts
Showing posts with label Forensic. Show all posts

Saturday, January 7, 2017

SANS Holiday Hack Challenge 2016 - Santa's Business Card

Santa's Business Card

The Counter Hack Team prepared an amazing challenge for 2016, full of details and very comprehensive. Here is my write-up:

It’s Christmas time, and a new adventure is waiting for the Dosis children. Santa has been kidnapped, Christmas is in peril, unless the Dosis children are able to solve this mystery. After finding Santa’s business card, they found out that Santa is very active in Social Media!!! He has twitter and Instagram accounts: @satanwclaus.

So, Jess and Josh took a look to Santa’s tweets, which appear to be hiding something, the use of dots “.” and questions marks are a bit suspicious. Jess knew that something was hidden, but in order to examine the tweets she needed to access all tweets and take a closer look. Of course, she already had access to the twitter API (including oauth access keys), and after writing a python script she was able to download all tweets into a cvs file. After opening the file in the terminal, Josh, who was looking from behind, told her: “Hey, it looks like the letter B, and a U… wait a minute, this is a hidden ASCII message”. 





Jess said: “You are right Josh, it says: BUG BOUNTY”. But what does this mean? bug bounty? what Santa has to do with “bug bounty”?

Then, the kids turned to instagram, to check the pictures published by Santa. Finding a very interesting one:



Jess: “Uhm, it looks like Santa is in the InfoSec business, look Josh, Santa has a Python cheat sheet from SANS, and a Violent Python cookbook for Pentesting”

Josh: “Wait a minute… Santa was downloading an application: SantaGram_v4.2.zip, but from where? what is this app for?”

Checking the picture, they found a very interesting sheet, that looks like a security nmap report for the site: www.northpolewonderland.com. The children linked the pieces together and use them as the following URL:
http://www.northpolewinderland.com/SantaGram_v4.2.zip, and downloaded the SantaGram_v4.2.zip file.

Josh: “What’s inside this app, let’s unzipped to take a look”:

unzip SantaGram_v4.2.zip

Jess: “It’s asking for a password, let’s try the hidden phrase in Santa’s tweets: bugbounty”

VoilĂ !!! the SantaGram_4.2.apk was in her screen.

Josh: “Jess, this is an android app!!!"

Now, it is time to answer the first two questions:

1) What is the secret message in Santa’s tweets?

“bug bounty”

 2) What is inside the ZIP file distributed by Santa’s team?

SantaGram_4.2.apk: android app.

After these amazing findings, the two kids approached Santa’s bag, and disappeared!!! materializing in a different place, but where… the North Pole!!!

The children continued analyzing the android app, SantaGram, trying to understand how it works, and what can be found inside, any clue that could lead to Santa. 

First, Jess used apktool to decode the apk file, and explore its resource and smali files:

apktool d SantaGram_v4.2.apk

In the res/values directory, the children found the strings.xml file with valuable information related to services used by the app:

- https://analytics.northpolewonderland.com
- http://ads.northpolewonderland.com
- http://dev.northpolewonderland.com
- http://dungeon.northpolewonderland.com
- http://ex.northpolewonderland.com

Not only that, an audio file was found in the res/raw directory: "discombobulatedaudio1.mp3".

Josh played the audio file, but he couldn’t understand a single word. 

Josh: “Jess, any idea about this audio? Can you understand what it says?”

Jess: “No idea Josh, it doesn’t sound right, it seems like something happened to the original audio”

Then, Josh found something really interesting… “Jess, look at this file (smali/com/northpolewonderland/santagram/b.smali), this is a username and password, maybe we can use it with the app”

Jess: “You are right Josh! nice finding!!!”



So, the answer to the next questions:

3) What username and password are embedded in the APK file?

Username: “guest”
Password: “busyreindeer78”

4) What is the name of the audible component (audio file) in the SantaGram APK file?

"discombobulatedaudio1.mp3"

Josh and Jess started a scavenger hunt, looking for the pieces of the cranberry Pi in the North Pole. after finding all the pieces, they were able to extract the SD of the cranberry Pi (cranbian-jessie.img), and insert it into Jess laptop.

Jess ran “disk -l cranbian-jessie.img” to take a look to the partition table:



Josh: “Wow, there it is! let’s mount cranbian-jessie.img2. It starts at sector 137216, and each sector is 512 bytes, which means: 70254592 bytes offset to mount it”

So, Jess ran the following command:

mkdir mnt; mount -o loop,ro,offset=$((137216*512)) cranbian-jessie.img ./mnt

Josh: “Here we go!!! let’s look inside… Uhmm, there is a cranpi user, if we are able to obtain its password, maybe we can access the protected rooms. Let’s talk to our friend John, he knows what to do”

Jess grabbed the “/etc/shadow” file, and gave it to John. John is very savvy in term of password testing, and only asked for a comprehensive list of known password, “rockyou.txt”, to perform its job:

john —wordlist=/tmp/rockyou.txt shadow

After some minutes, the password was found:

yummycookies     (cranpi)
 
Josh: “ I love cookies!!!, it’s time to open doors!”

The first door asked for a two parts password hidden inside the “out.pcap" file. This file was owned by the user itchy, and only has read permission for “itchy", but the current user was scratchy.

Josh: “Let’s check if we have any command available through sudo”

"sudo -l” showed that scratchy can run “tcpdump” and “strings” as “itchy” without providing any password.

First, they used:  sudo -u itchy tcpdump -r out.pcap -n -vv -X

Jess: “Josh, there is a HTTP connection, asking for firsthalf.html, and the response contains an HTML file with a form, and a hidden field whose name is 'part1' and value ‘santasli’, the second part must follow..”

Josh: “Yes, here it comes… GET /secondhalf.bin… but.. wait a minute, this is a binary file, can you see any string that looks like the second part?”

Jess: “No, I can’t!!!, but, where is it?”

The children continued looking inside the binary, using the tools available, until…

Jess: “Here it is… this is the second part”

sudo -u itchy strings -e l out.pcap

Shows: “part2:ttlehelper”

Josh: “Wow, so changing the encoding to little endian solved the puzzle”

The children entered the password: “santaslittlehelper” and entered to the first room.

The second room, was actually a game… Wumpus.. Josh jumped in, and started to play..

He didn’t need any hack or cheat to defeat the Wumpus, and obtained the key: “WUMPUS IS MISUNDERSTOOD”

The third room asked for a key in a hidden file… However, this is not a problem for the Dosis children:

After running: find . -type f -ls, the file was shown:

" ./.doormat/.\ /\ /\\/\\\\/Don't\ Look\ Here!/You\ are\ persistent,\ aren't\ you?/‘/key_for_the_door.txt”

Then, adding a bit of magic to find solved the puzzle: find . -iname \*txt -exec cat '{}' \;
"key: open_sesame”

The fourth door started a new game: “Wargame” following the same script as the film “Wargame”, after giving the first objective, the password was shown to the children: "LOOK AT THE PRETTY LIGHTS”

Josh: “This is really funny!!!”

Jess: “Come on Josh, focus, we need to hurry”

The fifth door shows a menu with an option to start a train, but it requires a password after issuing the command “START”

Josh: “It requires a password, let’s check the HELP option.. Uhm, is this less? yeah, it is”

So, Josh run: !bash … and he got a shell!!!

Jess: “Well done Josh, you’re really good at these puzzles”

after checking the Train_Console program, they realized that it was a shell script, and the password was embedded:

PASS=“24fb3e89ce2aa0ea422c3d511d40dd84"

Josh supplied the password to the program, and the train traveled back in time to 1978.

Jess: “Wow, I cannot believe it!!! We’re in 1978”

After going around looking for Santa, the children found Santa in the DFER room next to the reindeers.

The answers to this section questions are:

5) What is the password for the “cranpi” account n the cranberry Pi system?

yummycookies

6) How did you open each terminal door and where had the villain imprisoned Santa?

Santa was found in the DFER room next to the reindeers, in 1978.

Josh told her sister: “It’s time to exploit some servers!!!”

- The Mobile Analytics Server (via credentialed login)

Jess: “let’s start with the first one…https://analytics.northpolewonderland.com…”, so, Jess accessed the web server using her browser, and a login screen appeared.

Josh exclaim: “What if we try the username and password found in the SatanGram app?”

Jess: “Great idea Josh.. it works, we are in, check this out! there is a mp3 link”, and she downloaded the file:  “discombobulatedaudio2.mp3”

- The Dungeon Game

Jess ran a nmap on the next server: dungeon.northpolewonderland.com (35.184.47.139), showing that besides ports 22 (SSH) and 80 (HTTP), the port 11111 was open!

Immediately, Josh took his laptop and typed: “nc 35.184.47.139 11111”

Josh: “Jess, look at this, it’s a game!!!”



Jess: “but it’s quite old, 1978?”

Josh: “Yes, it is indeed, but it looks like fun. I’m gonna give a try”

After a while. there were no doubt that Josh was having a good time, but time wasn’t exactly what they had. So, Jess remembered that one of the elf in the North Pole gave her a binary with the game, so, she unzipped  it, and checked it. Like any other binary, besides checking header and libraries, there is always a good idea to run strings, just to check what strings are there:



“GDT”… this is weird, she told Josh to stop playing, and check if GDT was enable… Yup! it was.

Jess also found the source code in GitHub: https://github.com/devshane/zork 

Jess: “Josh, here is the source code, the difference seems to be the data file: dtextc.dat, it stores messages, rooms, objects, etc. Let’s check the commands available in the Game Debugging Tool”

Josh: “But let me play it, I already defeated the Cyclops!!!” 

Jess replied: “No time for that Josh, let’s first check the messages using ‘DT’… look, it has more messages available than the original database, let’s see the extra messages”

Josh: “Here is the answer!”



Jess: “Ok, I’m gonna send an email”

The children got a reply with the audio file attached to it: "discombobulatedaudio3.mp3”

- The Debug Server

Jess said: “We need to know how the SantaGram sends data to the debit server, if we find a way to craft specific messages to the server, maybe we can find the hidden audio file"

So, the Dosis children jumped into the SantaGram app. Jess, used Jadx to check the source code, while Josh was having fun with the smali code. He changed the parameter “debug_data_enabled” from false to true in the res/values/strings.xml, then he built the app again: apktool b SantaGram_4.2, resign it, using a custom set of digital certificate and private key, and run the android studio emulator to install it.

Josh ran the emulator with -http-proxy pointing to the ZAP proxy he had installed in his laptop. 



After playing for a while with the App, he accessed the Edit Profile Option, and a messages appeared in the proxy (ZAP) going to the debug server:

Request:



Response:



Jess: “The source code related to Edit profile is obfuscated, I can see some vars that are passed to the JSON builder: date, udid, debug and freemen”

Josh: “Yup, those are the vars, look at this” showing the ZAP captures.

Jess: “What if we add verbose to the request, and set it to true?”

Josh: “Good idea, let me try that”

Josh open a shell, and using curl, crafted a JSON request:


The key files has a array of file names containing the audio file needed: "debug-20161224235959-0.mp3”

After downloading the mp3 file, the children started the next Challenge.

- The Banner Ad Server

Jess accessed the Ad Server (http://ads.northpolewonderland.com), and inspected the HTML source:



Jess: “Josh, this website is using meteor, maybe we can use meteor miner to grab more information”

Josh: “Excellent!!! let’s get started”

The children activated meteor miner, navigating the available routes uncovered by meteor miner:



The route “admin/quotes” has a Collection available, HomeQuotes, so, Jess used the console to type the following: "HomeQuotes.find().fetch()”

Getting an array with five object as response. Then Jess checked each object obtaining the audio file needed:


The children downloaded the mp3 file: "ofdAR4UYRaeNxMg/discombobulatedaudio5.mp3”, jumped into the next server…

- The Uncaught Exception Handler Server

Josh: “I’m gonna work with the Android Emulator to check if I can generate an exception”

Jess: “No need for that Josh, Let’s check the code with Jadx”



Josh: “That’s perfect!! I can craft a request with this info”

So, Josh opened a shell, and crafted a new request:


Josh: “What if I change the value of the operation key, Let’s put something different…”


Jess: “Nice.. only WriteCrashDump or ReadCrashDump are supported… Try to call ReadCrashDump Josh”



Josh: “Now I need to add crashdump key and value… Uhm, I guess it will return the message previously sent with WriteCrashDump”



Josh: “I got it! It must be writing the message sent into a file with WriteCrashDump, and then reading it back with ReadCrashDump.. Let’s try to add a filter”



Jess: “You got it right Josh!!!”

Josh: “Uhm, Look at this code”



Jess: “This is wrong Josh, it’s requiring a file based on a value of a JSON key… User input without any validation.. this can only lead to trouble"

Josh: "Let try with a PoC... I'm sure that I can inject code"



Josh: "Done! I got the PoC working..."

Jess: "Josh, stop wasting time, we need to hurry"

And the children recovered the audio file: "discombobulated-audio-6-XyzE3N9YqKNH.mp3"

- The Mobile Analytics Server (post authentication)

Jess: “It’s time for the last server, let me check the source code of the SantaGram app in Jadx to see if I can find something else..”

Josh: “Too much work… It has a .git directory… somebody is not doing his job securing the deployment process…”



Jess: “Wow, who can do something like that… “

Josh: “I’m not going to complain…”

Josh downloaded the whole “.git” directory using wget: "wget -r https://analytics.northpolewonderland.com/.git/

Using git, the children were able to recover all the files: “git log and git checkout to go to a specific revision”

Josh: “There is a section, edit, that is only available to the administrator user…, look at this piece of code”

crypto.php


login.php:


Josh: “I can use this code to generate a cookie as the administrator user… it’s not using any random string, just the username and date as part of the cookie”



Josh: “I’m in as the administrator”

Jess: “Too much work Josh… look at this”



Jess: “The administrator password was in a previous commit..”

Josh: “It’s ok, I enjoy coding my way into apps…”

Jess: “Hey Josh, look at this section in the edit.php file”



Josh: “What??? the foreach is going through all the values in the report table!!! but the query is also defined there... If we create a report, and change it later, we could inject a crafted query to grab data from the audio table”

So, Josh used curl again to craft another request to an existing report: 




Josh: “Here it is.. the next file.. but it belongs to the administrator user, and the get audio only allows to download file for the guest user, so, we’ll need to getting directly from the database.. What if we encode it as base64, it could work”

Jess: “Go ahead Josh…”



After decoding the base64 audio file, the children recovered the last mp3 file: "discombobulatedaudio7.mp3”

Answer to this section questions:

7) Once you get approval of given in-scope target IP addresses from Tom Hessman at the North Pole, attempt to remotely exploit act of the following targets:

Target
Vulnerability
The Mobile Analytics Server (via credentialed login access)
Username and password found in apk file
The Dungeon Game
Game Debugging Tool (GDT)
The Debug Server
Provides protected information from a parameter that can be easily manipulated by a remote user
The Banner Ad Server
Protected information is sent to client, even if the data is not displayed
The Uncaught Exception Handler Server
It’s requiring a file based on unvalidated user input.
The Mobile Analytics Server (post authentication)
- Deploying the app including the codebase (git)
- Cookies doesn’t contain random values.
- Credentials are stored in the codebase
- It’s allowing unvalidated user input.

8) What are the names of the audio files you discovered rom each system above? 

discombobulatedaudio1.mp3
discombobulatedaudio2.mp3
discombobulatedaudio3.mp3
debug-20161224235959-0.mp3
discombobulatedaudio5.mp3
discombobulated-audio-6-XyzE3N9YqKNH.mp3
discombobulatedaudio7.mp3

After finding the last audio file, the Dosis children put all the audio files together, trying to understand.

Jess: “They sound very slow, we can play with the speed.. or the tempo of the audio files”

Josh: “Let’s do it!”

After while, the children solved the puzzle:

Jess: “There are 7 files, 7 seconds each… if we change the tempo to 7.0 and then concatenate the files, we could get the original audio, or at least something very similar”



The children concatenated the files using sox, and listened to the new audio file.

Josh: “I can get some phrases.. but it is still a bit robotic, and the accent..”

Jess: “It’s a British accent, let’s google the words we can understand”

"Father Christmas, Santa Claus. Or, as I've always known him, Jeff”

Josh: “What is this?”

Jess: “This is from Dr Who Christmas Carol… Let’s enter to the password protected room”

Jess: “Dr. Who! but why?”

Josh: “Star Wars Holidays Special, is that real? You wanted to change the pass using Santa’s magic, and because he didn’t want to help, then you kidnapped him”

And this is how the Dosis children saved Santa, and solve another Christmas Mystery…

9) Who is the villain behind the nefarious plot?

Dr. Who

10) Why had the villain abducted Santa?


To use Santa’s magic, and change the pass in 1978 preventing the Star Wars Special from being released. 

Monday, January 11, 2016

SANS Holiday Hack Challenge 2015 - Part 0x01



Christmas means many things to many people, in my case, this an excellent season to share with my family and friends, but also, it's the perfect time for a security challenge. I really enjoyed SANS Holiday Challenge 2013, and even if I couldn't participate in 2014, and was expecting this year Challenge.

I was right, the Counter Hack Team did an excellent job: https://www.holidayhackchallenge.com/, creating an amazing plot, 8bits video game and a technical challenge that included: network/firmware forensic, Web Application with NoSQL Pen-Testing, and a C application Pen-Testing. 

This post is the first of the SANS Holiday Hack Challenge 2015 series, which includes part 01, 02 and 03 of the Challenge. I've changed all IP addresses to localhost, because the targets used in the Challenge were using AWS, and those IPs can be assigned to other tenants.

I’ll start each section with a short answer to the questions, and then provide a more technical explanation. 

Part 1: Dance of the Sugar Gnome Fairies: Curious Wireless Packets


1) Which commands are sent across the Gnome’s command-and-control channel?


There is a command exchange between the gnome and a super gnome (GS-01), using DNS queries with TXT type records encoded with base64. The main commands are:

- NONE: nothing to execute- EXEC: execute an internal command (application), like: iwconfig, cat /tmp/iwlistscan.txt- FILE: retrieve a file from the gnome.  FILE:/root/Pictures/snapshot_CURRENT.jpg


2) What image appears in the photo the Gnome sent across the channel from the Dosis home?

It’s a photo of the Dosis’ room, taken from the gnome:





John Dosis provided me with the pcap file in the Dosis Neighborhood. The pcap file contains two types of traffic: 802.11 exchange between client and Access Point (Probe request and Beacon Frame) and DNS (UDP, port 53) between the gnome (10.42.0.18) and the gnome Server. 

Let’s focus on the DNS query exchange. The client (gnome) continuously queries a “DNS server” with the following information: “cmd.sg1.atnascorp.com: type TXT, class IN”, and the server responds with a TXT record, e.g.: "TXT:  Tk9ORTo=“. The TXT is a standard type, however, the weird part is the content of the TXT record. The presence of the “=“ symbol aims to a possible BASE64 encoding. In order to find out, we cam simple send this string to openssl base64:

echo "Tk9ORTo=" | openssl base64 -d ; echo

This results with the following string: “NONE:"

Trying a couple more of TXT records, we can find the following strings:

RVhFQzppd2NvbmZpZwo=: EXEC:iwconfig

With this command things become more interesting, because the client (gnome) starts sending TXT responses to the Server (Supergnome) as a standard DNS TXT response (but client to server, instead of server to client):

RVhFQzpTVEFSVF9TVEFURQ==: EXEC:START_STATE

Instead of continuing testing all posible base64 strings, a better approach is to filter only the DNS flow, and create a new PCAP file with this flow, and use scapy to automate the recovery. With the support of scapy and python, the recovery of the base64 commands and responses is very easy. The script can be found here: https://github.com/skysec/SANSHolidayHack2015/tree/master/part01/scripts.
It takes three parameters: <path to the cap file> <path to the results file> <operation mode>.

There are two operations mode: “command” and “image”. Executing the script with operation mode “command", recovers all commands with the corresponding base64 strings. After decoding all base64 strings, there is a command that ask the gnome to send the current image: “FILE:/root/Pictures/snapshot_CURRENT.jpg”, for this reason, the recoverData.py script includes an option to decode the image included in the PCAP file. 

As a side note, there is another weird thing, but this time in the 802.11 traffic. The gnome is using a Network with the ESSID “DosisHome-Guest”, but most of the probes and requests are performed with the network “December”. However, in the iwscanlist  only shows the following networks: 

- ESSID: “CHC”, Encryption: On, Channel: 1- ESSID: “DosisHome”, Encryption: On, Channel: 6- ESSID: “DosisHome-Guest”, Encryption: Off, Channel: 6

Also, the iwconfig shows that the gnome is connected to the "DosisHome-Guest” network, which makes sense based on the information extracted from the firmware. 

Part 2: I’ll be Gnome for Christmas: Firmware Analysis for Fun and Profit

3) What operating system and CPU type are used in the Gnome? What type of Web framework is the Gnome web interface built in?

The operating System is based on Linux (OpenWRT, Bleeding Edge, r47650) with an ARM CPU. OpenWRT is a Linux distribution for embedded devices.

The Web Framework is a Server Side JavaScript system: Node.JS.

4) What kind of a Database engine is used to support the Gnome web interface? What is the plaintext password stored in the Gnome database?

The Database used is a NoSQL database: MongoDB. The plaintext password stored in the database is: “SittingOnAShelf”, for the user: “admin".

With the help of Jessica, in the Dosis Neighborhood, I downloaded the Gnome’s firmware (sha256):
bee93a79bb8ee2eba526494b4e6e56a601e1fa9589a1cccf7bfe61261ab8db20  giyh-firmware-dump.binExecuting “strings” on the image (strings giyh-firmware-dump.bin) shows a PEM encoded certificate and boot loader information. Reviewing the Certificate with openssl (openssl x509 -in cert.pem -noout -text), shows a self-signed x509 v3 Certificate with the following information:

- Issuer (same as subject): “O=ATNAS Corporation"- Not before:  "Nov 28 12:25:45 2015 GMT"- Not After: “Nov 25 12:25:45 2025 GMT"- Public Key: RSA 4096 bits

In order to extract more information, “binwalk”, is extremely helpful. Binwalk shows the following information (“./part02/files/binwalk.info"):

- 0 (0x0): PEM Certificate- 1809 (0x711): “ELF 32-bit LSB shared object, ARM, version 1"- 168803 (0x29363): “ Squashfs filesystem, little endian, version 4.0, compression:gzip, size: 17376149 bytes,  4866 inodes, blocksize: 131072 bytes, created: Tue Dec  8 18:47:32 2015"

This is a lot better, with “strings" the first two sections can be known, but now with the information obtained using binwalk,  it’s possible to extract the third section (squashfs). This is a job for “dd”, skip the first two sections, and then write the rest of the firmware image into a new file:

"dd if=giyh-firmware-dump.bin of=filesystem.squashfs bs=1 skip=168803"

This will take a long time (using one byte block size). This is very slow, but in order to speed up the process, it’s necessary to increase the block size, which means finding a number that can divide “168803” and the rest of the image (17376149), making this task very hard. 

After extracting the squashfs image (“filesystem.squashfs”), we can mount it using the following commands:

mkdir firmware_dirsudo mount -o loop filesystem.squashfs firmware_dir

Stepping into “firmware_dir” shows a POSIX based system. The “/etc” has most system configurations, a couple of files: “openwrt_release” and “openwrt_version”. Openwrt is a Linux distribution for embedded devices. 

The “/etc/hosts” contains the IP address of the Supergnome 01:

- “A.B.C.D    supergnome1.atnascorp.com sg1.atnascorp.com supergnome.atnascorp.com sg.atnascorp.com"

With a comment: “# LOUISE: NorthAmerica build”. This Supergnome (SG1) is for North America, so, there should be more of them around the globe. 

Let’s step into “init.d”, here there are five custom scripts with comments: mongod, nodejs, autowlan, sgstatd, sgstatd and sgdnsc2. It looks like: Stuart, Auggie, Louise and Nedford, have written these scripts. These scripts include the path of the executable commands. Let’s take a look:

- mongod: Looks like a standard mongo server program for ARM architectures: “ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)”. The config file is located in “/etc/mongod.conf” and has the path of the “db” directory: “/opt/mongodb”. We’ll look at it later.- nodejs: The program path is located in “/www/bin/www”, where “/www” is a standard directory estructure for a node.js application, including a package.json. - autowlan: This is a shell script with a loop (while true) that scans wireless network available, and tries to connect to open networks (encryption key: off). This explains how the Gnome connects from every home to the Supergnomes. - sgdnsc2: This is a binary file: “ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)” located in "/usr/bin”. Let’s run “strings” against this file:

“""Server specified NONE action.Server specified EXEC action.Failed to execute the command requested.Server specified FILE action.Control server says HELLO. Entering command mode.Connection could not be made. Sleeping.reply.willingvictim.comcmd.willingvictim.comcheck.willingvictim.com172.16.240.129HELLO:NONE:EXEC:FILE:EXEC:START_STATEEXEC:STOP_STATEFILE:START_STATE,NAME=FILE:STOP_STATE“""

This is the binary that performs the communication with the SuperGnome using DNS as a supporting protocol. 

- sgstatd: This is a binary file: “ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)”. This is odd, this file is a x86 binary file, not an ARM compiled version. This explains a couple of things, like why Stuart, Louise, Auggie and Nedford couldn’t make the init script work in the Gnome. Of course it worked in development Louise, most probably you were using a x86 platform, not an ARM platform. Second, if this binary was compiled for a x86 architecture, maybe it’ll be used in the SuperGnomes. Let’s grab some information using “strings”:

“"“nobodyWelcome to the SuperGnome Server Status Center!Please enter one of the following options:1 - Analyze hard disk usage2 - List open TCP sockets3 - Check logged in users/bin/dfFailed to run command/bin/netstat -tan/usr/bin/whoEnter a short message to share with GnomeNet (please allow 10 seconds) =>Request Completed!Invalid choice!Canary not repaired.This function is protected!Server started...Unable to set SIGCHLD handlerUnable to create socketUnable to set socket reuse optionUnable to bind socketUnable to listen on socketUnable to find user/var/run/sgstatdUnable to change directory to /var/run/sgstatdUnable to remove extra groupsUnable to change GIDUnable to change UID/dev/urandom;*2$"GCC: (Debian 4.7.2-5) 4.7.2GCC: (Debian 4.4.7-2) 4.4.7“”"

There is a lot of information here: a menu, a couple of commands, user input message, and a canary. We’ll take a closer look later. 

Let’s explore the whole filesystem:

find . -type f -exec file '{}' \; > ../find.files"

It seems like our only x86 binary file is sgstatd, the rest of the files are: ARM executables, ASCII text, shell scripts and data. The following command:

egrep -R  '(STUART|LOUISE|AUGGIE|NEDFORD)' * | cut -d: -f1 | uniq"

Shows the files where those guys were involved (at least the ones they put their name on):

“”"etc/hostsetc/init.d/autowlanetc/init.d/mongodetc/init.d/nodejsetc/init.d/sgdnsc2etc/init.d/sgstatdetc/mongod.confetc/rc.d/Kmongodetc/rc.d/Knodejsetc/rc.d/Ksgdnsc2etc/rc.d/Ksgstatdetc/rc.d/S90autowlanetc/rc.d/S97mongodetc/rc.d/S98nodejsetc/rc.d/S98sgstatdetc/rc.d/S99sgdnsc2usr/sbin/autowlanwww/routes/index.js“”"

We’ve already checked most of these files, except the node.js app directory. 

Now, let’s check the mongodb database files: /opt/mongod. This is the content of the file directory: “ _tmp  gnome.0  gnome.ns  journal  local.0  local.ns”. The files local.* store the data of the “local” database, which stores data for the replication process and other instance-specific data (taken from mongodb reference manual). In this case, let’s sneak into the gnome files using “strings”:

“”"nome.settingssettingCurrent config file:value./tmp/e31faee/cfg/sg.01.v1339.cfgsettingAllow new subordinates?:valuesettingCamera monitoring?:valuesettingAudio monitoring?:valuesettingCamera update rate:value60minsettingGnome name:valueSG-01settingAllow file uploads?:valuesettingAllowed file formats:value.pngsettingAllowed file size:value512kbsettingFiles directory:value/gnome/1/files/gnome.statussg-availsg-upgnome.usersusernameuserpassworduseruser_levelusernameadminpasswordSittingOnAShelfuser_level“"'

I’ve removed a couple of entries, but it looks like configuration information of a SuperGnome, including usernames and passwords stored in clear text. For the sake of fun, let’s copy these files, and install our own instance of MongoDB. I copied the gnome.* files to the db directory in another host, set the right permissions, and run mongod. After accessing the mongo shell with “mongo”, we can run a couple of commands:

- “show collections”:“”"camerassettingsstatussystem.indexesusers“”"- “ db.cameras.find()”:“”"{ "_id" : ObjectId("56225c994a37f7d48337b9be"), "cameraid" : 1, "tz" : -5, "status" : "online" }{ "_id" : ObjectId("56225ca84a37f7d48337b9bf"), "cameraid" : 2, "tz" : 5, "status" : "online" }{ "_id" : ObjectId("563606624f51b1c4472f365e"), "cameraid" : 3, "tz" : -5, "status" : "online" }{ "_id" : ObjectId("563606834f51b1c4472f365f"), "cameraid" : 4, "tz" : -5, "status" : "online" }{ "_id" : ObjectId("563606a14f51b1c4472f3660"), "cameraid" : 5, "tz" : -8, "status" : "online" }{ "_id" : ObjectId("563606e84f51b1c4472f3661"), "cameraid" : 6, "tz" : 9, "status" : "online" }{ "_id" : ObjectId("56433d16ed9881a101c95422"), "cameraid" : 7, "tz" : -5, "status" : "online" }{ "_id" : ObjectId("56433d1aed9881a101c95423"), "cameraid" : 9, "tz" : -4, "status" : "online" }{ "_id" : ObjectId("56433d1bed9881a101c95424"), "cameraid" : 8, "tz" : -6, "status" : "online" }{ "_id" : ObjectId("56433d28ed9881a101c95425"), "cameraid" : 10, "tz" : -5, "status" : "online" }{ "_id" : ObjectId("56433d2bed9881a101c95426"), "cameraid" : 11, "tz" : 6, "status" : "online" }{ "_id" : ObjectId("56433d2fed9881a101c95427"), "cameraid" : 12, "tz" : 7, "status" : "online" }“”"- “ db.settings.find()”:“”"{ "_id" : ObjectId("562269a1b6e8d3a99a07300c"), "setting" : "Current config file:", "value" : "./tmp/e31faee/cfg/sg.01.v1339.cfg" }{ "_id" : ObjectId("562269b2b6e8d3a99a07300d"), "setting" : "Allow new subordinates?:", "value" : "YES" }{ "_id" : ObjectId("562269e0b6e8d3a99a07300e"), "setting" : "Camera monitoring?:", "value" : "YES" }{ "_id" : ObjectId("562269e9b6e8d3a99a07300f"), "setting" : "Audio monitoring?:", "value" : "YES" }{ "_id" : ObjectId("562269f3b6e8d3a99a073010"), "setting" : "Camera update rate:", "value" : "60min" }{ "_id" : ObjectId("56226a03b6e8d3a99a073011"), "setting" : "Gnome mode:", "value" : "SuperGnome" }{ "_id" : ObjectId("56226a0db6e8d3a99a073012"), "setting" : "Gnome name:", "value" : "SG-01" }{ "_id" : ObjectId("56226a1bb6e8d3a99a073013"), "setting" : "Allow file uploads?:", "value" : "YES" }{ "_id" : ObjectId("56226a2ab6e8d3a99a073014"), "setting" : "Allowed file formats:", "value" : ".png" }{ "_id" : ObjectId("56226a38b6e8d3a99a073015"), "setting" : "Allowed file size:", "value" : "512kb" }{ "_id" : ObjectId("56226a47b6e8d3a99a073016"), "setting" : "Files directory:", "value" : "/gnome/1/files/" }“”"- “ db.status.find()”:“”"{ "_id" : ObjectId("56421153b0aa2a3be47a2d04"), "sg-avail" : 5, "sg-up" : 5, "gnomes-avail" : 1733315, "gnomes-up" : 1653325, "backbone" : "UP", "storage" : 1353235, "memory" : 835325, "last-update" : 1447170332 }{ "_id" : ObjectId("564212abb0aa2a3be47a2d05"), "sg-avail" : 5, "sg-up" : 5, "gnomes-avail" : 1733315, "gnomes-up" : 1653325, "backbone" : "UP", "storage" : 1353235, "memory" : 835325, "last-update" : 1447170395 }“”"- “ db.users.find()”:“”"{ "_id" : ObjectId("56229f58809473d11033515b"), "username" : "user", "password" : "user", "user_level" : 10 }{ "_id" : ObjectId("56229f63809473d11033515c"), "username" : "admin", "password" : "SittingOnAShelf", "user_level" : 100 }“”"

Now, we’ve usernames and passwords!


Part 3: Let it Gnome! Let it Gnome! Let it Gnome! Internet-Wide Scavenger Hunt!

5) What are the IP addresses of the five SuperGnomes scattered around the world, as verified by Tom Hessman in the Dosis Neighborhood?
6) Where is each SuperGnome located geographically?

With the help of shodan.io, and using “supergnome” as search pattern, the following IP addresses are shown (and verified by Tom Hessman):


- SG-01: United States, Ashburn.
- SG-02: United States, Boardman.
- SG-03: Australia, Sydney
- SG-04: Japan, Tokyo
- SG-05: Brazil, Sao Paulo.