-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from ctognini/master
Add Sybase database support for SQL Injection
- Loading branch information
Showing
11 changed files
with
568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/com/waratek/spiracle/sql/servlet/sybase/Sybase_Get_Implicit_Join.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2017 Waratek Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.waratek.spiracle.sql.servlet.sybase; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.waratek.spiracle.sql.servlet.util.ParameterNullFix; | ||
import com.waratek.spiracle.sql.util.SelectUtil; | ||
|
||
/** | ||
* Servlet implementation class Get_Inner_Join | ||
*/ | ||
@WebServlet("/Sybase_Get_Implicit_Join") | ||
public class Sybase_Get_Implicit_Join extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @see HttpServlet#HttpServlet() | ||
*/ | ||
public Sybase_Get_Implicit_Join() { | ||
super(); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
ServletContext application = this.getServletConfig().getServletContext(); | ||
List<String> queryStringList = new ArrayList<String>(); | ||
queryStringList.add("id"); | ||
|
||
Map<String, String> nullSanitizedMap = ParameterNullFix.sanitizeNull(queryStringList, request); | ||
|
||
String id = nullSanitizedMap.get("id"); | ||
|
||
String sql = "SELECT * FROM users, address WHERE users.id = " + id + " AND users.id = address.id"; | ||
|
||
Boolean showErrors = true; | ||
Boolean allResults = true; | ||
Boolean showOutput = true; | ||
|
||
SelectUtil.executeQuery(sql, application, request, response, showErrors, allResults, showOutput); | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/com/waratek/spiracle/sql/servlet/sybase/Sybase_Get_Union.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2017 Waratek Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.waratek.spiracle.sql.servlet.sybase; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.waratek.spiracle.sql.servlet.util.ParameterNullFix; | ||
import com.waratek.spiracle.sql.util.SelectUtil; | ||
|
||
/** | ||
* Servlet implementation class Get_Union | ||
*/ | ||
@WebServlet("/Sybase_Get_Union") | ||
public class Sybase_Get_Union extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @see HttpServlet#HttpServlet() | ||
*/ | ||
public Sybase_Get_Union() { | ||
super(); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
ServletContext application = this.getServletConfig().getServletContext(); | ||
List<String> queryStringList = new ArrayList<String>(); | ||
queryStringList.add("id"); | ||
|
||
Map<String, String> nullSanitizedMap = ParameterNullFix.sanitizeNull(queryStringList, request); | ||
|
||
String id = nullSanitizedMap.get("id"); | ||
|
||
String sql = "SELECT name, surname, CONVERT(varchar(500),dob,3) FROM users WHERE id = " + id + " UNION SELECT address_1, address_2, address_3 FROM address WHERE id = " + id; | ||
|
||
Boolean showErrors = true; | ||
Boolean allResults = true; | ||
Boolean showOutput = true; | ||
|
||
SelectUtil.executeQuery(sql, application, request, response, showErrors, allResults, showOutput); | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/com/waratek/spiracle/sql/servlet/sybase/Sybase_Get_int_no_quote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2017 Waratek Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.waratek.spiracle.sql.servlet.sybase; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.waratek.spiracle.sql.servlet.util.ParameterNullFix; | ||
import com.waratek.spiracle.sql.util.SelectUtil; | ||
|
||
/** | ||
* Servlet implementation class Get_int | ||
*/ | ||
@WebServlet("/Sybase_Get_int_no_quote") | ||
public class Sybase_Get_int_no_quote extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @see HttpServlet#HttpServlet() | ||
*/ | ||
public Sybase_Get_int_no_quote() { | ||
super(); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
ServletContext application = this.getServletConfig().getServletContext(); | ||
List<String> queryStringList = new ArrayList<String>(); | ||
queryStringList.add("id"); | ||
|
||
Map<String, String> nullSanitizedMap = ParameterNullFix.sanitizeNull(queryStringList, request); | ||
|
||
String id = nullSanitizedMap.get("id"); | ||
|
||
String sql = "SELECT * FROM users WHERE id = " + id; | ||
|
||
Boolean showErrors = true; | ||
Boolean allResults = true; | ||
Boolean showOutput = true; | ||
|
||
SelectUtil.executeQuery(sql, application, request, response, showErrors, allResults, showOutput); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/com/waratek/spiracle/sql/servlet/sybase/Sybase_Get_string.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2017 Waratek Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.waratek.spiracle.sql.servlet.sybase; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.waratek.spiracle.sql.servlet.util.ParameterNullFix; | ||
import com.waratek.spiracle.sql.util.SelectUtil; | ||
|
||
/** | ||
* Servlet implementation class Get_string | ||
*/ | ||
@WebServlet("/Sybase_Get_string") | ||
public class Sybase_Get_string extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @see HttpServlet#HttpServlet() | ||
*/ | ||
public Sybase_Get_string() { | ||
super(); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
executeRequest(request, response); | ||
} | ||
|
||
private void executeRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
ServletContext application = this.getServletConfig().getServletContext(); | ||
List<String> queryStringList = new ArrayList<String>(); | ||
queryStringList.add("name"); | ||
|
||
Map<String, String> nullSanitizedMap = ParameterNullFix.sanitizeNull(queryStringList, request); | ||
|
||
String name = nullSanitizedMap.get("name"); | ||
|
||
String sql = "SELECT * FROM users WHERE name = '" + name + "'"; | ||
|
||
Boolean showErrors = true; | ||
Boolean allResults = true; | ||
Boolean showOutput = true; | ||
|
||
SelectUtil.executeQuery(sql, application, request, response, showErrors, allResults, showOutput); | ||
} | ||
|
||
} |
Oops, something went wrong.