Menu

KeePass_FTP

2008-10-29
2012-11-20
  • GoGoGadgetScott

    GoGoGadgetScott - 2008-10-29

    Normally I a quick to load up the latest beta but for months I have yielded the 2.x warning. After a breaking yet another flash drive, I decided to try 2.x for the ftp server option. The new features are very impressive. I was happy to ditch my future next keychain turned paperweight. The excitement came to abrupt end when work computer failed to launch 2.x. IT block the install of the latest .NET framework, as it is not compatible with the out-of-date version of Intergraph SmartPlant software we use.

    Long story short I am in the process of developing a set of batch files to automation the process of storing KeePass 1.x and a database on a FTP server. It is very beta with few features and no documentation. The use of batch files ensures that the process is simple and easy to review. Please kindly find the first beta release at the following address:
    http://gogogadgetscott.info/aboutme/blog/a/68

    Please advise your option.

    Best regards,
    Scott

     
    • Paul

      Paul - 2008-10-29

      I get "corrupt zip file" - retried the 3.7k download.

      Can you just post the code?

      cheers, Paul

       
      • GoGoGadgetScott

        GoGoGadgetScott - 2008-10-29

        >>>> config.bat
        ::
        ::  KeePass_FTP - The Open-Source FTP tool for KeePass Password Safe
        ::  Copyright (C) 2008 SEG Tech <keepass_ftp@gogogadgetscott.info>
        ::
        ::  This program is free software; you can redistribute it and/or modify
        ::  it under the terms of the GNU General Public License as published by
        ::  the Free Software Foundation; either version 2 of the License, or
        ::  (at your option) any later version.
        ::
        ::  This program is distributed in the hope that it will be useful,
        ::  but WITHOUT ANY WARRANTY; without even the implied warranty of
        ::  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        ::  GNU General Public License for more details.
        ::
        ::  You should have received a copy of the GNU General Public License
        ::  along with this program; if not, write to the Free Software
        ::  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
        :: 
        :: $Id: config.bat 10 2008-10-20 03:30:26Z admin $
        ::

        SET ftpHost=ftpsite.com
        SET ftpRoot=./
        SET ftpUsername=username
        SET ftpPassword=password
        SET database=Database.kdb

        :: Set to 0 for false, 1 for true
        SET readonly=1
        SET debugme=0

        SET package=KeePass.zip
        SET InFile=msg.ftp
        SET OutFile=ftp.log
        >>>>

        >>>> down.bat
        ::
        ::  KeePass_FTP - The Open-Source FTP tool for KeePass Password Safe
        ::  Copyright (C) 2008 SEG Tech <keepass_ftp@gogogadgetscott.info>
        ::
        ::  This program is free software; you can redistribute it and/or modify
        ::  it under the terms of the GNU General Public License as published by
        ::  the Free Software Foundation; either version 2 of the License, or
        ::  (at your option) any later version.
        ::
        ::  This program is distributed in the hope that it will be useful,
        ::  but WITHOUT ANY WARRANTY; without even the implied warranty of
        ::  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        ::  GNU General Public License for more details.
        ::
        ::  You should have received a copy of the GNU General Public License
        ::  along with this program; if not, write to the Free Software
        ::  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
        :: 
        :: $Id: down.bat 11 2008-10-20 03:30:29Z admin $
        ::

        REM @ECHO

        CALL config.bat

        :: generate message file
        > %InFile% ECHO user %ftpUsername% %ftpPassword%
        cls
        >>%InFile% ECHO cd %ftpRoot%
        >>%InFile% ECHO binary

        :: download files
        >>%InFile% ECHO get %database%
        >>%InFile% ECHO get %package%
        >>%InFile% ECHO get 7z.exe
        >>%InFile% ECHO get 7z.dll

        >>%InFile% ECHO close
        >>%InFile% ECHO bye
        cls

        :: run ftp
        IF %debugme%==0 ftp -v -n -s:%InFile% %ftpHost%
        IF %debugme%==1 ftp -d -n -s:%InFile% %ftpHost% >> %OutFile%
        cls

        :: post-ftp-cleanup
        :: For the paranoid: overwrite the temporary file before deleting it
        IF %debugme%==0 TYPE NUL > %InFile%
        IF %debugme%==0 DEL /F /Q %InFile%
        REM DEL /F /Q %OutFile%

        :: extract keepass
        7z.exe x %package% -y
        DEL /F /Q %package%

        :: run keepass with database as command line
        IF %readonly%==0 KeePass\KeePass.exe %database%
        IF %readonly%==1 KeePass\KeePass.exe %database% -readonly

        CALL up.bat

        :End

        >>>>

        >>>> up.bat
        ::
        ::  KeePass_FTP - The Open-Source FTP tool for KeePass Password Safe
        ::  Copyright (C) 2008 SEG Tech <keepass_ftp@gogogadgetscott.info>
        ::
        ::  This program is free software; you can redistribute it and/or modify
        ::  it under the terms of the GNU General Public License as published by
        ::  the Free Software Foundation; either version 2 of the License, or
        ::  (at your option) any later version.
        ::
        ::  This program is distributed in the hope that it will be useful,
        ::  but WITHOUT ANY WARRANTY; without even the implied warranty of
        ::  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        ::  GNU General Public License for more details.
        ::
        ::  You should have received a copy of the GNU General Public License
        ::  along with this program; if not, write to the Free Software
        ::  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
        :: 
        :: $Id: up.bat 14 2008-10-20 03:30:33Z admin $
        ::

        REM @ECHO

        CALL config.bat

        :: compress keepass app folder
        7z.exe a -tzip %package% KeePass\

        :: generate message file
        > %InFile% ECHO user %ftpUsername% %ftpPassword%
        >>%InFile% ECHO cd %ftpRoot%
        >>%InFile% ECHO binary

        :: upload files
        >>%InFile% ECHO put %database%
        >>%InFile% ECHO put %package%
        >>%InFile% ECHO put 7z.exe
        >>%InFile% ECHO put 7z.dll

        :: install batch files for save keeping
        >>%InFile% ECHO put config.bat
        >>%InFile% ECHO put down.bat
        >>%InFile% ECHO put up.bat

        >>%InFile% ECHO close
        >>%InFile% ECHO bye
        cls

        :: run ftp
        IF %debugme%==0 ftp -v -n -s:%InFile% %ftpHost%
        IF %debugme%==1 ftp -d -n -s:%InFile% %ftpHost% >> %OutFile%
        cls

        :: post-cleanup
        :: For the paranoid: overwrite the temporary file before deleting it
        IF %debugme%==0 TYPE NUL > %InFile%
        IF %debugme%==0 DEL /F /Q %InFile%
        REM DEL /F /Q %OutFile%

        RD /S /Q KeePass\

        DEL /F /Q %database%
        DEL /F /Q %package%
        DEL /F /Q 7z.exe
        DEL /F /Q 7z.dll

        SET ftpHost=
        SET ftpRoot=
        SET ftpUsername=
        SET ftpPassword=
        SET database=

        :End

        >>>>

         
    • Paul

      Paul - 2008-10-30

      Interesting use of the re-direct at the beginning of the line - not seen it done like that before.

      You need to be more paranoid, use "set local" to keep variables local, maybe even overwrite them.
      Write more rubbish data to the ftp file to truly overwrite the data.

      You don't seem to have used a temporary directory for the download - assume write access to current directory?
      Maybe create a temporary KeePass directory for everything:
      md %temp%\KeePass
      cd %temp%\KeePass

      I'm sure there is a completely stand alone command line zip program, no DLL.

      cheers, Paul

       

Log in to post a comment.