Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么';确定HTML中字符串输出位置的最佳算法是什么?_Html_Perl_Html Parsing - Fatal编程技术网

什么';确定HTML中字符串输出位置的最佳算法是什么?

什么';确定HTML中字符串输出位置的最佳算法是什么?,html,perl,html-parsing,Html,Perl,Html Parsing,我正在创建XSS扫描仪,现在我想知道字符串的输出位置 可能是, 在HTML标记之间,例如string 标记的属性,例如 现在我需要知道它属于哪种情况。如果我检查所有的标签和它们的属性,速度会非常慢,所以我需要一种更快的方法 有什么建议吗?运行perl p.Sstring是经过精心设计的,它不会在任何地方破坏HTML结构。我不确定是否理解您的问题,但这里是我尝试的答案。 此代码检查属性/标记中的$string是否是唯一的,例如string而不是hello string 我不明白这个问题。您正在

我正在创建XSS扫描仪,现在我想知道字符串的输出位置

可能是,

  • 在HTML标记之间,例如
    string
  • 标记的属性,例如
现在我需要知道它属于哪种情况。如果我检查所有的标签和它们的属性,速度会非常慢,所以我需要一种更快的方法

有什么建议吗?运行perl


p.S
string
是经过精心设计的,它不会在任何地方破坏HTML结构。

我不确定是否理解您的问题,但这里是我尝试的答案。 此代码检查属性/标记中的
$string
是否是唯一的,例如
string
而不是
hello string


我不明白这个问题。您正在HTML文件中查找字符串
string
?为什么不使用
grep
sed
print "String '$string' found between HTML tags.\n" if ($file =~ /<(\w+).*?>$string<\/\1>/);
print "String '$string' found in HTML attribute.\n" if ($file =~ /<\w+ (?:.+? )?\w+="$string"(?: .+?)?>/);
$FILE = 'C:/path/to/file.html';

open FILE or die "Cannot open $FILE for read: $!";
while (<FILE>) {
   $file .= $_;
}
close FILE;