Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' UNSECURE.BAS: Unsecures RMB and compatible PROG format files.
- ' Copyright (C) 1997 Oswego Software, Inc. All rights reserved.
- ' Written by Shawn Fessenden. No part of this program may be reproduced or
- ' transmitted by any means, electronic or otherwise, without the express
- ' written permission of Oswego Software, Inc.
- ' THIS PROGRAM IS FOR OSWEGO SOFTWARE, INC. INTERNAL USE ONLY!
- ' To use for BASIC/WS, copy prog source with HPCOPY in RAW mode.
- ' Run this program, then copy back with HPCOPY in RAW mode, set NEW HP
- ' FILE TYPE to -5808 (BASIC/WS PROG file type).
- OPTION BASE 1
- ' Frequently used constants.
- ' Boolean True & False.
- CONST False = 0 'Common definition of FALSE.
- CONST True = (NOT False) 'Common definition of TRUE.
- ' Access constants for crack data (i.e. enum {CRACK_UNUSED,CRACK_EOL...}).
- CONST CRACK.UNUSED = 0 'Not used.
- CONST CRACK.EOL = 1 'End of line token.
- CONST CRACK.SEC = 2 'Secure flag.
- CONST CRACK.UNSEC = 3 'Unsecure flag.
- CONST CRACK.PTRWORD = 4 'Offset to ptr to first possible secure flag.
- CONST CRACK.BIGENDIAN = 5 'True if machine type is big endian.
- CONST CRACK.CHECKLAG = 6 'Number of bytes to continue checking for EOL after first EOL is found.
- ' Variable declaration.
- ' Boolean.
- DIM bCheck AS INTEGER 'True = start checking for secure flag.
- ' Integers.
- DIM nThisByte AS INTEGER 'Current byte in in/out files.
- DIM nLastByte AS INTEGER 'Last byte in in/out files.
- DIM nSourceType AS INTEGER 'Select input file type.
- DIM nCrack(3, 6) AS INTEGER 'Crack constants.
- ' Pointers.
- DIM pInFile AS INTEGER 'Input file number.
- DIM pOutFile AS INTEGER 'Output file number.
- DIM pPtrWord AS INTEGER 'Ptr to ptr word in input file.
- 'i.e. PWORD *pwPtrWord. Note double-indirection.
- 'Yes, this *is* supposed to be obscure.
- ' Single precision.
- DIM fVarEnd AS SINGLE 'End of var table as defined by pointer word.
- DIM fBytePos AS SINGLE 'Current byte position in in/out files.
- DIM fLastEol AS SINGLE 'Byte positon of last Eol tag.
- DIM fFoundTags AS SINGLE 'Number of secure tags found.
- ' Strings.
- DIM sInFile AS STRING 'Input file.
- DIM sOutFile AS STRING 'Output file.
- DIM sByte AS STRING * 1 'Byte at current offset in in/out files.
- DIM sVarTbl AS STRING 'Message buffer, just to make everything look pretty.
- DIM sSpin(4) AS STRING * 1 'Progress spinner characters.
- DIM sPtrWord(4) AS STRING * 1 'Temporary holding bin for pointer bytes.
- DIM sVarTblStart AS STRING 'Var tbl start copy time.
- DIM sVarTblStop AS STRING 'Var tbl stop copy time.
- DIM sCrackStart AS STRING 'Crack start time.
- DIM sCrackStop AS STRING 'Crack stop time.
- DIM sMenu(3) AS STRING 'Main menu data.
- ' QUIT BITCHING! THIS IS SUPPOSED TO BE OBSCURE DAMNIT.
- ' Menu setup.
- MenuData:
- DATA 3
- DATA "HP BASIC/WS source."
- DATA "TransEra HT Basic for Windows source."
- DATA "Hewlett Packard HP Basic for Windows source."
- RESTORE MenuData
- READ i
- FOR j = 1 TO i
- READ sMenu(j)
- NEXT j
- ' Crack data setup.
- ' DATA EOL, SEC, UNSEC, PTRWORD, ENDIAN, CHECKLAG
- CrackData:
- DATA 3
- DATA 179,72,64,39,1,2
- DATA 201,1,0,267,0,2
- DATA 201,1,0,267,0,2
- RESTORE CrackData
- READ i
- FOR j = 1 TO i
- FOR k = 1 TO 6
- READ nCrack(j, k)
- NEXT k
- NEXT j
- ' Spinner setup.
- SpinnerData:
- DATA \,|,/,-
- RESTORE SpinnerData
- FOR i = 1 TO 4
- READ sSpin(i)
- NEXT i
- ' Begin Main.
- CLS
- ' Intro & choose source type.
- PRINT "Source file must be in PROG format, not ASCII."
- PRINT
- PRINT "Choose source type:"
- PRINT
- RESTORE MenuData
- READ i
- FOR j = 1 TO i
- PRINT TAB(5); LTRIM$(STR$(j)); ") "; sMenu(j)
- NEXT j
- PRINT
- PRINT "Enter 1 to "; LTRIM$(STR$(i));
- INPUT nSourceType
- IF nSourceType < 1 OR nSourceType > i THEN SYSTEM
- PRINT : PRINT
- ' Get file names.
- LINE INPUT "Input file :"; sInFile
- LINE INPUT "Output file:"; sOutFile
- PRINT
- ' Get file pointers.
- pInFile = FREEFILE
- pOutFile = pInFile + 1
- ' Open files.
- OPEN sInFile FOR BINARY AS #pInFile LEN = 1
- OPEN sOutFile FOR BINARY AS #pOutFile LEN = 1
- ' Get PtrWord. (offset to first possible secure flag).
- pPtrWord = nCrack(nSourceType, CRACK.PTRWORD)
- FOR i = 0 TO 3
- GET #pInFile, pPtrWord + i, sPtrWord(1 + i)
- NEXT i
- ' Convert pointer bytes to a file offset.
- IF nCrack(nSourceType, CRACK.BIGENDIAN) THEN
- ' Big Endian for HP BASIC/WS.
- fVarEnd = ((ASC(sPtrWord(1)) * 256 + ASC(sPtrWord(2))) * 65536) + ((ASC(sPtrWord(3)) * 256 + ASC(sPtrWord(4)))) + 12
- ELSE
- ' Little Endian for Basic for Windows.
- fVarEnd = ((ASC(sPtrWord(2)) * 256 + ASC(sPtrWord(1))) * 65536) + ((ASC(sPtrWord(4)) * 256 + ASC(sPtrWord(3)))) + 256
- END IF
- ' All bytes from the first to fVarEnd are the variable table (basically).
- sVarTbl = RIGHT$("000000" + HEX$(fVarEnd), 6) + " " + "VarTbl..... "
- PRINT sVarTbl;
- sVarTblStart = TIME$
- FOR fBytePos = 1 TO fVarEnd
- GET #pInFile, fBytePos, sByte
- PUT #pOutFile, fBytePos, sByte
- LOCATE CSRLIN, POS(0) - 1
- PRINT sSpin(fBytePos MOD 4 + 1);
- NEXT fBytePos
- sVarTblStop = TIME$
- ' Next byte may be a secure flag; make it an unsecure flag.
- GET #pInFile, fBytePos, sByte
- IF ASC(sByte) = nCrack(nSourceType, CRACK.SEC) THEN
- sByte = CHR$(nCrack(nSourceType, CRACK.UNSEC))
- fFoundTags = fFoundTags + 1
- END IF
- PUT #pOutFile, fBytePos, sByte
- fBytePos = fBytePos + 1
- ' Start looking for EOL markers.
- PRINT : PRINT TAB(8); "Cracking... ";
- sCrackStart = TIME$
- bCheck = False
- GET #pInFile, fBytePos, sByte
- fLastEol = fBytePos
- nThisByte = ASC(sByte)
- WHILE NOT EOF(pInFile)
- ' You're not supposed to be seeing this so shut up.
- ' Check to see if the current byte is a secure flag.
- IF bCheck AND nThisByte = nCrack(nSourceType, CRACK.SEC) THEN sByte = CHR$(nCrack(nSourceType, CRACK.UNSEC))
- ' Turn off secure checking CRACK.CHECKLAG bytes after last Eol.
- IF fBytePos >= fLastEol + nCrack(nSourceType, CRACK.CHECKLAG) THEN bCheck = False
- ' Write current byte.
- PUT #pOutFile, fBytePos, sByte
- ' Check to see if the current byte is an eol tag.
- IF nThisByte = nCrack(nSourceType, CRACK.EOL) THEN
- bCheck = True 'Start looking for secure flags.
- fLastEol = fBytePos 'Record position of this Eol.
- END IF
- ' Show progress.
- LOCATE CSRLIN, POS(0) - 1
- PRINT sSpin(fBytePos MOD 4 + 1);
- ' Bump pointer & get next byte.
- fBytePos = fBytePos + 1
- GET #pInFile, fBytePos, sByte
- nThisByte = ASC(sByte)
- WEND
- sCrackStop = TIME$
- CLOSE
- PRINT : PRINT
- PRINT "Var table copy start time: "; sVarTblStart
- PRINT "Var table copy end time : "; sVarTblStop
- PRINT
- PRINT "Crack start time : "; sCrackStart
- PRINT "Crack end time : "; sCrackStop
- PRINT : PRINT : PRINT : PRINT
- PRINT "Done."
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement