Microsoft SQL Server
You just logged into a MSSQL server let's see how can we abuse it.
Linked Databases
Let's check if the user has sysadmin privileges on the databases. This can be done by querying the syslogins table
The database is found to have two users, sa and external_user . The current user doesn't have sysadmin privileges, which means we can't use xp_cmdshell to execute OS commands directly.
Let's check if there are any linked servers on the current database
POO_CONFIG is a linked server. The EXEC statement can be used to execute queries on linked servers. Let's find out the user in whose context we are able to query the linked server.
Let's check if this user has sa privileges.
internal_user is also not a sysadmin. We can try to enumerate if the POO_CONFIG server has more links.
It's found that POO_CONFIG is in turn linked to POO_PUBLIC, making it a circular link. Let's use nested queries and look at the user we're running as.
It's found that POO_CONFIG is in turn linked to POO_PUBLIC, making it a circular link. Let's use nested queries and look at the user we're running as. A nested EXEC statement is used to find the username after crawling back from the POO_CONFIG link. The query returns sa , which means that the link allows us to execute queries as the sysadmin user
Adding new user
Now we can login a super user and enable_xp_cmdshell.
Execute External Script
executing commands
Read More.
Last updated