-
How to get the source code of a software/program
Greetings!
This is my first post here in the CodeGuru Forums, and I'm still a newbie to coding and programming.:blush:
Sometimes, I bump against a software or program, and don't understand how a part of it (or the entire software) works. So, I thought whether it might be possible to "Decompile" a program to get its source code, just like you would do on a webpage. Is it possible to be done at all? Is there any software designed for that purpose? If not, how can I build one?
Thanks in advance,
wkwkwkwk1
-
Re: How to get the source code of a software/program
If a software isn't delivered with the source it's usually against the EULA tamper with it.
See also http://forums.codeguru.com/misc.php?do=showrules
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
S_M_A
Well, it does make sense, they probably don't want anyone to steal their code, and most non-open-source software doesn't come with the code.
If the EULA doesn't specify that it's forbidden to «tamper with it», then would there be any problem?
Thanks in advance,
wkwkwkwk1
-
Re: How to get the source code of a software/program
I guess not but even so there is no easy way to reverse engineer a program written in C++ or any other compiled language. What you will get is something very similar to running the application in a debugger showing the assembly code. How that looks like it's easy for you to test by attaching the debugger to a running process and then hit break.
-
Re: How to get the source code of a software/program
Should I assume that you just want to know how to do this for curiosity's sake? You do not want to steal anyone's code or do anything malicious, right? You just want to peak under the "hood"? All right then, it is relatively easy to disassemble a program, that is, turn the machine code into assembly code, but it is much more difficult to turn that assembly code into a higher level language with variable and function names that are meaningful to humans. When a program is compiled, all of the variable names and internal function names are lost. They are replaced by arbitrary addresses that do not convey any information by themselves.
Nevertheless, with a thorough understanding of both assembly and high level programming and enough free time on your hands, there are things you can do. For example, sometimes I use Notepad to view C++ code I have written without having to run the C++ development environment. However, the default tab stop in Notepad is eight characters which makes reading my code more difficult. Using white hat hacking techniques, I was able to change the tab stop to four characters, the same as the C++ development environment. I basically added two lines of (high level) code to the executable file. This hack involved coding in machine language.
Another example was when I wanted to know how to set the wallpaper of my desktop through code. By looking at the MS Paint executable, I discovered the name of the Windows API function I needed to call. I then read the documentation for this function and was able to implement it in my own code.
The best use I have found for hacking programs is hacking my own executable files when they crash. When memory gets corrupted, seeing the relationship between various memory locations in the compiled code can be very insightful. Also, it is possible to insert debugging code that will not accidentally "fix" the problem by moving it to some other place.
Now, what do you have in mind?
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
Coder Dave
Should I assume that you just want to know how to do this for curiosity's sake? You do not want to steal anyone's code or do anything malicious, right? You just want to peak under the "hood"? All right then, it is relatively easy to disassemble a program, that is, turn the machine code into assembly code, but it is much more difficult to turn that assembly code into a higher level language with variable and function names that are meaningful to humans. When a program is compiled, all of the variable names and internal function names are lost. They are replaced by arbitrary addresses that do not convey any information by themselves.
Nevertheless, with a thorough understanding of both assembly and high level programming and enough free time on your hands, there are things you can do. For example, sometimes I use Notepad to view C++ code I have written without having to run the C++ development environment. However, the default tab stop in Notepad is eight characters which makes reading my code more difficult. Using white hat hacking techniques, I was able to change the tab stop to four characters, the same as the C++ development environment. I basically added two lines of (high level) code to the executable file. This hack involved coding in machine language.
Another example was when I wanted to know how to set the wallpaper of my desktop through code. By looking at the MS Paint executable, I discovered the name of the Windows API function I needed to call. I then read the documentation for this function and was able to implement it in my own code.
The best use I have found for hacking programs is hacking my own executable files when they crash. When memory gets corrupted, seeing the relationship between various memory locations in the compiled code can be very insightful. Also, it is possible to insert debugging code that will not accidentally "fix" the problem by moving it to some other place.
Now, what do you have in mind?
It took me a good five minutes to fully understand what you were saying there. No offense. Well, I have neither knowledge nor free time, so I guess I will have to develop my skills much further than this. I thought I wouldn't have been the first one to have this idea and that a software might have been developed, but turns out none of this happened.
How would you disassemble a program? It seems complicated to me...
And no, I respect the work of coders and programmers, and I know their lives depend on that code, so I'm not going to take that away from them. So no, not a bot of malicious or theft intentions.
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
wkwkwkwk1
How would you disassemble a program? It seems complicated to me...
If you have Microsoft Visual Studio installed and an application crashes due to an access violation or invalid machine instruction, you will be asked if you want to start the debugger that comes with Microsoft Visual Studio. This debugger has a rudimentary disassembler that will let you see how assembly language looks. Using a book about x86 machine language, I wrote my own disassembler that shows more in depth information and breaks the machine code out into functions by following the program flow from the beginning. This is definitely not a task for a beginner. I come from the Apple II generation where you had to write programs in machine language just so they would run in real-time. There were no compilers for Apple II computers, but they did have a built-in disassembler.
I do not know of any public available software that does what you want, but you are not the first one to think of this.
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
Coder Dave
If you have Microsoft Visual Studio installed and an application crashes due to an access violation or invalid machine instruction, you will be asked if you want to start the debugger that comes with Microsoft Visual Studio. This debugger has a rudimentary disassembler that will let you see how assembly language looks. Using a book about x86 machine language, I wrote my own disassembler that shows more in depth information and breaks the machine code out into functions by following the program flow from the beginning. This is definitely not a task for a beginner. I come from the Apple II generation where you had to write programs in machine language just so they would run in real-time. There were no compilers for Apple II computers, but they did have a built-in disassembler.
I do not know of any public available software that does what you want, but you are not the first one to think of this.
Thank you for the information. So I guess I will have to dig a lot deeper than this in coding. What programming language do you suggest, for a start? I have been around with C++ and Python, but I know very little of both.
-
Re: How to get the source code of a software/program
There has been disassemblers around as long as I've been in the business but I don't know how good they are today. Anyway, I think it's safe to assume that you don't have to take this from the binary level unless you really want to do so. The task however of translating optimized assembly into something of higher level is very hard. If you really want to go further with this I recommend that you check what sourceforge has to offer. Downloading something from another source might be pretty unsafe since it's in the gray zone of what's legal.
-
Re: How to get the source code of a software/program
General comment --
The reason there aren't books on how to break into people's houses for sale is because the person that writes the book could become liable if someone uses it and then breaks into a house. The same could be said to be true for breaking into software.
It sounds like you (wkwkwkwk1) haven't done much, if any, programming. If that is the case, then starting your education by cracking and hacking existing code is not the way to go. That is like trying to build an aircraft carrier before you've even learned how to build a basic fishing boat. There is a ton (millions if not hundreds of millions of lines) of code available on the internet and on this site. There is a lot of public code to be reviewing if your objective is to learn.
In fact, there is so much good code out there that is open, that it makes the concept of cracking/hacking code to learn seem.... bogus.
Just my perspective....
Brad!
-
Re: How to get the source code of a software/program
I understand what you are saying. Now that I'm starting my holidays, I will have more time to dig deeper into programming.
By the way, what does bogus mean? I'm from Portugal, so my English is quite limited.
Do you have any suggestion about what would be a good programming language to start? I was thinking about python.
Thanks in advance,
wkwkwkwk1
-
Re: How to get the source code of a software/program
I have never used Python so I do not know anything about it. I mainly use C++. It is sort of in the middle in terms of programming languages. It is not tedious like assembly language, but at the same time, it allows you to work directly with pointers and type casts. Other higher level languages are more restrictive. In addition to learning a programming language, I recommend learning some of the theory behind Computer Science. Specifically, I recommend learning about data structures and algorithms. You can do a lot more if you create your own data structures instead of always relying on some one else's code.
Now, the reason I know so much about looking into other's code is because, as I mentioned before, I grew up programming Apple II computers. I was completely self taught until I got into college. There were not many books out there about programming back in those days, so I learned a lot from looking at how existing programs worked. I am the type who learns by example. Today, however, there are a ton of books on programming all sorts of languages. There is also the internet which has lots of valuable sources, including this website. Most of what you will want to learn is already documented, but not everything ... You will still need to experiment.
bogus = fake
-
Re: How to get the source code of a software/program
Thank you for the information. I already tried C++ several times and gave up. Now I have been trying Python and it's going somewhat smoothly. I think it's due to the tutorial itself. And no, it's not «bogus», but I know it's easy to think it, I would do so, too.
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
wkwkwkwk1
I already tried C++ several times and gave up. Now I have been trying Python and it's going somewhat smoothly.
I would go for Java simply because it's more mainstream. You'll find downloads and tutorials at the Oracle Java site.
http://www.oracle.com/technetwork/java/index.html
It's Java SE SDK 7 you want to use and if you download it bundled with NetBeans you also get a nice development environment.
Source code for learning purposes is almost useless in isolation. It works well only as part of a thorough explanation. Or when you know already exactly what you're looking for. Otherwise it's very hard to absorb what went into a piece of code just by staring at it. It's like trying to become a Rembrandt or a Picasso by running their paintings through a copying machine.
Besides, decompilation has its limits. The original source can seldom be fully recovered because usually lots get lost in compilation. To continue the painting analogy; What you end up with is a blurred black and white version of the crisp colorful original.
-
Re: How to get the source code of a software/program
The only way to learn to program is to actually write programs. If you have the source code for something, you still need to try it to see if it does what you think it does. A lot of times you may need to make small changes to the code to get it to work, because the documentation may have been written for a different version of the compiler with slightly different libraries or different settings or what not. Also, your implementation of the code may use different assumptions. Experimentation is the key.
-
Re: How to get the source code of a software/program
I just wanted to clarify my comment ---
I agree that learning to program by looking at existing code is a good thing. Compiling other people's code then messing with it to see what happens is a fantastic way to learn. In fact, in some of the books I write, I created an element called "Type and Run" that's primary focus was exactly that -- you type in a mor4e complete program, compile, and run it. This program could then be played with to learn.
What I consider bogus is saying you need to decompile an existing program to learn how to program. There is enough available code that decompiling or cracking executable programs isn't needed.
As to trying to learn a programming language -- for the newbie, C++ and Java are both a bit more complex. I'd suggest starting with an interpreted language such as Visual Basic or C#. Of course, finding a good book or tutorial to start with never hurts!
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
Brad Jones
As to trying to learn a programming language -- for the newbie, C++ and Java are both a bit more complex. I'd suggest starting with an interpreted language such as Visual Basic or C#. Of course, finding a good book or tutorial to start with never hurts!
The complexity of a programming language isn't determined by how it's executed. In fact runtime systems aren't even part of languages per se. Any language can and most languages are being executed on several different runtime systems ranging from pure static compilation to pure dynamic interpretation to all sorts of mixes thereof.
So sure, some may consider C# easier to learn than Java but that's hardly due to how a program is made to run once written. Besides, the dominant runtime systems of these languages, the CLR and the JVM respectively, are virtually identical so that's not a distinguishing factor. I wouldn't claim Java is easier but it definately is the smaller more conservative language. Except for generics Java has stayed almost unaltered over the years while C# has grown substantially and is now challenging C++ in size. In this respect Java is far less complex than C#.
But for a newbie to programming the choise of language isn't that crucial because then it's more about the programming process rather than the language itself. Any multi-paradigmic language should do just fine. I suggested Java not for ease of learning but because it's the most "popular" of the modern general purpose languages. I know the Tiobe index can be criticised in all sorts of ways. Still, although not very precise it's an important indicator of actual language use I think,
http://www.tiobe.com/index.php/conte...pci/index.html
-
Re: How to get the source code of a software/program
Do you suggest any good tutorial?
EDIT: I can't afford to buy any book, sorry.
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
wkwkwkwk1
Do you suggest any good tutorial?
EDIT: I can't afford to buy any book, sorry.
If you're interested in Java there are quite a few free e-books. This seems to be one of the better,
http://it-ebooks.info/book/255/
It covers Java up to version 5. That's no longer the latest version since 8 will soon be introduced. But it's not a big restriction because version 5 was the most substantial update in the history of Java (most importantly introducing generics essentially doubling the complexity of Java in one go). Since then there has been smaller changes only of minor importance to a newbie. But you should download the latest version of Java of course.
Java has a large user community and there are several forums available. Apart from the one here at Codeguru there's also Oracle's own and Javaranch to name a few,
http://www.javaranch.com/
-
Re: How to get the source code of a software/program
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
wkwkwkwk1
Thank you!
You're wellcome.
And don't give up too easily. I'd say it takes something like 3-5 years to become fluent in Java. At least I needed that long to assimilate all new concepts to the point where they felt natural. I had a strong C background and maybe that was a disadvantage really. It may be easier to grasp object orientation if you're not too set in the procedural way of programming. Good luck.
-
Re: How to get the source code of a software/program
Yeah - Java with the Eclipse IDE is probably a good choice. I must agree that certainly C# isn't simpler - but I think the learning curve for it is pretty much the same as for Java, except if you get lost in some of the features added in the later versions of the language, without actually learning the fundamentals. I think it's better to learn C++ after you've become familiar with a different, more OO language (don't get me wrong, C++ is considered an OO language, however, this paradigm is not really enforced, it's rather an option, so some discipline on the part of the programmer is required - this is nice and flexible on one hand, but requires some experience on the other). Also, once you learn one language, you'll see that other languages are based on similar concepts.
So, pick a language you can find books, tutorials and tools for, and just start coding. Also make sure that you learn how to do basic debugging early on (beginners often think that is terribly complicated, but it's actually rather simple) - this will allow you to step through your program, executing line by line, checking values of variables as you go, and actually seeing in "slow-mo" what is going on as your program executes, and this will significantly help your understanding. Once you learn enough of the syntax, maybe find some simple programming problems to work on - just to get a better grasp on how to use what you learned so far. Write various test projects all the time - just to see what something does, what to expect, etc. Read stuff and practice, practice, practice. And, of course, use use the forms (here or wherever) to ask questions and enter discussions.
Regarding your original question - some code can be decompiled, some code might be freely available as open source; however, just looking at the code won't help you much if you can't understand it - this is why you must have a working knowledge of programming first (not so much a knowledge of a specific language, but the knowledge of how the more basic stuff is done) - so that you can understand how different parts of the program interact. But, yeah, open source code is a valuable resource to learn from.
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
Brad Jones
General comment --
The reason there aren't books on how to break into people's houses for sale is because the person that writes the book could become liable if someone uses it and then breaks into a house. The same could be said to be true for breaking into software.
Oh... you seem to be assuming there aren't any books on how to break into someone's house. that just isn't true...
Of course, the title won't be "How to break into someone's house"... but how about something like this book on Amazon here...
As a general rule, information and books on a wide variety of subjects are available, because there are legitimate uses for them. (learning how to be a professional locksmith for example).
The same is true for programming, there are legitimate reasons for reverse engineering, learning how virusses work (to write anti-virusses), how hackers work (to become beter at writing security) how cheaters work (to become better at stopping them), ...
Quote:
In fact, there is so much good code out there that is open, that it makes the concept of cracking/hacking code to learn seem.... bogus.
Just my perspective....
A valid perspective, although maybe a narrow one.
How about...
Software that the original manufacturer has stopped supporting (maybe they went out of bussiness), and that you need to somehow maintain...
In that case, reverse engineering to recreate the program, API hooking, application hooking, and other forms of bit twiddling might be a necessity. It's a very specific type of programming, sure, but saying it has no legit use is wrong.
-
Re: How to get the source code of a software/program
-
Re: How to get the source code of a software/program
Hi guys,
I'm digging up this old post because I have some specific questions.
I'm trying to find the source code of a program. I don't want to steal it, I just want to understand one thing.
I'm making 360 videos as a professional. Since YouTube has been hosting 360 videos, 360 metadatas have made their appearance. I've been desperately trying to look for a software that would read these 360 metadata and let me edit them. As this is all new, I have found nothing of the sort and I'm stuck with finishing up a video for a client.
So my next best guess was to understand what the 360 Metadata Injector produced by YouTube was injecting exactly. I don't care about how it does it, how the program is built or anything. All I want to know is what information it injects in the video and where. That'd be a good start for my quest (I've been trying to edit those metadata for two weeks now ...).
Is there any way I can get to that without being a professional coder?
Any help would be greatly appreciated. I'm starting to feel sleep deprived and fairly desperate as what I'm trying to do doesn't look much of an hassle ...
Thanks!
-
Re: How to get the source code of a software/program
Quote:
Originally Posted by
CelineK
Is there any way I can get to that without being a professional coder?
Reverse engineering a program without source code is one of the most challenging tasks for a programmer. If you do not program, then it's even more difficult.
Of course, looking from the outside, doing this might seem easy - it is anything but.