Free Essay

Sql Injection Methodology

In:

Submitted By Abhisamanta
Words 940
Pages 4
SQL Injection - Extracting database data from the page content up vote
4
down vote favorite I have a question I am hoping someone could help with..

I am in the process of writing an SQL Injection tool from scratch (I am aware there are already excellent tools out there such as SQL Map, but this one has to be written from scratch).

The problem I am having:

When manually performing SQL injection to determine tables names or column names and so on using strings such as:

www.vulnerable site.net/articles.php?id =-1 union select 1,2,group_concat(column_name),4 from information_schema.columns --

or

www.vulnarable site.net/articles.php?id =-1 union select 1,2,table_name,4 from information_schema.tables --

it is easy to determine the table names/column names as you can simply look at the page and read the column names that are returned in the page content.

But how can this be done in an automated way?

Doing this in an automated fashion is a lot harder though because how does the tool know what on the page that is returned when the sql injection is executed are table names/column names?

What would be the most reliable way to do this so the tool knows what parts of the page content to extract because they are table names/column names?

for example... could I parse/search the page content for strings seperated by commas to get the table and column names that are output by the injection? Is there better more reliable ways to do it?

your help with this is much appreciated, many thanks

web-application penetration-test sql-injection tools automated-testing shareimprove this question edited Apr 24 at 15:57

asked Apr 24 at 14:13

perl-user
18016
add comment (requires an account with 50 reputation)
2 Answers activeoldestvotes up vote
3
down vote accepted The easiest way is to use blind sql injection. You know if the question you are asking is right or wrong depending on how long the query takes to execute. This is also the most flexible approach because a blind sql injection exploit will work regardless of the type of sql injection being exploited (blind, non-blind, select, insert, update, delete....).

Another approach is to try and identify a visible field on the page while you brute force the number of columns. Once you find this location on the page, then you can scrape data from this point (sqlmap does something like this for non-blind injection):

www.vulnerable site.net/articles.php?id =-1 union select 'dsjhfsjhfdf' www.vulnerable site.net/articles.php?id =-1 union select 'dsjhfsjhfdf','sfjufewjfef'
...
This will work well with MySQL but some database types like postgresql, the columns in the union select must be the same type. So the database will also have to be brute-forced.

shareimprove this answer edited Apr 24 at 20:01

answered Apr 24 at 16:55

Rook
23.1k12179
I agree with your point about blind sql injection being the best/easiest way. However, in this instance I am concentrating on union based injection, so your second suggestion (scraping the data once you have found the location on the page and so on) is the kind of thing I am looking for. Could you explain this a little further as I am a little unsure as to exactly how that would work? thanks for your help – perl-user Apr 25 at 8:27
@perl-user Well finding the content on the page is a technically difficult approach. However, you can use a union select with blind sql injection. Here is an exploit that i wrote which uses a a binary search with blind SQL Injection to pull out bytes using O(log(n)) requests. I use a union select with blind sql injection to find messages in the bin_ask subroutine. Its also multithreaded, which makes it very fast. – Rook Apr 25 at 19:08
Very interesting, I will definately have a look at that, thanks. Could you also tell me a little more about how you said sqlmap does it for non-blind SQL injection please as that method is still something I'm interested in aswell, thanks a lot for your help – perl-user Apr 25 at 19:42
1
@perl-user If its non-blind injection you should be able to pull out the value of an arbitrary column. One option is to use the concat() function to surround the data that you are pulling out with a unique value. Then just use a regex to pull out the data between the two unique values. Damn simple son, maybe you should actually try solving problems, then you'll be a better problem solver ;) – Rook Apr 25 at 20:16 thanks, the concat_ws() function was what I required. I didn't realise it could be used in that way to effectively print a user defined string to the page as well as the database data, thanks for your help. – perl-user Apr 30 at 15:54 add comment (requires an account with 50 reputation) up vote
0
down vote
The easiest way is to access the page with legit input and with the injection and look at the difference. If you know what content is not results and know what the format of the expected result is, it isn't that hard to pick out the details with things like regular expressions or some other parsing engine.

Granted, any other dynamic elements (such as advertisements) that can differ from page load to page load may present a problem that would require a more elaborate plan.

Similar Documents

Premium Essay

Sql Injection Methodology

...SQL INJECION - TIPS & TRICKS - METHODOLOGIES ############################ # What you should look for # ############################ Try to look for pages that allow you to submit data (i.e: login page, search page, feedback, etc). Sometimes, HTML pages will use the POST command to send parameters to another ASP page. Therefore, you may not see the parameters in the URL. However, you can check the source code of the HTML, and look for "FORM" tag in the HTML code. You may find something like this in some HTML codes: <FORM action=Search/search.asp method=post> <input type=hidden name=A value=C> </FORM> Everything between the <FORM> and </FORM> have potential parameters that might be useful (exploit wise). ##################################################### # What if you can't find any page that takes input? # ##################################################### You should look for pages like ASP, JSP, CGI, or PHP web pages. Try to look especially for URL that takes parameters, like: http://[site.com]/page.asp?id=10 ######################################## # How do you test if it is vulnerable? # ######################################## Start with a single quote trick. Input something like: hi' or 1=1-- Into login, or password, or even in the URL. Example: - Login: hi' or 1=1-- - Pass: hi' or 1=1-- or - http://[site.com]/page.asp?id=hi' or 1=1-- If you must do this with a hidden field, just...

Words: 4826 - Pages: 20

Premium Essay

Sql Injection.

...due to a SQL injection flaw in a web application that communicate with a database. Over ten years have passed since a famous hacker coined the term “SQL injection” and it is still considered one of the major application threats. A lot has been said on this vulnerability, but not all of the aspects and implications have been uncovered, yet. This paper aim is to collate some of the existing knowledge, introduce new techniques and demonstrate how to get complete control over the database management system's underlying operating system, file system and internal network through SQL injection vulnerability in over-looked and theoretically not exploitable scenarios. This paper also discuss about the prevention from the SQL Injection, not only in ORACLE but also in PHP, C#, JAVA and other languages. INDEX ABSTRACT………………………………………………………………………………….....02 INTRODUCTION……………….…………………………….…….………………………….04 BLIND SQL INJECTION…………………………………….………………………………..05 SQL INJECTION OVERVIEW…………………………….………………………………....06 CATEGORIES OF SQL INJECTION ATTACKS…………………………………………..07 WHAT’S VULNERABLE…………………………………………………………..…………08 WHAT’S NOT VULNERABLE…………………………………………………….………….08 SQL INJECTION METHODS……………………………………….……………….……….09 SQL MANIPULATION………………………………………………………..……………….09 CODE INJECTION……………………………………………………….……………………10 FUNCTION CALL INJECTION……………………………………………………………….11 BUFFER OVERFLOWS………………………………………………………………………13 SQL INJECTION TESTING METHODOLOGY………………………………………….....14 PREVENTING SQL INJECTION...

Words: 3449 - Pages: 14

Free Essay

Veracode State of Software Security Report

...VOLUME 5 State of Software Security Report The Intractable Problem of Insecure Software APRIL 2013 Read Our Predictions for 2013 and Beyond Dear SoSS Report Reader, As some of you may know I have spent most of my 25 year career in the IT Security industry, more specifically, I’ve been focused on application security as the use of web and mobile applications has flourished. For the past five years I have been an active participant in the preparation of the report before you today—our annual State of Software Security Report, or as we fondly refer to it at Veracode, the SoSS Report. Throughout my career I have been evangelizing the need for more secure application development practices, and with the release of each new SoSS report I find myself of two minds. The optimist in me is proud of the vast improvement in general awareness of the importance of securing the application layer. But the pessimist remains very concerned that we are not seeing the dramatic decreases in exploitable coding flaws that I expect to see with each passing year. It’s as if for each customer, development team, or application that has become more secure, there are an equal number or more that do not. While the benefits of web applications are clear to organizations, the risks to their brands, infrastructure, and their data are seemingly not as clear, despite being more apparent than ever. It’s at this point of my letter that I could mention that a cyber-Vesuvius is about to bubble over and create...

Words: 5194 - Pages: 21

Premium Essay

Identifying Potential Malicious Attacks, Threats and Vulnerabilities

...Identifying Potential Malicious Attacks, Threats and Vulnerabilities Brian Cox Strayer Univerity Professor Leonard Roden Networking Security Fundamentals May 03, 2016            Have you ever thought about the measures that you need to go through when protecting yourself from online threats and attacks? There are many different types of attacks and threats that can be carried out against networks and organizations. The attacks that could be carried out can cause serious damage to the company and range on a scale from very minimal to very severe data loss and data theft. It is important for companies to take every precaution available and have not only the best software for prevention of these attacks but stay on top of what the intruders, hackers, attackers are learning and how the technology is forming when they are deploying these systems on their servers, networks, and office computers that employees will use on a day to day basis. The computers each employee is using should come with a User Agreement and the do’s and do not’s when it comes to daily computer usage. This will enhance the security as each employee will understand what is acceptable and how to obtain maximum security of their signed computer. It is also advisable within the User Agreement to list out the things that are unacceptable such as plugging in your phone, downloading things from the internet, and other things that may seem harmless but could hurt the company if it was exploited by accident...

Words: 1622 - Pages: 7

Premium Essay

Computer Tricks

...EC-Council Press | The Experts: EC-Council EC-Council’s mission is to address the need for well educated and certified information security and e-business practitioners. EC-Council is a global, member based organization comprised of hundreds of industry and subject matter experts all working together to set the standards and raise the bar in Information Security certification and education. EC-Council certifications are viewed as the essential certifications needed where standard configuration and security policy courses fall short. Providing a true, hands-on, tactical approach to security, individuals armed with the knowledge disseminated by EC-Council programs are securing networks around the world and beating the hackers at their own game. The Solution: EC-Council Press The EC-Council | Press marks an innovation in academic text books and courses of study in information security, computer forensics, disaster recovery, and end-user security. By repurposing the essential content of EC-Council’s world class professional certification programs to fit academic programs, the EC-Council | Press was formed. With 8 Full Series, comprised of 27 different books, the EC-Council | Press is set to revolutionize global information security programs and ultimately create a new breed of practitioners capable of combating this growing epidemic of cybercrime and the rising threat of cyber war. This Certification: C|EH – Certified Ethical Hacker Certified Ethical Hacker is a certification...

Words: 61838 - Pages: 248

Premium Essay

• Should Producers of Software-Based Services, Such as Atms, Be Held Liable for Economic Injuries Suffered When Their Systems Fail?

...Professional ethics includes relationships and responsibilities to customers and others who use the technology products that we develop. Honesty is a fundamental ethical value, however, some ethical problems are more subtle than the choice between honesty and dishonesty.  As technology professionals, we must have a "..good conscience in all things ... (Hebrews 13:18)" as we strive to do a thorough and careful job. But, we must recognize that, even using the best design methodologies, it is possible to produce software that is flawed.  Discuss the following: * Should producers of software-based services, such as ATMs, be held liable for economic injuries suffered when their systems fail? * Does your perspective on the level of culpability change when the development was conducted in accordance with industry best practices? * What steps, if any, can be taken to protect against potentially dangerous programming mistakes? The first question in the discussion board is interesting because there can be valid arguments made on both sides of the question. If it is found that the producer could have taken steps to avoid the economic injuries suffered from their software then they should be held liable for the damages but if the damages are no fault of their own then they should not be held liable. There was a recent case that got worldwide attention when hackers broke into Sony’s PlayStation network and stole account information from millions of customers. One article that...

Words: 703 - Pages: 3

Premium Essay

Web Application

...Chapter – 1 INTRODUCTION The world as we know it today is centered on the workings and ability of the World Wide Web. Internet security, however, is one area of concern and poses one of the biggest challenges to this internet savvy era. Our interaction with the internet has increased to such an extent , that experience, mixed with continued research has taught us that with each such interaction, we are prone to many malicious attacks, security lapses and even extremely skilled hacking operations. The field of Network Security and Cryptography has come a long way in the past decade, but it is safe to say that there is a lot more work to be done. Here we choose to concentrate on Web Applications and we particularly approach them from the developer’s perspective. With every step taken towards better security on the internet, end-users are doing their bit to safeguard their systems and data. However, keeping in mind how commercial and competitive the world we live in has become and the manner in which the market for web related products has grown, it becomes imperative for a developer to ensure that his web application is not just marketable as a breakthrough user friendly concept but also as a secure one. We imagine a world where, every skilled developer is able to make phenomenal applications and is able to provide his users with a large amount of credibility and reliability in terms of security. We aim to conceptualize and subsequently generate a security tool exclusively...

Words: 6435 - Pages: 26

Premium Essay

Lab 8

...Lab #8 – Assessment Worksheet Performing a Web Site and Database Attack by Exploiting Identified Vulnerabilities Course Name and Number: Student Name: Instructor Name: Lab Due Date: Overview In this lab, you performed simple tests to verify a cross-site scripting (XSS) exploit and an SQL injection attack using the Damn Vulnerable Web Application (DVWA), a tool left intentionally vulnerable to aid security professionals in learning about Web security. You used a Web browser and some simple command strings to identify the IP target host and its known vulnerabilities, and then attacked the Web application and Web server using cross-site scripting (XSS) and SQL injection to exploit the sample Web application running on that server. Lab Assessment Questions & Answers 1. Why is it critical to perform a penetration test on a Web application and a Web server prior to production implementation? To make sure no one can penetrate your web application before you put it in a live situation. 2. What is a cross-site scripting attack? Explain in your own words. Cross-site scripting is a type of computer security vulnerability typically found in web applications that enables attacks to inject client side script into web pages viewed by others 3. What is a reflective cross-site scripting attack? A reflective attack a type of computer security vulnerability it involves the web application dynamically generating a response using...

Words: 442 - Pages: 2

Free Essay

Cyber Crime

...legitimate cards the thieves went to work targeting ATMs to withdraw cash on an enormous scale. What is truly remarkable about this “heist” was how relatively simple and straight forward the methods employed by the hackers were. This attack has come to be known as an “Unlimited Operation”. How it happened It is extremely difficulty to answer how the hackers managed to steal such an enormous sum of cash with any degree of certainty. Given the very nature of how it was stolen, to publicly reveal specifics on how the heist was accomplished could possibly leave the institutions at the mercy of further attacks. However, the overwhelming online consensus points to SQL Injection as the method most suitable for this form of cyber-attack. [2] Structured Query Language (SQL) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS). Databases form the backbone of all financial institutions as they are responsible for recording all customer information, transactions and...

Words: 1338 - Pages: 6

Premium Essay

Web Application Attack Scenario

...Assignment 1: Web Application Attack Scenario (Student’s Name) (Professor’s Name) (Course Title) (Date of Submission) Introduction Web applications are nowadays serving as a company’s public face to the internet. This has created the need to identify threats and attacks directed to data servers and web applications. Hackers exploit vulnerabilities in input validation and authentication affecting the web application in order to gain illegal access and disclose sensitive data or manipulate it to their benefits. Common threats to data systems Data systems such as the web application and data servers are faced by a number of threats, some of these threats are discussed below: Spoofing: this is a situation where computer assume the identity of another and masquerading where a user assumes to be another (Cross, 2007). If the attacker manages to get high privileges, he can use this to attack the web system to insert or change the data, denial of service, or even damage the system. Scavenging: This is a threat presented by examining available data form accessible sources such as waste, network and search engines. Scavenging might identify the actual information needed by the hacker but in most cases, it is used as a way to select other threats for vulnerabilities that are well established for web systems attack. The information gathered through scavenging include, server software, type of operating system firewall and the application software. This risk highly lies at the client...

Words: 1087 - Pages: 5

Premium Essay

A Survey of Sql Injection Defense Mechanisms

...A Survey of SQL Injection Defense Mechanisms Kasra Amirtahmasebi, Seyed Reza Jalalinia and Saghar Khadem Chalmers University of Technology, Sweden akasra, seyedj, saghar{@student.chalmers.se} Abstract SQL Injection Attack (SQLIA) is a prevalent method which makes it possible for the attackers to gain direct access to the database and culminates in extracting sensitive information from the firm’s database. In this survey, we have presented and analyzed six different SQL Injection prevention techniques which can be used for securing the data storage over the Internet. The survey starts by presenting Variable Normalization and will continue with AMNESIA, Prepared statements, SQL DOM, SQLrand and SQLIA prevention in stored procedures respectively. that determining whether a SQL statement is allowable or not is done by checking the existence of normalized statement in the ready-sorted allowable list. 2.1. Background Many web pages ask users to input some data and make a SQL queries to the database based on the information received from the user i.e. username and passwords. By sending crafted input a malicious user can change the SQL statement structure and execute arbitrary SQL commands on the vulnerable system. Consider the following username and password example, in order to login to the web site, the user inputs his username and password, by clicking on the submit button the following SQL query is generated: SELECT * FROM user_table WHERE user_id = ‘john’ and password...

Words: 5643 - Pages: 23

Free Essay

Sec571 Security Concerns Regarding

...Security Concerns Regarding Quality Web Design Submitted to: SE571 Principles of Information Security and Privacy Keller Graduate School of Management Submitted: April 20, 2014 Table of Contents Executive Summary 1 Company Overview 1 Security Vulnerabilities 3 Threats Through Using VPN Tunnels 3 SQL Injections 4 Recommended Solutions 5 Threats Through Using VPN Tunnels 6 SQL Injections 8 Impact on Business Processes 9 Budget 10 Summary 11 References 12 Company Overview Quality Web Design (QWD) is a web development organization that creates client side web application that distributes web content to a user in order to improve an existing web site. They have a basic Microsoft shop that uses a Visual Studio Team Foundation Service to host the image repository as well as Visual Studio to design, QA and develop their site. They are also utilizing Microsoft SQL Server and Microsoft Exchange. Security Vulnerabilities The two Security vulnerabilities that I am going to document are VPN Tunnel potential security breaches as well as SQL Injection attacks. These are the two areas that I believe the organization has not looked at as potential risks for issues. Security Vulnerabilities The first threat that I want to elaborate on is a hardware vulnerability that is inherent in the use of VPN Tunnels. The main threat mostly lies with users not utilizing the same security precautions that are used in the office. Often users are unaware that they have a direct link straight...

Words: 1671 - Pages: 7

Premium Essay

Lab 12

...Internet world? RFI stands for Remote File Inclusion that allows the attacker to upload a custom coded/malicious file on a website or server using a script. This vulnerability exploits the poor validation checks in websites and can eventually lead to code execution on server or code execution on website (XSS attack using javascript). RFI is a common vulnerability and all website hacking is not entirely focused on SQL injection. Using RFI you can deface the websites, get access to the server and do almost anything. What makes it more dangerous is that you only need to have your common sense and basic knowledge of PHP to execute this one 2. What country is the top host of Structured Query Language (SQL) injection and SQL Slammer infections? Why can’t the U.S. government do anything to prevent these injection attacks and infections? The U.S. is the top host of SQL Injection and SQL Slammer infections. Cybercriminals have made vast improvements to their infrastructure over the last few years. Its expansion is thousands of websites vulnerable to SQL Injections. Malicious code writers have exploited these vulnerabilities to distribute malware so quick that the government cannot contain such a large quantity. 3. What does it mean to have a policy of nondisclosure in an organization? It is a contract where the parties agree not to disclose information covered by the agreement. It outlines confidential material, knowledge, or information that the parties wish to share...

Words: 411 - Pages: 2

Free Essay

Cmit 321 Final Exam

... d. DbEncrypt View Feedback Question 5 1 / 1 point In the TCP/IP stack, the __________ layer is where applications and protocols, such as HTTP and Telnet, operate. a. Internet b. network c. transport d. application View Feedback Question 6 1 / 1 point Attackers can use a simple test to find out if an application is vulnerable to an OLE DB error. They can fill in the username and password fields with __________. a. a pound sign b. two dashes c. a single quotation mark d. double quotes View Feedback Question 7 1 / 1 point __________ allow attackers to pass malicious code to different systems via a web application. a. SQL injection attacks b. XSS vulnerabilities c. Authentication hijacking attacks d. Command injection flaws View...

Words: 4865 - Pages: 20

Premium Essay

Graduating

...prevalent in today's Internet world? RFI stands for Remote File Inclusion that allows the attacker to upload a custom coded/malicious file on a website or server using a script. This vulnerability exploits the poor validation checks in websites and can eventually lead to code execution on server or code execution on website (XSS attack using javascript). RFI is a common vulnerability and all website hacking is not entirely focused on SQL injection. Using RFI you can deface the websites, get access to the server and do almost anything. What makes it more dangerous is that you only need to have your common sense and basic knowledge of PHP to execute this one. 2. What country is the top host of SQL Injection and SQL Slammer infections? Why can't the US Government do anything to prevent these injection attacks and infections? The U.S. is the top host of SQL Injection and SQL Slammer infections. Cybercriminals have made vast improvements to their infrastructure over the last few years. Its expansion is thousands of websites vulnerable to SQL Injections. Malicious code writers have exploited these vulnerabilities to distribute malware so quick that the government cannot contain such a large quantity. 3. What does it mean to have a policy of Nondisclosure in an organization? It is a contract where the parties agree not to disclose information covered by the agreement. It outlines confidential material, knowledge, or information that the parties wish to share with one another for...

Words: 319 - Pages: 2