import cgitb
import Cookie, urllib2
from cookielib import FileCookieJar
cgitb.enable()
c = Cookie.SmartCookie()
c['ini'] = 1
savedc = FileCookieJar()
savedc.add_cookie_header(c.output())
savedc.save()
Run Code Online (Sandbox Code Playgroud)
这不是保存饼干吗?...
我一直在阅读python文档,如100万次,我只是不明白:(
请帮助某人:(
当我通过URL访问我的Perl脚本时意味着什么,但是当我这样做时,源代码会打印在屏幕上?
这是否意味着Perl没有正确设置?我在Fedora上使用Apache.
当我尝试STDOUT在Perl CGI脚本中打印图像时,在浏览器中查看时图像会被剪裁.
这是以下代码:
if ($path =~ m/\.jpe?g$/i)
{
my $length = (stat($path))[7];
$| = 1;
print "Content-type: image/jpg\r\n";
print "Content-length: $length\r\n\r\n";
open(IMAGE,"<$path");
binmode(IMAGE);
binmode(STDOUT);
my ($image, $buff);
read IMAGE, $buff, $length;
syswrite STDOUT, $buff, $length;
close IMAGE;
}
Run Code Online (Sandbox Code Playgroud) 我尝试在我的服务器上执行一个简单的perl脚本,我得到一个内部500服务器,当我检查错误日志时,它显示:
Premature end of script headers: test.pl
这是perl脚本:
#!/usr/bin/perl -w
print "Content-type: text/plain\n\n";
print "testing...\n";
Run Code Online (Sandbox Code Playgroud)
我的cgi-bin文件夹具有0755的权限.脚本本身也是0755.该脚本由apache拥有,并且在apache组中.该脚本通过命令行正常工作.
有什么问题,我该如何解决这个问题?!
谢谢大家的帮忙!
有趣的发现在suExec:
2010-09-14 17:38:28]: uid: (10001/som) gid: (2522/2522) cmd: test.pl
[2010-09-14 17:38:28]: target uid/gid (10001/2522 or 2521) mismatch with directory (48/0) or program (48/0)
Run Code Online (Sandbox Code Playgroud)
但我的cgi文件夹与test.pl脚本相同 - 它是指另一个目录吗?
我有一个CGI脚本(编译的C程序),它输出其命令行参数(argv [0],argv [1]等).
如果我尝试http://ajf.me/c/?abc,我会将"abc"作为第二个参数.
但是,如果我尝试http://ajf.me/c/?a=bc我没有得到任何第二个参数.
为什么使用=停止参数传递给程序?
如果重要的是C代码:
#include <stdio.h>
int main (int argc, char *argv[]) {
int i;
printf("Content-Type: text/html;charset=utf-8\n\n");
printf("<!DOCTYPE html>\n");
printf("<html>\n");
printf("<head>\n");
printf("<title>ajf.me powered by ANSI C!</title>\n");
printf("</head>\n");
printf("<body>\n");
printf("<h2>Supplied Arguments</h2>\n");
printf("argc: %d\n", argc);
printf("<ol>\n");
for (i = 0; i < argc; ++i) {
printf("<li>%s</li>\n", argv[i]);
}
printf("</ol>\n");
printf("<em>Yes, this is vulnerable to null-byte injection. For instance, <a href=\"?Injected%%00Null\" style=\"font-family: monospace; color: green;\">?Injected\\0Null</a>.</em>\n");
printf("</body>\n");
printf("</html>\n");
}
Run Code Online (Sandbox Code Playgroud) 我们如何从下面提到的url中获取文件夹的值:
http://my.indiamart.com/cgi/?my-enquiries.mp#folders=1
Run Code Online (Sandbox Code Playgroud)
我已经尝试了CGI对象,%ENV变量和许多东西,但仍然无法得到它.
请建议..
我想创建一个身份验证机制,其中客户端是JavaScript,它从客户端获取密码和用户名并将其发布到CGI Perl脚本.
问题是用户名和密码是自由文本.我想让它加密或散列,但在CGI我想检查它,所以我再次需要密码.
有任何想法吗?
我正在尝试执行这行代码
key_inside = CGI::unescape(key)
val_inside = CGI::unescape(val)
Run Code Online (Sandbox Code Playgroud)
它给我的错误就像
undefined method `tr' for :oauth_consumer_key:Symbol\n
Run Code Online (Sandbox Code Playgroud)
我正在使用Rails 2.3.18和ruby 1.9.3
任何人都可以建议可能出现的问题吗?
-----更新------
我注释掉了window.URL.revokeObjectURL( imgSrc );,现在调用适用于所有浏览器.看起来这个网址在Chrome中过早被撤销了.我仍然很想知道为什么会这样,并且知道我现在处理撤销URL的方式是否存在任何人的意见.我现在撤销最后一个URL,因为下一个URL已加载if (imgSrc) {window.URL.revokeObjectURL( imgSrc );}(imgSrc现在是一个全局变量).
我有一个网站,它使用AJAX调用CGI脚本,输出图像/ jpeg数据,然后使用createObjectURL函数将blob响应设置为页面上图像的src.目前它适用于所有浏览器,但Chrome.
在所有其他浏览器中显示图像,但在Chrome中我收到消息:Failed to load resource: the server responded with a status of 404 (Not Found)后跟一个前缀为的网址blob:.
我尝试过使用webkitURL,但是这给了我同样的错误webkitURL is deprecated.
这是我的AJAX调用的代码:
var filepath = "/babelia.cgi";
xmlhttp=new XMLHttpRequest();
xmlhttp.onload = function(oEvent) {
if (imgSrc) {window.URL.revokeObjectURL( imgSrc );}
var blob = xmlhttp.response;
if (endless) {
imgSrc = (window.URL ? URL : webkitURL).createObjectURL( blob );
document.getElementById("palette").src = imgSrc;
// window.URL.revokeObjectURL( imgSrc );
babel();
}
}
xmlhttp.open("POST",filepath,true); …Run Code Online (Sandbox Code Playgroud) 我在/ Library/WebServer/CGI-Executables中有一个名为test.cgi的python脚本.我在/ Library/WebServer/Documents中有一个index.html文件.我的html文件包含一个发布到CGI脚本的表单,并且工作正常.当我的脚本尝试写入文件时,我收到以下错误:
我指定的输出目录无关紧要,我得到相同的错误信息.我已经尝试更改cgi-bin文件夹和脚本的权限,但这也不起作用.有什么建议?
cgi ×10
perl ×5
javascript ×2
python ×2
ajax ×1
apache ×1
blob ×1
c ×1
cgi-bin ×1
cookies ×1
encryption ×1
escaping ×1
image ×1
io ×1
jpeg ×1
parameters ×1
permissions ×1
post ×1
ruby ×1
server-error ×1
url ×1
webserver ×1