Skip to content

Instantly share code, notes, and snippets.

View kakash1hatake's full-sized avatar

kakash1hatake kakash1hatake

  • Russia
View GitHub Profile
@kakash1hatake
kakash1hatake / penv_runtime.sh
Last active May 16, 2020 07:46
get env variable of the particular process using gdb
#!/bin/sh
#
# get env variable of the particular process. It can show variables that were created at runtime. Requires root privileges
# usage: sudo penv_runtime.sh pid var_name
#
pid=$1
var_name=$2
var_value=`gdb -q -batch -ex "attach $pid" -ex 'call (char*) getenv("'$var_name'")' -ex 'detach' | egrep '^\$1 ='`
@kakash1hatake
kakash1hatake / penv.sh
Last active May 16, 2020 07:45
show env variables of the particular process that were created during process startup
#!/bin/sh
#
# show env variables of the particular process that were created during process startup. requires root privileges
# usage: sudo penv.sh pid
pid=$1
awk 'BEGIN {RS="\0"; ORS="\n"} $0' "/proc/$pid/environ"
@kakash1hatake
kakash1hatake / chenv.sh
Last active May 14, 2020 17:10
set or replace env variable in existing process. requires root privileges
#!/bin/sh
#
# set or replace env variable in existing process. requires root privileges
# usage: sudo chenv.sh pid var_name var_value
#
pid=$1
env_name=$2
env_val="$3"