Skip to content

Commit

Permalink
docker-compose prepared for mssql in docker
Browse files Browse the repository at this point in the history
initial-db script was added.
  • Loading branch information
ahmetak4n committed Oct 17, 2023
1 parent f4398ea commit a4f81d9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DI/Services/SqlInjectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class SqlInjectionService : ISqlInjectionService
{
private string GetConnectionString()
{
var connectionString = ConfigurationManager.ConnectionStrings["SqlExpress"].ConnectionString;
var connectionString = ConfigurationManager.ConnectionStrings["MsSql"].ConnectionString;

return connectionString;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ public string ErrorBasedWithSqlDataAdapter(string param)
public string BooleanBased(string param)
{
string result = "not found";
string query = "SELECT * from [dbo].[USER] WHERE NAME = '" + param + "';";
string query = "SELECT * from [dbo].[VULN_NETFRAMEWORK_USER] WHERE NAME = '" + param + "';";

using (SqlConnection connection = new SqlConnection(
GetConnectionString()))
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
db:
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "Change_Me@123"
image: mcr.microsoft.com/mssql/server
restart: always
ports:
- 1433:1433
volumes:
- ./scripts/:/usr/share/scripts/
command:
- /bin/bash
- -c
- |
/opt/mssql/bin/sqlservr &
sleep 30
/opt/mssql-tools/bin/sqlcmd -U sa -P $$MSSQL_SA_PASSWORD -l 30 -e -i /usr/share/scripts/initial.sql
sleep infinity
6 changes: 6 additions & 0 deletions scripts/initial.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE DATABASE VULN_NETFRAMEWORK;
GO
USE VULN_NETFRAMEWORK;
CREATE TABLE VULN_NETFRAMEWORK_USER (ID INT, NAME NVARCHAR(50), ROLE NVARCHAR(20));
INSERT INTO VULN_NETFRAMEWORK_USER VALUES(1, 'admin','admin');
GO
2 changes: 1 addition & 1 deletion vuln-netframework/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</handlers>
</system.webServer>
<connectionStrings>
<add name="SqlExpress" connectionString="Server=localhost\SQLEXPRESS;Database=vuln-framework;Trusted_Connection=True;" />
<add name="MsSql" connectionString="Server=localhost,1433;User Id=sa;Password=Change_Me@123;Database=VULN_NETFRAMEWORK;" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down

0 comments on commit a4f81d9

Please sign in to comment.