Skip to content

Instantly share code, notes, and snippets.

@adampielak
Forked from ptrsimon/bashsnoop.sh
Created October 4, 2023 21:23
Show Gist options
  • Select an option

  • Save adampielak/023e037fb610068acc3d33a3792ee0fd to your computer and use it in GitHub Desktop.

Select an option

Save adampielak/023e037fb610068acc3d33a3792ee0fd to your computer and use it in GitHub Desktop.
Read not-yet-flushed history from a running shell
bpid=$(ps -o pid,comm xwwwf | grep -A1 screen| tail -1 | awk '{print $1}'); \
gcore $bpid; strings core.$bpid | grep '@' | grep root
# no gdb? no problem! dd to the rescue
bpid=$(ps -o pid,comm xwwwf | grep -A1 screen| tail -1 | awk '{print $1}'); \
offset=$(grep heap /proc/$bpid/maps|cut -d '-' -f 1); \
end=$(grep heap /proc/$bpid/maps|cut -d '-' -f 2|awk '{print $1}'); \
dd if=/proc/$bpid/mem iflag=skip_bytes,count_bytes bs=$(getconf PAGESIZE) skip=$((0x$offset)) count=$((0x$end - 0x$offset)) status=none \
| strings | grep root@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment