• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NOD32 linux mirror update 1.1
#1
This is a workaround for linux version of NOD32 mirror update server. You still need to purchase a valid key and password to make updates work though. This version is based on work of someone else. I reworked it and included auto-cleanup feature, so all NUP files under mirror directory are checked and if they are not present in update.ver anymore, they get deleted.

This version of update tool doesn't require ESET Gateway Security and supports mirroring protocol version 2 and 3. Their update URL must be different - filename of both versions is update.ver, the content is different.


Installation:
  • Download and install linux executable unrar-free (Debian package name is unrar-free; it should be compatible with other distributions as well though).
  • Download the script below, modify the settings and test the script.
  • Configure the webserver to access the mirror update directory at certain path.
  • Add the script execution hourly to crontab (ex. 15 * * * * root /root/scripts/nodupdate.sh &> /dev/null).
  • Configure NOD32 update server on client computers to use local mirror.


PHP version is more advanced and faster.



.rar   unrar-free.rar (Size: 31,96 KB / Downloads: 977)

.rar   nodupdate.rar (Size: 1,52 KB / Downloads: 1 763)
[Image: kavove-zrnka-lajna.jpg]
Coffee phreak!
  Reply
#2
I know this post is quite old but.. It had been useful to me. Smile
I tried your script but it didn't work anymore (with a samba share), so I did some little modifications.

Code:
#!/bin/bash

##############################################
# CONFIGURATION
##############################################
# system paths
WGET="/usr/bin/wget"
UNRAR="/usr/bin/unrar"
PS="/bin/ps"
MV="/bin/mv"
RM="/bin/rm"
MD5="/usr/bin/md5sum"

# temporary path, must exist and be writeable
TMP="/tmp"

# clean-up old unused files :  0 - disable, 1 - enable-saves disk space
clean_unused="0"

# ESET updates server
SERVERURL="u33.eset.com"

# Local shared folder
BASE="/var/shares/antivirus/nod32"

# Username and password sent to you by e-mail from ESET
USER="EAV-01234567"
PASS="gej24i34j2"

# What languages should be IGNORED (not downloaded)
EXCLUDE_LANGUAGES=( fr ch nl ge jp pl pt sk sp hr hu )

##############################################
# DO NOT EDIT BELOW THIS LINE
##############################################

# Functions, pre-checks

SERVERv3="http://$SERVERURL/eset_upd/"

function err_disp {
if [ $? = 0 ];then
:
else
  echo $1
  exit 0
fi
}

function FilterLanguages {
    list=$(cat "$TMP/update.ver"|grep ".nup")
    for s in ${EXCLUDE_LANGUAGES[@]}; do
        list=$(echo "$list"|grep -v "$s.nup")
        done
    list=${list//"file="/""}
    echo "$list"
    }

if [ -f $TMP/nod32list ];then
   $RM -f $TMP/nod32list
   err_disp 'Failed while deleting old file'
fi

if [ -f $TMP/v3.ver ];then
   $RM -f $TMP/v3.ver
   err_disp 'Failed while deleting old file'
fi

${PS} aux|grep wget|grep "$SERVERURL" >/dev/null 2>&1
if [ $? = 0 ];then
    kill `ps aux|grep wget|grep "$SERVERURL"|awk '{print $2}'`
    err_disp 'Failed while killing process'
fi

if [ ! -d ${BASE} ];then
    mkdir -p ${BASE}
    err_disp 'Failed while creating nod32 base home directiory'
fi

# Downloading the informational update files
$WGET -t 9 -T 9 -nH -q -nd -O $TMP/v3.ver $SERVERv3/update.ver
err_disp 'Failed while downloading update.ver v3'

$UNRAR x -inul $TMP/v3.ver $TMP
echo "`FilterLanguages`" >> $TMP/nod32list

$RM $TMP/update.ver

# Downloading the data files, adding/updating differences
$WGET --http-user=$USER --http-passwd=$PASS -N -t 9 -T 9 -m -nH -P $BASE --input-file=$TMP/nod32list -B "http://$SERVERURL" --quiet

if [ $? = 0 ]; then
    $UNRAR p -inul $TMP/v3.ver | sed 's/\/download/download/' > $BASE/update.ver
    fi


# Cleaning old NUP datafiles
if [ "$clean_unused" = "1" ]; then

    if [ ! -f $TMP/nod32list ]; then
        exit 0
        fi

    ARY=(`cat "$TMP/nod32list" | tr '\r' ' ' | tr '\n' ' '`)

    if [ "${#ARY[@]}" -lt "10" ]; then
        exit 0
        fi

    EFS=( )

    filelist=`ls -1R "$BASE"`
    de=${#BASE}
        for s in $filelist; do
        if [ "${s:(-1)}" = ":" ]; then
            cdir=${s:($de)}
            cdir=${cdir:0:(${#cdir}-1)}
            else
            ext=${s:(-4)}
            if [ "$ext" = ".nup" ]; then
                EFS=( "${EFS[@]}" "$cdir/$s" )
                fi
            fi
        done

    # echo "Existing files: ${#EFS[@]}\nUplink files: ${#ARY[@]}\nCleaning..."

    if [ "${#EFS[@]}" -lt "10" ]; then
        exit 0
        fi

    function FindInArray {
        FOUND=0
        for s in ${ARY[@]}; do
            if [ "$s" = "$1" ]; then
                FOUND=1
                break
                fi
            done
        echo "$FOUND"
        }

    for s in ${EFS[@]}; do
        FOUND=`FindInArray $s`
        if [ "$FOUND" = "0" ]; then
            rm "$BASE$s"
            fi
        done

    fi
    
$RM -f $TMP/nod32list

...maybe it could be useful to someone else! Wink

Cheers!
  Reply
#3
Acctually, it's at least one year ago I sent this script to eset :O
I got a really updated version running on my production server :-D
  Reply
#4
Awesome - works a treat!
  Reply
#5
THANKS!!! It Works!
  Reply
#6
Is there could translate into PHP script?

Please... Big Grin
  Reply
#7
ofidz:
It has been developed half a year ago, but I found bugs, so I had to fix them and continue with testing extensively... and in the meantime i completely forgot to publish it :-D
http://ashus.ashus.net/viewtopic.php?f=3&t=153
[Image: kavove-zrnka-lajna.jpg]
Coffee phreak!
  Reply
#8
Hi all,
We have developed a bash script, which is works great with NOD v3.0 and 4.0 too (these are compatibile, instead under 3.0) on Debain Linux.
I didn't found any solution before which support the newest nod clients, but this works and quite simple. Here it is:

Code:
#!/bin/sh
LOCAL=/NOD_mirror
URL=http://um10.eset.com/eset_upd
USER=
PASSWD=
WGET="wget --user=$USER --password=$PASSWD -t 15 -T 15 -N -nH -nd -q"
UPDATEFILE="update.ver"
cd $LOCAL
CMD="$WGET $URL/$UPDATEFILE"
eval "$CMD" || exit 1;
if [ -n "`file $UPDATEFILE|grep -i rar`" ]; then
(
  cd /tmp
  rm -f /tmp/$UPDATEFILE
  unrar-free -x $LOCAL/$UPDATEFILE ./
)
UPDATEFILE=/tmp/$UPDATEFILE
URL=`echo $URL|sed -e s:/eset_upd::`
fi
TMPFILE=/tmp/nod32tmpfile
grep file=/ $UPDATEFILE|tr -d \\r > $TMPFILE
FILELIST=`cut -c 6- $TMPFILE`
rm -f $TMPFILE
echo "Downloading updates..."
for FILE in $FILELIST; do
  CMD="$WGET \"$URL$FILE\""
  eval "$CMD"
done
cp $UPDATEFILE $LOCAL/update.ver
perl -i -pe 's/\/download\/\S+\/(\S+\.nup)/\1/g' $LOCAL/update.ver
echo "Done."

That's all. I tested on NOD v4.0, works great, clients download updates successfully (probably 3.0 is working well, too).
You can publish the mirror with smb UNC path, or via http. I used lighttpd webserver with plain text authenticate for that. Unfortunately htdigest authentication cannot be used, the clients don't support this authentication method.
Just I thought, lot of the IT admins can use this script :-)
Have a nice day!
  Reply
#9
Merlot, your script works like a charm, merci Smile

Let's see if we can modify Ashus' php-implementation so that it works with the new clients again...

Azadi
  Reply
#10
Merlot, tell me please, is this normal, that script creates a few big files rather than a lot of smaller ones >?

I'm interested in linux bash/php script that CAN download files from eset servers... but usually (at all times) like exp. windows client mirrot create a lot of small from 10k to 1.5 MB files. ~ 30 files at all. But your script create several BIG ones...
  Reply




Users browsing this thread: 1 Guest(s)