make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / rsysrq
blobea5e74075c104ff3966bd63ada3279eb83c62b5e
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 rsysrq - Send SysRQ commands remotely over the network
10 =cut
12 EOF
16 # SysRq Help:
17 # loglevel(0-9)
18 # re(B)oot
19 # (C)rash
20 # t(E)rminate-all-tasks
21 # memory-(F)ull-oom-kill
22 # k(I)ll-all-tasks
23 # thaw-filesystems(J)
24 # secure-attention-(K)ey
25 # show-backtrace-a(L)l-active-cpus
26 # show-(M)emory-usage
27 # (N)ice-all-RT-tasks
28 # power(O)ff
29 # show-registers(P)
30 # show-all-timers(Q)
31 # un(R)aw
32 # (S)ync
33 # show-(T)ask-states
34 # (U)nmount
35 # force-fb(V)
36 # show-blocked-tasks(W)
37 # dump-ftrace-buffer(Z)
41 if [ $# != 3 ]; then
42 echo "Usage: $0 host[:port] sysrq-keys sysrq-password"
43 exit 1
46 expr "$1" : '.*:' >/dev/null && hostport=$1 || hostport=$1:9
47 keys=$2
48 password=$3
49 ipaddr=`gethostip -d ${hostport%:*}`
52 seqno=`date +%s`
53 salt=`dd bs=12 count=1 if=/dev/urandom 2>/dev/null | openssl enc -base64`
54 data=$keys,$seqno,$salt
55 data=$data,`echo -n "$data,$ipaddr,$password" | sha1sum | cut -c1-40`
58 echo "$data" | socat stdin udp-sendto:$hostport