LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2018, 12:31 PM   #1
mhsh0001
LQ Newbie
 
Registered: Jul 2018
Posts: 5

Rep: Reputation: Disabled
Post changing compiled bash program in redhat linux


hi guys,
I compiled a bash programming 3 years ago, unfortunately i lost the source code and i want to change only some lines of that code, is there any possibility or any approach to change (remove or add) some line of that code and the run it again?
 
Old 07-03-2018, 12:45 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Unlikely, but it depends on the programming language (no, bash isn't a programming language).
 
1 members found this post helpful.
Old 07-03-2018, 12:48 PM   #3
mhsh0001
LQ Newbie
 
Registered: Jul 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
simple bash programming

is there any way to change it to assembly and change it and the compile the assembly?
 
Old 07-03-2018, 01:11 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,672

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
No idea because it depends on what tool you used to "compile" your bash script? If you used shc you might be able to reconstruct the source code by the following technique.

https://stackoverflow.com/questions/...ed-bash-script
 
Old 07-03-2018, 01:15 PM   #5
mhsh0001
LQ Newbie
 
Registered: Jul 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
Am i wrong?

Am i wrong?
I am supposed every compile version of any languages in linux, compile to the assembly and then run into the binary language that cpu understand it, so we could be "middle man" and change the assembly, so we could change some of our codes and variables in the source code without even know it.
 
Old 07-03-2018, 01:31 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,672

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Yes, reverse engineering a compiled program is not easy.

Again if you do not remember what tool you used there isn't much we can do.

For example CCsh is a commercial bash script compiler that converts your script to c code. I'm not familiar with the compiler but it would be extremely difficult to determine where any original bash variables are located much less be able to change any lines of code.

Last edited by michaelk; 07-03-2018 at 01:41 PM.
 
Old 07-03-2018, 01:55 PM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,879
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by mhsh0001 View Post
Am i wrong?
I am supposed every compile version of any languages in linux, compile to the assembly and then run into the binary language that cpu understand it, so we could be "middle man" and change the assembly, so we could change some of our codes and variables in the source code without even know it.
You are incorrect about a bash script. Bash is a scripting language and you do not compile the scripts, you merely run them.


In your first post you said you compiled it.


How did you compile something which doesn't require a compiler?
 
Old 07-03-2018, 02:42 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,218

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by mhsh0001 View Post
Am i wrong?
I am supposed every compile version of any languages in linux, compile to the assembly and then run into the binary language that cpu understand it, so we could be "middle man" and change the assembly, so we could change some of our codes and variables in the source code without even know it.
For a BASH script? That would be stupid. Just write the script again.

Compiling BASH scripts is even more stupid. Not sure how or why you did that, but you obviously shouldn't do that again.

(If this was something actually worth going to the effort to binary-patch, I would have recommended looking into ida pro).

Last edited by dugan; 07-03-2018 at 02:47 PM.
 
Old 07-03-2018, 03:27 PM   #9
mhsh0001
LQ Newbie
 
Registered: Jul 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
maybe i could not tell my need, i want to reverse engineer bash programming and manipulate my old code. is there any source about reverse engineering bash linux?
 
Old 07-03-2018, 03:29 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,218

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by mhsh0001 View Post
maybe i could not tell my need, i want to reverse engineer bash programming and manipulate my old code. is there any source about reverse engineering bash linux?
LOL no.
 
Old 07-03-2018, 04:16 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,672

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
To repeat myself it depends on what tool you used to "compile" your bash script. If you used shc it might be possible to recover your code. There is a link in the conclusions section that explains how to do it.

http://www.linux-magazine.com/Online...Shell-Compiler

If you used CCsh then I would say not possible. CCsh coverts the bash script to c and then compiles. You can use a decompiler but you will only get c code and that will not be identical to the original code that was generated from the bash script. Nothing exists to get back to your original bash script.
 
1 members found this post helpful.
Old 07-03-2018, 10:14 PM   #12
mhsh0001
LQ Newbie
 
Registered: Jul 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
my goal is not to see the original bash script, i just wanted to remove some line from execution. is it possible? and how?
 
Old 07-03-2018, 10:51 PM   #13
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,218

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by mhsh0001 View Post
my goal is not to see the original bash script, i just wanted to remove some line from execution. is it possible?
LOL no.

(I believe I already answered this?)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiled program not showing up as compiled and not able to run. hjoshuaj Linux - Newbie 3 03-27-2014 05:49 AM
[SOLVED] changing a line in a config file while installing the program using bash script Joe_Louis Programming 11 07-23-2011 05:05 AM
Errors in Allegro in a C++ program, compiled with gcc, in a Linux console AlegroGuy Programming 9 11-17-2010 07:17 PM
A C program which was compiled properly in DevCPP is not compiling in Linux-Fedora. varalakshmi Linux - Newbie 2 10-30-2010 03:37 AM
pre-compiled CPU stress program for linux glock19 Linux - General 1 11-01-2001 12:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration