shc icon indicating copy to clipboard operation
shc copied to clipboard

I lost my shell script but have my C Code can i reverse it.

Open RainbowTabitha opened this issue 4 years ago • 2 comments

RainbowTabitha avatar Oct 10 '20 00:10 RainbowTabitha

compile the c code, run it and get the source (to know how you may do a bit google search)

neurobin avatar Oct 10 '20 10:10 neurobin

As long as your script takes a little bit to run, you can easily dump the code with something like this: ./shctest.bin & PID=$!; sleep 0.2; ps -wwq $PID -o cmd= | sed -E 's/-c \s+(#!)/\1/'

Basically it will run it in the background, wait 200ms to make sure the wrapper has done the call to exec, then find the full command in the process list and trim away the million spaces it adds to pretend that the code is not there. You'll have to add in the newlines again manually. There are probably more ways still to reverse it in a more readable form, but it's a way to do it.

SteenSchutt avatar May 27 '21 15:05 SteenSchutt