[TOOL][WINDOWS]Sign-em! v2.0 ->Batch sign zip files | No signature verification error

Search This thread

Ryuinferno

Senior Member
Apr 3, 2012
3,548
7,112
ryuinferno.github.io
[TOOL][WINDOWS]Sign-em! v2.0 ->Batch sign zip files | No signature verification error

Sign-em! v2.0

Hi all! As we know, making zip files is a must no matter when we want to flash a new ROM, theme, mods and so on...but at times we need to sign the zip files before flashing them in recovery...especially ROM Makers or Themers, you may find it troublesome to sign your zip files via command prompt...even though there are already other scripts out there that can auto sign the files, but we still need to rename it one by one...and even though the zips are signed, but we still get "signature verification error" (usually in stock recovery)...

And that's what happened to me...so I decided to write a script to automate the whole process! There you have it: Sign-em!

This script will sign all your zip files with test keys. Instructions as below:
1. Download View attachment sign-em.zip.
2. Extract sign-em.zip anywhere on your PC.
3. Put your files in "Input".
4. Execute "sign-em.bat"
5. Your signed files will be in "Output", md5 checksum will be in a file named "md5.txt" in the same folder


**JRE is required
**IMPORTANT: DO NOT leave spaces when you name your zip files, e.g. "123 abc.zip" is a no go, "123abc.zip" is the correct way


Screenies:
nGWXx.jpg


Planned features:
- Option to set heap size
- Linux version

Changelog:
Code:
[U]v1.0[/U]
-Initial release

[U]v2.0[/U]
- Generates md5 checksum of signed zips
- Files are now properly signed (No more signature verification error)

Credits:
- http://www.pc-tools.net/win32/md5sums for Md5sums v1.2

Hope you will enjoy my work and please do not mirror my work!​

Feedbacks are welcomed too! :)
 
Last edited:

Ryuinferno

Senior Member
Apr 3, 2012
3,548
7,112
ryuinferno.github.io
Re: [DEV][TOOL][WINDOWS] Sign-em! v1.0 --> Batch sign zip files!!! No Hassles!!!

Lol...what you used?CWM or stock recovery?CWM zips do not need to be signed...
 

Ryuinferno

Senior Member
Apr 3, 2012
3,548
7,112
ryuinferno.github.io
Re: [DEV][TOOL][WINDOWS] Sign-em! v2.0 --> Batch sign zip files!!! No Hassles!!!

Hey guys...I just updated this tool...it now generates md5 checksum of signed zips and files are now properly signed (No more signature verification error)...hope that it helps...:)
 
  • Like
Reactions: Hybridz_08

cerui

New member
Sep 3, 2011
4
0
Daaaayyyuum. It DOES really work. I've got no choice but to stay with stock ICS 4.0.4 and flashing CWM recovery will make bootloop. Now I can install some mods thru recovery e3. Man, You're great.

For people out there: if you have installed java jdk and it's not working you've got to make PATH to jdk. [Right click at My Computer and look for ->Environment Variables, under System Variables]
 

walauu

Senior Member
Apr 7, 2012
269
42
java.lang.IllegalArgumentException: MALFORMED
at java.util.zip.ZipCoder.toString(Unknown Source)
at java.util.zip.ZipFile.getZipEntry(Unknown Source)
at java.util.zip.ZipFile.access$900(Unknown Source)
at java.util.zip.ZipFile$1.nextElement(Unknown Source)
at java.util.zip.ZipFile$1.nextElement(Unknown Source)
at java.util.jar.JarFile$1.nextElement(Unknown Source)
at java.util.jar.JarFile$1.nextElement(Unknown Source)
at com.android.signapk.SignApk.addDigestsToManifest(SignApk.java:194)
at com.android.signapk.SignApk.main(SignApk.java:468)

Hello I get this error. I didnt know what is the problem. I am trying to make an update.zip to install all the apps I wanted to install after every flash of new rom.. Can you help me please? Thank you..
 

walauu

Senior Member
Apr 7, 2012
269
42
I realised if the folder is empty, Im able to signed it. But when I put the .apk into data\app then I couldnt sign it anymore.. The zip file is just 3MB.. Is that consider large??? May I know what is the correct way to do an update.zip? Not placing apk files into data\app, zip it and sign it?? Correct me if Im wrong..
 

Ryuinferno

Senior Member
Apr 3, 2012
3,548
7,112
ryuinferno.github.io
First, do you have a META-INF folder in your zip? If yes, this tool only signs zipped files, it does not zip it for you...if not, Google up on how make an update zip...this tool only gets it signed for you...
 

walauu

Senior Member
Apr 7, 2012
269
42
I created 2 folders.

First will be data\app and I paste my apk files inside app folder

Second is META-INF/com/google/android with update-script

Inside update-script I wrote:
show_progress 0.1 0
copy_dir PACKAGE:data ROOT:data
show_progress 0.1 10

After that I zip both data and META-INF into Update.zip and sign it. Then that error came out. Can you teach me how to make an update.zip to install apps? Thank you..

p/s: I get all this information from google.. I dont really know whether it works or not because Im not able to sign the file..
 
Signing - XT_15.zip
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
at java.util.zip.ZipOutputStream.write(ZipOutputStream.java:314)
at com.android.signapk.SignApk.copyFiles(SignApk.java:422)
at com.android.signapk.SignApk.main(SignApk.java:490)

Files signed successfully if no errors above...

Hope you enjoyed my work...:)
Ryuinferno @ XDA 2013

you can help me dude..??
what's wrong ??
 

samhattem

New member
Jan 19, 2008
2
0
Signing - .ubuntu.zip

Signing - f16ref-ota-eng.ubuntu.zip
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.io.ByteArrayOutputStream.grow(Unknown Source)
at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
at java.io.ByteArrayOutputStream.write(Unknown Source)
at java.util.zip.DeflaterOutputStream.deflate(Unknown Source)
at java.util.zip.DeflaterOutputStream.write(Unknown Source)
at java.util.zip.ZipOutputStream.write(Unknown Source)
at com.android.signapk.SignApk.copyFiles(SignApk.java:422)
at com.android.signapk.SignApk.main(SignApk.java:490)

Files signed successfully if no errors above...

Hope you enjoyed my work...:)
Ryuinferno @ XDA 2013


help please
 

Top Liked Posts

  • There are no posts matching your filters.
  • 71
    [TOOL][WINDOWS]Sign-em! v2.0 ->Batch sign zip files | No signature verification error

    Sign-em! v2.0

    Hi all! As we know, making zip files is a must no matter when we want to flash a new ROM, theme, mods and so on...but at times we need to sign the zip files before flashing them in recovery...especially ROM Makers or Themers, you may find it troublesome to sign your zip files via command prompt...even though there are already other scripts out there that can auto sign the files, but we still need to rename it one by one...and even though the zips are signed, but we still get "signature verification error" (usually in stock recovery)...

    And that's what happened to me...so I decided to write a script to automate the whole process! There you have it: Sign-em!

    This script will sign all your zip files with test keys. Instructions as below:
    1. Download View attachment sign-em.zip.
    2. Extract sign-em.zip anywhere on your PC.
    3. Put your files in "Input".
    4. Execute "sign-em.bat"
    5. Your signed files will be in "Output", md5 checksum will be in a file named "md5.txt" in the same folder


    **JRE is required
    **IMPORTANT: DO NOT leave spaces when you name your zip files, e.g. "123 abc.zip" is a no go, "123abc.zip" is the correct way


    Screenies:
    nGWXx.jpg


    Planned features:
    - Option to set heap size
    - Linux version

    Changelog:
    Code:
    [U]v1.0[/U]
    -Initial release
    
    [U]v2.0[/U]
    - Generates md5 checksum of signed zips
    - Files are now properly signed (No more signature verification error)

    Credits:
    - http://www.pc-tools.net/win32/md5sums for Md5sums v1.2

    Hope you will enjoy my work and please do not mirror my work!​

    Feedbacks are welcomed too! :)
    14
    Sign-em-anywhere 3.0

    So here we go... although I would have liked an answere by ryuinferno, as this is his thread.

    This is now: sign-em-anywhere 3.0.

    It is only an extension to sign-em 2.0, so the download will provide both versions.
    I really tried to make it noob-safe. Hope I managed to do that.
    And I never asked for pressing thank-button, but this time I think it would only be fair you would use it, if you like my 650 lines of code.

    Have fun.
    Best regards
    the.gangster

    Taken from the README:
    If you don't change anything sign-em-anywhere 3.0 will behave like Ryuinferno's sign-em.bat 2.0,
    except that it
    - is no longer prone to spaces or even brackets in paths or filenames,
    - uses Java autodetection
    - should leave no doubt if finished successfully or not
    - writes unique md5-files (like supported by modern recoveries) instead of dumping all hashes into one md5.txt

    The signing itself will still be done with the certificates by RYU.

    Whenever the script "thinks" that it could have been started from explorer it will offer you the chance to optionally provide additional parameters.
    But I also added some more features.

    For the hottest one, that will bring you the windows explorer integration, you need to edit the script,
    but it will even tell you what to modify and where in the script.
    You will see something like:

    . . . . checking prerequisites first...
    ____ ERROR: YOU HAVE TO DEFINE wkSignem variable in the script first
    ++++ Advice:
    Change from line 20:set wkSignEm=PLEASE_ENTER_PATH_TO_signapk.jar
    change to line 20:set wkSignEm=x:\whereever you extracted this to\Tools
    ____ SORRY: Failed prerequisite


    As almost all parameters should be explained in the script's help already, I will only paste it's output in here. Please read it, not to miss a feature.

    For all supported configuration settings use /? variables. Editing should only be done in the configuration section.
    e.g. wkJavaXmxSize has to be lowered on machines with less than 8GB RAM or 32bit-Java editions.
    I left it preconfigured to 4000 MB to cope even with uncompressed ROM.zip files of CyanDelta.
    Tested on Windows x64 with 8GB RAM and (portable) 64bit-Java.


    This is the help output:
    _________________________________________________________________________________________________________

    Sign-em-anywhere v3.0 by the.gangster @ XDA 2015
    originally based upon Sign-em v2.0 by Ryuinferno @ XDA 2013

    - modded by the.gangster to support some more stuff:
    - added support for: Files as well as foldernames now are allowed to have spaces
    - added support for: Autosearch Java.exe in default directories and registry
    - added support for: Defining an explicit Java directory (useful for portable versions)
    - added error detection: in most cases it will leave no doubt if an error occured
    - added support for: Commandline parameters
    - * /? show usage and help info
    - * /SIM simulation only if you only want to see what would be done
    - * /SearchJava search for installed Java versions
    - * /JavaInfo show java.exe version and possible extended non-standard commandline parameters
    - * /SendTo copy script for enabling integration into Explorer's SendTo functionality
    - * /out use output directory instead of source directory for writing signed files
    - * /out path use named path as output directory
    - * ZipFile(s) inputfile(s) can be given by commandline or by using "send to" in explorer now


    You called: sign-em-anywhere.cmd **** with paras: /?

    Detected screen resolution of 1920x1080
    resized console to 230 colums

    using local paths...

    ########################## H E L P #################################################

    sign-em-anywhere.cmd Script for signing zip files

    SYNTAX: sign-em-anywhere.cmd [/SIM] [/OUT [alternate path]] [ZipFile1 [ZipFile2] ...]
    or sign-em-anywhere.cmd /SendTo
    or sign-em-anywhere.cmd /SearchJava
    or sign-em-anywhere.cmd /JavaInfo

    Supported parameters (COMMANDS) are:

    /?
    Show help in case someone asks for it
    /debug
    Can be used to override preconfigured setting by commandline
    - '/debug off' to turn off verbose mode
    - '/debug on' (or only /debug) to turn on verbose mode
    /sim
    Used only for simulation or testing.
    This will show commands instead of executing them.
    Must be first parameter if combined with '/SendTo'
    /out
    Used for defining the target directory of signed files
    Can be very useful if 'sending to' from a read-only filesystem
    or an MTP mounted device where zips get opened in some temp folder first
    - if used followed by a foldername, that foldername will be used
    - otherwise, the signed files will be written to "X:\%YourPath%\Output"
    /SearchJava
    Allows you to search for installed Java.exe files.
    Will search default file and registry paths.
    /javainfo
    Show Java version information as well as extended non-standard
    commandline parameter information that could be used
    /SendTo
    This allows you to copy the current script to the SENDTO folder.
    - Once done you will be able to use Windows Explorer to right-click on a zip
    or a selection of multiple zip files and choose 'Send To sign-em-anywhere.cmd'
    So no copying to any Input folder needed.
    - Then by default the signed ZIP will be written to the folder where the unsigned
    zip originated from. But that outputfolder can also be overruled by /out parameter.
    - Also a named file will be created with the md5 sum
    /config
    Edit this script at the location it is currently running from.
    - making it easier to edit the copy in e.g. SendTo-Folder for having
    a configuration that differs from the main one.

    DETAILED CONFIGURATION SETTINGS HELP:
    /? variables
    will give detailed description of the settings in the config section header

    ADDITIONAL INFORMATION:
    if a signed file already exists at the target location it will be overwritten

    CURRENT CONFIGURATION:
    wkSignEm : X:\%YourPath%\Tools
    Configured for autodetecting a Java version
    (You can use parameter /SearchJava or /Sim for searching beforehand)
    Java parameters: -Xdiag -Xmx4000m
    2
    Signing - XT_15.zip
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2271)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
    at java.util.zip.ZipOutputStream.write(ZipOutputStream.java:314)
    at com.android.signapk.SignApk.copyFiles(SignApk.java:422)
    at com.android.signapk.SignApk.main(SignApk.java:490)

    Files signed successfully if no errors above...

    Hope you enjoyed my work...:)
    Ryuinferno @ XDA 2013

    you can help me dude..??
    what's wrong ??

    Signing - f16ref-ota-eng.ubuntu.zip
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Unknown Source)
    at java.io.ByteArrayOutputStream.grow(Unknown Source)
    at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
    at java.io.ByteArrayOutputStream.write(Unknown Source)
    at java.util.zip.DeflaterOutputStream.deflate(Unknown Source)
    at java.util.zip.DeflaterOutputStream.write(Unknown Source)
    at java.util.zip.ZipOutputStream.write(Unknown Source)
    at com.android.signapk.SignApk.copyFiles(SignApk.java:422)
    at com.android.signapk.SignApk.main(SignApk.java:490)

    Files signed successfully if no errors above...

    Hope you enjoyed my work...:)
    Ryuinferno @ XDA 2013


    help please

    Open up sign-em.bat

    Edit this line
    Code:
    java -jar .\Tools\signapk.jar -w .\Tools\testkey.x509.pem .\Tools\testkey.pk8 %%A .\Output\%%~nA-signed.zip

    into this
    Code:
    java -Xmx1024m -jar .\Tools\signapk.jar -w .\Tools\testkey.x509.pem .\Tools\testkey.pk8 %%A .\Output\%%~nA-signed.zip
    2
    @Ryuinferno
    I downloaded sign-em 2.0 a few weeks ago, after changing to official CM12.1 ROM with its very restricted CM recovery in order to be able to sign some ZIPs myself for flashing.
    Although it helped me already "out of the box", I modified it with some features I missed. Then I added some more that I thought would be nice to have or that helped me testing. So I added errorhandling, "file- and path with space"-support, Java-autodetection...
    The result was a script, that is backwards compatible with yours, using INPUT and OUTPUT folders if called without parameters, but where the main focus was put on Windows Explorer integration.
    It can simply be used by right-klicking on a file (or even multiple selected files) in any folder and choosing "send to->Sign-em-anywhere.cmd"
    By default it will also put the signed output-files back into the source folder, but also ouputting to either defaultOutput-folder or an alternate folder is possible (useful if sending to from a readonly drive).

    For an overview of the changes I have added the output of the help that I also added.
    attachment.php


    If you should be interested, I would share it here.

    Best regards
    the.gangster
    2
    Ok, here is my linux script. It is "rough and ready", but it works for me. Your mileage may vary. No warranties offered - use at your own risk.
    Code:
    #!/bin/sh
    # -----------------------------------------------------------------------------#
    #  Linux script to sign an update zip file for Android stock recovery          #
    #  DarthJabba9 mod, adapted from "sign-em", by Ryuinferno @ XDA                #
    #                      !!! USE AT YOUR OWN RISK !!!                            #
    # -----------------------------------------------------------------------------#
    
    # no parameter or "-h"
    [ -z "$1" ] || [ "-h" = "$1" ] || [ "--help" = "$1" ] && {
      echo "Syntax = $0 <unsigned-zipfile.zip>"
      echo "** Only works one one file at a time. **"
      exit
    }
    
    # zip file not found
    [ ! -f "$1" ] && {
      echo "File not found: \"$1\""
      exit
    }
    
    # make sure we can find java
    tmp=$(which java)
    [ -z "$tmp" ] && {
      echo "ERROR: I cannot find java. Quitting ..."
      exit
    }
    
    # path stuff
    DIR=$(dirname $0)
    [ "$DIR" = "." ] && DIR=$PWD
    FIL=$(basename $0)
    FNAME="$DIR/$FIL"
    [ ! -x $FNAME ] && {
      echo "Error locating linux script. Quitting ..."
      exit
    }
    
    # make sure we can find md5sum
    tmp=$(which md5sum)
    [ -z "$tmp" ] && {
      echo "WARNING: I cannot find md5sum - no checksum will be created ..."
      echo "Run \"sudo apt-get install md5sum\" to install it."
    }
    
    # --- do some processing  ---
    src="$1"
    
    # - remove any path names
    base=$(basename "$src")
    
    # - remove file extension
    src1="${base%.*}"
    
    # output directory (defaults to /tmp/)
    outdir=/tmp
    
    # Tools directory
    toolsdir=$DIR/Tools
    
    # - signed zip name
    dest=$outdir/"$src1"-signed.zip
    
    # - md5 text name
    mdfive="$dest-md5.txt"
    
    # do the job
    echo "Signing $src ..."
    java -jar $toolsdir/signapk.jar -w $toolsdir/testkey.x509.pem $toolsdir/testkey.pk8 "$src" "$dest"
    
    # create md5 checksum
    [ -n "$tmp" ] && {
       echo "Calculating md5 checksum ... "
       $tmp "$dest" >> $mdfive
    }
    
    # report
    echo "$src has been signed successfully if no errors are shown above..."
    [ -f "$dest" ] && {
      echo "#------------------------------------------------------------------#"
      echo "Output signed file: $dest"
      [ -f "$mdfive" ] && echo "MD5 checksum: $mdfive" 
      echo "#------------------------------------------------------------------#"
    }
    
    echo "Hope you enjoyed our work... :)"
    echo "Ryuinferno @ XDA 2013; DarthJabba9 @ XDA 2015"