cgi

PHP-FPM详解

a 夏天 提交于 2019-12-06 01:42:24
目录 作用 安装 全局配置 配置进程池 参考Company开发环境 转发请求给PHP-FPM 思考 作用 PHP-FPM(PHP FastCGI Process Manager)意:PHP FastCGI 进程管理器,用于管理PHP 进程池的软件,用于接受web服务器的请求。 PHP-FPM提供了更好的PHP进程管理方式,可以有效控制内存和进程、可以平滑重载PHP配置。 (1). 为什么会出现php-fpm fpm的出现全部因为php-fastcgi出现。为了很好的管理php-fastcgi而实现的一个程序 (2). 什么是php-fastcgi php-fastcgi 只是一个cgi程序,只会解析php请求,并且返回结果,不会管理(因此才出现的php-fpm)。 (3)为什么不叫php-cgi 其实在php-fastcgi出现之前是有一个php-cgi存在的,只是它的执行效率低下,因此被php-fastcgi取代。 (4)那fastcgi和cgi有什么区别呢? 亲们,这区别就大了,当一个服务web-server(nginx)分发过来请求的时候,通过匹配后缀知道该请求是个动态的php请求,会把这个请求转给php。 在cgi的年代,思想比较保守,总是一个请求过来后,去读取php.ini里的基础配置信息,初始化执行环境,每次都要不停的去创建一个进程,读取配置,初始化环境,返回数据

SAPI(PHP常见的四种运行模式)

梦想与她 提交于 2019-12-06 01:42:16
SAPI(Server Application Programming Interface)服务器应用程序编程接口,即PHP与其他应用交互的接口,PHP脚本要执行有很多方式,通过Web服务器,或者直接在命令行下,也可以嵌入在其他程序中。 SAPI提供了一个和外部通信的接口,常见的SAPI有:cgi、fast-cgi、cli、apache模块的DLL、isapi ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CGI CGI 即通用网关接口(Commom Gateway Interface),它把网页和WEB服务器中的执行程序连接起来,把从HTML接收的指令传递给服务器的执行程序,再把服务器执行程序的结果返还给HTML页。CGI的跨平台性能极佳,几乎可以在任何操作系统上实现。 CGI方式在遇到连接请求先要创建CGI的子进程,激活一个CGI进程,然后处理请求,处理完后结束这个子进程。这就是fork-and-execute模式。所以用cgi方式的服务器有多少连接请求就会有多少cgi子进程

xctf-i-got-id-200(perl网页文件+ARGV上传造成任意文件读取)

余生颓废 提交于 2019-12-06 00:39:32
打开url发现有三个链接,点进去都是.pl文件,且只有files可以上传文件。 .pl文件都是用perl编写的网页文件 这里上传了又将文件的内容全部打印出来,那么猜想后台应该用了param()函数。 param()函数会返回一个列表的文件但是只有第一个文件会被放入到下面的接收变量中。如果我们传入一个ARGV的文件,那么Perl会将传入的参数作为文件名读出来。对正常的上传文件进行修改,可以达到读取任意文件的目的: 这里附上网上大佬们猜测的后台代码: use strict; use warnings; use CGI; my $cgi= CGI->new; if ( $cgi->upload( 'file' ) ) { my $file= $cgi->param( 'file' ); while ( <$file> ) { print "$_"; } } bp进行抓包,将上传的文件类型及文件内容处复制再粘贴一行,将filename去掉,然后内容填入ARGV 然后盲猜flag文件,读取试试 或者直接先读取file.pl文件,盲猜在/var/www/cgi-bin/file.pl或者/var/www/cgi-bin/file.pl两个拿去试 发现确实使用了param()函数,然后我们利用bash来进行读取当前目录下的文件 payload为: /cgi-bin/file.pl?/bin

Python - User input to CGI via. Threading and reading file

橙三吉。 提交于 2019-12-06 00:06:28
Look at the bottom of this post, for final working code. It's a working Python/CGI script which can get user-input to a CGI-script by calling another script which then sends it's commands through a local socket. Original post: As far as I know, there isn't any way to send user input directly to a Python/CGI script which has allready sent it's header. Like, warning the user under specific circumstances and waiting for a confirmation. Neither have I been able to find any published solutions to this. If I'm wrong, please correct me. I currently have a Python script which can connect to servers,

网关协议学习:CGI、FastCGI、WSGI

淺唱寂寞╮ 提交于 2019-12-05 23:40:04
CGI CGI即通用网关接口(Common Gateway Interface),是外部应用程序(CGI程序)与Web服务器之间的接口标准,是在CGI程序和Web服务器之间传递信息的规程。CGI规范允许Web服务器执行外部程序,并将它们的输出发送给Web浏览器,CGI将Web的一组简单的静态超媒体文档变成一个完整的新的交互式媒体。通俗的讲CGI就像是一座桥,把网页和WEB服务器中的执行程序连接起来,它把HTML接收的指令传递给服务器的执行程序,再把服务器执行程序的结果返还给HTML页。CGI 的跨平台性能极佳,几乎可以在任何操作系统上实现。 CGI方式在遇到连接请求(用户请求)先要创建cgi的子进程,激活一个CGI进程,然后处理请求,处理完后结束这个子进程。这就是fork-and-execute模式。所以用cgi方式的服务器有多少连接请求就会有多少cgi子进程,子进程反复加载是cgi性能低下的主要原因。当用户请求数量非常多时,会大量挤占系统的资源如内存,CPU时间等,造成效能低下。 CGI脚本工作流程: 浏览器通过HTML表单或超链接请求指向一个CGI应用程序的URL。 服务器收发到请求。 服务器执行所指定的CGI应用程序。 CGI应用程序执行所需要的操作,通常是基于浏览者输入的内容。 CGI应用程序把结果格式化为网络服务器和浏览器能够理解的文档(通常是HTML网页)。

Show progress of PYTHON CGI script

非 Y 不嫁゛ 提交于 2019-12-05 22:46:35
I have a PYTHON CGI script(Content-type: text/plain ) which takes about 10 minutes to execute. I want to see the execution status of my script on my browser . Like below: Part 1 of script executed... Part 2 of script executed.. Part 3 of script executed.. Execution Complete I am using print statements, but it is outputting all the print statements all-together only after the script has completed execution, and not one by one. Please help .. Try doing: import sys ... print "Part 1 of script executed..." sys.stdout.flush() # do this after the print This flushes the standard out buffer, which

Python CGIHTTPServer crashes with “OSError: [Errno 13] Permission denied”

一个人想着一个人 提交于 2019-12-05 22:00:28
问题 I am running the following command from my home directory: python -m CGIHTTPServer This runs the server, but when I try to access a script in the cgi-bin directory I get: Traceback (most recent call last): File "/usr/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi os.execve(scriptfile, args, env) OSError: [Errno 13] Permission denied Running as root does not make a difference. The files seem to have all the right permissions: student@bandersnatch:~$ ls -lhR .: total 12K drwxr-xr-x 2

cgi.parse_multipart function throws TypeError in Python 3

浪子不回头ぞ 提交于 2019-12-05 21:26:54
问题 I'm trying to make an exercise from Udacity's Full Stack Foundations course. I have the do_POST method inside my subclass from BaseHTTPRequestHandler , basically I want to get a post value named message submitted with a multipart form, this is the code for the method: def do_POST(self): try: if self.path.endswith("/Hello"): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers ctype, pdict = cgi.parse_header(self.headers['content-type']) if ctype == 'multipart

How to locate Perl modules in the same directory as the script

和自甴很熟 提交于 2019-12-05 20:07:20
Now that recent versions of Perl have removed "." from @INC, I'm curious about best practices for module file location. Until now, the *.pm files associated with each application on our web site were in the same directory as the scripts. This, I gather, creates a security vulnerability. We don't have write access to the remaining directories in @INC. We could just leave the pm files where they are, and add use lib "."; to all our existing scripts, but wouldn't this just preserve the security vulnerability? Any suggestions on how our Perl scripts and their associated modules can be best

End perl script without waiting for system call to return

為{幸葍}努か 提交于 2019-12-05 19:37:30
I'm running a simple apache web server on Linux (Ubuntu 14.04) with a perl CGI script handling some requests. The script initiates a system command using the system function, but I want it to return immediately, regardless of the outcome of the system call. I've been adding an ampersand to the end of the scalar argument passed to system ( I am aware of the implications of command injection attacks ) and although this does cause the system command to return immediately, the script will still not exit until the underlying command has completed. If I trigger a dummy ruby script with a 10 second