aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Nazaryev <sergey@nazaryev.ru>2017-04-05 23:01:27 +0000
committerSergey Nazaryev <sergey@nazaryev.ru>2017-04-05 23:10:38 +0000
commit91a02f8adb8e4bc018d249098a76686c7de21e25 (patch)
tree23cb5fe392c5edc7332eb52c7d552334310a3277
downloadxctu-decoder-master.zip
xctu-decoder-master.tar.gz
xctu-decoder-master.tar.bz2
Initial commitHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--README.md21
-rw-r--r--XCTUDecodeRequest.java10
-rwxr-xr-xdecode.sh33
4 files changed, 65 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6b468b6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.class
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2115dc7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+XCTU Firmware Decoder
+---------------------
+
+If you want to disassembly firmware from XBee's products, you can use
+this application for decoding firmwares from XBee's proprietary
+format (`*.ehx2`) to something usual (SREC file, for example).
+
+Requirements
+------------
+
+ - Linux :3
+ - installed XCTU at your home directory (for example, at ~/opt/XCTU-NG)
+ - installed JDK for javac
+
+Usage
+-----
+
+```shell
+export XCTUDIR=$HOME/opt/XCTU-NG
+./decode.sh "${XCTUDIR}/radio_firmwares/xbee_dm24/xbp24-dm_8073.ehx2 > firmware.srec
+```
diff --git a/XCTUDecodeRequest.java b/XCTUDecodeRequest.java
new file mode 100644
index 0000000..e870a9a
--- /dev/null
+++ b/XCTUDecodeRequest.java
@@ -0,0 +1,10 @@
+public class XCTUDecodeRequest {
+ public static void main(String[] args) {
+ try {
+ com.digi.xctung.xbee.models.a var9 = new com.digi.xctung.xbee.models.a(args[0], true, false, 0xfe, 0);
+ var9.a();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/decode.sh b/decode.sh
new file mode 100755
index 0000000..cd483f1
--- /dev/null
+++ b/decode.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+set -efu
+
+log() {
+ printf "$@" >&2
+}
+
+fatal() {
+ log "$@"
+ exit 1
+}
+
+[ -z "${XCTUDIR:-}" ] && \
+ fatal "Please, set environment variable XCTUDIR,
+e.g. XCTUDIR=/home/zar/opt/Digi/XCTU-NG\n"
+
+[ $# -ne 1 ] && fatal "usage: %s <file.ehx2>\n" "$0"
+
+file=$1
+[ ! -e "$file" ] && fatal "No file \"%s\" exists\n" "$file"
+
+dir=$(dirname "$file")
+dec=$(printf "%s.dec" "$file")
+
+touch "$dec"
+
+chmod u-w "$dir"
+[ ! -e "XCTUDecodeRequest.class" ] && javac -cp "${XCTUDIR}/plugins/*" XCTUDecodeRequest.java
+java -cp "${XCTUDIR}/plugins/*:." XCTUDecodeRequest "$file" 2>/dev/null
+chmod u+w "$dir"
+
+cat "$dec"
+rm "$dec"