This is the super card reader/writer placed at the information desk of the HITCON activity team. Please refer to the folder chameleon_station
.
This is the server which process all the game event. It would be accessed by all the arduino through WiFi. It may also be accessed by other activity (such as dashboard and 大地遊戲).
(copied from dev hackmd)
(內部 code name: popcat)
encode(incr)
,incr 初始化成 1,代表每次刷卡會加 1
lambda x: x + 1337
,decode 是做在 arduino 上的,api server 會直接記錄收到的 incr
lambda x: x + 0xaa94237c
,decode 定義為 lambda x: x - 0xaa94237c
。得到的數值 cast 成 int32_t(值域 $[-2147483648, 2147483647)$)uint32_t encode(int16_t x) {
int16_t r = rand();
return (r << 16) + (int16_t(r + x))
}
int16_t decode(uint32_t x) {
int16_t upper = (x >> 16);
int16_t lower = (x & 0xffff);
return lower - upper;
}
(內部 code name: dinorun)
(內部 code name: crypto game)
遊戲機制
卡片上有另一個空間存 concat(x, card_uid)
的 hmac,所有讀卡機共享一個 hmac 的 key
import hmac
key = b'\xde\xad\xbe\xef'
card_uid = b'\xde\xad\xbe\xef'
data = b'aaaa'
h = hmac.new(key, digestmod='sha256')
h.update(card_uid)
h.update(data)
print(h.hexdigest())
concat(x, card_uid)
得來的,滿足的話即可獲得獎品(每日限額)#ifdef DEVCORE
static uint32_t update_data(uint32_t src) {
static char str[] = "DVCR";
return src ^ *(int *)str;
}
#elif defined CYCRAFT
static uint32_t update_data(uint32_t src) {
static char str[] = "CRFT";
return src ^ *(int *)str;
}
#elif defined FOXCONN
static uint32_t update_data(uint32_t src) {
static char str[] = "2317";
return src ^ *(int *)str;
}
#elif defined ISIP
static uint32_t update_data(uint32_t src) {
static char str[] = "ISIP";
return src ^ *(int *)str;
}
#elif defined KLICKLACK
static uint32_t update_data(uint32_t src) {
static char str[] = "KKCO";
return src ^ *(int *)str;
}
#elif defined CHT_SEC
static uint32_t update_data(uint32_t src) {
static char str[] = "CHTS";
return src ^ *(int *)str;
}
#elif defined TRAPA
static uint32_t update_data(uint32_t src) {
static char str[] = "TRPA";
return src ^ *(int *)str;
}
#elif defined RAKUTEN
static uint32_t update_data(uint32_t src) {
static char str[] = "RKTN";
return src ^ *(int *)str;
}
#elif defined KKCOMPANY
static uint32_t update_data(uint32_t src) {
static char str[] = "KBOX";
return src ^ *(int *)str;
}
#elif defined OFFSEC
static uint32_t update_data(uint32_t src) {
static char str[] = "OFSC";
return src ^ *(int *)str;
}
uint32_t wild1(uint32_t x) { // just reset
// IMPORTANT: do not check hmac!
return 0;
}
uint32_t wild2(uint32_t x) {
return x + 1;
}
uint32_t wild3(uint32_t x) {
// uint5_t r = LSB 5 bit
// ror(x, r)
return ;
}
uint32_t wild4(uint32_t x) {
// low 16 bits swap with high 16 bits
return ;
}
uint32_t wild5(uint32_t x) {
// random flip 2 bits
return ;
}