Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.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
分步分解/分解这个模糊的perl脚本_Perl_Deobfuscation - Fatal编程技术网

分步分解/分解这个模糊的perl脚本

分步分解/分解这个模糊的perl脚本,perl,deobfuscation,Perl,Deobfuscation,作为标题-请任何人解释下一个脚本是如何工作的 这将打印文本:“Perl人很聪明” 这只打印“b” perl-MO=Deparse仅显示以下内容: use warnings; use strict 'refs'; '' =~ m[(?{print "b",$/})]; 但我不知道为什么;( 像脚本一样分解的推荐方法是什么?如何开始 因此,我们尝试了以下方法: '' =~ ( '(?{' . ( '])@@^{' ^

作为标题-请任何人解释下一个脚本是如何工作的

这将打印文本:“Perl人很聪明”

这只打印“b”

perl-MO=Deparse仅显示以下内容:

use warnings;
use strict 'refs';
'' =~ m[(?{print "b",$/})];
但我不知道为什么;(

像脚本一样分解的推荐方法是什么?如何开始

因此,我们尝试了以下方法:

'' =~
(
        '(?{'
        .
        (
                '])@@^{' ^ '-[).*['
        )
        .
        '"'
        .
        (
                 '-[)@{:__({:)[{(-:)^}' ^ '}>[,[]*&[[[[>[[@[[*_'
        )
        .
        ',$/})'
)
几个部分由
连接起来。按位
^
的结果可能会给出文本部分。如下:

perl -e "print '-[)@{:__({:)[{(-:)^}' ^ '}>[,[]*&[[[[>[[@[[*_'"
打印“Perl家伙很聪明”和第一个生成“打印”的
^

但当我把它改写成:

'' =~
(
    '(?{'
    .
    (
        'print'
    )
    .
    '"'
    .
    (
         'Perl guys are smart'
    )
    .
    ',$/})'
)
我的perl告诉我:

panic: top_env
奇怪,我第一次看到这样的错误信息

这意味着:不允许用
结果替换
'str1'^'str2'
,(不理解为什么)以及为什么perl打印紧急消息

我的perl:

This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-multi-2level

Ps:生成示例

理解这里发生的事情的诀窍是查看由XOR和串联构造的字符串:

(?{print "Perl guys are smart",$/})
这是表单的一个实验性正则表达式特性。因此,您看到打印到终端的是

print "Perl guys are smart",$/
''=~…
$/
调用的是Perl的输入记录分隔符,默认情况下是一个换行符。

在该行中

.('_/).+{' ^ '/]@@_[
当您计算
']'^'-'
时,结果将是字母
p
^
是一个按位字符串操作,因此在此之后,我们按字母顺序获得结果字符串

检查我的脚本,它像你的例子一样工作。我希望它能帮助你

use v5.14;

# actually we obfuscated print and your word + "
# it looks like that (print).'"'.(yor_word")
my $print  = 'print';
my $string = 'special for stackoverflow by fxzuz"';

my $left  = get_obfuscated($print);
my $right = get_obfuscated($string);

# prepare result regexp
my $result = "'' =~ ('(?{'.($left).'\"'.($right).',\$/})');";

say 'result obfuscated ' .  $result;
eval $result;

sub get_obfuscated {

    my $string = shift;
    my @letters = split //, $string;

    # all symbols like :,&? etc (exclude ' and \)
    # we use them for obfuscation
    my @array = (32..38, 40..47, 58..64, 91, 93..95, 123..126);

    my $left_str = '';
    my $right_str = '';

    # obfuscated letter by letter
    for my $letter (@letters) {

        my @result;
        # get right xor letters
        for my $symbol (@array) {

            # prepare xor results
           my $result = ord $letter ^ $symbol;
           push @result, { left => $result, right => $symbol } if $result ~~ @array;
        }

        my $rand_elem = $result[rand $#result];
        $left_str  .= chr $rand_elem->{left};
        $right_str .= chr $rand_elem->{right};
    }

    my $obfuscated = "'$left_str' ^ '$right_str'";
    say "$string => $obfuscated";

    return $obfuscated;
}

但事实上,没有人应该写这样的代码,所以没有理由去理解它。现在明白了。没有人应该受伤,所以没有理由学习急救。;)事实上,我觉得它很有趣,我也想理解它。@cajwine:如果有人写这样的代码(除了开玩笑),那么他们就是白痴。如果您发现自己身处(例如)这样的工作环境中,这样的代码是可以容忍的,那么您应该离开。但不管怎样,我仍然建议将“学习Perl”作为第一步@OliCharlesworth,我真的不明白为什么您不能接受它只是作为“用perl完成的奇怪事情”的简单演示。我很确定没有人在现实生活中使用它。至少,这并不意味着这样的代码可以生成字符串是有趣的。
.('_/).+{' ^ '/]@@_[
use v5.14;

# actually we obfuscated print and your word + "
# it looks like that (print).'"'.(yor_word")
my $print  = 'print';
my $string = 'special for stackoverflow by fxzuz"';

my $left  = get_obfuscated($print);
my $right = get_obfuscated($string);

# prepare result regexp
my $result = "'' =~ ('(?{'.($left).'\"'.($right).',\$/})');";

say 'result obfuscated ' .  $result;
eval $result;

sub get_obfuscated {

    my $string = shift;
    my @letters = split //, $string;

    # all symbols like :,&? etc (exclude ' and \)
    # we use them for obfuscation
    my @array = (32..38, 40..47, 58..64, 91, 93..95, 123..126);

    my $left_str = '';
    my $right_str = '';

    # obfuscated letter by letter
    for my $letter (@letters) {

        my @result;
        # get right xor letters
        for my $symbol (@array) {

            # prepare xor results
           my $result = ord $letter ^ $symbol;
           push @result, { left => $result, right => $symbol } if $result ~~ @array;
        }

        my $rand_elem = $result[rand $#result];
        $left_str  .= chr $rand_elem->{left};
        $right_str .= chr $rand_elem->{right};
    }

    my $obfuscated = "'$left_str' ^ '$right_str'";
    say "$string => $obfuscated";

    return $obfuscated;
}