View Full Version : How to check if a DVD is CSS protected without scanning the video
Chatwalker
10th March 2004, 15:49
Hi folks
Is there a way to find out if a DVD is CSS protected without scanning the Video. Maybe a Flag in the IFO??
Thanks for any ideas
Chatwalker
UMP
10th March 2004, 16:03
Originally posted by Chatwalker
Hi folks
Is there a way to find out if a DVD is CSS protected without scanning the Video. Maybe a Flag in the IFO??
Thanks for any ideas
Chatwalker
Have a look at the FairUse source code, you'll find samples about such flag checking. dvdUdf.Encrypted() should be a good starting point.
Regards,
ump
Nic
10th March 2004, 16:50
(@Chatwalker: Fairuse seems to get that flag by calling CtlReadCopyright, find the call in css.cpp and the code that reads the structure in DvdIo.cpp)
UMP
14th March 2004, 10:01
Regarding some feedback from the latest FU release, I suspect the "copyright bit" method to not be 100% reliable, through I could not yet have the practical demonstration of it. I fear the only way to _reliably_ determine if a DVD is CSS protected is to scan some sectors.
Here is some sample code from DeCSS. The variable fil refers to an open file stream :
int DeCSScrack::IsCiphered()
{
int OldPos = ftell(fil),i = 0,r;
char SecBuf[2048];
r = 2048;
fseek(fil,0,SEEK_SET);
while (i<OptionNumSearchSectors && r==2048)
{
r = fread(&SecBuf,1,2048,fil);
if (SecBuf[(SecBuf[13] & 0x07) + 20] & 0x30) break;
}
fseek(fil,OldPos,SEEK_SET);
return i<OptionNumSearchSectors ? 1:0;
}
Regards,
ump
Chatwalker
15th March 2004, 10:02
Thanks for your replies!!!!
Regards,
Chatwalker
GZZ
28th March 2004, 15:51
Can anyone translate the code to pascal (delphi) or just explain it, I´m a bit lost about the '& 0x07' and what this if line test
if (SecBuf[(SecBuf[13] & 0x07) + 20] & 0x30) break
why are there not if xxx = xxx then break, don't see the equil to. If anyone could please explain it. Thanks
GZZ
Nic
28th March 2004, 17:06
SecBuf is an array of bytes.
if you do logical AND with the 13th byte of SecBuf and the number 7 then add twenty you get the position to check for in SecBuf for the scrambling bits. ( this refers to [(SecBuf[13] & 0x07) + 20 )
(I dont think I've ever seen a packet where it isn't always the same offset, but I guess it's good to check, and that's what that code does)
Then at that offset in secbuf logical AND the value with hexidecimal 30 (i.e 30h or 48 in decimal). If the resulting value is not zero then the 2048 bytes are encrypted...
(sorry I don't know pascal/delphi), hope that makes sense.
-Nic
ps
For a simpler version (that doesn't do the check), programs such as DeCSS+ just did:
if ( SecBuf[0x14] & 0x30 )
which means if the 14h (20th) byte of SecBuf when AND'd with 0x30 (48) equals anything other than zero, then SecBuf is encrypted
GZZ
28th March 2004, 19:11
yea - it made it all much more clear to me. Thanks alot.
GZZ
GZZ
28th March 2004, 21:13
I made som Delphi (pascal) code, which work for me:
Function CSSProtected(Filename: String; SectorToSearch: Integer): Boolean;
var
Fic: TfileStream;
buf: Array[0..2047] of byte;
I: Integer;
Begin
Fic := TFileStream.Create(Filename, fmOpenRead or fmShareDenyWrite);
Try
Fic.Seek(0, soBeginning);
I := 0;
Result := False; //NOT CSS protected
While I < SectorToSearch do
Begin
Inc(I);
Fic.Read(Buf, 2048);
If (Buf[20] and $30) <> 0 then
Begin
Result := True; //CSS protected
break;
end;
end;
finally
Fic.Free;
end;
end;
I hope anyone can use it.
GZZ
Nic
29th March 2004, 17:07
I guess:
If (Buf[(Buf[$14] and 7)+20] and $30) = $30 then
would also work...so that's delphi....wacky.
-Nic
Fuel
10th April 2004, 00:42
Hi guyz,
im a newbie in dvd tech world and i was also curious how to detect if a dvd is encrypted or not.
my question is, in order to use the CSSProtected function from above, Filename must be any IFO file or exactly which file ?
I tried to search info about DVD File structure and i found that IFO is not encrypted ! Im confused.
Thanks alot.
Nic
10th April 2004, 18:08
That's very true the IFO file is not encrypted. and BUP files are just backup files of the IFO file. So you check on the VOB File.
Fuel
11th April 2004, 17:23
Thanks for your reply, I have one more question: on which of the VOB file should this algorithm be applied ( Is VIDEO_TS.vob encrypted too ?) and what is the meaning exactly of the number of sectors to search (what is its range) ?
Thanks alot.
Gr8 forum !
GZZ
11th April 2004, 19:50
Yea normally all *.vob files are encrypted. But to be 100% sure, you can use it on ALL the vob files. It not nessary to do so, because normally, if one vob file are encrypted, then they are all encryted. But I normally call the function with:
the VTS_0x_0.vob file are normally a menu file and they are not always encrypted, so don't test on those, it will give you a false alarm.
Call the function like this
CSSProtected('C:\VTS_01_1.VOB', 1000);
1000 are sectors and a sector are 2048 byte, so it will scan 1000 x 2048 byte = 2048000 byte ~ 2 mb. Which should be enough, but remember that you can't scan more sectors then the size of the file are.
So just take the filesize(in byte) / 2048 = Number of sectors in file
GZZ
Fuel
12th April 2004, 01:04
Thanks for your replies Nic and GZZ.
I used the code for checking DVDs and it doesn work correctly. On one of them it says its not encrypted and it is.
I used the following function:
bool IsCiphered(const char *sPath)
{
FILE *fil = fopen(sPath, "rb");
if(fil == NULL)
{
MessageBox(NULL, "Error opening the file", "", MB_OK | MB_ICONERROR);
return false;
}
int nSectors = 20000;
int i = 0,r = 2048;
char SecBuf[2048];
fseek(fil,0,SEEK_SET);
while ( (i < nSectors) && (r == 2048) )
{
i++;
r = fread(&SecBuf, 1, 2048, fil);
//If the resulting value is not zero then the 2048 bytes are encrypted...
if (SecBuf[(SecBuf[13] & 0x07) + 20] & 0x30)
return true;
}
fclose(fil);
return false;
}
i tried also with
if( SecBuf[0x14] & 0x30 )
return true;
but still doesnt work.
Any idea ?
any help would mean alot to me.
Thanks !
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.