A look at terminal emulators, part 1
A look at terminal emulators, part 1
Posted Mar 31, 2018 23:42 UTC (Sat) by domo (guest, #14031)In reply to: A look at terminal emulators, part 1 by domo
Parent article: A look at terminal emulators, part 1
added $str =~ tr/\033//d; to my confirm-paste copy and this particular exploit is not effective anymore...
Posted Mar 31, 2018 23:54 UTC (Sat)
by domo (guest, #14031)
[Link]
--- Downloads/confirm-paste.txt 2018-04-01 02:49:34.886913091 +0300
Posted Apr 2, 2018 8:41 UTC (Mon)
by jwilk (subscriber, #63328)
[Link] (4 responses)
Posted Apr 3, 2018 14:12 UTC (Tue)
by anarcat (subscriber, #66354)
[Link] (3 responses)
Posted Apr 3, 2018 21:30 UTC (Tue)
by domo (guest, #14031)
[Link] (1 responses)
my $count = ($str =~ tr/[\0-\010\012-\037]//);
i.e. all ascii codes below 32 except tab, to trigger confirm-paste.
Posted Apr 4, 2018 13:39 UTC (Wed)
by mgedmin (subscriber, #34497)
[Link]
Posted Apr 5, 2018 6:56 UTC (Thu)
by pabs (subscriber, #43278)
[Link]
Personally I tend to paste into a GUI text editor before pasting into the terminal.
I sometimes wonder if anyone did any fuzzing of paste routines in those editors.
A look at terminal emulators, part 1
Here is the full diff compared to confirm-paste in urxvt github repository:
+++ dotdir/urxvt/chomp-and-confirm-paste 2018-04-01 02:40:11.030578963 +0300
@@ -21,9 +21,14 @@
sub on_tt_paste {
my ($self, $str) = @_;
+ chomp $str; $str =~ tr/\033//d;
+
my $count = ($str =~ tr/\012\015//);
- return unless $count;
+ unless ($count) {
+ $self->tt_paste ($str);
+ return 1;
+ }
$self->{paste} = \$str;
$self->msg ("Paste of $count lines, continue? (y/n)");
Enumerating badness usually doesn't end well. There are other control sequences that could be used for code execution (^[^E and ^X^E at least). Proof of concept exploits:
A look at terminal emulators, part 1
The latter works only if your editor is terminal-based and uses vi keybindings.
$({ echo; cowsay pwned; }>&2)[201~
[201~Dicowsay pwnedZZ
A look at terminal emulators, part 1
A look at terminal emulators, part 1
A look at terminal emulators, part 1
A look at terminal emulators, part 1