CodeIgniter + uploadify + Session Cookie (Flash)


The solution:
This guide has been written for CI 2.1.0, it can easily be edited for prior versions.

EDIT
-In later versions of uploadify post_params in JavaScript may be replaced by formData

1. Extend CI_Session
Create a MY_Session.php under /application/libraries or extend your own one. Copy the whole sess_read() function from /system/libraries/Session.php and paste it into your newly created MY_Session.php.

Replace:

$session $this->CI->input->cookie($this->sess_cookie_name); 

With:

if (isset($_POST['browser_cookie']))
  
{
   $_cookie 
$this->CI->input->post('browser_cookie');
   
$enc_key $this->CI->config->item('encryption_key');
   
$session trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256$enc_keybase64_decode($_cookie), MCRYPT_MODE_ECBmcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256MCRYPT_MODE_ECB), MCRYPT_RAND)));
  
else {
   $session 
$this->CI->input->cookie($this->sess_cookie_name);
  

2. Session Library Setup
Setup your Session Library properly (add an encryption_key in your config.php) and enable table based sessions as well as disable sess_match_useragent in config.php (important!)

3. In your view where uploadify is embedded, you will have to append post params to your upload function. Here is a sample code:

$('#do_upload').uploadify({
  swf
'/js/uploadify/uploadify.swf',
  
uploader'/objects/upload_images/' object_id,
  
post_params{"browser_cookie""<?= trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->config->item('encryption_key'), $_COOKIE[$this->config->item('sess_cookie_name')], MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)))); ?>"},
  
cancelImage'/js/uploadify/uploadify-cancel.png',
  
checkExistingfalse,
  
multitrue,
  
autotrue,
  
onUploadSuccess: function(filedataresult){
     
//do something useful
  
}
 }
); 

This has to be parsed by your PHP parser in order to fill the values. You could also just declare a variable like

var browser_cookie = “<?= trim…....... ?>”

and just load this global variable in your upload function.

4. How does it work?
Basically it generates an encrypted version of your session cookie and posts it to your server. As you have already modified the session class, it recognizes that your session cookie has been sent via post and is using this instead. Basically it’s just a simulation of what the browser would do if it wasn’t Flash.

5. Conclusion and caveats
If CI Basis is updated, don’t forget to update your MY_Session as well. It is just ensuring that.

Make sure that your cookie is valid before sending the files to your server. Otherwise you could raise the value of “sess_time_to_update” in your config.php.



출처 : https://ellislab.com/forums/viewthread/216227/#999189

 

온라인 게임사용자의 개인 정보를 노린 악성코드가 확산되고 있어 주의가 요구된다.

 잉카인터넷(대표 주영흠 www.nprotect.com)은 지난 26일께부터 국내외 불특정 다수의 웹 사이트가 자동화된 SQL인젝션(Injection) 공격 피해를 입었으며 이는 어도브 플래시플레이어의 액션 스크립트(Action Script)를 악용한 것이라고 28일 밝혔다.

 이번 공격에 사용된 악성 스크립트코드가 국내 많은 사이트에 삽입됐기 때문에 사이트 관리자와 해당 사이트에 방문하는 사용자들의 감염 피해가 우려된다. 스크립트에 의해 연결된 ‘1231.swf’ ‘1232.swf’ 등의 악성 플래시 파일이 실행되면 웹사이트에 숨겨져 있는 또 다른 악성 실행파일이 TEMP 폴더에 ‘orz.exe (42,268바이트)’라는 파일명으로 다운로드되고 자동으로 실행된다.

 잉카인터넷은 “컴퓨터를 보호받으려면 어도브 플래시플레이어 버전을 업데이트해야 한다”며 “플래시플레이어 버전이 ‘9.0.115.0’이거나 하위 버전이라면 신속한 업데이트가 필요하다”고 강조했다.

상위 버전은 웹사이트(http://www.adobe.com/shockwave/download/flash/trigger/kr/2/index.html)에서 내려받을 수 있다.
출처 : 전자신문 (2008.05.09)

-------------------------------------------------------------------------------------------------------
설치시에 구글 툴바 설치 하겠다는 체크표시는 없애구 진행하세요~

'정보공유' 카테고리의 다른 글

Microsoft Baseline Security Analyzer  (0) 2008.06.02
메모리해킹  (0) 2008.05.07
MS Windows XP Service Pack 3  (1) 2008.04.24

 

+ Recent posts