PHPã§ã®ã»ãã·ã§ã³ã®ãã¹ãŠã®ææ ®æ·±ããšåªããå®è£ ã«ãããããããã»ãšãã©ã®éçºè ã¯é ããæ©ããæšæºæ©èœãæ¡åŒµ/å€æŽããå¿ èŠã«çŽé¢ããŸãã 察åŠãã¹ãéèŠãªãã€ã³ãã¯æ¬¡ã®ãšããã§ãã
- ã»ãã·ã§ã³åºå®ã ã»ãã·ã§ã³ã®çé£ããä¿è·ããããã«ãsessidã¯æ¬¡ã®æ
å ±ãç¹åŸŽãšããŠããŸãã
ãŠãŒã¶ãŒã éåžžãIPãŸãã¯UserAgentããŸãã¯ãã¹ãŠäžç·ã§ãã
ããªãã®session_set_save_handlerã ã»ãã·ã§ã³å€æ°ããã¡ã€ã«ã·ã¹ãã ã«ä¿åããã®ã¯æé©ãªãœãªã¥ãŒã·ã§ã³ã§ã¯ãªãããã
é ããæ©ãããã»ãã·ã§ã³ãmemcachedãããŒã¹ããŸãã¯ä»ã®å Žæã«è»¢éããããšãæ€èšããå¿ èŠããããŸãã
session.use_trans_sid =0ãPHPã«çµã¿èŸŒãŸããŠããurl_rewriterã¡ã«ããºã ã¯éåžžã«åŒ·åã§äŸ¿å©ãªãã®ã§ããã
ã»ãã·ã§ã³ã§ããã䜿çšãããšãäžé£ã®äžå¿«ãªç¬éããããŸãã å¿ æ»ã®æ€çŽ¢ãšã³ãžã³ãããªã³ã¯ã
åœåã§å ¥åãå®å šã«ç¡é¢ä¿ãªãµã€ãã®ãã°ã«sessidããã©ã€ãã¢ãããïŒHTTP_REFERERçµç±ãªã©ïŒ
ãããã£ãŠããã®æ©èœã¯éåžžç¡å¹ã«ãªã£ãŠãããsessidã®éä¿¡ã«ã¯Cookieã®ã¿ã䜿çšãããŸãã
æåŸã®ãã€ã³ãã«ã€ããŠè©³ãã説æããããšæããŸãã äºå®ãã»ãšãã©ã®å€§èŠæš¡ãªãµã€ãã¯
ïŒgoogleãozonãlivejournalãpaypal ..ïŒCookieãä»ããŠã®ã¿æ©èœããŸãã ãšãŠãå¥åŠã«æãã
Cookieãæããªã人ã ãã€ã³ã¿ãŒãããäžã§éåžžã«ãŸãã§ãããç¡èŠãããå¯èœæ§ã¯äœãããã§ãã
Liveinternetã®çµ±èšã«ãããšãCookieãç¡å¹ã«ãªã£ãŠãã人ã®æ°ã¯çŽ4ïŒ ã§ãã
å°ãªãããã å°ãªããšããã®ãããªå·šäººã芳客ã®ãã®éšåãæèçã«é®æããå¯èœæ§ã¯äœã
éåžžã«è¯ãçç±ããªããã°ãªããŸããã§ããã ãããŠã圌ãã¯èŠã€ãããŸããã
ãããã®4ïŒ ã«ã¯ãæ°žç¶çãªCookieãæã£ãŠããªã人ãå«ãŸããŠããããšãããããŸã
ïŒããŒãã»ããã©ã€ãã¿ã€ã ã䜿çšïŒãã»ãã·ã§ã³ã»ãã·ã§ã³ã¯æ©èœããŸã-ã©ã€ãã¿ã€ã = 0 ãŸããã»ãã·ã§ã³Cookieã¯ã»ãšãã©ãã¹ãŠã®ãŠãŒã¶ãŒã«æå¹ã§ãã
ã»ãã¥ãªãã£èšå®ãlynxã§ãCookieãç¡å¹ã«ãããèšå®ãããŠãã人ã§ãã :)
ãšã«ããã100ïŒ ã®ä¿èšŒãäžããããªãããšã¯æããã§ãã ããšãã°ãCookieããã¡ã€ã¢ãŠã©ãŒã«ãåæããå¯èœæ§ããããŸãïŒãã ãããããäžæã§ãïŒ
lifetime = 0ã§ã«ããããŸãïŒã ãŠãŒã¶ãŒã¯ãCookieã®ãµããŒããªãã§èªäœã®ãã©ãŠã¶ã䜿çšã§ããŸãã
ïŒäŸïŒçç ã®ã¯ããŒã©ãŒïŒã ããããããªãã¯ä»ã«äœãç¥ããªã...
ããããç§èªèº«ã®çµéšããå€æãããšïŒãããŠãäžçŽã®åå¿ãã®çµéšã¯éæ¥çã«ããã確èªããŸãïŒãç§ã¯å®éã«ã¯ãããå¯èœã§ãããšèšããŸã
ãŠãŒã¶ãŒãã»ãã·ã§ã³Cookieãæã£ãŠããããšãæåŸ ããŠãå®å šã§ãã ãŸãããã®è«æãæ¯æããŠ
PHPã®ããã©ã«ãã§ã¯ãsession.use_only_cookiesãã©ã¡ãŒã¿ãŒã¯1ã«èšå®ãããŠããŸãã CookieãæããªããŠãŒã¶ãŒã®å Žåãã»ãã·ã§ã³ã¯æ©èœããŸããã
ãŸããéåžžã¯ã»ãã·ã§ã³ã䜿çšãããã»ãšãã©ã®å Žæã§Cookieã®ãµããŒãã«é Œãããšãã§ãããããå®éã«ã¯Cookieãä»ããŠç©äºãããç°¡åã§äŸ¿å©ã«ããããšãã§ããåæã«ãã¹ãŠã®ã±ãŒã¹ã§æ©èœããŸãã
ã»ãã·ã§ã³ãšããŠã ãªãç§ã¯ç°¡åã«èšã£ãŠããã®ã§ããïŒ Cookieãã¹ããŒããããããå¿ããŠããŸã£ããããæåã§åŠæ¹ããå¿ èŠã¯ãããŸããã
ããããŒïŒå ŽæïŒ..ïŒãAjaxã䜿çšããéã«èŠããŠããå¿ èŠã¯ãããŸããã
ãã®ãªã¯ãšã¹ããã¹ã¯ãªãããéçhtmlãç»åããŸãã¯cssã®ã©ããåç §ããŠãããã ã»ãã·ã§ã³ã¯æ¬¡ã®å Žåã«ã®ã¿å¿ããããŸãã
åãCookieãä»ããŠæ©èœããå ŽåããããŠåžžã«ãããšã¯éããŸããã :)
ããã§ãç¬èªã®session_set_save_handlerã«ã€ããŠå°ã説æããŸãã ãã¡ããããã¹ãŠã¯ã©ã®ããŒã¿ãšã©ã®ãããã®æéã«äŸåããŸã
ä¿åããå¿ èŠããããŸãã ãã¡ãããäžè¬çãªå Žåã¯ãããŒã¿ããŒã¹ãŸãã¯ãã¡ã€ã«ã·ã¹ãã ã䜿çšããå¿ èŠããããŸãã ã»ãã·ã§ã³ã®å¯¿åœãçãå Žåã
ãŸããã»ãã·ã§ã³å ã®ããŒã¿èªäœã¯ç°¡åã«å埩ã§ããã¡ã¢ãªïŒãŸãã¯memcachedïŒãæ©èœããŸãã ãŸããã»ãã·ã§ã³ã
ãŠãŒã¶ãŒã®èªèšŒã«ã€ããŠã¯ãååãšããŠããµãŒããŒåŽã«äœããä¿åããããšãäžè¬çã«å¿ èŠãã©ãããæ€èšãã䟡å€ããããŸãã
å®éãCookieã䜿çšããå Žåãsave_handlerãå®å šã«ç Žæ£ããã¯ã©ã€ã¢ã³ãããã®ãã¹ãŠã®ããŒã¿ãä¿åã§ããŸãã
ç¹°ãè¿ãã«ãªããŸãããphpbbãwordpressãgmailãªã©ã«ãã£ãŠæ®ãããCookieã®å€§ãŸããªç 究ã¯ããã®ã¢ãããŒããéåžžã«äžè¬çã§ããããšã瀺ããŸãã
䜿çšãããçåœã«å¯Ÿããæš©å©ããããŸãã èŠããŠããã¹ãå¯äžã®ããšã¯ãã¯ãããŒã¯ç°¡åã«åœé ã§ãããšããããšã§ãã
ãããã£ãŠãç²ç®çã«ããããä¿¡é Œããããšã¯äžå¯èœã§ã¯ãããŸããã
ãããŠãããã§ãã€ã³ã1-ã»ãã·ã§ã³åºå®åã«é²ã¿ãŸãã æšæºã®ã»ãã·ã§ã³ã¡ã«ããºã ãšåæ§ã«ã
ãŸããéä¿¡ã®å¯èœæ§ãæé€ããããã«ããŠãŒã¶ãŒãèå¥ããæ å ±ã«Cookieããã€ã³ãããå¿ èŠããããŸã
圌女ã®ããäžã€ã ããã«ããŠãŒã¶ãŒã«ããå€æŽã®å¯èœæ§ããCookieãä¿è·ããå¿ èŠããããŸãã
ã»ãã·ã§ã³ãšåæ§ã«ããµãŒããŒã«ä¿åããŠãã調æŽããããšã§ãããè¡ãããšãã§ããŸã
å¿ èŠãªæ å ±ïŒåãIPãšUserAgentïŒã
ãããããµãŒããŒã«ã¯äœãä¿åããªãããšã«ããŸããã ãµãŒããŒã®ã¡ã¢ãªã䜿çšããã«ãããå®è¡ã§ãããã©ãããèŠãŠã¿ãŸãããã
æ¿èªã®äžè¬çãªã±ãŒã¹ãæ€èšããŠãã ãããæ£ãããŠãŒã¶ãŒåãšãã¹ã¯ãŒããå ¥åãããšãCookieã«ãŠãŒã¶ãŒãä¿åãããŸã
ãã®äžæã®èå¥åïŒIDïŒãããã³ãµãŒããŒã«ã¢ã¯ã»ã¹ãããã³ã«ããã®èå¥åã«ãã£ãŠãŠãŒã¶ãŒãèå¥ããŸã
ãã°ã€ã³ãæ€èšããŠãã ããã èå¥åããªãå ŽåããŸãã¯æéãçµéããå ŽåããŠãŒã¶ãŒã«ãŠãŒã¶ãŒåãšãã¹ã¯ãŒããå床èŠæ±ããŸãã
ããã§ã®æ¬ ç¹ã¯äœã§ããïŒ
- ãŠãŒã¶ãŒã¯Cookieå
ã®IDãç°¡åã«å€æŽã§ããå¥ã®ãŠãŒã¶ãŒãšããŠèªèãããŸãã
ãŠãŒã¶ãŒã¯ãå¥ã®ãŠãŒã¶ãŒããCookieãçã¿ãåœè£ ããããšãã§ããŸãã
æéãçµéãããã©ãããå€æããæ¹æ³ã¯æ確ã§ã¯ãããŸããã ãµãŒããŒã«ã¿ã€ã ã¢ãŠããä¿åããªãããã次ã®å Žåã¯ããããŸãã
ãŠãŒã¶ãŒãæšæ¥ç§ãã¡ã®ãšããã«æ¥ãããŸãã¯åœŒã¯ãã§ã«2ãæéåãCookieãæã£ãŠããã 圌ããã€ãã°ã€ã³ãããèŠããŠããªã
ç¹ã«ãã®ã³ã³ãã¥ãŒã¿ãŒããã
ãŠãŒã¶ãŒãCookieã®ããŒã¿ãå€æŽã§ããªãããã«ããããã«ãããžã¿ã«çœ²åã䜿çšã§ããŸãã ããšãã°ãmd5
ç§å¯ã®èšèãšãŠãŒã¶ãŒIDããã ãŸãã¯ããã®ãŠãŒã¶ãŒã®ãã¹ã¯ãŒãããã ãŸãã¯ããã¹ã¯ãŒãããã·ã¥ããããã¹ã¯ãŒãèªäœã
ããŒã¿ããŒã¹ã«ä¿åããªãã§ãã ããã èŠããã«ããŠãŒã¶ãŒã¯èªåèªèº«ã«ã€ããŠã®ã¿ç¥ã£ãŠããããä»ã®äººã«ã€ããŠã¯ç¥ããªããããªæ å ±ãå¿ èŠã§ãã
èªåãåœè£ ããããŠãŒã¶ãŒã ãŸãã¯ãŸã£ããç¥ããŸããïŒç§å¯ã®èšèïŒã
ãããã£ãŠãèšå®ããCookieã¯æ¬¡ã®ããã«ãªããŸãã
$ cookie = $ useridã ã|ã ã md5ïŒ$ãŠãŒã¶ãŒIDããç§å¯ã®èšèãïŒ;
ãŠãŒã¶ãŒãå¥ã®ãŠãŒã¶ãŒã®Cookieãéä¿¡ã§ããªãããã«ããããã«ãåãããžã¿ã«çœ²åã§IPã䜿çšãã
UserAgentã
$ cookie = $ useridã ã|ã ã md5ïŒ$ãŠãŒã¶ãŒIDããç§å¯ã®èšèãã $ _SERVER ['REMOTE_ADDR']ïŒ
Cookieãåä¿¡ãããšããã®CookieãéãããŠããUserAgentãšIPã䜿çšããŠçœ²åãæ€èšŒããŸãã
眲åãçŸåšã®èª€ã£ãå€ã䜿çšããå Žå-眲åã¯æ£ãããªããªããCookieã¯åãå ¥ããããŸããã
ãããŠæåŸã«ãè¡åã®æã æãç°¡åãªæ¹æ³ã¯ããã³ããŒã䜿çšããããšã§ãããŠãŒã¶ãŒãæ£ããCookieããæ£ããCookieãéä¿¡ããéã
IPãšUserAgent-éå§ããŸãã ãã ããã»ãã·ã§ã³ã®ç¶ç¶æéã匷å¶çã«å¶éãããå Žåã¯ã次ãè¿œå ã§ããŸãã
Cookieèªäœã®æéã ãããŠãŸã眲åããã
$ cookie = $ useridã ã|ã ã $æéã ã|ã ã md5ïŒ $ãŠãŒã¶ãŒIDã $æéã ãç§å¯ã®èšèãã $ _SERVER ['REMOTE_ADDR']ã $ _SERVER ['HTTP_USER_AGENT'] ïŒ
æçµçã«ç§ãã¡ãæã£ãŠãããã®ïŒãµã€ãã«å¯ŸããŠãŠãŒã¶ãŒãèªèšŒããæå°éã®è² è·ãäœæããããã®å®å šã«ä¿¡é Œã§ããã¡ã«ããºã
ãµãŒããŒã«ã
æã£ãŠããªããã®ïŒå€ãã®ã»ãã·ã§ã³ããŒã¿ãä¿åããããšã¯ã§ããŸããã Cookieã®ãµã€ãºã«ã¯å¶éããããmd5ã¯é·ãè¡ãé£ã¹ãŸã
ããã»ããµæéããããŠãŠãŒã¶ãŒãæ¯åãã®ãŽãããã¹ãŠããåãããããšã¯äŸ¡å€ããããŸããã
æ倧é·ã¯ããããgmailã®ããã«ãã䟡å€ããããŸã-çŽ120ãã€ãã ã»ãã·ã§ã³äžã«ããã«äœãä¿åã§ããã
ãããããŸãããã ãããã«ãããå€ãã®å€æ°ãä¿åããå¿ èŠãããå Žåãç§èŠã§ã¯ãŸã æšæºã䜿çšããå¿ èŠããããŸã
äžè¬çãªã±ãŒã¹åãã«èšèšãããPHPã»ãã·ã§ã³ã
ããã©ãŒãã³ã¹ã
ãŸããçŸåšéããŠããã»ãã·ã§ã³ã®æ°ãããããŸããã ç¡å¶éã«éãããšãã§ããŸãã
ååãšããŠããã®ãããªèšé²ãä¿æããããšã劚ãããã®ã¯äœããããŸããããç§ãã¡èªèº«ããµãŒããŒããªãããŒããããã£ãã®ã§ã...
æšæºã»ãã·ã§ã³ã䜿çšãããããåªããŠããŸãããsave_handlerãšsession_fixationã䜿çšããŸããïŒ ããã§ã¯ãã¹ãŠãäžç®çç¶ã§çºçããã©ãããã§ãä»å ¥ã§ãããšããäºå®ã ã³ãŒãã®ã·ã³ãã«ãã ãŸããã¹ããŒã-æ±çšæ§ãšåŒãæãã«ã
- ãŠãŒã¶ãŒã¯Cookieå
ã®IDãç°¡åã«å€æŽã§ããå¥ã®ãŠãŒã¶ãŒãšããŠèªèãããŸãã