emmy
20.10.2009, 15:01
Привет, вот в этом (http://my.opera.com/d.i.z./blog/2009/07/25/patch-for-user-scripts-activation-prompt) блоге некто под ником d.i.z. выложил патч для браузера Опера. Смысл патча - убрать предупреждение об использовании пользовательских скриптов (userjs) на странице. (Если так будет понятнее, то это аналог Greasemonkey в Firefox)
Предупреждение возникает только при включенной настройке "opera:config#User Prefs|User JavaScript on HTTPS" и только на страницах, работающих по безопасному протоколу (https).
Вышеупомянутый патч действительно убирает это предупреждение.
Собственно вопрос в том, нет ли у него каких-нибудь побочных эффектов.
Ссылки:
Блог: http://my.opera.com/d.i.z./blog/2009/07/25/patch-for-user-scripts-activation-prompt
Архив: http://files.myopera.com/d.i.z./blog/opera-userjs_activation.zip
P.S.
Содержимое архива:
/patch_tools
upx.exe
perl510.dll
perl.exe
patch_https_ujs_prompt.bat
patchscript_ujs.pl
Файлы из папки patch_tools проверены и полностью совпадают с оригинальными upx и perl.
patchscript_ujs.pl:
$OPERABIN = $ARGV[0];
if ( !$OPERABIN ) {
print " - Missing file argument for perl script!\n";
exit 1;
}
open(FILE,'<'.$OPERABIN) or die " - Error opening file $OPERABIN for reading!\n";
binmode FILE;
my($buf, $data, $n);
$err = 0;
# read content of binary file to buf
while ( ($n = read(FILE, $data, 100000) ) != 0 ) {
$buf .= $data;
}
# perform regepx on buf
# see if maybe already patched
if ( $buf =~ m/\x8B.\x10\xC6\x40\x38\x01/ ) {
print " - Seems like first part of the patch is already applied. NOT proceeding!\n";
$err = 1;
}
elsif ( $buf =~ m/\x8B.\x10\x83\x78\x38\x00/ ) {
# pattern found
print " - First match found (https userjs approved patch)!\n";
$buf =~ s/\x8B(.)\x10\x83\x78\x38\x00/\x8B$1\x10\xC6\x40\x38\x01/;
}
# there are multiple matches of replaced string in file so we can't check if already patched
if ( $buf =~ m/\xC7\x40\x08\x01\x00\x00\x00\x89.\x0C/ ) {
# pattern found
print " - Second match found (userjs object 'modified' flag)!\n";
$buf =~ s/\xC7\x40\x08\x01\x00\x00\x00\x89(.)\x0C/\x89$1\x08\xc7\x40\x0c\x01\x00\x00\x00/;
}
else {
print " - Second match couldn't be found. NOT proceeding!\n";
$err = 1;
}
close(FILE);
# return error when no match found
if ( $err ) { exit 1; }
# create file with modified buf
open(FILE, ">".$OPERABIN) or die " - Error opening file ".$OPERABIN." for writing!\n";
binmode FILE;
print FILE $buf;
close(FILE);
patch_https_ujs_prompt.bat:
@echo OFF
set OPERABIN=opera.dll
set PERLPATCHFILE=patchscript_ujs.pl
set TOOLSDIR=patch_tools
echo Unpacking %OPERABIN%...
%TOOLSDIR%\upx -d %OPERABIN%
if exist temp_opera.dll del temp_opera.dll
copy %OPERABIN% temp_opera.dll
echo Patching...
%TOOLSDIR%\perl -W %PERLPATCHFILE% %OPERABIN%
if errorlevel 1 goto ERR
echo Opera patching completed successfully!
echo Your original Opera file is now '%OPERABIN%_%PERLPATCHFILE%'
:OK
echo Press any key to exit.
if exist %OPERABIN%_%PERLPATCHFILE% del %OPERABIN%_%PERLPATCHFILE%
move temp_opera.dll %OPERABIN%_%PERLPATCHFILE%
goto EOF
:ERR
echo Error! Press any key to exit.
del temp_opera.dll
:EOF
pause > nul
Предупреждение возникает только при включенной настройке "opera:config#User Prefs|User JavaScript on HTTPS" и только на страницах, работающих по безопасному протоколу (https).
Вышеупомянутый патч действительно убирает это предупреждение.
Собственно вопрос в том, нет ли у него каких-нибудь побочных эффектов.
Ссылки:
Блог: http://my.opera.com/d.i.z./blog/2009/07/25/patch-for-user-scripts-activation-prompt
Архив: http://files.myopera.com/d.i.z./blog/opera-userjs_activation.zip
P.S.
Содержимое архива:
/patch_tools
upx.exe
perl510.dll
perl.exe
patch_https_ujs_prompt.bat
patchscript_ujs.pl
Файлы из папки patch_tools проверены и полностью совпадают с оригинальными upx и perl.
patchscript_ujs.pl:
$OPERABIN = $ARGV[0];
if ( !$OPERABIN ) {
print " - Missing file argument for perl script!\n";
exit 1;
}
open(FILE,'<'.$OPERABIN) or die " - Error opening file $OPERABIN for reading!\n";
binmode FILE;
my($buf, $data, $n);
$err = 0;
# read content of binary file to buf
while ( ($n = read(FILE, $data, 100000) ) != 0 ) {
$buf .= $data;
}
# perform regepx on buf
# see if maybe already patched
if ( $buf =~ m/\x8B.\x10\xC6\x40\x38\x01/ ) {
print " - Seems like first part of the patch is already applied. NOT proceeding!\n";
$err = 1;
}
elsif ( $buf =~ m/\x8B.\x10\x83\x78\x38\x00/ ) {
# pattern found
print " - First match found (https userjs approved patch)!\n";
$buf =~ s/\x8B(.)\x10\x83\x78\x38\x00/\x8B$1\x10\xC6\x40\x38\x01/;
}
# there are multiple matches of replaced string in file so we can't check if already patched
if ( $buf =~ m/\xC7\x40\x08\x01\x00\x00\x00\x89.\x0C/ ) {
# pattern found
print " - Second match found (userjs object 'modified' flag)!\n";
$buf =~ s/\xC7\x40\x08\x01\x00\x00\x00\x89(.)\x0C/\x89$1\x08\xc7\x40\x0c\x01\x00\x00\x00/;
}
else {
print " - Second match couldn't be found. NOT proceeding!\n";
$err = 1;
}
close(FILE);
# return error when no match found
if ( $err ) { exit 1; }
# create file with modified buf
open(FILE, ">".$OPERABIN) or die " - Error opening file ".$OPERABIN." for writing!\n";
binmode FILE;
print FILE $buf;
close(FILE);
patch_https_ujs_prompt.bat:
@echo OFF
set OPERABIN=opera.dll
set PERLPATCHFILE=patchscript_ujs.pl
set TOOLSDIR=patch_tools
echo Unpacking %OPERABIN%...
%TOOLSDIR%\upx -d %OPERABIN%
if exist temp_opera.dll del temp_opera.dll
copy %OPERABIN% temp_opera.dll
echo Patching...
%TOOLSDIR%\perl -W %PERLPATCHFILE% %OPERABIN%
if errorlevel 1 goto ERR
echo Opera patching completed successfully!
echo Your original Opera file is now '%OPERABIN%_%PERLPATCHFILE%'
:OK
echo Press any key to exit.
if exist %OPERABIN%_%PERLPATCHFILE% del %OPERABIN%_%PERLPATCHFILE%
move temp_opera.dll %OPERABIN%_%PERLPATCHFILE%
goto EOF
:ERR
echo Error! Press any key to exit.
del temp_opera.dll
:EOF
pause > nul