Debugging/Reverse engineering Linux shell script.

(Intended for someone[me] who don’t faint on sight of some assembler code and can look for relevant information from the dump of a binary).

(In draft)

1.Debugging

using option vx for debugging shell script might be a good idea when you can not find anything wrong by the visual inspection

[howTo]

say you have a shellscript called DoGreatStuff

called with parameters me you they $4 etc

call it as : set -vf DoGreatStuff me you they $4 etc

Example run for cd for list in my computer is

set -vx ls $1
set -vx ls $1
__vte_prompt_command
++ __vte_prompt_command
__vte_osc7)”
__vte_osc7)
__vte_osc7
+++ __vte_osc7
__vte_urlencode “${PWD}”)”
__vte_urlencode “${PWD}”)
__vte_urlencode “${PWD}”
++++ __vte_urlencode /home/tanmay
++++ LANG=C
++++ str=/home/tanmay
++++ ‘[‘ -n /home/tanmay ‘]’
++++ safe=/home/tanmay
++++ printf %s /home/tanmay
++++ str=
++++ ‘[‘ -n ” ‘]’
++++ ‘[‘ -n ” ‘]’
+++ printf ’33]7;file://%s%s\a’ tanmay /home/tanmay
++ printf ’33]0;%s@%s:%s07%s’ tanmay tanmay ‘~’ ”

Ignore other things but you can see that ls is a C program.. (Not a good example here but I hope explains the point here)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.