// project: far ftp password decoder.
// author: ilya levin
// date: dec 1999
// rem: pretty jerk code style... who cares.. it works anyway :)
//

// decode the passwords to all ftp servers, stored by far
// ftp plugin. has been tested on far v1.63 by eugene roshal.
// no installation requires, just run the exe file. please 
// note this is the simple utility, not the crack tool.

#include <windows.h>
#include <string.h>
#include <stdlib.h>

char Msg[16000]="far ftp password decoder (x) ilya levin, 1999\n"
                "------------------------------------------------------\n";

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmd, int nShow )
{ HKEY k, z;
  long rc, hrc, i;
  DWORD idx=0;
  char buf[2048]="\0";
  char zuf[5]="\0";
  BYTE pwd[512];

  if (rc==ERROR_SUCCESS)
  { rc=RegEnumKey(k,idx,buf, sizeof(buf));
    while (rc==ERROR_SUCCESS)
    { strcat(Msg, buf);
      if (RegOpenKey(k, buf, &z)==ERROR_SUCCESS)
      { hrc=sizeof(pwd);
        if (RegQueryValueEx(z, "Password", 0, NULL, pwd, &hrc)==ERROR_SUCCESS)
        { strcat(Msg," --- ");
          pwd[0]^=pwd[1]; pwd[0]|=0x50; hrc--;
          for(i=2; i<hrc; i++) {pwd[i]^=pwd[0]; sprintf(zuf,"%c", pwd[i]); strcat(Msg, zuf);} 
        } else strcat(Msg," no password");
        RegCloseKey(z);
      }
      strcat(Msg,"\n");
      rc=RegEnumKey(k,idx++,buf, sizeof(buf));
    }
    RegCloseKey(k);
  } else strcat(Msg,"sorry, far data not found\n");

  MessageBox(0, Msg, "far ftp passwords", MB_OK); 
  return 0;
}