Last active
September 6, 2015 06:36
-
-
Save imZack/81f21869937a79870575 to your computer and use it in GitHub Desktop.
hitcon 2015 nano wargame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import re | |
import serial | |
import time | |
port = None | |
lines = [] | |
def game0(line): | |
if line == 'Nano$ enter your answer:': | |
# enter you answer here | |
answer = '' | |
port.write('%s\n' % answer) | |
port.flush() | |
def game1(line): | |
if line == 'Nano$ show map': | |
global lines | |
# here is map | |
lines = lines[-3:] | |
# for line in lines: | |
# print line | |
# write you rules to send [w] [a] [s] [d] here | |
port.write('d\n') | |
port.flush() | |
else: | |
lines.append(line) | |
def game2(line): | |
if line == 'Nano$ enter your answer:': | |
global lines | |
lines = lines[-1:] | |
total = 0 | |
# write you rules to calculate answer here | |
port.write('%d\n' % total) | |
port.flush() | |
else: | |
lines.append(line) | |
def main(): | |
# enter your choice here | |
choice = '0' | |
while True: | |
line = port.readline()[:-1] | |
print line | |
if line == 'Nano$ enter your choice:': | |
port.write('%s\n' % choice) | |
port.flush() | |
if line == 'Nano$ finish': | |
port.close() | |
break | |
if choice == '0': | |
game0(line) | |
if choice == '1': | |
game1(line) | |
if choice == '2': | |
game2(line) | |
if choice == '3': | |
game3(line) | |
if __name__ == '__main__': | |
port = serial.Serial(port=3, baudrate=115200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE) | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
λ ~/ avrdude -F -c arduino -b 57600 -P /dev/tty.wchusbserialfd120 -pm328 -vv -U flash:r:program.bin:r | |
avrdude: Version 6.1, compiled on Aug 28 2015 at 13:24:58 | |
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ | |
Copyright (c) 2007-2014 Joerg Wunsch | |
System wide configuration file is "/usr/local/Cellar/avrdude/6.1/etc/avrdude.conf" | |
User configuration file is "/Users/zack/.avrduderc" | |
User configuration file does not exist or is not a regular file, skipping | |
Using Port : /dev/tty.wchusbserialfd120 | |
Using Programmer : arduino | |
Overriding Baud Rate : 57600 | |
AVR Part : ATmega328 | |
Chip Erase delay : 9000 us | |
PAGEL : PD7 | |
BS2 : PC2 | |
RESET disposition : dedicated | |
RETRY pulse : SCK | |
serial program mode : yes | |
parallel program mode : yes | |
Timeout : 200 | |
StabDelay : 100 | |
CmdexeDelay : 25 | |
SyncLoops : 32 | |
ByteDelay : 0 | |
PollIndex : 3 | |
PollValue : 0x53 | |
Memory Detail : | |
Block Poll Page Polled | |
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack | |
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- | |
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff | |
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff | |
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 | |
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 | |
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 | |
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 | |
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 | |
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 | |
Programmer Type : Arduino | |
Description : Arduino | |
Hardware Version: 2 | |
Firmware Version: 1.16 | |
Vtarget : 0.0 V | |
Varef : 0.0 V | |
Oscillator : Off | |
SCK period : 0.1 us | |
avrdude: AVR device initialized and ready to accept instructions | |
Reading | ################################################## | 100% 0.02s | |
avrdude: Device signature = 0x1e950f | |
avrdude: Expected signature for ATmega328 is 1E 95 14 | |
avrdude: safemode: lfuse reads as 0 | |
avrdude: safemode: hfuse reads as 0 | |
avrdude: safemode: efuse reads as 0 | |
avrdude: reading flash memory: | |
Reading | ################################################## | 100% 18.33s | |
avrdude: writing output file "program.bin" | |
avrdude: safemode: lfuse reads as 0 | |
avrdude: safemode: hfuse reads as 0 | |
avrdude: safemode: efuse reads as 0 | |
avrdude: safemode: Fuses OK (E:00, H:00, L:00) | |
avrdude done. Thank you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TRINGS(1) STRINGS(1) | |
NAME | |
strings - find the printable strings in a object, or other binary, file | |
SYNOPSIS | |
strings [ - ] [ -a ] [ -o ] [ -t format ] [ -number ] [ -n number ] [--] [file ...] | |
DESCRIPTION | |
Strings looks for ASCII strings in a binary file or standard input. Strings is useful for identifying random | |
object files and many other things. A string is any sequence of 4 (the default) or more printing characters | |
ending with a newline or a null. Unless the - flag is given, strings looks in all sections of the object | |
files except the (__TEXT,__text) section. If no files are specified standard input is read. | |
The file arguments may be of the form libx.a(foo.o), to request information about only that object file and | |
not the entire library. (Typically this argument must be quoted, ``libx.a(foo.o)'', to get it past the | |
shell.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
λ ~/ strings program.bin | |
/_?OA__O/01 | |
$$_>O | |
$$_>O | |
g+h+i+q | |
O__O | |
O__O | |
O__O | |
._?O | |
/_?O | |
i2sB | |
i>s@ | |
<--- | |
8-)- | |
c/r/ | |
+[?O | |
,_?O | |
,_?O | |
,_?O | |
,_?O | |
!,1,B-@1 | |
H Y j { | |
COpm | |
D)U)f)w) | |
KZ_O | |
O__OoO | |
L__O! | |
?OOO_O | |
'i'x' | |
N__O$ | |
a,q,` | |
APP@ | |
APP@ | |
'J01 | |
Y/H/7/&/f | |
.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
Nano$ I WANT TO PLAY A GAME ! | |
Nano$ now, you are in (0,0) of an unknown maze. | |
Nano$ you must reach (14, 14) of this maze. | |
Nano$ you have ten seconds to reach it. | |
Nano$ the 'O' is where you are. | |
Nano$ the '.' mark is road. | |
Nano$ the '+' mark is wall. | |
Nano$ send [w] to move up | |
Nano$ send [d] to move right | |
Nano$ send [s] to move down | |
Nano$ send [a] to move left | |
Nano$ show map | |
Nano$ | |
= ? | |
HITCON 2015 NANO GAME | |
User$ my answer is | |
b347bae2bfcd1ef679aa3177d017f042e52dca2 | |
Nano$ key is 457E1A295B9D1C48 | |
Nano$ wrong answer | |
Nano$ finish | |
User$ send [ | |
Nano$ key is 3D52CB746F9E6C83 | |
Nano$ key is 273A9C1E2D380B48 | |
Nano$ [0] Morse | |
Nano$ [1] Maze | |
Nano$ [2] Calculator | |
Nano$ enter your choice: | |
User$ choice [0] Morse | |
User$ choice [1] Maze | |
User$ choice [2] Calculator | |
Nano$ activate Morse | |
Nano$ .... .. - -.-. --- -. -. .- -. --- --. .- -- . -- --- .-. ... . | |
Nano$ enter your answer: | |
Nano$ activate Maze | |
Nano$ activate Calculator | |
Nano$ timeout (9 seconds) | |
Nano$ timeout (1 seconds) | |
(/)Z | |
(/ ] | |
!P0@ | |
!P0@ | |
/_?O | |
O__OF | |
/_?O0 | |
O__OF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment