Giter VIP home page Giter VIP logo

gogcheck's Introduction

Table of Contents

gogcheck

Bash script for the purpose of scanning your GOG offline installer collection for valid digital signatures and correct checksums, making sure your downloads have not been modified by someone else.

Usage: gogcheck [options] [file/directory ...]
The script accepts multiple .exe files and directories as arguments. If no files or directories are specified, the current directory will be used. If neither the -s, -b/-B, nor -i/-I option is used, all checks will be run.

Options:

  -b  Enable bin files check
  -B  Same as -b, but disable checksum calculation
  -c  Compact mode: all output but filenames and results is suppressed
  -1  Same as -c
  -C  Disable colors
  -f  Force checks on all exe files (not just setup_*.exe and patch_*.exe)
  -h  Display this help
  -i  Enable Inno Setup check
  -I  Same as -i, but disable test-extracting
  -r  Traverse directories recursively
  -R  Disable RAR test-extracting
  -s  Enable exe digital signature verification
  -S  Silent mode: all output is suppressed; only the 1st exe file is checked
      (Used for exit code checks)
  --  Anything following this is considered a file/directory

The script consists of 3 functions, which run in this order:

  1. sigcheck: checks .exe files for valid digital signatures
  2. bincheck: checks if .bin files' checksums (which the .exe contains) are valid (only means something if sigcheck succeeds)
  3. innocheck: test-extracts game files from both .exe and .bin files and verifies their checksums (sometimes which the .exe contains)

Sample output:

$ gogcheck setup_a_corrupted_game.exe 
[1] setup_a_corrupted_game.exe
Running signature check...
Current PE checksum   : 0E22C4AF
Calculated PE checksum: 0E22C4DF    MISMATCH!!!
Signature Index: 0  (Primary Signature)
Message digest algorithm  : SHA1
Current message digest    : C421540390F3ACE7D031A4D54F0E5CA539D866AD
Calculated message digest : EEF389073A91EE3470FCC7B5EE0CCDFF7A54BD22    MISMATCH!!!
Signature verification: failed
Number of verified signatures: 1
Failed
Running bin check...
Exe file claims not to have bin files.
No matching bin files found.
Running innoextract check...
117 files (404.23 MiB)
117 checksums (105 SHA-1, 12 MD5)
Test-extracting files...
Extraction successful.

1 file checked, 1 error

Files that produced errors:
[1] setup_a_corrupted_game.exe (digital signature)

Sample output (compact mode):

$ gogcheck -1
[1] ./setup_a_corrupted_game.exe Error
[2] ./setup_ftl_advanced_edition_1.6.13b_(36400).exe OK
[3] ./setup_terraria_v1.4.1.2_(42619).exe OK
[4] ./setup_the_witcher_adventure_game_1.2.5a_(12082).exe OK

4 files checked, 1 error

Files that produced errors:
[1] ./setup_a_corrupted_game.exe (digital signature)

Required programs:

Optional:

  • unrar to let innoextract test RAR archives

Modify Script Variables

To optionally specify a Certificate Authority (CA) file (also see makecertfile) or to override default program names, edit the script's "USER VARIABLES" section or pass them as command line prefixes:

certfile=/etc/ssl/certs/ca-certificates.crt osslsigncode_binary=/usr/local/bin/osslsc_2.7 innoextract_binary=inno_1.9 unrar_directory=~/bin gogcheck ...

gogcheck may still have bugs. Please report issues at https://github.com/hippie68/gogcheck/issues. Any feedback is very welcome!

makecertfile

Sometimes new GOG installers may be signed by new certificates that aren't included in the provided (or automatically used) certificate authorities file, causing the following error in osslsigncode/sigcheck:

Error: unable to get local issuer certificate
PKCS7_verify error
...

The optional "makecertfile" script can be used to create an up-to-date certificate file.
The script downloads files from external servers: Mozilla's certificate list and additional certificates whose URLs can be added to the script (separated by newlines).
Be aware the script downloads and executes the third party script "mk-ca-bundle.pl" from the cURL GitHub repository.

Usage: makecertfile OUTPUT_FILENAME
The script will generate a new certificate file named "OUTPUT_FILENAME".
See Modify Script Variables for how to make gogcheck aware of the newly-generated file.

Required programs:

Optional:

  • sha256sum to let makecertfile verify mk-ca-bundle.pl's integrity

For Windows Users

The script is confirmed to work with either of the following setups:

Cygwin and Git Bash

You can use the required programs' Windows versions (.exe files). Note that curl.exe is already included in Windows 10/11.

WSL

You can install the required programs' Linux versions in WSL like this:

sudo apt install osslsigncode innoextract unrar curl perl coreutils

Mark the scripts as executable: chmod +x gogcheck makecertfile.
To run gogcheck from anywhere inside WSL, for example put it in /usr/local/bin: cp gogcheck /usr/local/bin.
When editing the scripts from within Windows, make sure the editor you are using is respecting the Unix/Linux "LF" newline character format. On a recent, fully updated Windows 10/11 build, notepad.exe can be used. To instead edit the scripts from within WSL, use a Linux editor (for example nano: nano gogcheck; save with Ctrl-x).

Q&A

What does it mean if sigcheck's output goes green?

  • It means the string that went green is known to the script. The latter which contains a section in which you can put known-legit strings found in your purchased games. This pre-made string collection is not complete. However, as this optional feature is just there for visual convenience, to quickly spot both known and new strings, it does not affect osslsigncode's functionality.

Is RAR support required?

  • As innoextract does not know checksums for files stored inside RAR bin files (as opposed to Inno Setup bin files), the verification chain "valid .exe digital signature -> verified .bin checksums -> verified .bin archive contents" is broken at the final stage. You can still let innoextract use unrar/unar to check for regular CRC errors.

gogcheck's People

Contributors

hazzuk avatar hippie68 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

brunnels

gogcheck's Issues

Git BASH: exe setups from gog.com are failing with signature error

I am using the script on windows 10 with git bash.
I assigned the paths to the 2 external tools correctly and also assigned the path to the cert.
For some reason no matter which setup i scan every exe will be reported with an "digital signature error".

Is this known ?
Which informations do you need to reproduce this issue ?

Wrong checksum error but checksum do match

Hello,

I'm trying gogcheck under git-bash 2.39.0.1 (64-bit) + osslsigncode 2.5 (x64-mingw) and it always says "wrong checksum" even if checksum is correct.

gogcheck_git-bash

I don't know what is causing this behaviour.

I need a little help with this. :)

Support for patches

It sounds like patches aren't supported.

Example: patch_cyberpunk_2077_2.0_(67690)_to_Build_4902785Change_6408866_with_EP1_RL_(67718).exe

Without unrar, the script complains that you need unrar. With unrar, it exits with no output.

Are patches even digitally signed, actually?

New digital signature serial number?

I've stumbled upon a recent upload (1 month old) which has signature's serial number not previously seen 0bad5d6bf5ce1ef257dafb8b75be92b2 - can anyone check if it's authentic? For some reason the issuer is called "Sectigo RSA Time Stamping Signer #4" instead of digicert, so it's a bit suspicious.

https://lenp.pardesicat.xyz/G21DoCu0

gogcheck: line 305: 09: value too great for base (error token is "09")

gogcheck works wonderfully for every GOG release I throw at it, however for some reason, the EVERSPACE 2 files are an outlier. See my terminal output below:

$ gogcheck -r --
[1] ./setup_everspacetm_2_0.8.25294_(64bit)_(54783).exe
Running signature check...
Current PE checksum   : 00137EC8
Calculated PE checksum: 00137EC8
Signature Index: 0  (Primary Signature)
Message digest algorithm  : SHA1
Current message digest    : 1F0C0350716EA35984438A8A2F52600A8D956277
Calculated message digest : 1F0C0350716EA35984438A8A2F52600A8D956277
Signer's certificate:
Signer #0:
Subject: /C=PL/ST=Mazowieckie/L=Warszawa/O=GOG Sp. z o.o./CN=GOG Sp. z o.o.
Issuer : /C=US/O=DigiCert, Inc./CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1
Serial : 0B17A63F5D10CB7D3B78AF8F676C7667
Number of certificates: 4
Signer #0:
Subject: /C=US/O=DigiCert, Inc./CN=DigiCert Trusted G4 RSA4096 SHA256 TimeStamping CA
Issuer : /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Trusted Root G4
Serial : 073637B724547CD847ACFD28662A5E5B
Signer #1:
Subject: /C=US/O=DigiCert, Inc./CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1
Issuer : /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Trusted Root G4
Serial : 08AD40B260D29C4C9F5ECDA9BD93AED9
Signer #2:
Subject: /C=US/O=DigiCert, Inc./CN=DigiCert Timestamp 2022 - 2
Issuer : /C=US/O=DigiCert, Inc./CN=DigiCert Trusted G4 RSA4096 SHA256 TimeStamping CA
Serial : 0A7A4A889EC99942900663384D86979D
Signer #3:
Subject: /C=PL/ST=Mazowieckie/L=Warszawa/O=GOG Sp. z o.o./CN=GOG Sp. z o.o.
Issuer : /C=US/O=DigiCert, Inc./CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1
Serial : 0B17A63F5D10CB7D3B78AF8F676C7667
The signature is timestamped: Apr  2 01:53:37 2022 GMT
Hash Algorithm: sha256
Timestamp Verified by:
Issuer : /C=US/O=DigiCert, Inc./CN=DigiCert Trusted G4 RSA4096 SHA256 TimeStamping CA
Serial : 0A7A4A889EC99942900663384D86979D
Timestamp Server Signature verification: OK
Signature verification: OK
Number of verified signatures: 1
Running binary check...
/home/systwi/.local/bin/gogcheck: line 305: 09: value too great for base (error token is "09")
1 file checked, 0 errors

$ echo $?
0
$ ls -la
total 35272608
drwxr-xr-x 2 systwi systwi       4096 Apr 12 07:23  .
drwxr-xr-x 3 systwi systwi       4096 Apr 12 06:31  ..
-rw-r--r-- 1 systwi systwi 4293736958 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-1.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-2.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-3.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-4.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-5.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-6.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-7.bin'
-rw-r--r-- 1 systwi systwi 4294967294 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-8.bin'
-rw-r--r-- 1 systwi systwi 1759352026 Apr  2 14:58 'setup_everspacetm_2_0.8.25294_(64bit)_(54783)-9.bin'
-rw-r--r-- 1 systwi systwi    1239168 Apr  2 12:10 'setup_everspacetm_2_0.8.25294_(64bit)_(54783).exe'

Tested using Arch GNU/Linux.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.