Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache shell_exec php jako inny uzytkownik
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) Polish OTW
View previous topic :: View next topic  
Author Message
soban_
l33t
l33t


Joined: 27 Aug 2008
Posts: 668
Location: /home/soban

PostPosted: Wed Aug 31, 2011 6:58 pm    Post subject: Apache shell_exec php jako inny uzytkownik Reply with quote

Mam nastepujacy problem, potrzebuje wywolac z shella jako inny uzytkownik pewien skrypt. Jednak nie mam pojecia jak bezpiecznie to zrobic, wiem ze z poziomu su moglbym, ale to chyba jednak za bardzo jest niebezpieczne? Tak przedstawia sie zawartosc nastepujacych plikow:
Code:
cat /home/uzytkownik/panel/cos.php
<?php
$output = shell_exec('/home/uzytkownik/panel/skrypt.sh');
echo "<pre>$output</pre>";
?>
Oraz:
Code:
cat /home/uzytkownik/panel/skrypt.sh
#!/bin/bash
whoami
I dostaje oczywiscie efekt, ze skrypt jest wywolany z poziomu uzytkownika "apache". Macie pomysl jak uruchomic ten skrypt z poziomu "uzytkownik"? Podaje jeszcze dodatkowe informacje:
Code:
[I] www-servers/apache
     Available versions:  (2) 2.2.14-r1 2.2.15 2.2.16 ~2.2.16-r1 2.2.17
        {apache2_modules_actions apache2_modules_alias apache2_modules_asis apache2_modules_auth_basic apache2_modules_auth_digest apache2_modules_authn_alias apache2_modules_authn_anon apache2_modules_authn_dbd apache2_modules_authn_dbm apache2_modules_authn_default apache2_modules_authn_file apache2_modules_authz_dbm apache2_modules_authz_default apache2_modules_authz_groupfile apache2_modules_authz_host apache2_modules_authz_owner apache2_modules_authz_user apache2_modules_autoindex apache2_modules_cache apache2_modules_cern_meta apache2_modules_cgi apache2_modules_cgid apache2_modules_charset_lite apache2_modules_dav apache2_modules_dav_fs apache2_modules_dav_lock apache2_modules_dbd apache2_modules_deflate apache2_modules_dir apache2_modules_disk_cache apache2_modules_dumpio apache2_modules_env apache2_modules_expires apache2_modules_ext_filter apache2_modules_file_cache apache2_modules_filter apache2_modules_headers apache2_modules_ident apache2_modules_imagemap apache2_modules_include apache2_modules_info apache2_modules_log_config apache2_modules_log_forensic apache2_modules_logio apache2_modules_mem_cache apache2_modules_mime apache2_modules_mime_magic apache2_modules_negotiation apache2_modules_proxy apache2_modules_proxy_ajp apache2_modules_proxy_balancer apache2_modules_proxy_connect apache2_modules_proxy_ftp apache2_modules_proxy_http apache2_modules_proxy_scgi apache2_modules_reqtimeout apache2_modules_rewrite apache2_modules_setenvif apache2_modules_speling apache2_modules_status apache2_modules_substitute apache2_modules_unique_id apache2_modules_userdir apache2_modules_usertrack apache2_modules_version apache2_modules_vhost_alias apache2_mpms_event apache2_mpms_itk apache2_mpms_peruser apache2_mpms_prefork apache2_mpms_worker debug doc ldap selinux ssl static suexec threads}
     Installed versions:  2.2.17(2)(12:07:50 24.04.2011)(apache2_modules_actions apache2_modules_alias apache2_modules_auth_basic apache2_modules_authn_alias apache2_modules_authn_anon apache2_modules_authn_dbm apache2_modules_authn_default apache2_modules_authn_file apache2_modules_authz_dbm apache2_modules_authz_default apache2_modules_authz_groupfile apache2_modules_authz_host apache2_modules_authz_owner apache2_modules_authz_user apache2_modules_autoindex apache2_modules_cache apache2_modules_cgi apache2_modules_cgid apache2_modules_dav apache2_modules_dav_fs apache2_modules_dav_lock apache2_modules_deflate apache2_modules_dir apache2_modules_disk_cache apache2_modules_env apache2_modules_expires apache2_modules_ext_filter apache2_modules_file_cache apache2_modules_filter apache2_modules_headers apache2_modules_include apache2_modules_info apache2_modules_log_config apache2_modules_logio apache2_modules_mem_cache apache2_modules_mime apache2_modules_mime_magic apache2_modules_negotiation apache2_modules_rewrite apache2_modules_setenvif apache2_modules_speling apache2_modules_status apache2_modules_unique_id apache2_modules_userdir apache2_modules_usertrack apache2_modules_vhost_alias ssl threads -apache2_modules_asis -apache2_modules_auth_digest -apache2_modules_authn_dbd -apache2_modules_cern_meta -apache2_modules_charset_lite -apache2_modules_dbd -apache2_modules_dumpio -apache2_modules_ident -apache2_modules_imagemap -apache2_modules_log_forensic -apache2_modules_proxy -apache2_modules_proxy_ajp -apache2_modules_proxy_balancer -apache2_modules_proxy_connect -apache2_modules_proxy_ftp -apache2_modules_proxy_http -apache2_modules_proxy_scgi -apache2_modules_reqtimeout -apache2_modules_substitute -apache2_modules_version -apache2_mpms_event -apache2_mpms_itk -apache2_mpms_peruser -apache2_mpms_prefork -apache2_mpms_worker -debug -doc -ldap -selinux -static -suexec)
     Homepage:            http://httpd.apache.org/
     Description:         The Apache Web Server.
Oraz
Code:
[I] dev-lang/php
     Available versions:
        (5.2)   [M]5.2.17
        (5.3)   5.3.6 ~5.3.6-r1 [M]~5.3.7_rc5
        (5.4)   [M]~5.4.0_alpha3
        {adabas apache2 bcmath berkdb birdstep bzip2 calendar cdb cgi cjk +cli crypt +ctype curl curlwrappers db2 dbase dbmaker debug discard-path doc embed empress empress-bcs enchant esoob exif fdftk +fileinfo +filter firebird flatfile force-cgi-redirect fpm frontbase ftp gd gd-external gdbm gmp +hash +iconv imap inifile interbase intl iodbc ipv6 +json kerberos kolab ldap ldap-sasl libedit mhash msql mssql mysql mysqli mysqlnd ncurses nls oci8 oci8-instant-client odbc pcntl +pcre pdo +phar pic +posix postgres qdbm readline recode reflection sapdb +session sharedext sharedmem +simplexml snmp soap sockets solid spell spl sqlite sqlite3 ssl suhosin sybase-ct sysvipc threads tidy +tokenizer truetype unicode wddx xml xmlreader xmlrpc xmlwriter xpm xsl zip zlib}
     Installed versions:  5.3.6(5.3)(10:57:38 30.06.2011)(apache2 berkdb bzip2 cgi cli crypt ctype curl fileinfo filter ftp gd gdbm hash iconv json mysql mysqli nls pdo phar posix postgres readline session simplexml snmp sockets spell sqlite ssl threads tokenizer truetype unicode xml zip zlib -adabas -bcmath -birdstep -calendar -cdb -cjk -curlwrappers -db2 -dbmaker -debug -doc -embed -empress -empress-bcs -enchant -esoob -exif -firebird -flatfile -fpm -frontbase -gd-external -gmp -imap -inifile -interbase -intl -iodbc -ipv6 -kerberos -kolab -ldap -ldap-sasl -libedit -mhash -mssql -mysqlnd -oci8 -oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sapdb -sharedext -sharedmem -soap -solid -sqlite3 -sybase-ct -sysvipc -tidy -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl)
     Homepage:            http://php.net/
     Description:         The PHP language runtime engine: CLI, CGI, FPM/FastCGI, Apache2 and embed SAPIs.
Jeszcze zeby troche utrudnic sprawe to powiem ze folder ze strona znajduje sie w /home/strona/www/panel jest podlinkowany tam panel z poziomu roota do /home/uzytkownik/panel, no ale chyba to nie problem.
_________________
gg: 525600
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Wed Aug 31, 2011 8:19 pm    Post subject: Reply with quote

Masz php odpalane z userem apache i pozwalasz na shell_exec? Przeciez to jest strzal w stope i proszenie sie o wlamanie. Poczytaj o suphp, suexec i odpalaniu php per-vhost.

Tak czy inaczej, jezeli naprawde musisz z php odpalic skrypt szelowy - cos jest bardzo nie tak.
Back to top
View user's profile Send private message
soban_
l33t
l33t


Joined: 27 Aug 2008
Posts: 668
Location: /home/soban

PostPosted: Wed Aug 31, 2011 8:22 pm    Post subject: Reply with quote

A jak bys zaproponowal to zrobic? Tak potrzebuje z shella sie dostac, bo musze dac innym mozliwsc zresetowania uslugi, zatrzymania jej itp. Chyba ze masz inny pomysl na zrealizowanie czegos takiego. No oczywiscie dostep do tego bedzie na haslo i niewiele osob bedzie wiedzialo o tym i mialo do tego dostep (tylko administratorzy - wiec jakies 3 osoby).
_________________
gg: 525600
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Wed Aug 31, 2011 8:27 pm    Post subject: Reply with quote

Sposobow jest wiele, napisanie sobie jakiegos deamona ktory po unix socketcie bedzie odbieral zdania, autoryzowal i wykonywal, to jeden z przykladow.
Back to top
View user's profile Send private message
soban_
l33t
l33t


Joined: 27 Aug 2008
Posts: 668
Location: /home/soban

PostPosted: Wed Aug 31, 2011 8:35 pm    Post subject: Reply with quote

No ale z htaccess tez chyba uzyskam jakis stopien autoryzacji do tego. A pisanie nowej aplikacji to tez niezla mysl, tylko zastanawiam sie czy to rzeczywiscie bedzie mialo sens przy wykonaniu 3-4 polecen z szela...
_________________
gg: 525600
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Wed Aug 31, 2011 8:48 pm    Post subject: Reply with quote

Whoa, ja tylko mam nadzieje, ze nie jestes kolejnym sprzedawca watpliwych VPSow, bo jak widze, ze chcesz do 2-3 polecen robic jakis dziwny panel w php, z shell_exec, przy czym nie masz pojecia nawet jakie to niesie za soba dziury, to az sie boje.
Back to top
View user's profile Send private message
soban_
l33t
l33t


Joined: 27 Aug 2008
Posts: 668
Location: /home/soban

PostPosted: Wed Aug 31, 2011 9:22 pm    Post subject: Reply with quote

E nie, ja to tylko robie pod testowy panel - ktory i tak zniknie pod server gry mc. A jest to potrzebne, ze wzgledu na sprawdzanie pluginow, ktore po skonfigurowaniu wymagaja przeladowania serwera/uslugi. Nic to z VPSami nie ma wspolnego. A nie chce dawac pelnego dostepu po ssh do konta.
_________________
gg: 525600
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) Polish OTW All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum