First version of an serial openbeaconsniffer. Yay.

This commit is contained in:
Stefan `Sec` Zehl 2011-07-27 19:03:25 +02:00
parent 9e4f27ad12
commit 196ac680e9
4 changed files with 250 additions and 25 deletions

View File

@ -1 +1,38 @@
#include "../tester/config.c"
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/print.h"
#include "lcd/display.h"
#include "filesystem/ff.h"
#include <string.h>
/**************************************************************************/
void readcfg(void) {
readConfig();
};
void savecfg(void){
saveConfig();
};
void applycfg(void){
applyConfig();
};
void show(void){
lcdClear();
lcdPrint("time:"); lcdPrintInt(globalconfig.time); lcdNl();
lcdPrint("btrig:"); lcdPrintInt(globalconfig.backlighttrigger); lcdNl();
lcdPrint("bval:"); lcdPrintInt(globalconfig.backlightvalue); lcdNl();
lcdPrint("lcd:"); lcdPrintInt(globalconfig.lcdstate); lcdNl();
lcdPrint("priv:"); lcdPrintInt(globalconfig.privacy); lcdNl();
lcdRefresh();
};
void lcdmirror(void){
lcdToggleFlag(LCD_MIRRORX);
};

View File

@ -12,9 +12,17 @@
#include "usbcdc/usbhw.h"
#include "usbcdc/cdcuser.h"
#include "usbcdc/cdc_buf.h"
#include "usbcdc/util.h"
#include <string.h>
#define BEACON_CHANNEL 81
#define BEACON_MAC "\x1\x2\x3\x2\1"
uint32_t const testkey[4] = {
0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E
};
#if CFG_USBMSC
#error "MSC is defined"
#endif
@ -26,18 +34,18 @@
/**************************************************************************/
void f_ser(void) {
void ser_enable(void) {
usbCDCInit();
};
void f_disconnect(void) {
void ser_disable(void) {
usbCDCOff();
};
#define LEN 10
void f_sread(){
uint8_t buf[LEN+1];
int l=LEN;
#define myLEN 10
void ser_read(){
uint8_t buf[myLEN+1];
int l=myLEN;
lcdPrint("Bytes:");
CDC_OutBufAvailChar (&l);
@ -53,21 +61,94 @@ void f_sread(){
lcdPrintln(buf);
};
void f_echo(){
uint8_t buf[2] = {0,0};
int l;
while(1){
CDC_OutBufAvailChar(&l);
if( l ){
l = 1;
CDC_RdOutBuf (buf, &l);
puts(buf);
}
//puts("hello world\r\n");
//delayms(1);
}
};
void f_say(){
void ser_say(){
puts("hello world\r\n");
};
void f_init(){
nrf_init();
struct NRF_CFG config = {
.channel= BEACON_CHANNEL,
.txmac= BEACON_MAC,
.nrmacs=1,
.mac0= BEACON_MAC,
.maclen ="\x10",
};
nrf_config_set(&config);
};
void f_beacon(void){
struct NRF_CFG config = {
.channel= BEACON_CHANNEL,
.txmac= BEACON_MAC,
.nrmacs=1,
.mac0= BEACON_MAC,
.maclen ="\x10",
};
nrf_config_set(&config);
};
int enctoggle=0;
void f_enctog(){
enctoggle=1-enctoggle;
lcdClear();
lcdPrint("Encryption:");
if(enctoggle)
lcdPrintln("ON");
else
lcdPrintln("Off");
};
const char* IntToStrX(unsigned int num, unsigned int mxlen){
#define LEN 32
static char s[LEN+1];
char * o=s;
int len;
s[LEN]=0;
for (len=(LEN-1);len>=(LEN-mxlen);len--){
s[len]=(num%16)+'0';
if(s[len]>'9')
s[len]+='A'-'9'-1;
num/=16;
};
return &s[len+1];
};
void f_recser(void){
__attribute__ ((aligned (4))) uint8_t buf[32];
int len;
getInputWaitRelease();
do{
len=nrf_rcv_pkt_time_encr(1000,sizeof(buf),buf,enctoggle?testkey:NULL);
if(len==0){
puts("(Timeout)\r\n");
};
puts("pkt: ");
puts("[");puts(IntToStrX(len,2));puts("] ");
puts(IntToStrX( *(int*)(buf+ 0),2 ));
puts(" ");
puts(IntToStrX( *(int*)(buf+ 1),2 ));
puts(" ");
puts(IntToStrX( *(int*)(buf+ 2),2 ));
puts(" ");
puts(IntToStrX( *(int*)(buf+ 3),2 ));
puts(".");
puts(IntToStrX( *(int*)(buf+ 4),8 ));
puts(".");
puts(IntToStrX( *(int*)(buf+ 8),8 ));
puts(".");
puts(IntToStrX( *(int*)(buf+ 12),4 ));
puts(" [");
len=crc16(buf,14);
puts(IntToStrX(len,4)); puts("]\r\n");
delayms(10);
}while ((getInputRaw())==BTN_NONE);
};

View File

@ -1 +1,83 @@
#include "../tester/util.c"
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "lcd/allfonts.h"
#include "filesystem/ff.h"
#include "filesystem/select.h"
#include "funk/nrf24l01p.h"
#include "usb/usbmsc.h"
#include <string.h>
/**************************************************************************/
void show_ticks(void) {
int dx=0;
int dy=8;
lcdClear();
dx=DoString(0,dy,"Ticks:");
while ((getInputRaw())==BTN_NONE){
DoInt(0,dy+8,_timectr);
lcdDisplay();
};
dy+=16;
dx=DoString(0,dy,"Done.");
};
void adc_light(void) {
int dx=0;
int dy=8;
dx=DoString(0,dy,"Light:");
DoString(0,dy+16,"Night:");
while ((getInputRaw())==BTN_NONE){
DoInt(dx,dy,GetLight());
DoInt(dx,dy+16,isNight());
DoInt(dx,dy+8,globalconfig.backlighttrigger);
lcdDisplay();
};
dy+=8;
dx=DoString(0,dy,"Done.");
};
void gotoISP(void) {
DoString(0,0,"Enter ISP!");
lcdDisplay();
ISPandReset();
}
void lcd_mirror(void) {
lcdToggleFlag(LCD_MIRRORX);
};
void lcd_invert(void) {
lcdToggleFlag(LCD_INVERTED);
};
void adc_check(void) {
int dx=0;
int dy=8;
// Print Voltage
dx=DoString(0,dy,"Voltage:");
while ((getInputRaw())==BTN_NONE){
DoInt(dx,dy,GetVoltage());
lcdDisplay();
};
dy+=8;
dx=DoString(0,dy,"Done.");
};
void msc_menu(void){
DoString(0,8,"MSC Enabled.");
lcdDisplay();
usbMSCInit();
getInputWaitRelease();
getInputWait();
DoString(0,16,"MSC Disabled.");
usbMSCOff();
};

View File

@ -1 +1,26 @@
#include "../tester/uuid.c"
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "funk/nrf24l01p.h"
#include <string.h>
#include "funk/rftransfer.h"
#include "funk/openbeacon.h"
#include "core/iap/iap.h"
/**************************************************************************/
void f_uuid(void) {
IAP_return_t iap_return;
iap_return = iapReadSerialNumber();
lcdPrintIntHex(iap_return.Result[0]); lcdNl();
lcdPrintIntHex(iap_return.Result[1]); lcdNl();
lcdPrintIntHex(iap_return.Result[2]); lcdNl();
lcdPrintIntHex(iap_return.Result[3]); lcdNl();
}