0

I am trying to install a Live Kali Linux on a USB without the two beeps at booting. I found the fifth post in this thread that says:

This can also depend on UEFI vs BIOS

For BIOS you can use the following PERL script on the ISO file itself and it will take care of any place ^G exists in the iso:

perl -p -i -e 's;\x6d\x65\x6e\x75\x07;\x6d\x65\x6e\x75\x20;g' your-kali.iso

The beep was added for accessibility to the UEFI boot menu as well so you may still get the beep. To remove that you must edit grub.cfg and comment out or remove the following two lines:

insmode play
play 960 440 1 0 4 440 1

I used live build to make the changes to grub.cfg, generated the iso, and then ran the perl script prior to flashing to the usb.

I managed to delete the (x07) byte for BIOS with the given Perl script, so I tried the same thing with "insmode play play 60 440 1 0 4 440 1" (I opened grub.cfg in a hex editor, copied the hex of this string, 696E736D6F6420706C61790A706C61792039363020343430203120302034203434302031, and put 20 in the place of every byte).

I ran this script perl -p -i -e 's;\x69\x6e\x73\x6d\x6f\x64\x20\x70\x6c\x61\x79\x0a\x70\x6c\x61\x79\x20\x39\x36\x30\x20\x34\x34\x30\x20\x31\x20\x30\x20\x34\x20\x34\x34\x30\x20\x31;\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20;g' your-kali.iso.

But the string is still in the iso.

Why does it not get replaced?

4

2 回答 2

1

您一次读取一行,它被定义为一个字节序列,直到换行(包括)。因此$_,除了最后,永远不会有换行符。

perl -i -pe'
   s/^i(?=nsmode play$)/#/;
   s/^p(?=lay 960 440 1 0 4 440 1$)/#/;
' your-kali.iso

这独立地注释掉了这些行。如果要将它们作为一组替换,则需要一个缓冲区。

perl -i -pe'
   if (/^insmode play$/) {
      $buf = $_;
      $_ = "";
      next;
   }

   $_ = $buf . $_;
   $buf = "";
   s/^insmode play\nplay 960 440 1 0 4 440 1\n/#nsmode play\n#lay 960 440 1 0 4 440 1\n/;

   END { print $buf }
' your-kali.iso
于 2018-04-19T03:22:08.723 回答
1

perl -p -e CODE通常在输入的每一行上运行指定的 CODE,其中行(在 POSIX-y 系统上)由换行符 ( \x0a) 分隔,因此此代码不允许您在搜索模式包含\x0a.

我的方法(这是 Perl,所以有很多方法可以做到这一点)更像

perl -p -i -e '$_="" if $_ eq "insmod play\n" || 
               $_ eq "play 960 440 1 0 4 440 1\n"' your-kali.iso

当输入行与两个目标模式之一匹配时,这会将输入行替换为空字符串(也就是说,从输出中删除它们,而不是用空格字符串替换它们)。

于 2018-04-18T21:08:53.677 回答