forked from envyniv/denpa-qr-inv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdb_handler.sh
71 lines (59 loc) · 1.8 KB
/
gdb_handler.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
GDB=$DEVKITARM/bin/arm-none-eabi-gdb
GDBPORT=4000
#BLACK=$(tput setaf 0)
#RED=$(tput setaf 1)
#GREEN=$(tput setaf 2)
#LIME_YELLOW=$(tput setaf 190)
#YELLOW=$(tput setaf 3)
#POWDER_BLUE=$(tput setaf 153)
#BLUE=$(tput setaf 4)
#MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
#WHITE=$(tput setaf 7)
#BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
#BLINK=$(tput blink)
#REVERSE=$(tput smso)
#UNDERLINE=$(tput smul)
function QRBinContentsInGDB() {
bin=$1
limit = $2
#I probably could've used perl but I happen to be incompetent :)
xxd -p $bin | fold -w2 | while IFS= read -r line; do
echo "0x$line";
done | tr "\n" "," | sed 's/...../& /g; s/..$//'
#| sed "s/.....{$limit\}//"
}
export -f QRBinContentsInGDB
function chooseServer() {
#if ! kdialog --radiolist \
# "What console should we connect to?" $@ >/tmp/RosalinaClient; then
if ! kdialog --radiolist \
"What console should we connect to?" $@ | read CHOSEN_IP; then
echo "Operation cancelled"
exit
fi
}
export -f chooseServer
function message() {
echo "${CYAN}$1${NORMAL}"
}
function scanForGDB() {
#sometimes this won't pick up anything.
nmap -Pn -p$GDBPORT --open 192.168.1.1/24 -oG - | \
grep Up | cut -d ' ' -f 2
}
while [ -z "${IP_ADDRESSES}" ]; do
message "GDB Server(s) not found. Scanning Again."
IP_ADDRESSES=$(scanForGDB)
done
message "Rosalina GDB Server(s) found. Building list."
for IP in $IP_ADDRESSES; do
echo "$IP GDB@$IP on"
done | xargs -I % bash -c 'chooseServer "%"'
# can't use --command since the gdb file is parametric
# we need to run it through bash first
# can't use python automation because devkitARM gdb is compiled without python
# support by default :upside_down_smile:
$GDB < (echo $(<prod.gdb)) #--command=prod.gdb --symbols=symfile