项目作者: royveshovda

项目描述 :
Small hacking competiton used by Ice.net during NDC Oslo 2017. Purpose to get a code to win a prize.
高级语言: JavaScript
项目地址: git://github.com/royveshovda/competition.git
创建时间: 2017-05-29T04:24:14Z
项目社区:https://github.com/royveshovda/competition

开源协议:

下载


NDC Competition

Used by Ice during NDC Oslo 2017

Built using Elixir and Phoenix. Deployed using Nerves.

The competition was hosted on a Raspberry Pi Zero W with 3 LEDs.
The goal was to get all three LEDs to light up.

RPi at Ice

Steps for winning

  1. Figure out SSID and password to get on the same network as the RPi. Provided by hints on the spot.
  2. Find the IP of the RPi. Do a local scan or brute force search. The RPi responds to ping.
  3. Find the port of the webserver. Portscan or provided by hints
  4. Find the API at /api
  5. Follow the instructions on the API. Three questions needs to be answered. Each question lights up an LED.
  6. After all three questions are correctly answered, you get a 4 character code to verify you are a winner.

Hardware setup

The hardware setup is a connection of 3 LEDs with resistors to protect the LEDs. The Fritzing file can be found here.

Layout

Up and running

If you have never used Elixir, Phoenix and Nerves before, you need to install these on you computer first. In addition the setup uses Slack to notify the hosts on what is going on (including notifying winners), and timber.io to log system events and exceptions.

Elixir

Elixir is the main language of this setup.
Head over to https://elixir-lang.org and follow instructions there to install Elixir.

Phoenix

Phoenix framework is the webserver. Follow instructions at http://www.phoenixframework.org to install.

Nerves

Nerves is used to bundle everything in a nice image to the SD card of the RPi. It wraps together the OS, runtime and your code in a package, and helps you burn the image to the SD card. Go to http://nerves-project.org to install.

Slack

The setup needs a Slack webhook to post notifications to. Follow the instructions on Slack to create a webhook. Use the URL in the config (described below).

Timber.io

The setup uses timber.io for logging. Head over to timber.io, sign up and get an API key. Use the API key in the config file (described below).

Config

To avoid getting secret leaking to github (or any other source controls), you need to create the following file: /apps/firmware/config/prod.secret.exs and fill in the blanks from the template below.

  1. use Mix.Config
  2. config :firmware, :wlan0,
  3. ssid: "<WLAN SSID>",
  4. psk: "<WLAN password>"
  5. config :timber,
  6. api_key: "<API key from timber.io>"
  7. config :api, Api.Endpoint,
  8. secret_key_base: "<random secure key - can reuse the one in confix.exs>"
  9. config :api, :questions,
  10. q1: "What is 1+1",
  11. a1: 2,
  12. q2: "What is 2+2?",
  13. a2: 5,
  14. q3: "What is the Answer to the Ultimate Question of Life, The Universe, and Everything?",
  15. a3: 42
  16. config :api, :slack,
  17. url: "<url to slack webhook>"

Instructions

With all the above in place, you can follow these steps to get up and running (instructions verified on MacOS, might differ on Windows):

  1. Go to the folder /apps/firmware
  2. Set target (hardware type): export MIX_TARGET=rpi0
  3. Set environment: export MIX_ENV=prod
  4. Download dependecies: mix deps.get
  5. Compile: mix compile
  6. Generate firmware image: mix firmware
  7. Plug in SD card to your computer
  8. Burn image to SD card: mix firmware.burn
  9. Plug the SD card into the RPi
  10. Power up the RPi