èšèªïŒ Perl
Roskomnadzorã«ãã£ãŠäœæããããµãŒãã¹ã«ã¯ãéåžžã«é·ãèªã¿ã«ããååããããŸããããã¡ã€ã³åãã€ã³ã¿ãŒãããäžã®Webãµã€ãããŒãžãããã³ãã·ã¢é£éŠã§ã®é åžãçŠæ¢ãããŠããæ å ±ãå«ãã€ã³ã¿ãŒãããäžã®ãµã€ããç¹å®ã§ãããããã¯ãŒã¯ã¢ãã¬ã¹ã®çµ±äžã¬ãžã¹ããªã ããããã£ãŠãç°¡åã«ããããã«ãRoskomnadzorãµãŒãã¹ãšåŒã³ãŸãã
ææŠãã
RoskomnadzorãªãœãŒã¹ããçŠæ¢ãµã€ãã®ãªã¹ãã®èªåããŠã³ããŒããæŽçããŸãã ã·ã¹ãã ã¯1ã€ã®ãã¹ãå ã«å®è£ ããå¿ èŠããããããŠã³ããŒããããã¡ã€ã«ã¯ç¹å®ã®æ·±ãã§ããŒããŒã·ã§ã³ããå¿ èŠããããŸãã
æè©
çŠæ¢ãµã€ãã®ãªã¹ãã«é¢ããŠã¯ããã§ã«å€ãã®ããšãèšãããŠããŸããããã®ãããã¯ã«ã€ããŠå床è°è«ããããšã¯æå³ããããŸããã
ãã ãããã®ã¬ãã¹ã³ã®æãããªç¡æå³ãã«ãããããããçŠæ¢ãµã€ãã®ãªã¹ããæ¯æ¥ããŠã³ããŒãããããšã¯ãå€ãã®ã€ã³ã¿ãŒããããããã€ããŒã«ãšã£ãŠå¿ èŠã«ãªã£ãŠããŸãã ããã¯äž»ã«ãRoskomnadzorããã®è«æ±ãé¿ããããã«è¡ãããŸãã åœç¶ãæåã«é ã«æµ®ãã¶ã®ã¯ãããŠã³ããŒãããã»ã¹ãèªååããããšã§ãã æ®å¿µãªãããRoskomnadzorã®Webãµã€ãã§ã¯ãèªååã®æ¹æ³ãããªãææ§ã«èª¬æãããŠãããæè¡çãªãµããŒãã¯ã»ãšãã©ãããŸããã ããã«ãããã»ã¹ã®èªååã®å ŽåããµãŒãã¹ã®æäœã¯SOAPãããã³ã«ã®äžã§å®è¡ãããŸããããããåã³ãè¿œå ããŸããã
ãã®æ©äŒã«ãçŠæ¢ãµã€ãã®ãªã¹ããèªåçã«ããŠã³ããŒãããæ¹æ³ã玹ä»ããŸãã 誰ãããã®ãããªåé¡ãæ±ããŠããå¯èœæ§ããããç§ã®èšäºãçŸåšãã®è§£æ±ºçãæ¢ããŠãã人ã ã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸãã
Habréãå«ãããã®ãããã¯ã«é¢ããå€ãã®èšäºããã§ã«æžãããŠãããšèšããããåŸãŸããããããã®èšäºã«èšèŒãããŠããæ¹æ³ã¯ãã»ãšãã©ã®å Žåãå®å šãªèªååãå®çŸã§ããŸããã§ããã ãªã¹ãã®ãªã¯ãšã¹ããæã§äœæããå¿ èŠãããå Žæãæã§ã¹ã¯ãªãããå®è¡ããå Žæãªã©ã ç§ã®å Žåãã·ã¹ãã ã¯å®å šã«èªåçã«åäœãããã¹ãŠãæ£åžžãã©ããã®ã¿ã確èªããŸãã ççŽã«èšã£ãŠãã·ã¹ãã ãäžããããã«ãç§ã¯Tosterã§èŠã€ããèšäºãå©çšããŸããã Perlã¹ã¯ãªãããæ瀺ããŸããããå°ãå€æŽããŠäœããè¿œå ããŸããã
ãã¡ãããå®è£ ã¯ããªãç²éã§ããããšãå€æããŸããããéåžžã«æ©èœããŠããŸãã ãã¹ãŠã1ã€ã®ãã¹ãã«é 眮ãããŸããã ããã¯Windows XPã®å€ãäŒèšã³ã³ãã¥ãŒã¿ãŒã§ãRutokenããã©ã°ã€ã³ããããããã¯ãŒã¯ã«æ¥ç¶ãããã©ãã¯ã«éããããŸããã ãããã£ãŠãRoskomnadzorãµãŒãã¹ããã¢ãŒã«ã€ããããŠã³ããŒãããããã£ã¬ã¯ããªã¯ãããŒã«ã«ãããã¯ãŒã¯ã§å ±æãããŸãã
次ã«ãå®è£ ãæ€èšããŸãã
OSãšããŠãç§ãèšã£ãããã«ãWindows XPã䜿çšãããŸããïŒããŒãžã§ã³ã¯é¢ä¿ãããŸããïŒãWindowsVistaãšWindows 7ããããã®ç®çã«é©ããŠããŸãã
æåã¯ããã¹ãã®å¯äžã®ç®çã¯çŠæ¢ãµã€ãã®ã¬ãžã¹ããªãæäœããããšã§ãããšèããŠããŸãã
1.èªå®ãããåé¢é»å眲åïŒESïŒããã³ãããæäœããããã®ãœãããŠã§ã¢ïŒãœãããŠã§ã¢ïŒ
é»å眲åã®ååŸã¯ãè°è«ã®ããã®å¥ã®ãããã¯ã§ãã é©åãªã©ã€ã»ã³ã¹ãæã£ãŠããããŸããŸãªäŒæ¥ããè³Œå ¥ããããšãã§ããŸãããã®æ¹æ³ã¯ãéåžžãäŒæ¥èªäœãã調ã¹ã䟡å€ããããŸãã ç§ãã¡ã®å ŽåãEPã¯LLC LLC "CRIPTO-PRO"ããååŸããã®ã§ãããã¯ç§ã説æããã±ãŒã¹ã§ãã
è³Œå ¥ãããããã«ã¯ãæå·åããŒãå«ã眲ååªäœïŒRutokenïŒãES蚌ææžããã¯ãã«ã«ãµããŒãçšã®èšŒææžãããã³ãœãããŠã§ã¢ã»ãããå«ããã£ã¹ã¯ãå«ãŸããŠããŸãã
OSãã€ã³ã¹ããŒã«ããããã¹ããåäœããæºåãã§ããããæåã«è¡ãããšã¯ESã§åäœããããã«å¿ èŠãªãœãããŠã§ã¢ãã€ã³ã¹ããŒã«ããããšã§ãã
æåã«ãRutokenã®ãã©ã€ããŒãã€ã³ã¹ããŒã«ããŸãïŒãœãããŠã§ã¢ãã£ã¹ã¯ã«ãããã©ã€ããŒã¯é©åããŸããã§ããïŒã ãããã¯è£œé å ã®Webãµã€ãïŒWindowsçšRutokenã»ã¯ã·ã§ã³ïŒã§èŠã€ããããšãã§ããŸãã
ãã©ã€ããŒãããŠã³ããŒãããŠã€ã³ã¹ããŒã«ããŸãã ãã¹ãŠãæ£ããè¡ããããšãRutokenãUSBããŒãã«æ¿å ¥ãããåŸãLEDãç¹ç¯ããŸãã ïŒãããã£ãŠãããã°ã©ã ã¯ãRutoken Control PanelããšåŒã°ããŸãïŒã
次ã«ãCrypto-PROããã°ã©ã ãã€ã³ã¹ããŒã«ããŸãã æ¥ç¶ãããRutokenã§ãããè¡ãå¿ èŠããããŸãã
蚌ææžã¯1幎éæå¹ã§ãããæŽæ°ããå¿ èŠããããŸãã ãã®å Žåãå€ã蚌ææžãåé€ããæ°ãã蚌ææžãæ¥ç¶ããå¿ èŠããããŸãã 蚌ææžæ å ±
ãStart-> Crypto-Pro-> Certificatesãã§èŠã€ããããšãã§ããŸã
ãã®å Žæã§åé¡ãçºçããå Žåã¯ããã¯ãã«ã«ãµããŒãã«é£çµ¡ããããšããå§ãããŸãã圌ãã¯ãã¹ãŠãæ£ç¢ºã«èª¬æããŸãã
ç§ã®å Žåãå€ã蚌ææžãæŽæ°ããŠããŸããã ãããè¡ãã«ã¯ã ã蚌ææžãã»ã¯ã·ã§ã³ã«è¡ãã
"Certificates-current user-> Personal-> Registry-> Certificates" ãå€ã蚌ææžãæåã§åé€ããRutokenãæ¿å ¥ããŠãã·ã³ãåèµ·åããŸããã çŸåšã®èšŒææžã¯èªåçã«ååŸãããŸããã
蚌ææžãæ£ããã€ã³ã¹ããŒã«ãããŠããããšã確èªããã«ã¯ããããã«å«ãŸããŠããCrypto-AWPããã°ã©ã ã䜿çšããŠãã¡ã€ã«ã«æåã§çœ²åããŸãã
ãããè¡ãã«ã¯ãããã°ã©ã ãã€ã³ã¹ããŒã«ãã空ã§ã¯ãªãä»»æã®ãã¡ã€ã«ãäœæããŸãã
Crypto-AWPããªã³ã«ããŠãããã眲å->眲åããéžæãããã¡ã€ã«ãéžæããŠãã€ã¢ãã°ã衚瀺ããæåŸã«èšŒææžãéžæããŠãOKããã¯ãªãã¯ããŸãã ãã¹ãŠãæ£ããè¡ãããå Žåã 次ã«ããã€ã¢ãã°ã§æå®ããããã£ã¬ã¯ããªã«ããã¡ã€ã«filename.sigã衚瀺ãããŸãã ãã®ãã¡ã€ã«ã¯ãåé¢ãããé»å眲åã§ãã
Crypto-AWPããã°ã©ã ã¯ãçŠæ¢ãµã€ãã®ãªã¹ãã®èªåã¢ããããŒãã·ã¹ãã ã«ã¯é¢äžããŸããã
å¿ èŠãªæãéèŠãªãã®ã¯ããŠãŒãã£ãªãã£csptest.exeã§ãïŒESæ€èšŒã¯ãã®å©ããåããŠè¡ãããšãã§ããŸãïŒãããã¯Crypto-PROã®äžéšã§ãã
ããã¯ãESãäœæããããã®ã³ã³ãœãŒã«ãŠãŒãã£ãªãã£ã§ãã Windows OSã§ã®ã¿æ©èœããŸãã
éçºè ã«ãããšããã®ãŠãŒãã£ãªãã£ã¯ãã¹ãå°çšã§ãããæŠéã·ã¹ãã ã§äœ¿çšããããšã¯ã§ããŸããã 圌女ã®èœåã¯äžå®å šã§ãã éåžžã®æäœã§ã¯ãLinuxãµãŒããŒã§æ©èœããå¥ã®ãŠãŒãã£ãªãã£ã䜿çšãããŸãããå¥éæéãæ¯æãå¿ èŠããããŸãã
å®è·µã§ã¯ãcsptest.exeãã¿ã¹ã¯ã®è§£æ±ºã«éåžžã«é©ããŠããããšã瀺ãããŠããŸãã
2.èªåããŠã³ããŒãã®æ§æ
RoskomnadzorãµãŒãã¹ã®äœ¿çšã¯ã SOAPãããã³ã«ã®äžã§è¡ãããŸãã
ã¢ã«ãŽãªãºã ã¯æ¬¡ã®ãšããã§ã
5åããšã«ãããŠã³ããŒããåœæ¥ã«å®è¡ããããã©ããã確èªããŸãïŒç®çã®ååã®ã¢ãŒã«ã€ããååšããŸãïŒ
ã¯ãã®å ŽåãäœãããŸããã
ããã§ãªãå Žåã¯ãããŠã³ããŒããéå§ããŸãã
çŠæ¢ãµã€ãã®ãªã¹ããã¢ããããŒãããããã®ææ°ã®ãªã¯ãšã¹ããäœæããŸã
眲åãã¡ã€ã«ãäœæãã
ãµãŒããŒã«ãªã¯ãšã¹ããéä¿¡ãããªã¯ãšã¹ãã³ãŒãïŒãŸãã¯ãªã¯ãšã¹ããæ£ããå Žåã¯ãšã©ãŒã¡ãã»ãŒãžïŒãååŸããŸã
ãªã¯ãšã¹ããæ£ããå Žåã¯ã5åéåŸ æ©ãïŒãªã¯ãšã¹ãã¯1ã2ååŠçãããŸãïŒããªã¯ãšã¹ãã³ãŒãããµãŒããŒã«éä¿¡ããŸã
å¶éä»ããã¡ã€ã«ã®ãªã¹ããå«ãã¢ãŒã«ã€ãããã€ããªã¢ãŒãã§åãå ¥ããŸã
ãªã¯ãšã¹ããæ£ãããªãå Žåããšã©ãŒã³ãŒããååŸããäœãããŸããã
ã¢ã³ããŒãã·ã¹ãã ã¯æ¬¡ã®ãšããã§ãã
4ã€ã®ãã¡ã€ã«ã3ã€ã¯perlã¹ã¯ãªããã1ã€ã¯.batãã¡ã€ã«ã¿ã€ã
ãã¡ã€ã«ïŒ make_request.pl ã get_register.pl ã rotation.pl ã roscomnadzor.bat
ã¹ã¯ãªããã®ç®çã
make_request.pl- RoskomnadzorãµãŒãã¹ãžã®ãªã¯ãšã¹ããäœæããŸã
get_register.pl- RoskomnadzorãµãŒãã¹ã«ãªã¯ãšã¹ããéä¿¡ããçµæãåŠçããŸã
rotation.pl-ããŠã³ããŒãããã¢ãŒã«ã€ããæå®ã®æ·±ãã§å転ããŸã
roscomnadzor.bat-ã¹ã¯ãªãããšãŠãŒãã£ãªãã£ãåæããŸã
ã·ã¹ãã å±é
CïŒ//ãã©ã€ãïŒãŸãã¯ä»ã®ãã©ã€ãïŒã®ã«ãŒãã«äœæ¥ãã£ã¬ã¯ããªãäœæããŸãã ç§ã¯roscomnadzorãšåŒã°ããŠããŸãã
ãã®äžã«ããœãŒã¹ãšçµæã®2ã€ã®ãµããã£ã¬ã¯ããªãäœæããŸãã
ã¹ã¯ãªããã¯ãœãŒã¹ãã£ã¬ã¯ããªã«é 眮ããå¿ èŠããããŸãããã®æäœã®çµæã¯çµæãã£ã¬ã¯ããªã«é 眮ãããŸãã çŠæ¢ãµã€ãã®ãªã¹ããå«ãã¢ãŒã«ã€ãã
ã¹ã¯ãªãããé 眮ããåŸãã«ãŒããã£ã¬ã¯ããªãããã¡ã€ã«ãžã®ãã¹ãç»é²ããå¿ èŠããããŸãïŒãŸãã¯ããã¹ãŠãçŸããå®è¡ãããå Žåã¯ãconfigã«é 眮ããŸãïŒã
åäœåç
æé ãå®è¡ããã«ã¯ã roscomnadzor.batãã¡ã€ã«ãå®è¡ããå¿ èŠããããŸã
roscomnadzor.batã®ãªã¹ã
if not exist "D:\roscomnadzor\result\reestr_%Date:~6,4%_%Date:~3,2%_%Date:~0,2%.zip" ( rem perl D:\roscomnadzor\source\make_request.pl rem < csptest>csptest.exe -sfsign -sign -detached -add -in < >request.txt -out < >request.txt.sig -my < >@example.ru rem perl D:\roscomnadzor\source\get_register.pl ren D:\roscomnadzor\result\reestr.zip "reestr_%Date:~6,4%_%Date:~3,2%_%Date:~0,2%.zip" perl D:\roscomnadzor\source\rotation.pl )
1.ãªã¯ãšã¹ããã¡ã€ã«ã®äœæ
make_request.plã¹ã¯ãªããã¯ãªã¯ãšã¹ããäœæãããªã¯ãšã¹ããã¡ã€ã«ã¯ãœãŒã¹ãã£ã¬ã¯ããªã«äœæãããŸãã
ããŠã³ããŒãèŠæ±ã¯ã次ã®åœ¢åŒã®xmlãã¡ã€ã«ã§ãã
<?xml version="1.0" encoding="windows-1251"?> <request> <requestTime>yyyy-mm-ddT115:00:00.000+04:00</requestTime> <operatorName> </operatorName> <inn> </inn> <ogrn> </ogrn> <email>company@cmail.ru</email> </request>
make_request.plã®ãªã¹ã
use POSIX qw(strftime); my $date = strftime "%Y-%m-%d", localtime; # unlink('< >request.txt'); unlink('< >request.txt.sig'); # xml $request='<?xml version="1.0" encoding="windows-1251"?><request><requestTime>'.$date.'T115:00:00.000+04:00</requestTime><operatorName>COMPANY NAME</operatorName><inn>1111111111</inn><ogrn>1111111111111</ogrn><email>company@example.ru</email></request>'; # my $filename = '< >request.txt'; open(my $fh, '>', $filename) or die " '$filename' $!"; print $fh $request; close $fh;
2.眲åãã¡ã€ã«ãäœæãã
眲åãã¡ã€ã«ãäœæããã«ã¯ãåããŠãŒãã£ãªãã£csptest.exeã䜿çšããbatãã¡ã€ã«ããåŒã³åºãããŸãã
D:\"Program files"\"Crypto Pro"\CSP\csptest.exe -sfsign -sign -detached -add -in < >request.txt -out < >request.txt.sig -my < >@example.ru
ããã§ïŒ
-my-ããŒã®ææè ã瀺ããŸãã
-in-眲åãããã¡ã€ã«ãæå®ããŸãã ãã¡ã€ã«ãcsptestãã©ã«ããŒã«ãªãå Žåããã«ãã¹ãæå®ããå¿ èŠããããŸãã;
-out-眲åãã¡ã€ã«ã®ååãæå®ããŸãã
3. RoskomnadzorãµãŒãã¹ãšã®å¯Ÿè©±
ã¹ã¯ãªããget_register.plã¯ããªã¯ãšã¹ãã®éä¿¡ãšçµæã®åŠçãæ åœããŸã
get_register.plã®ãªã¹ã
use MIME::Base64; use SOAP::Lite; use POSIX qw(strftime); #----------------------------------------------------------------------- # , $key1=0; $key2=0; if (open(FP, '< >request.txt')) {$key1=1;} if (open(FP, '< >request.txt.sig')) {$key2=1;} # - if( ($key1==1)&($key2==1)) { #---------------------------- # open(FIL,"< >request.txt"); while ($line = <FIL>) { $ln.=$line; } close (FIL); $req=$ln; #---------------------------- # open(FIL1,"< >request.txt.sig"); while ($line1 = <FIL1>) { $ln1.=$line1; } close (FIL1); $sig=$ln1; #---------------------------- # wsdl- $soap = SOAP::Lite->service('http://vigruzki.rkn.gov.ru/services/OperatorRequest/?wsdl'); $r = $soap->getLastDumpDate(); # @r = $soap->sendRequest($req, $sig); $code = $r[2]; # 5 sleep 1, print "$_\n" for 1..300; #300 @r = $soap->getResult($code); #------------------------- # ( ) #my $date = strftime "%Y-%m-%d_at_%H-%M-%S", localtime; #my $date = strftime "%Y-%m-%d", localtime; my $filename = '< >reestr.zip'; open(my $fh, '>', $filename) or die " '$filename' $!"; binmode $fh; print $fh decode_base64($r[1]); close $fh; }
ã¹ã¯ãªããã®å®è¡çµæïŒãµãŒããŒã®å¯çšæ§ã«ããïŒã¯ã次ã®åœ¢åŒã®ååã®ã¢ãŒã«ã€ãã§ãïŒ reestr_yyyy_mm_dd.zip
4.çµæã®å転
ããŠã³ããŒãé »åºŠãäœãå Žåã§ããé ããæ©ããããã·ã³ã®ããŒããã©ã€ãäžã®ãã¹ãŠã®é åãããžãŒã«ãªããæãæ²æšãªçµæãæãå¯èœæ§ããããŸãã ã·ã¹ãã ã®æäœæ§ãé·æéç¶æããã«ã¯ãããŒããŒã·ã§ã³ãæŽçããå¿ èŠããããŸãã æ°ããã¢ãŒã«ã€ããããŠã³ããŒãããããšãå€ãã¢ãŒã«ã€ãã¯åŸã ã«åé€ãããŸãã
rotation.plã¹ã¯ãªããã¯ã å転ããªãã«ããŸã
ããŒããŒã·ã§ã³ã®æ·±ãã¯ãçµæãã£ã¬ã¯ããªã«åæã«ããã€ã®ã¢ãŒã«ã€ããååšãããã決å®ããŸãïŒç¹å®ã®ããžãã¯ã«ã€ããŠãçŸåšã®æ¥ãšæ¯èŒããéå»ã®æéééïŒ
rotation.plã®ãªã¹ã
use POSIX qw(strftime); use Time::Local; # $birthtime =timelocal(localtime()); $interval = 0 + # 0 0 * 60 + # 0 0 * 60 * 60 + # 0 50 * 60 * 60 * 24; # 20 $then = $birthtime - $interval; my $date = strftime "%Y_%m_%d", localtime($then); # unlink('< >reestr_'.$date.'.zip');
5.ã¹ã±ãžã¥ãŒã«ãããèµ·å
ã¹ã±ãžã¥ãŒã«ã§å®è¡ããã«ã¯ãæšæºã®Windowsã¿ã¹ã¯ã¹ã±ãžã¥ãŒã©ã䜿çšããŸãã
schtasksïŒ http://www.windowsfaq.ru/content/view/83/57 ïŒ
roscomnadzor.batãèµ·åãããæéééã¯ããµãŒããŒããã®ãªã¯ãšã¹ãã®ã¿ã€ã ã¢ãŠããããé·ãããå¿ èŠããããŸã
ãã¹ãŠãé 調ã«æ©èœããŠããéã«ã3æäžæ¬ã«ã·ã¹ãã ãéå§ããŸããã
ãæž èŽããããšãããããŸããã ç§ã®èšäºãã圹ã«ç«ãŠã°å¹žãã§ãã