{"id":13,"date":"2009-05-31T20:50:59","date_gmt":"2009-05-31T20:50:59","guid":{"rendered":"http:\/\/www.vidarholen.net\/contents\/blog\/?p=13"},"modified":"2009-05-31T20:53:07","modified_gmt":"2009-05-31T20:53:07","slug":"two-classic-ways-of-getting-owned","status":"publish","type":"post","link":"https:\/\/www.vidarholen.net\/contents\/blog\/?p=13","title":{"rendered":"Two classic ways of getting owned"},"content":{"rendered":"<p>There are two classic ways that Linux newbies open themselves up for pranks and shenanigans (or worse): double-su and startx. The double-su will not cause any holes that a crafty conman couldn&#8217;t already have arranged, but the startx trick can actually be a serious back door.<\/p>\n<p>The double-su is when you su twice from some other user&#8217;s shell. Imagine, if you will, that Vidar just called over the admin of the company&#8217;s server, pointed to top where a process is running un-niced at 99% and has racked up hours and hours of cpu time. Vidar makes a big fuss about this, so the admin says &#8220;fine, move over&#8221;, and does the following at Vidar&#8217;s terminal:<\/p>\n<p><code><br \/>\nvidar@kelvin ~ $ <b>su<\/b><br \/>\nPassword:<br \/>\nroot@kelvin:\/home\/vidar# <b>renice 19 3156<\/b><br \/>\n3156: old priority 0, new priority 19<br \/>\nroot@kelvin:\/home\/vidar# <b>su vidar<\/b><br \/>\nvidar@kelvin ~ $<br \/>\n<\/code><\/p>\n<p>He then scampers off to lunch. Spotted the problem? &#8220;su&#8221; doesn&#8217;t switch to another user&#8217;s account; UNIX\/Linux doesn&#8217;t allow non-root users to do that, even if they have the password. Instead, it starts another shell on top of the old one. Then the admin run su again, creating a third shell on top of the other two. Now, when Vidar exits the third shell, he finds himself back at the second one, with full root access:<\/p>\n<p><code><br \/>\nvidar@kelvin ~ $ <b>exit<\/b><br \/>\nexit<br \/>\nroot@kelvin:\/home\/vidar# <b>echo \"Want to buy: Baggy pants and a more suitable job. Love, your admin\" >> \/etc\/issue<\/b><br \/>\nroot@kelvin:\/home\/vidar# <b>exit<\/b><br \/>\nexit<br \/>\nvidar@kelvin ~ $<br \/>\n<\/code><\/p>\n<p>The admin clearly should have ended his su-session with <code>exit<\/code> rather than <code>su originaluser<\/code> Of course, the <i>real<\/i> issue here is using &#8220;su&#8221; on untrusted hardware and software. <\/p>\n<p>If Vidar was evil, he could just as easily have set up a software or hardware keylogger, a spoofed su or simply used strace. This is the reason why the double-su is more of a prank opportunity than an exploit. <\/p>\n<p>Now, startx, on the other hand&#8230;! Some users, mostly for leetness, like to log in in text mode and then &#8220;startx&#8221; to start X, instead of a graphical login. What most of these don&#8217;t consider, is that both the shell and startx are still running on the virtual console it was started on. <\/p>\n<p>If the user dutifully locks the screen before attending wetware chores, you can hit Ctrl-Alt-F1 to get to this shell, Ctrl-Z and bg. You now have a shell running as this user. If that isn&#8217;t enough, you can <code>killall xscreensaver<\/code> and Ctrl-Alt-F7. You now have an unlocked X session:<\/p>\n<p><code><br \/>\nvidar@kelvin ~ $ startx<br \/>\n<b>^Z<\/b><br \/>\n[1]+  Stopped                 startx<br \/>\nvidar@kelvin ~ $ <b>bg<\/b><br \/>\n[1]+ startx &<br \/>\nvidar@kelvin ~ $ <b>killall xscreensaver<\/b><br \/>\nvidar@kelvin ~ $ <b>clear; exit;<\/b><br \/>\n<\/code><\/p>\n<p>This user should at least have used <code>startx & exit<\/code> to log off the virtual console when X started. <\/p>\n<p>So how serious is this hole? It depends on how far you&#8217;re willing to go. Sure, with physical access you can try all sorts of things, like rebooting with a livecd. If you know there&#8217;s a bios password you can&#8217;t clear, you can take the disk out. If the disk is encrypted, you can try a cold boot attack. But surely by then, the user&#8217;s back and is trying to figure out why you&#8217;re pouring liquid nitrogen into his hardware. <\/p>\n<p>It might have been easier to hit him over the head before he locked the screen in the first pace.<\/p>\n<p>More seriously, proper startx usage turns getting your stuff from a trivial act of stealthy espionage into a violent crime or an invasive and time consuming thousand-euro procedure. Don&#8217;t underestimate that. <\/p>\n<p>If you can think of any other classical security no-nos being reinvented by every new generation of Linux users, do comment!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two classic ways that Linux newbies open themselves up for pranks and shenanigans (or worse): double-su and startx. The double-su will not cause any holes that a crafty conman couldn&#8217;t already have arranged, but the startx trick can actually be a serious back door. The double-su is when you su twice from some &hellip; <a href=\"https:\/\/www.vidarholen.net\/contents\/blog\/?p=13\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Two classic ways of getting owned&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[6,4,22],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-basic-linux","category-linux","category-security"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":0,"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vidarholen.net\/contents\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}