>** create a binary script >STRTOFILE("MESSAGEBOX('Hello World')","temp.prg") >COMPILE temp.prg >cBlob = FILETOSTR("temp.fxp") >DELETE FILE temp.prg >DELETE FILE temp.fxp > > >** test our function >SECURESCRIPT(cBlob) > >*********************************** >FUNCTION SECURESCRIPT(cBlob) > >cTempFile = ADDBS(SYS(2023))+SYS(2015)+".fxp" >** copy script to temp file >nLen = STRTOFILE(cBlob, cTempFile) >** open file readonly to lock it >hnd = FOPEN(cTempFile) >** check the file size to make sure it is OK >IF FSEEK(hnd,0,2) = nLen > ** execute it > DO (cTempFile) >ENDIF >** cleanup >FCLOSE(hnd) >DELETE FILE (cTempFile) >This is not sufficient for me:
** create a binary script STRTOFILE("MESSAGEBOX('Hello World')","temp.prg") COMPILE temp.prg NODEBUG cBlob = FILETOSTR("temp.fxp") DELETE FILE temp.prg DELETE FILE temp.fxp ** test our function SECURESCRIPT(cBlob) *********************************** FUNCTION SECURESCRIPT(cBlob) cTempFile = ADDBS(SYS(2023))+SYS(2015)+".fxp" ** copy script to temp file nLen = STRTOFILE(cBlob, cTempFile) ** open file readonly to lock it hnd = FOPEN(cTempFile) ** check the file size to make sure it is OK IF FSEEK(hnd,0,2) = nLen * simulate a hacker capture cRun = 'notepad.exe "'+cTempFile+ '"' RUN &cRun * If you are a hacker, then you know whether to do with the program of capture DO (cTempFile) ENDIF ** cleanup FCLOSE(hnd) DELETE FILE (cTempFile)This is the least one that guarantees the code (at least to User Privilege of the OS)
** create a binary script STRTOFILE("MESSAGEBOX('Hello World')","temp.prg") COMPILE temp.prg cBlob = FILETOSTR("temp.fxp") && this is not sure, but this is not a problem DELETE FILE temp.* ** test our function SECURESCRIPT(cBlob) *********************************** FUNCTION SECURESCRIPT(cBlob) * here i can do a CRC64 ON ERROR ? MESSAGE() cTempFile = ADDBS(SYS(2023))+SYS(2015)+".fxp" hnd = FCREATE(cTempFile) && i want exclusive access, with READ IF FWRITE(hnd,cBlob) = LEN(cBlob) AND FFLUSH(hnd,.T.) cRun = 'notepad.exe "'+cTempFile+ '"' RUN &cRun DO (cTempFile) && VFP doesn't see that that ago himself, very amusing ENDIF ** cleanup FCLOSE(hnd) && here you lose DO (cTempFile) && now you can access, BUT IT IS FREE DELETE FILE (cTempFile)