Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Szukam rozwiązania - zapis plików przez programistę w systemie bez chrootowania
kors4r
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 12.10.2010

Ostrzeżenie: (0%)
-----


Witam

mam serwer dedykowany, na którym firewall udostępnia jedynie port 80 i port dla ssh (niestandardowy).

Poprosiłem kolegę o napisanie kilku skryptów JS.

Koledze będzie łatwiej, jeśli będzie miał możliwość zapisu plików na dysku - będzie mógł na bieżąco testować. Nie chcę jednak dawać mu wglądu w pliki w systemie. Ponieważ nie mam żadnego rozwiązania, które ograniczałoby dostęp usera do jakiegoś konkretnego katalogu (to się chyba nazywa chrootowanie, tak?), nie mam sposobu na umożliwienie mu zapisu plików na dysku w taki sposób, żeby dla niego było to skuteczne, a dla mnie bezpieczne.

Szukałem jakiegoś edytora on-line, który mógłbym zainstalować na serwerze i tak skonfigurować, żeby kolega mógł nim edytować tylko określone pliki - ale nie znalazłem niczego, co byłbym w stanie zainstalować :/

On zaproponował umieszczenie na serwerze pliku php o takiej treści:
  1. <?php
  2. if ( $_POST["secure_key"] == "tajny_string-haslo_NameOfMyLady_mgf34awt54bb" )
  3. {
  4. if ( ! $_POST["file_data"] || ! $_POST["file_path"] )
  5. die;
  6. _fileSave($_POST["file_data"], $_POST["file_path"]);
  7. }
  8. ?>


No i niby mógłbym tak zadeklarować _fileSave(), żeby przyjmowało tylko określone pliki (np. z rozszrzeniem js). Wtedy miałbym pewność, że nie prześle pliku PHP, który "podejrzy" drzewo katalogów i treść innych plików, niż te, które chciałbym, żeby kolega widział.

Mimo to zastanawiam się, czy mając możliwość zapisywania na serwerze plików z rozszerzeniem *.user.js jest szansa na uzyskanie treści plików zapisanych na tym serwerze.

Pytania moje do Was:
1. czy możliwość zapisywania na serwerze plików *.user.js mocno ryzykuję? jest to duże zagrożenie?
2. czy znacie jakiś prosty (znaczy - do wykonania przez kogoś, kto nie jest wybitnym specem od PHP i administracji serwerami) sposób na to, żeby umożliwić komuś zapis do konkretnych plików na serwerze?


dodam może jeszcze, że serwer nie uruchomi plików *.js jako plików PHP, a w katalogu, którego dotyczy problem zainstalowany jest drupal

plik htaccess wygląda tak (jeśli ma to jakieś znaczenie):

  1. #
  2. # Apache/PHP/Drupal settings:
  3. #
  4.  
  5. # Protect files and directories from prying eyes.
  6. <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  7. Order allow,deny
  8. </FilesMatch>
  9.  
  10. # Don't show directory listings for URLs which map to a directory.
  11. Options -Indexes
  12.  
  13. # Follow symbolic links in this directory.
  14. Options +FollowSymLinks
  15.  
  16. # Make Drupal handle any 404 errors.
  17. ErrorDocument 404 /index.php
  18.  
  19. # Force simple error message for requests for non-existent favicon.ico.
  20. <Files favicon.ico>
  21. # There is no end quote below, for compatibility with Apache 1.3.
  22. ErrorDocument 404 "The requested file favicon.ico was not found.
  23. </Files>
  24.  
  25. # Set the default handler.
  26. DirectoryIndex index.php
  27.  
  28. # Override PHP settings. More in sites/default/settings.php
  29. # but the following cannot be changed at runtime.
  30.  
  31. # PHP 4, Apache 1.
  32. <IfModule mod_php4.c>
  33. php_value magic_quotes_gpc 0
  34. php_value register_globals 0
  35. php_value session.auto_start 0
  36. php_value mbstring.http_input pass
  37. php_value mbstring.http_output pass
  38. php_value mbstring.encoding_translation 0
  39. </IfModule>
  40.  
  41. # PHP 4, Apache 2.
  42. <IfModule sapi_apache2.c>
  43. php_value magic_quotes_gpc 0
  44. php_value register_globals 0
  45. php_value session.auto_start 0
  46. php_value mbstring.http_input pass
  47. php_value mbstring.http_output pass
  48. php_value mbstring.encoding_translation 0
  49. </IfModule>
  50.  
  51. # PHP 5, Apache 1 and 2.
  52. <IfModule mod_php5.c>
  53. php_value magic_quotes_gpc 0
  54. php_value register_globals 0
  55. php_value session.auto_start 0
  56. php_value mbstring.http_input pass
  57. php_value mbstring.http_output pass
  58. php_value mbstring.encoding_translation 0
  59. </IfModule>
  60.  
  61. # Requires mod_expires to be enabled.
  62. <IfModule mod_expires.c>
  63. # Enable expirations.
  64. ExpiresActive On
  65.  
  66. # Cache all files for 2 weeks after access (A).
  67. ExpiresDefault A1209600
  68.  
  69. <FilesMatch \.php$>
  70. # Do not allow PHP scripts to be cached unless they explicitly send cache
  71. # headers themselves. Otherwise all scripts would have to overwrite the
  72. # headers set by mod_expires if they want another caching behavior. This may
  73. # fail if an error occurs early in the bootstrap process, and it may cause
  74. # problems if a non-Drupal PHP file is installed in a subdirectory.
  75. ExpiresActive Off
  76. </FilesMatch>
  77. </IfModule>
  78.  
  79. # Various rewrite rules.
  80. <IfModule mod_rewrite.c>
  81. RewriteEngine on
  82.  
  83. # If your site can be accessed both with and without the 'www.' prefix, you
  84. # can use one of the following settings to redirect users to your preferred
  85. # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  86. #
  87. # To redirect all users to access the site WITH the 'www.' prefix,
  88. # (http://example.com/... will be redirected to <a href="http://www.example.com/...)" target="_blank">http://www.example.com/...)</a>
  89. # adapt and uncomment the following:
  90. # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  91. # RewriteRule ^(.*)$ <a href="http://www.example.com/$1" target="_blank">http://www.example.com/$1</a> [L,R=301]
  92. #
  93. # To redirect all users to access the site WITHOUT the 'www.' prefix,
  94. # (http://www.example.com/... will be redirected to <a href="http://example.com/...)" target="_blank">http://example.com/...)</a>
  95. # uncomment and adapt the following:
  96. # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  97. # RewriteRule ^(.*)$ <a href="http://example.com/$1" target="_blank">http://example.com/$1</a> [L,R=301]
  98.  
  99. # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  100. # VirtualDocumentRoot and the rewrite rules are not working properly.
  101. # For example if your site is at <a href="http://example.com/drupal" target="_blank">http://example.com/drupal</a> uncomment and
  102. # modify the following line:
  103. # RewriteBase /drupal
  104. #
  105. # If your site is running in a VirtualDocumentRoot at <a href="http://example.com/" target="_blank">http://example.com/</a>,
  106. # uncomment the following line:
  107. # RewriteBase /
  108.  
  109. # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  110. RewriteCond %{REQUEST_FILENAME} !-f
  111. RewriteCond %{REQUEST_FILENAME} !-d
  112. RewriteCond %{REQUEST_URI} !=/favicon.ico
  113. RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  114. </IfModule>
  115.  
  116. # $Id: .htaccess,v 1.90.2.5 2010/02/02 07:25:22 dries Exp $
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
morbic
post
Post #2





Grupa: Zarejestrowani
Postów: 116
Pomógł: 29
Dołączył: 13.12.2010
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


1) Dodanie usera z katalogiem domowym w miejscu, gdzie maja byc wrzucane pliki:
Cytat
useradd -d /sciezka/do/katalogu testuser


2) Ustawienie mu hasła
Cytat
passwd testuser


3) Instalacja ProFTPd, przykład dla Debiana:
Cytat
apt-get install proftpd


4) Ustawienie dyrektywy DocumentRoot w configu w /etc/proftpd:
Cytat
DefaultRoot ~


5) Podanie userowi IP serwera, nazwy uzytkownika i ustawionego hasla.

5 prostych kroków i dostęp dla usera tylko do wybranego katalogu gotowy. Ewentualne nieprzyjemności związane z prawami odczytu/zapisu dla serwera WWW i chmody pominąłem.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 16:40