[GELÖST] Windows-Header-Analyse in der Bash

Antworten
Benutzeravatar
GEI
Beiträge: 233
Registriert: 12 Feb 2010, 13:00
Wohnort: Braunschweig
Kontaktdaten:

[GELÖST] Windows-Header-Analyse in der Bash

Beitrag von GEI »

hi @all,

vielleicht hat ja jemand einen Hinweis für mich .... Ich such schon seit ein paar Tagen.

Ich möchte direkt auf dem OPSI-Server mittels Shellscipts vorhandende Windows-Dateien analysieren, um aus dem Dateiheader vor allem die Fileversion bzw. Productversion zu extrahieren.
In einigen Fällen kommt man ja mit "strings" + grep weiter, wie z.B. bei GoogleChrome oder Putty:

Code: Alles auswählen

root@opsi:~/o/dfn_chrome# strings -n 10  CLIENT_DATA/GoogleChromeStandaloneEnterprise.msi | grep Copyright
50.0.2661.94 Copyright 2011 Google Inc.
root@opsi:~/o/dfn_chrome# strings -n 10  CLIENT_DATA/GoogleChromeStandaloneEnterprise.msi | grep Copyright | cut -d" " -f1
50.0.2661.94

root@opsi:~/o/dfn-watch_putty# strings -n5 CLIENT_DATA/putty.exe | grep PuTTY-Release
PuTTY-Release-0.67
root@opsi:~/o/dfn-watch_putty# strings -n5 CLIENT_DATA/putty.exe | grep PuTTY-Release | cut -d'-' -f3
0.67
Nun gibt es aber andere .exe/.msi, wo dies nicht zum Ziel führt. Als Beispiel mag hier das SetupFile von Xmind gelten, das ist z.B. mit InnoSetup generiert worden (Download: http://www.xmind.net/xmind/downloads/xm ... indows.exe). In den Eigenschaften dieser Datei über den Windowsexplorer werden im Tab "Details" die Dateiversion 3.6.1.0 und als Productversion 3.6.1.201512240102 angezeigt.
Wie kommt man in der Linux-Bash an diese Header-Informationen? Auch mit "objdump" aus den GNU-Binutils komme ich nicht zum Ziel.
Zuletzt geändert von GEI am 10 Mai 2016, 12:02, insgesamt 1-mal geändert.
Leibniz-Institut für Bildungsmedien | Georg-Eckert-Institut (GEI)
---
'opsi4instituts' = Communityprojekt für wissenschaftliche Einrichtungen
offenes Repository, Update-Notifier
wiki.o4i.org - www.gei.de/institut/direktion/it-service/opsi4instituts
Benutzeravatar
SisterOfMercy
Beiträge: 1556
Registriert: 22 Jun 2012, 19:18

Re: Windows-Header-Analyse in der Bash

Beitrag von SisterOfMercy »

A quick search turns up this: https://apps.ubuntu.com/cat/applications/pev/
and this:

Code: Alles auswählen

$ wrestool --extract --raw --type=version putty.exe | strings -el | grep Version -A 1
But what do you need this for? Somebody might know a different solution. For instance, if this is to export to some other thing you can always ask the opsi server for the correct version. Or would this be to automate opsi-makeproductfile?
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
Benutzeravatar
GEI
Beiträge: 233
Registriert: 12 Feb 2010, 13:00
Wohnort: Braunschweig
Kontaktdaten:

Re: Windows-Header-Analyse in der Bash

Beitrag von GEI »

SisterOfMercy hat geschrieben: https://apps.ubuntu.com/cat/applications/pev/
$ wrestool --extract --raw --type=version putty.exe | strings -el | grep Version -A 1
super, das war genau der richtige Tip! DANKE !!!
But what do you need this for? Somebody might know a different solution.
Ich vergleiche via Cron-Bashscripte die Version vom lokalen CLIENT_DATA/$SetupFile$ mit der auf der Website des Software-Herstellers genannten/downloadbaren aktuellen Version. Falls sich der Filename oder die Version unterscheidet, wird gedownloadet sowie gegebenfalls nochmals ein "cmp" gegen die lokale Version vorgenommen.
Erst wenn eine neuere Version vorliegt, wird eine Benachrichtigungsmail versandt (siehe auch viewtopic.php?f=7&t=8360) :idea:
"xmind" ist mittlerweise das Softwareprodukt #100, komplette Liste siehe #1 o.g. vorherigen Forenbeitrag.

Beispiel xmind (ca. 100 Lines, stark gekürzt)

Code: Alles auswählen

...
MAILTO_DFN="opsi4instituts-notify@listserv.dfn.de"
STORAGEPATH="CLIENT_DATA"
LOGTAG="opsipackage"
OPSIPRODUCT="xmind"                                                     # opsi-Paketname
PATTERN="xmind-*-windows.exe"                                      # xmind-7-update1-windows.exe
...
CLIENTDATA_FILENAME="`ls -1 $STORAGEPATH/$PATTERN | cut -d'/' -f2`"
CLIENTDATA_VERSION="`pev -p $STORAGEPATH/$PATTERN | sed 's/\.0$//g'`"
...
STATUS_FILE="status-version.wget"
STATUS_URL="http://www.xmind.net/download/win/"
wget -q $STATUS_URL     -O $STATUS_FILE
...
DOWNLOAD_VERSION="`cat $STATUS_FILE | grep -i "latest release"| html2text | cut -d'(' -f2 | cut -d')' -f1  | tr -d '^v'`"
DOWNLOAD_LINK="`cat $STATUS_FILE | grep -i exe | grep download | cut -d'=' -f3 | cut -d'"' -f2`"
DOWNLOAD_FILENAME="`echo $DOWNLOAD_LINK  | cut -d'/' -f6`"
MAILTXT_DFN="Sie finden ein Update der Software {$OPSIPRODUCT} Version: [$DOWNLOAD_VERSION] unter $DOWNLOAD_LINK."
...
[ ! "$CLIENTDATA_VERSION" = "$DOWNLOAD_VERSION" ] && {
wget --user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64;" $DOWNLOAD_LINK
MESSAGE="{$OPSIPRODUCT} Update gefunden! [$CLIENTDATA_VERSION] -> [$DOWNLOAD_VERSION]" 
echo "$MAILTXT_DFN "    | mail -s "[$LOGTAG]-$MESSAGE " $MAILTO_DFN
}
...
Leibniz-Institut für Bildungsmedien | Georg-Eckert-Institut (GEI)
---
'opsi4instituts' = Communityprojekt für wissenschaftliche Einrichtungen
offenes Repository, Update-Notifier
wiki.o4i.org - www.gei.de/institut/direktion/it-service/opsi4instituts
Antworten