A couple people brought to my attention that the coddec patch, well, doesn’t work. And they were right! I just committed a new patch which should work. Also, provided here are hopefully some instructions to get this working:
- Download coddec.rar from wherever
- Extract into some directory and cd into the directory
- patch -p1 < coddec.patch
- find . -name “*.java” > FILES.TXT
- for/f %x in (FILES.TXT) do javac %x (or some equivalent sh)
- java -classpath . net.rim.tools.compiler.Compiler FOO.COD
I’m using JDK 1.6.0 R12 (java -version -> java version “1.6.0_12”)
Make sure you don’t attempt to disassemble “COD” files that are actually “ZIP” files. Also, for COD files that have interdependencies, you may need to have all “.COD” files in the same directory in order for coddec to parse them all.
Ignore a lot of the output, it’s all debugging from the original coddec plus some of my own crap… Also, it very well may fail to parse certain cod files. I use it on third-party applications, YMMV.
ariev
August 2, 2010
Do you mean coddec.patch is work very well? I’ve tried to patch it and it doesn’t work anyway…
I hope your little patch could work.
Thank’s
Robert
August 3, 2010
Please fix the dead link at https://dontstuffbeansupyournose.com/2009/02/19/disassembling-blackberry-apps-take-2/trac/browser/projects/bberry/coddec.patch
Thanks!
John
August 19, 2010
Hi! This link is dead, and I would love for it not to be. Is there any chance you can repost the patch?
Thanks!
alex
August 27, 2010
dear, can you send the patch to zfj123589@126.com, i like the reversing code very musch… Thanks very much.. a bber
s7ephen
September 19, 2010
We will be fixing all the old articles (links, images, etc) in the next few days.
Cesar
September 3, 2010
Hi, interesting article!!! could you send me the patch, seems like the link is broken!
I have lost the source code of a Blackberry project.. and my client is asking for modifications!!! damn it!!! Do you think I can at least get some of the sources using this tool?
Thanks you!
Cesar.-
s7ephen
September 19, 2010
Cesar,
Thanks for commenting. We will be fixing all the old articles (links, images, etc) in the next few days. I hope that is ok for you.
sg
September 22, 2010
Hi,
Can i get a copy of the patch pelase. The link to the patch seems to be dead.
Any help highly appreciated.
Non
September 24, 2010
Is the patch in github current?
longzetian
September 29, 2010
waitting for fix the broken link
Carlos
October 7, 2010
Please fix the patch download. 🙂
john
October 7, 2010
Hey s7ephen,
Are you still in the process of updating the site links? I would very-much like to get that patch.
Thanks.
ghohan
October 8, 2010
Dear,
Already 2 weeks when will fix the download link…
Regards,
GhoHan
Duncan
October 12, 2010
I got the error below trying to run this with the latest patch, so I did some debugging.
Error:
java.io.IOException: no class ref found at offset: 0xc1
at net.rim.tools.compiler.codfile.DataSection.getClassRef(DataSection.java:1782)
at net.rim.tools.compiler.codfile.AdvancedMemberRef.(AdvancedMemberRef.java:38)
at net.rim.tools.compiler.codfile.DataSection._ifaZ(DataSection.java:668)
at net.rim.tools.compiler.codfile.DataSection.addClassRefs(DataSection.java:325)
at net.rim.tools.compiler.codfile.Codfile.processCodeSegment(Codfile.java:144)
at net.rim.tools.a.coddec.enumerateModules(coddec.java:958)
at net.rim.tools.a.coddec.parseFile(coddec.java:993)
at net.rim.tools.a.coddec.main(coddec.java:1021)
Turns out that the decompiler always think its decompiling Version 6 (_isVersion6 is always true).
net.rim.tools.compiler.codefile.DataSection:134:
_Version = 6;
if (_Version >= 6)
{
_isVersion6 = true;
fh = false;
z_eGZ = false;
z_e4Z = false;
z_e7Z = false;
}
I’m not sure if the above snippet is even required since those values are set again around DataSection:155. I added
_isVersion6 = false;
to DataSection:156 and now it decompiles my V5 cod without crashing.HSNHasan
July 6, 2012
I’ve downloaded the file from the article link above, I did the same (_isVersion6 = false) and it worked! thanks 🙂
Raj
October 14, 2010
Any updates on the links? I’ve noticed they are still broken?
bobo
October 19, 2010
Any info on when we can expect to have the link and doc back up? I have lost the source of one my app (HD failure) and would really like to have it back.
s7ephen
October 22, 2010
Ok, I have fixed the patch download link, sorry for the delay guys. I am also in the process of fixing up the code snippets that were in the original article.
s7ephen
October 22, 2010
Ok, sorry for the delay folks, but I have fixed the codec patch link in the article, but here it is also:
http://github.com/s7ephen/dontstuffbeansupyournose.com/blob/master/bberry/coddec.patch
I am in the process of fixing all the other broken links on the site as well. Sorry for the delay.
Calvin
February 1, 2011
Hi Guys Thanks for the app. Very Much Noob! I was wondering if someone might have a bit of a walkthrough to get this app up and running.
Thanks for any help!
franc
February 14, 2011
If you get errors like all hunks FAILED it is maybe because the line endings are windows and not unix style.
Use then first (only in your dir where the bin and net dirs are!) something like:
find . -type f -name ‘*.java’ -exec dos2unix {} \;
to change this and after you can do the:
patch -p 1 < coddec.patch
franc
February 14, 2011
When trying to compile it, e.g.:
javac ./net/rim/tools/compiler/codfile/AdvancedMemberRef.java
i get hundreds of errors like e.g.:
./net/rim/tools/compiler/codfile/AdvancedMemberRef.java:84: class, interface, or enum expected
package net.rim.tools.compiler.codfile;
^
./net/rim/tools/compiler/codfile/AdvancedMemberRef.java:86: class, interface, or enum expected
import java.io.IOException;
^
./net/rim/tools/compiler/codfile/AdvancedMemberRef.java:88: class, interface, or enum expected
import net.rim.tools.compiler.io.StructuredOutputStream;
^
./net/rim/tools/compiler/codfile/AdvancedMemberRef.java:167: class, interface, or enum expected
package net.rim.tools.compiler.codfile;
^
./net/rim/tools/compiler/codfile/AdvancedMemberRef.java:169: class, interface, or enum expected
import java.io.IOException;
^
./net/rim/tools/compiler/codfile/AdvancedMemberRef.java:171: class, interface, or enum expected
import net.rim.tools.compiler.io.StructuredOutputStream;
^
6 errors
What is wrong with it?
I am using java 1.6.0_22:
# java -version
java version “1.6.0_22”
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
recursion
March 28, 2011
Download coddec.rar from http://rapidshare.com/files/129584453/coddec.rar.html
1. Extract into some directory and cd into the directory
2. patch -p1 > FILES.txt
5. for/f %x in (FILES.TXT) do javac %x (or some equivalent sh)
The above commands should work in windows GNU patch available at http://savannah.gnu.org/projects/patch/
recursion
March 28, 2011
Not sure what happened with the previous post. Steps 2 – 6
recursion
March 28, 2011
Download coddec.rar from http://rapidshare.com/files/129584453/coddec.rar.html
1. Extract into some directory and cd into the directory
2. patch -p1 > FILES.txt
3 Change line 346 in ./net/rim/tools/compiler/exec/c.java
to c_static c1 = new c_static(l, j, i1, dataoutputstream1);
4. dir /O:N /b /s *.java >> FILES.txt
5. for/f %x in (FILES.TXT) do javac %x (or some equivalent sh)
6. java -classpath . net.rim.tools.compiler.Compiler Whatever.COD
The above commands should work in windows GNU patch available at http://savannah.gnu.org/projects/patch/
recursion
March 28, 2011
Step 2 should be
patch -p1 < coddec.patch
franc
April 1, 2011
No, no, no, still a million of errors, look:
C:\coddec>javac C:\coddec\net\rim\pkg_b\a.java
C:\coddec\net\rim\pkg_b\a.java:12: cannot find symbol
symbol: class b
public class a extends b
^
C:\coddec\net\rim\pkg_b\a.java:15: cannot find symbol
symbol : class c
location: class net.rim.pkg_b.a
public a(byte abyte0[], int i, int j, c c)
^
2 errors
C:\coddec>javac C:\coddec\net\rim\pkg_b\b.java
C:\coddec\net\rim\pkg_b\b.java:25: cannot find symbol
symbol : class c
location: class net.rim.pkg_b.b
protected c z_ifc;
^
C:\coddec\net\rim\pkg_b\b.java:39: cannot find symbol
symbol : class c
location: class net.rim.pkg_b.b
public b(byte abyte0[], int i, int j, c c1)
^
2 errors
And this is just the beginning…
franc
April 1, 2011
And the code-formatting on this site is a kind of not working.
e.g. I had the “^” sign under the “b” from “public class a extends b” but not as the first position. The “code”-tag should keep the spaces, but doesn’t.
Ts,ts,ts…
slawlerguy
April 7, 2011
hi guys, i suck at the internet i am just reading these comments now. try this
http://rapidshare.com/files/456344884/coddec_crap.zip
i know for a fact that the pre-compiled code in this zip file works, because i’ve used it. however, i haven’t actually been using this in like 2.5 years or so. but it worked on the last set of cod’s i had. inside should be a batch file, doit.bat:
doit.bat examplecodfile.cod
if you are lucky it will print out lots of data to OUT and create a directly called decompiled with “decompiled” code. it will actually be “java” files with RIM JVM assembly code
s7ephen
April 27, 2011
An alternate download link is here. The text of the blogpost also has the new download link.
John Paul Thomas
June 24, 2012
THIS IS HOW YOU DO IT!!!! HE IS RIGHT! IT WORKS! TODAY IS 6/24/2012 AND THIS JUST WORKED! DO IT AND BE DONE WITH IT!
Droopy
June 15, 2011
Finally it works great.
Is it possible to change something on bytecode level (decompile directory) and recompile it to final .COD again??? Invert process of CODDEC.
Also, is it possible to transform .JAVA generated to source code level, and change and recompile again to .COD?
slawlerguy
July 27, 2011
basically, no. going back to .COD requires RIM’s proprietary java compilers, moreover, you need codesigning certs from RIM to get a valid COD file.
also getting actual .JAVA from the disassembled java is , ahem, an exercise for the reader. you basically need to write your own version of “jad” that can deal with RIM’s proprietary java bytecode (it is not, in fact, JVM bytecode, but “RIM’s own kinda-similiar-to-jvm-but-not-really” bytecode)
littledog
June 21, 2011
I don’t know how to use “patch -p1 < coddec.patch" command in cmd, it shows :" 'patch' is not recognized as an internal or external command……."
How can i "patch" it?
thanks!
slawlerguy
July 27, 2011
you need to get patch from a linux system, or via unix utils for windows
also, please be aware or \r vs. \n vs. \r\n issues when dealing with patch, java, windows, mac, unix, and/or a combination of the above.
tony
June 29, 2011
I got this notes when i patch the code you shared.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
./net/rim/tools/compiler/exec/Comparator.java:7: net.rim.tools.compiler.exec.Comparator is already defined in this compilation unit
import java.util.Comparator;
^
./net/rim/tools/compiler/exec/Comparator.java:9: cyclic inheritance involving net.rim.tools.compiler.exec.Comparator
public interface Comparator
^
./net/rim/tools/compiler/exec/c.java:18: net.rim.tools.compiler.exec.c is already defined in net.rim.tools.compiler.exec
static class c
slawlerguy
July 27, 2011
if you are having issues compilng stuff
look for coddec_crap.zip i posted on a rapidshare link.
also, please be aware of \r vs \n vs \r\n issues. patch and other unix utilities sometimes get upset when they read unexpected whitespace characters.
franc
July 28, 2011
If I understand well, with coddec_crap it is possible to decompile cod-files, but you don’t get any readable java-sources, only bytecode?
What is the sense then for the coddec-crap?
What can I do with it, when I can not change and recompile anything after “decompiling” it?
Is it usable at least for some machine-language-gurus?
slawlerguy
July 28, 2011
You get RIM JVM disassembly (that is, it gives you the instruction mnemonnics for each bytecode and gives you class definitions and some class cross-references). Yes, you have to be a machine-language guru much like attempting to reverse any binary file format. The principle nice thing about it is by default with a COD file you cannot even determine which portion of the file is bytecode, plus the bytecode is not standard JVM and you wouldn’t know what to make of it even if it was.
I was able to use it to find hidden encryption keys or “passwords” that apps used to authenticate themselves to servers or do “DRM” (e.g., with some custom “crypto” scheme). Things like that.
franc
July 28, 2011
Ah, ok, this sounds not too bad.
Unfortunately I am far away from this deepness of machine and java code 😦
But it is good to know that it would be possible 🙂
Walkin
August 17, 2011
@Slawlerguy, how do you interpret the resulting java bytecodes?
I want to try keygen an app using the coddec.
slawlerguy
August 18, 2011
I dunno… its like reading regular jam bytecode assembly, just withba few differences. Inter class/module field and method referenceswill not be properly resolved and so require guesswork on your part.
As for jvm, its a stack machin with the concept of local variables. Most opcodes that “do something” work with the operand stack. Each function frame also has local variables identified by number. So for example” aload 2″ would take the objectref in local variable number 2 and push it onto the operand stack. “iadd” would then pop that objectref and the previous one on the operand stack, treat them as signed integers, add them, and push the resulting int back onto the operand stack.
Sometimes you can cut/paste the assembly and feed it to a regular old java assembler to run snippets of code in standalone programs
Hopefully that sets you in the right direction….
jenicek
October 19, 2011
Great! Thanks a lot!!!
neptune
June 6, 2012
Can any one please tell me that how could I rebuild the disassembled application.
franc
June 25, 2012
Could you please read the comment of slawlerguy on July 28, 2011 some posts above?
It is not possible for you to recompile the “disassembled” code.
Javier Falbo
April 7, 2013
I have finally done it to completely reverse to plain java source code. If someone needs helps advice me. Even recompilation is possible.
max
April 9, 2013
@javier Falbo can u help me how u did u reversed the .cod to plan text
slawlerguy
April 25, 2013
awesome dude! finally someone took it to the next level. I actually did hardly anything, just enough to get my information for an assignment. the hard part is resolving all the inter-class cross references and properly decoding the tables that contain “ids” of methods and such. (at least that is my recollection…)
Javier Falbo
April 28, 2013
@max please post an email so i could contact you there. I could provide you java source code. Only for research or educational purposes. Not for anything that violates terms or conditions.
Mecca EL
December 12, 2013
Javier, if possible, I’d like any assistance you could offer in reversing code. I learn from a different perspective, and reversing java can help me understand how to write code faster, If that makes sense
meccael@gmail.com