0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

html の正当性の証明。CGI(perl,python)の場合。

Posted at

CGI や HTML が改ざんされにくく運用されているか

1.submitter.cgi (提出者。意味を拒否し、責任を転送する者)
2.examiner.cgi (検査者。形式を拒否し、意味だけを問う者)

1.に関して言うなら

  • Decodeがない。書類を受けて examiner.cgi に提出検 (user にやらせて提出させる)
  • または、制限された領域は decode を通さない。その部分の検査は examiner.cgi に任せる。
  • 三相的にGETのみデコードする。
submitter.cgi
#!/usr/local/bin/perl

#! C:/python3_12/python -X utf8
# http://localhost/python_pip.cgi #仮に
# -*- coding: utf-8 -*-

#
# submitter
*
$tuse CGI;
use File::stat;
use POSIX qw(strftime);
# enye
# set
$this_cgi = "./submitter.cgi";
$examiner_cgi = "examiner.pl";
print qq|<form name="仮想_value=$mtime" action="./examiner.cgi" method="post"><br>\n|;
# mtime の取得
my $mtime_cgi  = stat($0)->mtime;  # $0 は実行中の CGI ファイル自身
# 整形
my $stamp_str     = $stamp;
my $mtime_cgi_str  = strftime "%Y-%m-%dT%H:%M:%S", localtime($mtime_cgi);
prit qq|<input type="hidden" name="me_submitter_cgi" value="$mtime_cgi_str">\n|;
print <<"EOF";
parametr
EOF

2.に関して言うなら

  • form 送信がない。検査後に reload https:...../submitter.cgi?Accepted=bad
  • 三相的に、してやる。(検査して間違っていればやり直させる) bad,good くらいは出来る。
examiner.cgi(examiner.pl)
#!/usr/local/bin/perl

#! C:/python3_12/python -X utf8
# http://localhost/python_pip.cgi #仮に
# -*- coding: utf-8 -*-

#
# submitter
*
$tuse CGI;
use File::stat;
use POSIX qw(strftime);
# enye
# set
$this_cgi = "./examiner.cgi";
$submitter_cgi = "./submitter.cgi"; # クロス構造になる。
&resive_decode();
$you_submitter_cgi = $resive{'me_submitter_cgi'};
$are_you_a_subordinate = $submitter_cgi;
# mtime の取得
my $mtime_file = stat($are_you_a_subordinate)->mtime;
# 整形
my $stamp_str     = $stamp;
my $mtime_file_str = strftime "%Y-%m-%dT%H:%M:%S", localtime($mtime_file);
if ($mtime_file_str eq $you_submitter_cgi) {
    reload "https:...../submitter.cgi?Accepted=ok";
} else {
    reload "https:...../submitter.cgi?Accepted=I_ll_give_you_hard_work(prison)";
}

足りないところも多々ありますが、こんな感じです。

それでは。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?